Repository navigation
fix(extraction): keep text inside infographic boxes when infographic extraction is off - #2839
Conversation
…extraction is off Since #2815, Page Elements v3 postprocessing removes title, paragraph, and header/footer boxes contained in table, chart, or infographic boxes. With extract_infographics=False the OCR stage never reads infographic crops, so on scanned pages whose text lies inside an infographic box all text was dropped and the page produced no rows. Thread extract_infographics into the page-elements stage the same way the OCR stage receives it, and only treat infographic boxes as text containers when infographic content is extracted. Table and chart containment is unchanged. Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
… on and off Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
Keep current Parse guidance and correct the infographic extraction default while resolving the documentation conflict.
Skip infographic title matching alongside contained-text suppression so title-only pages keep an OCR target.
|
Superseded by #2861, which batches the release fixes into one PR, one commit per original PR. This change is commit-for-commit identical there. |
|
Reopened: keeping the release fixes as individual PRs for review. #2861 is closed. |
[Medium impact] The change reaches document extraction workflows that use Page Elements v3. The missing type annotations must be addressed before merging. Findings
Fix with agent prompt### Issue 1
nemo_retriever/src/nemo_retriever/models/nim/primitives/model_interface/yolox.py:undefined-1592
The new `suppress_text_in_infographics` parameter has no type annotation. The same applies to `match_infographics` in `match_structured_boxes_with_title` and `suppress_text_in_infographics` in `postprocess_included_texts`.
The repository requires type annotations on every public function parameter. Add `: bool` to these three new parameters; the older untyped parameters are outside this finding.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryPreserves detected page text inside infographic regions when infographic extraction is off.
Reviews (2) · Last reviewed commit: "Merge main into infographic text preserv..." · Reviewed by Greptile |
| confs, | ||
| class_="title", | ||
| classes=["table", "chart", "title", "infographic"], | ||
| suppress_text_in_infographics=True, |
There was a problem hiding this comment.
New flags lack types. The new
suppress_text_in_infographics parameter has no type annotation. The same applies to match_infographics in match_structured_boxes_with_title and suppress_text_in_infographics in postprocess_included_texts.
The repository requires type annotations on every public function parameter. Add : bool to these three new parameters; the older untyped parameters are outside this finding.
Rule Used: All public functions, methods, and class attributes must have type annotations. This includes parameter types, return types, and class-level attributes. Private/internal helpers (prefixed with _) are encouraged but not required. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: nemo_retriever/src/nemo_retriever/models/nim/primitives/model_interface/yolox.py
Line: 1592
Comment:
**New flags lack types.** The new `suppress_text_in_infographics` parameter has no type annotation. The same applies to `match_infographics` in `match_structured_boxes_with_title` and `suppress_text_in_infographics` in `postprocess_included_texts`.
The repository requires type annotations on every public function parameter. Add `: bool` to these three new parameters; the older untyped parameters are outside this finding.
**Rule Used:** All public functions, methods, and class attributes must have type annotations. This includes parameter types, return types, and class-level attributes. Private/internal helpers (prefixed with _) are encouraged but not required. ([source](https://github.com/nvidia/nemo-retriever/blob/dc3ffe92e7efe27648079031ee5f3b0abc386815/.greptile/config.json))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Retain current extraction documentation and clarify that detected text and title boxes inside infographic regions remain when infographic extraction is disabled. Signed-off-by: Jacob Ioffe <jioffe@nvidia.com>
There was a problem hiding this comment.
Devin Review found 1 finding. It is left for you to triage below.
|
|
||
|
|
||
| def postprocess_included_texts(boxes, confs, labels, classes): | ||
| def postprocess_included_texts(boxes, confs, labels, classes, suppress_text_in_infographics=True): |
There was a problem hiding this comment.
🟡 Missing types on new public options
New suppress_text_in_infographics and match_infographics parameters lack type annotations across three public helpers. The repository's Type Safety rules require complete annotations on public interfaces.
Devin left this for you to triage: Real repo-rule gap (new bool params lack annotations), but #2839 is already merged. Recommend a tiny follow-up PR off main adding : bool to the three helpers; no behaviour change.
Learn more
The new options on postprocess_included, match_structured_boxes_with_title, and postprocess_included_texts have boolean defaults but no parameter annotations. The package's Type Safety rules apply to all public interfaces, including these helpers.
Example: match_structured_boxes_with_title(..., match_infographics=True) introduces an unannotated public option, while postprocess_page_elements_v3 annotates its corresponding option as bool.
Recommended fix: Annotate the newly added parameters as suppress_text_in_infographics: bool = True and match_infographics: bool = True in all three helpers.
Was this helpful? React with 👍 or 👎 to provide feedback.
Keeps title, paragraph, and header/footer boxes that lie inside infographic boxes when
extract_infographics=False, so pages whose text sits in an infographic still produce rows.Since #2815, Page Elements v3 postprocessing removes text boxes contained in table, chart, or infographic boxes, and #2816 labels more regions as infographics. With infographic extraction off, no OCR pass reads infographic crops, so that text was dropped and the page produced no row.
cc @jiaruic09 (author of #2815 and #2816)
¹ Mean of 2 runs.
² Evals ran on 00ff799. The later commit (92e8e98) only changes docs.
The PR recovers rows: bo10k 9,940 → 9,981 docs (full table below); ViDoRe keeps the same 12,973 rows.
What changed
postprocess_page_elements_v3(..., suppress_text_in_infographics=True)passes the flag throughpostprocess_included_textstopostprocess_included. When it is False, onlytableandchartcount as text containers.detect_page_elements_v3(..., extract_infographics=True)passessuppress_text_in_infographics=extract_infographicson the local and remote postprocessing paths.build_graphand_MultiTypeExtractBaseaddextract_infographicsto the Page Elements kwargs, the same way the OCR stage already gets it.Why it's safe
extract_infographics=Truethe result is unchanged and text inside infographics is still removed, because infographic OCR re-reads it.tests/test_page_elements_infographic_text.pyuses raw detections from a real scanned page whose text lies inside one infographic box. Text survives with the flag off and is removed with it on, and table-contained paragraphs are removed either way. The existing Page Elements, YOLOX, and graph-builder tests also pass.Not tested: remote Page Elements NIM end to end (the same postprocess function is unit-tested); Nemotron Parse is unaffected.
Details
mainSetup: 8x NVIDIA RTX PRO 6000 Blackwell Server Edition, Nemotron 3.5 Embed BF16, default settings with infographic extraction off,
main= b1c42db. bo10k is the mean of two runs per arm (run-to-run spread ±0.3%); bo767 is one run per arm. The bo10k +1.0% is most likely the recovered rows going through OCR and embedding.Link to Devin session: https://nvidia-cloud.devinenterprise.com/sessions/57f5368b39844a038449e009f6bdd631
Open in Devin Desktop: https://nvidia-cloud.devinenterprise.com/desktop/session/57f5368b39844a038449e009f6bdd631?variant=devin
Requested by: @jioffe502
👀 1 finding for you to triage · Follow Devin's work