<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Encephos</title>
    <description>The latest articles on DEV Community by Encephos (@encephos).</description>
    <link>https://dev.to/encephos</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4052993%2F04354e87-255d-4d31-bd84-2b90a6f45117.png</url>
      <title>DEV Community: Encephos</title>
      <link>https://dev.to/encephos</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/encephos"/>
    <language>en</language>
    <item>
      <title>Check out my new Post!</title>
      <dc:creator>Encephos</dc:creator>
      <pubDate>Wed, 29 Jul 2026 11:24:42 +0000</pubDate>
      <link>https://dev.to/encephos/check-out-my-new-post-a0c</link>
      <guid>https://dev.to/encephos/check-out-my-new-post-a0c</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/encephos/how-to-stop-llms-from-hallucinating-on-complex-html-tables-python-2e0k" class="crayons-story__hidden-navigation-link"&gt;How to stop LLMs from hallucinating on complex HTML tables (Python)&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/encephos" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4052993%2F04354e87-255d-4d31-bd84-2b90a6f45117.png" alt="encephos profile" class="crayons-avatar__image" width="420" height="420"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/encephos" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Encephos
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Encephos
                
              
              &lt;div id="story-author-preview-content-4262368" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/encephos" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4052993%2F04354e87-255d-4d31-bd84-2b90a6f45117.png" class="crayons-avatar__image" alt="" width="420" height="420"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Encephos&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/encephos/how-to-stop-llms-from-hallucinating-on-complex-html-tables-python-2e0k" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Jul 29&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/encephos/how-to-stop-llms-from-hallucinating-on-complex-html-tables-python-2e0k" id="article-link-4262368"&gt;
          How to stop LLMs from hallucinating on complex HTML tables (Python)
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/python"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;python&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ai"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ai&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/webscraping"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;webscraping&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/opensource"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;opensource&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
            &lt;a href="https://dev.to/encephos/how-to-stop-llms-from-hallucinating-on-complex-html-tables-python-2e0k#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success crayons-icon c-btn__icon"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>How to stop LLMs from hallucinating on complex HTML tables (Python)</title>
      <dc:creator>Encephos</dc:creator>
      <pubDate>Wed, 29 Jul 2026 11:24:20 +0000</pubDate>
      <link>https://dev.to/encephos/how-to-stop-llms-from-hallucinating-on-complex-html-tables-python-2e0k</link>
      <guid>https://dev.to/encephos/how-to-stop-llms-from-hallucinating-on-complex-html-tables-python-2e0k</guid>
      <description>&lt;p&gt;If you are building Retrieval-Augmented Generation (RAG) pipelines or feeding web data into Large Language Models (LLMs), you already know the golden rule: &lt;strong&gt;Garbage in, garbage out.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Text extraction is mostly a solved problem. But the moment you encounter &lt;strong&gt;HTML tables&lt;/strong&gt;, things usually get messy. And if those tables contain &lt;code&gt;rowspan&lt;/code&gt; or &lt;code&gt;colspan&lt;/code&gt; attributes, standard extraction pipelines break completely.&lt;/p&gt;

&lt;p&gt;The result? Misaligned Markdown, missing context, and an LLM that hallucinates relationships between headers and cells. &lt;/p&gt;

&lt;p&gt;After hitting this wall one too many times, I decided to build a Python library to solve this specific problem once and for all: &lt;strong&gt;&lt;a href="https://github.com/Encephos/table2md" rel="noopener noreferrer"&gt;html-table-rescuer&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here is why standard parsers fail, and how this new tool fixes it.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Problem: Spanned Cells destroy Context
&lt;/h3&gt;

&lt;p&gt;Most standard &lt;code&gt;table-to-markdown&lt;/code&gt; scripts or naive web scrapers read HTML row by row (&lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt;), cell by cell (&lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt;). &lt;/p&gt;

&lt;p&gt;But look at what happens when a table uses a &lt;code&gt;&amp;lt;td rowspan="2"&amp;gt;&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The HTML:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;border=&lt;/span&gt;&lt;span class="s"&gt;"1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;rowspan=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Spanned Header&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Row 1 Data&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Row 2 Data&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What standard parsers output:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;| Header | Value | 
| ----- | ----- | 
| Spanned Header | Row 1 Data | 
| Row 2 Data |  | 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the shift? In the second row, the data is pushed into the wrong column. If you feed this into an LLM, the model will associate "Row 2 Data" with the first column header. The context of the "Spanned Header" is completely lost for the second row.&lt;/p&gt;




