Skip to content

fix(vlm): use each element's own page for force_backend_text#3807

Open
anxkhn wants to merge 1 commit into
docling-project:mainfrom
anxkhn:fix/vlm-force-backend-text-multipage
Open

fix(vlm): use each element's own page for force_backend_text#3807
anxkhn wants to merge 1 commit into
docling-project:mainfrom
anxkhn:fix/vlm-force-backend-text-multipage

Conversation

@anxkhn

@anxkhn anxkhn commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

In the VLM DocTags pipeline, _turn_dt_into_doc re-extracted backend text using the page variable left over from the preceding page-collection loop, which is always the last page. On a multi-page document converted with force_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=True and 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:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

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>
@github-actions

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @anxkhn, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/pipeline/vlm_pipeline.py 84.61% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant