fix(vlm): use each element's own page for force_backend_text#3807
Open
anxkhn wants to merge 1 commit into
Open
fix(vlm): use each element's own page for force_backend_text#3807anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
In the DocTags pipeline, _turn_dt_into_doc re-extracted backend text using the `page` variable left over from the page-collection loop, which is always the last page. On a multi-page document with force_backend_text=True, every text element was therefore extracted from the last page's backend and scaled by the last page's height, so all pages received the final page's text. Derive each element's page from its own provenance (page = conv_res.pages[element.prov[0].page_no - 1]) and skip pages without a size, mirroring the pattern already used for picture extraction in _assemble_document. This restores the per-element behavior originally added in PR docling-project#1371, which was lost during a later refactor. Add a regression test that converts a two-page DocTags document with force_backend_text=True and asserts each page's element text comes from its own page's backend. Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
Contributor
|
✅ DCO Check Passed Thanks @anxkhn, all your commits are properly signed off. 🎉 |
Contributor
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
In the VLM DocTags pipeline,
_turn_dt_into_docre-extracted backend text using thepagevariable left over from the preceding page-collection loop, which is always the last page. On a multi-page document converted withforce_backend_text=True, every text element was therefore re-extracted from the last page's backend and scaled by the last page's height, so all pages received the final page's text (and wrong crop coordinates).This derives each element's page from its own provenance (
page = conv_res.pages[element.prov[0].page_no - 1]) and skips pages without a size, mirroring the pattern already used for picture extraction in_assemble_document. Single-page conversions are unaffected. This restores the per-element behavior that was originally added in #1371 and later lost during the vlm-models refactor, so no reference conversion data changes.A regression test converts a two-page DocTags document with
force_backend_text=Trueand asserts each page's text comes from its own page's backend (it fails before this change because page 1's element receives page 2's text).Checklist: