Skip to content

fix(deepseek-ocr): keep continuation lines in non-table blocks - #4910

Closed
Yi-111-a wants to merge 1 commit into
docling-project:mainfrom
Yi-111-a:fix-deepseek-continuation-lines
Closed

Yi-111-a wants to merge 1 commit into
docling-project:mainfrom
Yi-111-a:fix-deepseek-continuation-lines

Conversation

@Yi-111-a

@Yi-111-a Yi-111-a commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

_collect_annotation_content stopped after the first non-empty line for any label other than tables and pictures. A DeepSeek-OCR response like

text[[100,100,900,300]]
First line
Second line

text[[100,400,900,500]]
Next block

produced First line and Next block as text items and silently dropped Second line. Unlimited-OCR delegates to the same collector after normalizing its <|det|>.. markers, so it lost the same lines.

The collector now gathers the block's consecutive non-empty lines until the next annotation or the first blank line. Empty lines, following annotations, captions, and table markup keep their boundaries, so caption linkage and table parsing are unchanged; figure/image/table blocks are handled by their existing branches. This fixes both parsers.

Closes #4905

Testing

  • New plain-string tests in tests/test_unlimited_ocr_markdown.py pinning the issue's reproduction for both response shapes: continuation lines survive, and an annotation line / blank line still ends a block.
  • uv run pytest -q tests/test_unlimited_ocr_markdown.py: 9 passed.
  • tests/test_deepseekocr_vlm.py cannot be collected locally (it imports the full VLM pipeline stack, which needs the models extra); its reference-data paths are untouched by this change.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @Yi-111-a, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 19, 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)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added the bug Something isn't working label Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 1f6aacf744. The analysis read the diff only. It did not run code from this pull request.

This pull request updates _collect_annotation_content to collect consecutive non-empty lines for text blocks in DeepSeek-OCR and Unlimited-OCR. It also adds unit tests for multiline OCR text blocks.

CI safety: no concern found. A maintainer must still approve CI.

Possible duplicates

PR State Signal Assessment
#4909 open also references issue #4905; changes the same code duplicate: PR #4909 changes the same function to preserve multiline text blocks for DeepSeek-OCR and Unlimited-OCR.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Oct 19, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at 8523cc67a3. It read the code and did not run it.

No blocking defect found. The new loop in _collect_annotation_content stops at the next annotation or the first blank line after content. That keeps the old boundaries for tables, captions and figures. The three DeepSeek reference sources in tests/data/md_deepseek/sources put each block's content on one line before a blank line, so their output does not change.

A maintainer makes the merge decision. This review never approves the pull request.

_collect_annotation_content stopped after the first non-empty line for
labels other than tables and pictures, so a multi-line text/title block
lost every line after the first one. Unlimited OCR delegates to the same
collector after normalizing its markers, so it lost the same lines.

Now every non-table block collects consecutive non-empty lines until the
next annotation or the first blank line, so all content in the first
block survives until the next annotation. Empty lines, following
annotations, captions, and table markup keep their boundaries.

Fixes docling-project#4905

Signed-off-by: Yi-111-a <153097222+Yi-111-a@users.noreply.github.com>
@Yi-111-a

Copy link
Copy Markdown
Contributor Author

DCO check fixed: the single commit now carries the Signed-off-by trailer (amended 8523cc6). No content change.

@Yi-111-a
Yi-111-a force-pushed the fix-deepseek-continuation-lines branch from 8523cc6 to 1f6aacf Compare October 20, 2026 09:00
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem and removed ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Oct 20, 2026

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cau-git

cau-git commented Oct 22, 2026

Copy link
Copy Markdown
Member

@Yi-111-a this has been already handled in #4964, thanks. I am therefore closing this PR.

@cau-git cau-git closed this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeepSeek and Unlimited OCR discard continuation lines in text blocks

3 participants