&lt;h3&gt;
  
  
  The Solution: A Grid Logic Solver
&lt;/h3&gt;

&lt;p&gt;To fix this, we can't just parse the tags; we need to understand the underlying mathematical grid of the table.&lt;/p&gt;

&lt;p&gt;I built &lt;code&gt;html-table-rescuer&lt;/code&gt; to do exactly that. It uses &lt;code&gt;BeautifulSoup&lt;/code&gt; to parse the DOM, but then applies a custom &lt;strong&gt;Grid Logic Solver&lt;/strong&gt;. It calculates the exact matrix coordinates for every cell, resolving all row and column spans perfectly.&lt;/p&gt;

&lt;p&gt;But more importantly for AI workflows: &lt;strong&gt;It preserves the semantic context.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of leaving spanned cells blank, it actively fills them so the LLM retains the context for &lt;em&gt;every single row&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What &lt;code&gt;html-table-rescuer&lt;/code&gt; outputs:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;| Header | Value | 
| ----- | ----- | 
| Spanned Header | Row 1 Data | 
| dito (Spanned Header) | Row 2 Data | 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Notice how the tool fills the gap with a customizable prefix like "dito" so the LLM knows it belongs to the span above!)&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Deep Tag Parsing &amp;amp; Nested Tables
&lt;/h3&gt;

&lt;p&gt;Another massive headache in web scraping is deep nesting. &lt;br&gt;
Often, a &lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt; doesn't just contain text. It contains a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, which contains a &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;, which contains an &lt;code&gt;&amp;lt;a href="..."&amp;gt;&lt;/code&gt; and some &lt;code&gt;&amp;lt;b&amp;gt;&lt;/code&gt; bold text.&lt;/p&gt;

&lt;p&gt;If you just extract the text, you lose valuable metadata (like links). &lt;code&gt;html-table-rescuer&lt;/code&gt; recursively parses inline tags. It keeps your links, bold, and italic formatting alive in the final Markdown output. &lt;/p&gt;

&lt;p&gt;It even safely extracts &lt;strong&gt;nested tables&lt;/strong&gt; without destroying the grid of the parent table.&lt;/p&gt;


&lt;h3&gt;
  
  
  Quick Start
&lt;/h3&gt;

&lt;p&gt;I wanted to make it as easy to use as possible. You can install it via pip:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;html-table-rescuer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And parse any complex HTML in just a few lines of Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;table2md.core&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;TableParser&lt;/span&gt;

&lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
&amp;lt;!-- Insert your gnarly, complex HTML table here --&amp;gt;
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# Initialize parser
&lt;/span&gt;&lt;span class="n"&gt;parser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;TableParser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Parse all tables
&lt;/span&gt;&lt;span class="n"&gt;tables&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;parser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tables&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Export to clean Markdown for your LLM context window
&lt;/span&gt;    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tables&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;to_markdown&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

    &lt;span class="c1"&gt;# Or export to JSON / CSV if you need structured data
&lt;/span&gt;    &lt;span class="c1"&gt;# print(tables[0].to_json())
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;(Note: It also includes a wrapper to ingest HTML tables directly as **LangChain Document objects&lt;/em&gt;&lt;em&gt;).&lt;/em&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  🤝 Try it out and break it!
&lt;/h3&gt;

&lt;p&gt;This is the initial release (&lt;code&gt;v0.1.0&lt;/code&gt;), and it's completely open-source. &lt;/p&gt;

&lt;p&gt;If you are currently building AI agents, RAG pipelines, or just doing heavy web scraping, I'd love for you to try it out. &lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/Encephos/html-table-rescuer" rel="noopener noreferrer"&gt;Encephos/html-table-rescuer&lt;/a&gt;&lt;br&gt;&lt;br&gt;
📦 &lt;strong&gt;PyPI:&lt;/strong&gt; &lt;a href="https://pypi.org/project/html-table-rescuer/" rel="noopener noreferrer"&gt;html-table-rescuer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Throw your most complex, ugliest HTML tables at it. If the parser breaks, please open an issue on GitHub. Let's fix the dirty data problem together! &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy Scraping!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>webscraping</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
