Fix duplicate Table/Chart sections in to_markdown_by_page#1741
Open
randerzander wants to merge 3 commits intoNVIDIA:mainfrom
Open
Fix duplicate Table/Chart sections in to_markdown_by_page#1741randerzander wants to merge 3 commits intoNVIDIA:mainfrom
randerzander wants to merge 3 commits intoNVIDIA:mainfrom
Conversation
When multiple chunks per page all carry table/chart column data, _collect_page_record was appending a section for each chunk, producing 3x Table/Chart headers with identical content. _dedupe_blocks could not catch this because auto-incremented headers (### Table 1, ### Table 2) made otherwise-identical blocks appear distinct. Fix: deduplicate sections by content-only key (stripping the numeric header) before combining with text blocks, and filter out text blocks whose content is already represented by a labeled section. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
randerzander
commented
Mar 27, 2026
| # markdown formatted table from the first page | ||
| >>> chunks[1]["text"] | ||
| '| Table | 1 |\n| This | table | describes | some | animals, | and | some | activities | they | might | be | doing | in | specific |\n| locations. |\n| Animal | Activity | Place |\n| Giraffe | Driving | a | car | At | the | beach |\n| Lion | Putting | on | sunscreen | At | the | park |\n| Cat | Jumping | onto | a | laptop | In | a | home | office |\n| Dog | Chasing | a | squirrel | In | the | front | yard |\n| Chart | 1 |' | ||
| '| This | table | describes | some | animals, | and | some | activities | they | might | be | doing | in | specific |\n| locations. |\n| Animal | Activity | Place |\n| Giraffe | Driving | a | car | At | the | beach |\n| Lion | Putting | on | sunscreen | At | the | park |\n| Cat | Jumping | onto | a | laptop | In | a | home | office |\n| Dog | Chasing | a | squirrel | In | the | front | yard |\n| Chart | 1 |' |
Collaborator
Author
There was a problem hiding this comment.
Notice here that the text surrounding the table (captured in crop because it increases relevance for recall) is also included in the markdown format.
ToDo: exclude surrounding text from markdown formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
when running the core pipeline on multimodal_test.pdf and using to_markdown_by_page, table and charts get duplicated in the markdown text.
Claude's description:
When multiple chunks per page carry table/chart column data,
_collect_page_recordappended a section per chunk, producing 3× Table/Chart headers with identical content._dedupe_blockscouldn't catch this because auto-incremented headers made identical blocks appear distinct.Fix: deduplicate sections by content-only key (stripping the numeric header) before combining with text blocks, and filter out text blocks whose content is already covered by a labeled section.