Skip to content

fix(ingest): enable OCR text extraction in default pipeline - #2524

Open
iamdevdhanush wants to merge 5 commits into
NVIDIA:mainfrom
iamdevdhanush:main
Open

fix(ingest): enable OCR text extraction in default pipeline#2524
iamdevdhanush wants to merge 5 commits into
NVIDIA:mainfrom
iamdevdhanush:main

Conversation

@iamdevdhanush

Copy link
Copy Markdown

Description

Fixes the default CLI ingest pipeline to activate OCR text extraction for all extraction methods, not just pdfium_hybrid and ocr.
The default extract_text=True flag was ignored for method="pdfium" (the default) because three code paths gated OCR activation on:
if method in ("pdfium_hybrid", "ocr") and extract_text:
This condition was always False when method="pdfium", causing:

  • Default CLI ingest of images (retriever ingest scanned_doc.png) to skip OCR and produce empty text
  • Default CLI ingest of PDFs with scanned pages to skip OCR in the PDF graph builder
    Remove the method restriction in all three locations. OCR text extraction now activates whenever extract_params.extract_text is True, regardless of extraction method:
  • ingestor_runtime.py:792 — PDF graph builder OCR kwargs
  • multi_type_extract_operator.py:106 — _ocr_stage_needed() helper
  • multi_type_extract_operator.py:484 — _run_detection_pipeline() OCR kwargs
    Five new regression tests in test_ocr_version_selection.py verify the fix.

Closes #2443

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@iamdevdhanush
iamdevdhanush requested review from a team as code owners August 17, 2026 18:17
@iamdevdhanush
iamdevdhanush requested a review from mahikaw August 17, 2026 18:17
@copy-pr-bot

copy-pr-bot Bot commented Aug 17, 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 Aug 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR enables OCR text extraction for the default pdfium pipeline and adds full-page OCR fallback handling for scanned pages lacking text-region detections.

  • Schedules OCR whenever text extraction is enabled.
  • Marks scanned pdfium pages as requiring OCR text.
  • Routes full-page OCR predictions into page text and adds regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
nemo_retriever/src/nemo_retriever/common/modality/ocr/shared.py Adds full-page OCR crop handling and routes its predictions into page text.
nemo_retriever/src/nemo_retriever/graph/ingestor_runtime.py Enables OCR graph construction whenever text extraction is requested.
nemo_retriever/src/nemo_retriever/operators/extract/pdf/extract.py Marks scanned pages using the default pdfium method as requiring OCR text extraction.
nemo_retriever/src/nemo_retriever/operators/graph_ops/multi_type_extract_operator.py Enables OCR stage selection and text kwargs independently of the extraction method.
nemo_retriever/tests/test_ocr_version_selection.py Adds regression tests for default pdfium OCR scheduling, scanned-page eligibility, and full-page crop creation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[PDF or image ingest] --> B{extract_text enabled?}
    B -- No --> C[Continue without text OCR]
    B -- Yes --> D[Schedule OCR stage]
    D --> E{Text-region crop available?}
    E -- Yes --> F[OCR text crops]
    E -- No --> G[OCR full-page fallback]
    F --> H[Populate page text]
    G --> H
Loading

Reviews (5): Last reviewed commit: "Merge branch 'main' into main" | Re-trigger Greptile

Comment thread nemo_retriever/src/nemo_retriever/graph/ingestor_runtime.py
extract_text=False,
extract_tables=False,
extract_charts=False,
extract_infographics=False,

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.

P2 New test lacks annotations

The new test_detection_pipeline_includes_ocr_for_default_method function leaves monkeypatch untyped and omits its -> None return annotation, weakening static checking and violating the repository's public-function annotation standard.

Rule Used: All public functions, methods, and class attribute... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: nemo_retriever/tests/test_ocr_version_selection.py
Line: 410

Comment:
**New test lacks annotations**

The new `test_detection_pipeline_includes_ocr_for_default_method` function leaves `monkeypatch` untyped and omits its `-> None` return annotation, weakening static checking and violating the repository's public-function annotation standard.

**Rule Used:** All public functions, methods, and class attribute... ([source](.greptile))

---

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!

Comment thread nemo_retriever/src/nemo_retriever/operators/extract/pdf/extract.py
Comment thread nemo_retriever/src/nemo_retriever/common/modality/ocr/shared.py Outdated
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.

[BUG]: Default ingest pipeline via CLI skips OCR extract_text

1 participant