Skip to content

feat(parse): text-layer fallback, 8192-token length retry, and Markdown tables for Parse 3.5 - #2869

Open
jioffe502 wants to merge 34 commits into
mainfrom
devin/1795047395-parse-quality-guards
Open

jioffe502 wants to merge 34 commits into
mainfrom
devin/1795047395-parse-quality-guards

Conversation

@jioffe502

@jioffe502 jioffe502 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds three quality guards to full-page Nemotron Parse 3.5 batch extraction. Each one targets a failure mode measured on bo10k (text retrieval) and the eight ViDoRe v3 subsets (image+text retrieval). All three are ParseParams settings and are on by default.

Setting Default Behavior
text_layer_min_overlap 0.3 If fewer than 30% of Parse page-text words occur in the native PDF text layer, or Parse returns no page text, page text comes from the text layer instead. This applies only to pages with at least 30 native words. Table, chart, and infographic regions are kept, and native lines whose tokens all occur in that structured text are left out so table cells are not repeated. Untagged native /v1/parse Markdown is never replaced, since its tables are inline. The fallback also applies to native /v1/parse endpoints, which select the model server-side. Records text_source="text_layer" and text_layer_lines_dropped.
length_retry_max_tokens 8192 Local pages that stop with finish_reason="length" are rerun with this limit, unless their output tail compresses like a loop. The retry applies only when the first limit is lower. Records length_retry.
table_format (full page) markdown (was HTML) Shorter Table text that ranks better. Chart routing still defaults to simple_html.

NemotronParse35.invoke_batch_results gains an optional per-call max_tokens (vLLM only), which the retry uses.

Scope: batch full-page Parse 3.5 (NemotronParseActor / nemotron_parse_pages) and the local vLLM adapter. The retry needs the local model. The text-layer fallback and markdown default apply to all Parse 3.5 paths.
Unchanged: chart routing, the OCR pipeline, service/Helm, and remote endpoint request parameters.
Base: built on #2862. Until #2862 merges, this diff includes it.

Measurements

Offline A/B on saved Nemotron-3.5-Parse captures (picture-text prompt, temperature 0.2, repetition penalty 1.05, top-k 50, max_tokens=4096). Page-level embeddings, dense top-10, no reranker. bo10k uses text; ViDoRe v3 (all 8 subsets, unweighted mean) uses text+image.

Parse output bo10k R@5 / R@10 / nDCG@10 bo10k table R@10 ViDoRe R@5 / R@10 / nDCG@10 ViDoRe finance_fr R@10
Baseline .8137 / .8612 / .7197 .9021 .5218 / .6324 / .5834 .4879
+ text-layer fallback .8107 / .8589 / .7181 .9021 .5266 / .6385 / .5889 .5363
+ fallback + markdown tables .8159 / .8619 / .7243 .9149 .5261 / .6379 / .5890 .5353

On bo10k, repeated baseline runs vary by about .003. The fallback switched 2,946 of 213,538 bo10k pages and 467 of 19,252 ViDoRe pages. An empty-Picture crop pass was also measured and is left out because it gave no gain with the picture-text prompt.

End-to-end batch ingest of this branch on bo10k (213,538 pages, 2 GPUs, same settings and layout as the baseline, max_tokens=4096):

bo10k R@5 R@10 nDCG@10 pages/s table R@10 infographic R@10
Baseline (#2862 settings) .8129 .8619 .7203 49.4 .902 .772
This branch .8129 .8627 .7228 46.8 .915 .767

Page metadata: 0 failures, 2,918 pages used the text layer, 745 pages reran at 8,192 tokens, and length-capped pages fell from 1,664 to 983.

End-to-end on ViDoRe v3 (all 8 subsets, 19,252 pages, unweighted mean):

ViDoRe mean R@5 R@10 nDCG@10
Baseline (#2862 settings) .5214 .6320 .5831
This branch .5248 .6379 .5887

Page metadata: 0 failures, 467 pages used the text layer (all of the gain is in finance_fr), 62 pages reran at 8,192 tokens, and length-capped pages fell from 92 to 41.

Structured-line dedupe on fallback pages, measured offline on the same captures with the earlier 80%-word-coverage rule (fallback + markdown, without vs with dedupe). The current rule requires every token to match, so it drops a subset of those lines:

bo10k R@5 / R@10 / nDCG@10 ViDoRe mean R@5 / R@10 / nDCG@10 finance_fr R@10 bo10k table tokens repeated in page text
Without dedupe .8166 / .8634 / .7244 .5259 / .6378 / .5890 .5359 84.6%
With dedupe .8159 / .8634 / .7247 .5257 / .6379 / .5889 .5361 7.6%

The end-to-end runs above predate the dedupe, the retry-failure handling, and the rebase onto the current #2862. Those changes do not alter successful-page Parse output, apart from the removal of duplicated lines on fallback pages.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes. New tests/test_nemotron_parse_quality_guards.py (19 tests) and a vLLM max_tokens override test. Targeted Parse/params/chart-routing/runtime tests pass (477). Per-file full suite passes except test_nemotron_rerank_vl_v2_hf, which fails on a Hugging Face download, on the Batch local Parse 3.5 vLLM generation across pages and Ray UDF threads #2862 base too.
  • The documentation is up to date with these changes (ParseParams table in nemo-retriever-api-reference.md, incomplete-page guide in troubleshoot.md).

Link to Devin session: https://nvidia-cloud.devinenterprise.com/sessions/f1b18f26cd8b480b883b4fdd5fabab63
Open in Devin Desktop: https://nvidia-cloud.devinenterprise.com/desktop/session/f1b18f26cd8b480b883b4fdd5fabab63?variant=devin
Requested by: @jioffe502


🟢 Devin fixed all 2 findings · Follow Devin's work

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues remain.

Summary

Adds native PDF text fallback, optional longer retries for capped local pages, and Markdown table defaults for full-page Parse 3.5.

  • Parse can use PDF text when its page text is missing or garbled.
  • Local Parse reruns pages that stop at the output token limit.
  • Full-page Parse 3.5 tables use Markdown by default.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Page image] --> B[Parse output]
  B --> C{Local output capped and eligible?}
  C -->|Yes| D[Retry with larger limit]
  D -->|Call fails| E[Keep first-pass output]
  D -->|Call succeeds| F[Use retry output]
  C -->|No| G[Route text and structured regions]
  E --> G
  F --> G
  G --> H{Native text fallback qualifies?}
  H -->|Yes| I[Replace page text and remove repeated structured lines]
  H -->|No| J[Keep Parse text]
  I --> K[Return content and completion details]
  J --> K
Loading

Reviews (13) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

greptile-apps[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 2 findings. Devin automatically fixed all 2 findings.

Fixed by Devin (2)
  • Inline tables lost during fallback — Untagged native /v1/parse Markdown is now never replaced by the text layer, because its inline tables have no structured region to keep. A test covers a native Markdown table page.
  • Distinct PDF lines dropped as duplicates — A line is now dropped only when every token occurs in the structured text, so 'Bonus 1 2 3 4' is kept next to a 'Base 1 2 3 4' table. A test covers this.

View findings in Devin Review · Follow Devin's work

Devin Review

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…alidate blank pages

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…cument routing KV cache

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…ilure

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1795047395-parse-quality-guards branch from 1d91591 to 38ce78f Compare November 19, 2026 14:06
greptile-apps[bot]

This comment was marked as resolved.

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…ndpoints

The structured-line drop ignored single-digit tokens and matched words across
all regions, so 'Revenue 9' was dropped when a table held 'Revenue 5'. A line
is now dropped only when every token containing a digit also occurs in the
structured text. Native /v1/parse callers omit the model name, so the text-layer
fallback now also runs for native endpoints.

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…text layer

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
dropped = 0
for line in native_text.splitlines():
tokens = _RE_TOKEN.findall(line.lower())
if tokens and all(token in structured_tokens for token in tokens):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Require a matching passage before dropping a native line

The single-digit fix does not resolve the remaining cross-row/cross-region match: structured_tokens is one set for every retained region, so co-occurrence anywhere is treated as duplication. Reproduced at this head: _drop_structured_lines("Sales 2024 100", ["Sales 2023 100", "Costs 2024 200"]) returns ("", 1), although neither table row contains the native fact "Sales 2024 100". When the default fallback activates, that fact disappears from both page text and ordered_page_text without an error. Match the normalized line against one actual passage/region, preserving label/value associations, or retain the native line when duplication cannot be established. Please extend the differing-values regression with this case; a page-wide token set is still too broad.

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.

Fixed in 7cc895e. _drop_structured_lines now splits structured text into rows (lines, plus HTML </tr> boundaries) and drops a native line only when all of its tokens occur within a single row. Sales 2024 100 is kept against rows Sales 2023 100 and Costs 2024 200, while a native line that duplicates one row is still dropped. New test: test_fallback_keeps_lines_matched_only_across_structured_rows.

…e-quality-guards

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>

# Conflicts:
#	nemo_retriever/src/nemo_retriever/models/local/nemotron_parse35.py
#	nemo_retriever/src/nemo_retriever/operators/extract/parse/nemotron_parse.py
#	nemo_retriever/tests/test_nemotron_parse35_vllm.py
…empty native responses

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
…e-quality-guards

Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>

# Conflicts:
#	docs/docs/extraction/nemo-retriever-api-reference.md
#	nemo_retriever/src/nemo_retriever/operators/extract/parse/nemotron_parse.py

This branch has not been deployed

No deployments
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.

2 participants