Repository navigation
feat(MinerU):Add support for MinerU table and image chunk classification - #16703
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughMinerU parsing now caches page metadata, normalizes content, produces table and image media blocks, and returns them to downstream parsing. Position handling preserves unpositioned media, while vision enrichment is limited to image sections and raw parsing paths. ChangesMinerU Media Parsing
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Parser
participant MinerUParser
participant MediaBlocks
participant VisionWrapper
Parser->>MinerUParser: parse_pdf
MinerUParser->>MediaBlocks: build table and image blocks
MediaBlocks-->>Parser: return sections and media blocks
Parser->>Parser: append media bboxes
Parser->>VisionWrapper: enrich raw image media
VisionWrapper-->>Parser: return enriched image chunks
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
deepdoc/parser/mineru_parser.py (1)
756-784: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd logging for the new media-block generation flow.
_transfer_to_media_blocksis a new flow that resolves images and builds table/image chunks but emits no logs (e.g., count of media blocks produced, or when a media type is skipped). A debug/info line here would aid observability, consistent with the surrounding parser code that already logs block counts.As per coding guidelines:
**/*.py: "Add logging for new flows".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/mineru_parser.py` around lines 756 - 784, Add logging inside _transfer_to_media_blocks to cover this new media-block generation flow, since it currently resolves tables/images and returns silently. Use the existing parser logger pattern in MinerUParser and emit a debug/info message when a media item is skipped (for unsupported types or disabled tables) and a summary count of media blocks produced before returning. Keep the log placement close to the processing in _transfer_to_media_blocks so the behavior is easy to trace alongside _normalize_output_type, _resolve_output_image, _build_table_text, and _build_image_texts.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/flow/parser/parser.py`:
- Around line 421-434: Figure blocks without an image can still be emitted from
the parser and later hit markdown rendering where VLM.image2base64 expects
b["image"], causing a KeyError. Update the parser logic in the
mineru_media_blocks handling to either skip those image-less figure boxes or
flatten them to text-only entries before appending to bboxes, and ensure the
downstream writer path in VLM/image rendering only processes figure boxes when
an image key exists.
---
Nitpick comments:
In `@deepdoc/parser/mineru_parser.py`:
- Around line 756-784: Add logging inside _transfer_to_media_blocks to cover
this new media-block generation flow, since it currently resolves tables/images
and returns silently. Use the existing parser logger pattern in MinerUParser and
emit a debug/info message when a media item is skipped (for unsupported types or
disabled tables) and a summary count of media blocks produced before returning.
Keep the log placement close to the processing in _transfer_to_media_blocks so
the behavior is easy to trace alongside _normalize_output_type,
_resolve_output_image, _build_table_text, and _build_image_texts.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4cd47385-bdd8-4487-8e40-fa084bdb45fb
📒 Files selected for processing (2)
deepdoc/parser/mineru_parser.pyrag/flow/parser/parser.py
|
相同的问题! |
|
Thanks for the PR. I reviewed the changes against What it fixes
Concerns worth addressing (not necessarily blockers)
Question for the author
I'm happy to help with either path. |
|
@Aeovy Could you please also help to fix CI failure? - I guess this may be a wrong test and your fix expose the bad behavior. =================================== FAILURES =================================== |
Thanks for reviewing,I will add few more commits to this pr to fix them this week :) |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
deepdoc/parser/mineru_parser.py (1)
897-897: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor: implicit
Optionalonparse_method.
parse_method: str = Noneshould beparse_method: Optional[str] = Noneper PEP 484 (flagged by Ruff RUF013). Cosmetic, no runtime impact.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/mineru_parser.py` at line 897, Update the _transfer_to_sections method annotation so parse_method is typed as Optional[str] while retaining its existing None default and runtime behavior.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@deepdoc/parser/mineru_parser.py`:
- Around line 941-971: Update _transfer_to_media_blocks so missing or invalid
position data produces no positions rather than the synthetic page-0 zero-bbox
fallback. Preserve valid results from extract_positions, and ensure downstream
media blocks receive an empty positions collection when no real bounding box
exists.
- Around line 863-870: The _build_table_text method currently returns "FAILED TO
PARSE TABLE" without recording the failure. Before returning this fallback when
no usable table content exists, log a diagnostic message through the parser’s
existing logging mechanism, while preserving the current successful text
assembly and fallback return value.
- Line 908: Update parse_pdf and _transfer_to_media_blocks so parse_method is
passed into media-block conversion; when parse_method is "paper", exclude IMAGE
and TABLE outputs from media blocks, while preserving existing behavior for
other methods and non-media content.
---
Nitpick comments:
In `@deepdoc/parser/mineru_parser.py`:
- Line 897: Update the _transfer_to_sections method annotation so parse_method
is typed as Optional[str] while retaining its existing None default and runtime
behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d42680d8-c3f6-47ab-af4a-7926e32ddc7d
📒 Files selected for processing (1)
deepdoc/parser/mineru_parser.py
162868a to
7dddf1a
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (6)
test/unit_test/deepdoc/parser/test_mineru_parser.py (1)
133-134: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDrop the absence assertion for the removed VLM helper.
assert not hasattr(parser, "_enhance_images_with_vlm")guards a method that no longer exists; it pins a deleted API rather than current behavior.As per coding guidelines, "remove tests that protect obsolete behavior".
♻️ Proposed change
assert image_texts == ["Figure caption", "Figure footnote"] - assert not hasattr(parser, "_enhance_images_with_vlm")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/unit_test/deepdoc/parser/test_mineru_parser.py` around lines 133 - 134, Remove the obsolete hasattr assertion from the parser test, leaving the image text assertions unchanged. Do not add a replacement assertion for the deleted _enhance_images_with_vlm helper.Source: Coding guidelines
deepdoc/parser/mineru_parser.py (3)
936-952: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd a
case _fallback to the match.
sectionis only bound inside the enumerated cases; today every reachableMinerUContentTypeis covered, but adding a new enum member would reuse the previous iteration'ssectionvalue instead of failing loudly.♻️ Proposed guard
case MinerUContentType.LIST: list_items = output.get("list_items") section = "\n".join(self._normalize_text_lines(list_items if isinstance(list_items, list) else None)) + case _: + self.logger.debug("[MinerU] Unhandled section type=%s", output.get("type")) + continue🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/mineru_parser.py` around lines 936 - 952, Update the match on output_type in the section-building logic to add a case _ fallback that raises an explicit error for unsupported MinerUContentType values, preventing section from retaining a previous iteration’s value. Keep the existing enumerated cases unchanged.
922-922: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFix the implicit
Optionalannotation.
parse_method: str = Noneis invalid typing (PEP 484) and is flagged by Ruff RUF013.♻️ Proposed fix
- def _transfer_to_sections(self, outputs: list[dict[str, Any]], parse_method: str = None, table_enable: bool = True): + def _transfer_to_sections(self, outputs: list[dict[str, Any]], parse_method: str | None = None, table_enable: bool = True):🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/mineru_parser.py` at line 922, Update the _transfer_to_sections method signature so parse_method explicitly allows None using the project's supported Optional/nullable annotation style, while preserving its existing default and behavior.Source: Linters/SAST tools
409-413: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLog when the target page size is unavailable.
_content_bbox_to_page_spacewarns and bails when_get_page_sizereturnsNone, but here the bbox silently passes through unscaled, so a downstream wrong position has no diagnostic trail.As per coding guidelines, "Add logging for new flows" applies to
**/*.py.🪵 Proposed tweak
target_page_size = self._get_page_size(page_idx) - if target_page_size is not None: + if target_page_size is None: + self.logger.warning("[MinerU] Missing page size for page_idx=%s; using raw middle bbox=%s", page_idx, bbox) + else: page_width, page_height = target_page_size🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/mineru_parser.py` around lines 409 - 413, Update _middle_bbox_to_page_space to log a warning and return the existing unscaled/fallback result when _get_page_size(page_idx) returns None, matching _content_bbox_to_page_space’s diagnostic behavior; preserve the current scaling path when target_page_size is available.Source: Coding guidelines
rag/flow/parser/parser.py (1)
446-451: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueLog instead of silently swallowing the position conversion failure.
Positions here are produced by
MinerUParser._transfer_to_media_blocksas fixed 5-tuples, so an exception means malformed upstream data — dropping it silently makes that undebuggable. Flagged by Ruff S110/BLE001.As per coding guidelines, "Add logging for new flows" applies to
**/*.py.🪵 Proposed fix
if positions: try: box["positions"] = [[p[0] + 1, p[1], p[2], p[3], p[4]] for p in positions] - except Exception: - pass + except Exception as e: + logging.warning("MinerU media block has malformed positions %s: %s", positions, e)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rag/flow/parser/parser.py` around lines 446 - 451, Update the exception handler in the position conversion block within MinerUParser._transfer_to_media_blocks to log the conversion failure instead of silently passing. Use the module’s existing logger and include the exception details, while preserving the current behavior of still appending the box without converted positions.Sources: Coding guidelines, Linters/SAST tools
test/unit_test/rag/flow/parser/test_media_vision.py (1)
14-69: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winFour copies of the same AST-exec symbol loader across the new tests. Each helper parses a source file, picks a single top-level node by name, compiles it, and execs it into a stubbed namespace — differing only in module path, symbol name, namespace stubs, and a hardcoded
parents[...]depth. Extract one shared_load_symbol(relative_module_path, symbol_name, namespace)helper into a common test utility.
test/unit_test/rag/flow/parser/test_media_vision.py#L14-L69: replace_load_media_vision_function,_load_vision_figure_parser_class, and_load_pdf_context_functionwith calls to the shared helper, keeping only their distinct namespace stubs.test/unit_test/rag/test_naive_mineru.py#L14-L29: replace_load_by_mineruwith the shared helper and drop the duplicateparents[3]repo-root computation.As per coding guidelines, "collapse duplicate implementations".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/unit_test/rag/flow/parser/test_media_vision.py` around lines 14 - 69, Extract the shared AST symbol-loading logic into a common test utility helper such as _load_symbol, centralizing repository-root resolution, source parsing, top-level symbol lookup, compilation, and execution. In test/unit_test/rag/flow/parser/test_media_vision.py lines 14-69, replace _load_media_vision_function, _load_vision_figure_parser_class, and _load_pdf_context_function with calls to the helper while preserving their namespace stubs. In test/unit_test/rag/test_naive_mineru.py lines 14-29, replace _load_by_mineru with the helper and remove its duplicate parents[3] root calculation.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@deepdoc/parser/mineru_parser.py`:
- Around line 936-952: Update the match on output_type in the section-building
logic to add a case _ fallback that raises an explicit error for unsupported
MinerUContentType values, preventing section from retaining a previous
iteration’s value. Keep the existing enumerated cases unchanged.
- Line 922: Update the _transfer_to_sections method signature so parse_method
explicitly allows None using the project's supported Optional/nullable
annotation style, while preserving its existing default and behavior.
- Around line 409-413: Update _middle_bbox_to_page_space to log a warning and
return the existing unscaled/fallback result when _get_page_size(page_idx)
returns None, matching _content_bbox_to_page_space’s diagnostic behavior;
preserve the current scaling path when target_page_size is available.
In `@rag/flow/parser/parser.py`:
- Around line 446-451: Update the exception handler in the position conversion
block within MinerUParser._transfer_to_media_blocks to log the conversion
failure instead of silently passing. Use the module’s existing logger and
include the exception details, while preserving the current behavior of still
appending the box without converted positions.
In `@test/unit_test/deepdoc/parser/test_mineru_parser.py`:
- Around line 133-134: Remove the obsolete hasattr assertion from the parser
test, leaving the image text assertions unchanged. Do not add a replacement
assertion for the deleted _enhance_images_with_vlm helper.
In `@test/unit_test/rag/flow/parser/test_media_vision.py`:
- Around line 14-69: Extract the shared AST symbol-loading logic into a common
test utility helper such as _load_symbol, centralizing repository-root
resolution, source parsing, top-level symbol lookup, compilation, and execution.
In test/unit_test/rag/flow/parser/test_media_vision.py lines 14-69, replace
_load_media_vision_function, _load_vision_figure_parser_class, and
_load_pdf_context_function with calls to the helper while preserving their
namespace stubs. In test/unit_test/rag/test_naive_mineru.py lines 14-29, replace
_load_by_mineru with the helper and remove its duplicate parents[3] root
calculation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 97e2180b-c0a1-4254-835c-24c401762cd7
📒 Files selected for processing (10)
deepdoc/parser/figure_parser.pydeepdoc/parser/mineru_parser.pyrag/app/manual.pyrag/app/naive.pyrag/flow/parser/parser.pyrag/flow/parser/utils.pyrag/nlp/__init__.pytest/unit_test/deepdoc/parser/test_mineru_parser.pytest/unit_test/rag/flow/parser/test_media_vision.pytest/unit_test/rag/test_naive_mineru.py
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
deepdoc/parser/mineru_parser.py (2)
976-983: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winSkip disabled tables before processing their positions.
When
table_enable=False,_line_tag()still runs first. Malformed table bbox data can therefore abort parsing even though table processing is disabled; valid tables also incur unnecessary work. Move this gate immediately after type normalization.Proposed fix
if output_type not in {MinerUContentType.TABLE, MinerUContentType.IMAGE}: self.logger.debug("[MinerU] Skip non-media type=%s", output.get("type")) continue + if output_type == MinerUContentType.TABLE and not table_enable: + self.logger.debug("[MinerU] Skip table (table_enable=False)") + continue position_tag = self._line_tag(output) if "page_idx" in output and "bbox" in output else "" positions = [(pages[-1], left, right, top, bottom) for pages, left, right, top, bottom in self.extract_positions(position_tag) if pages] if output_type == MinerUContentType.TABLE: - if not table_enable: - self.logger.debug("[MinerU] Skip table (table_enable=False)") - continue🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/mineru_parser.py` around lines 976 - 983, Move the table_enable=False guard in the output-processing flow to immediately after output_type normalization, before computing position_tag or calling extract_positions. Preserve the existing skip log and continue behavior, while ensuring disabled tables never invoke _line_tag, extract_positions, or _build_table_text.
362-374: 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy liftBound the raster cache to the requested page range.
This materializes every PDF page and
parse_pdfinvokes it withoutpage_from/page_toat Line 1061. A one-page parse therefore still retains the full document in memory, creating avoidable memory spikes for large PDFs. Render only the requested pages or lazily cache media crops, while preserving absolute-page coordinate mapping.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@deepdoc/parser/mineru_parser.py` around lines 362 - 374, The PDF raster cache in the parser initialization must be limited to the requested page range. Update the flow around the page-loading logic and the parse_pdf call site so page_from/page_to are propagated instead of defaulting to the full document, while preserving absolute page indices in page_sizes and coordinate mapping. Ensure page_images contains only requested pages, avoiding full-document materialization for single-page parses.
🧹 Nitpick comments (1)
test/unit_test/deepdoc/parser/test_mineru_parser.py (1)
154-170: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert VLM behavior rather than attribute absence.
assert not hasattr(parser, "_enhance_images_with_vlm")only protects against one implementation shape; a renamed or delegated VLM call would still pass. Spy on the enrichment boundary, or keep this test focused on the caption/footnote output contract. (raw.githubusercontent.com)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/unit_test/deepdoc/parser/test_mineru_parser.py` around lines 154 - 170, Update test_build_image_texts_uses_only_mineru_caption_and_footnote to verify behavior through the enrichment boundary rather than asserting absence of _enhance_images_with_vlm; spy on any VLM enrichment call and assert it is not invoked, while preserving the existing caption and footnote output assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@deepdoc/parser/mineru_parser.py`:
- Around line 976-983: Move the table_enable=False guard in the
output-processing flow to immediately after output_type normalization, before
computing position_tag or calling extract_positions. Preserve the existing skip
log and continue behavior, while ensuring disabled tables never invoke
_line_tag, extract_positions, or _build_table_text.
- Around line 362-374: The PDF raster cache in the parser initialization must be
limited to the requested page range. Update the flow around the page-loading
logic and the parse_pdf call site so page_from/page_to are propagated instead of
defaulting to the full document, while preserving absolute page indices in
page_sizes and coordinate mapping. Ensure page_images contains only requested
pages, avoiding full-document materialization for single-page parses.
---
Nitpick comments:
In `@test/unit_test/deepdoc/parser/test_mineru_parser.py`:
- Around line 154-170: Update
test_build_image_texts_uses_only_mineru_caption_and_footnote to verify behavior
through the enrichment boundary rather than asserting absence of
_enhance_images_with_vlm; spy on any VLM enrichment call and assert it is not
invoked, while preserving the existing caption and footnote output assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9c4e570a-8bd7-407e-b7ca-68a71af7a0b8
📒 Files selected for processing (2)
deepdoc/parser/mineru_parser.pytest/unit_test/deepdoc/parser/test_mineru_parser.py
|
@Aeovy pls check CI error - seems like Lefthook issue. |
072fdd5 to
5d57c83
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16703 +/- ##
=======================================
Coverage 90.65% 90.65%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 650 650
Misses 39 39
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fixed,I clicked the 'update branch' by accident |
Review: MinerU table & image chunk classification (#16703)Thanks for the contribution. I reviewed the current diff (via 1.
|
5d57c83 to
f536586
Compare
Thanks for the detailed review. I rebased the branch onto the current main and rechecked each item against the resulting diff.
The code shown in the review does not match the current rebased HEAD. The position-shaped branch currently preserves the original value:
Commit
I agree that the two loops have some source-level similarity, but I did not consolidate them in this feature PR because they are inside mutually exclusive provider branches.
The existing The paths also differ slightly: MinerU preserves all non-empty caption and description entries, while the current OpenDataLoader path keeps only the first list item. I therefore
The image-only filter was not intended as a behavior change. Commit Tables retain their structured HTML, and the VLM description is appended to that searchable text. The focused test verifies that one image and one table each receive exactly one The duplicate-inference issue is handled separately by making the caller own VLM enrichment: the MinerU parser no longer performs its own internal VLM pass. General/raw invokes
Retaining unpositioned media is intentional. When MinerU provides no valid bbox, the media block now carries an empty position list instead of a fabricated zero-area bbox. Missing display coordinates should prevent PDF In Manual chunking, such media is excluded only from the position-sorted text-section merge. It remains in This changes chunk counts only for media whose position metadata is unavailable. Those chunks remain searchable and renderable, but do not receive misleading position metadata.
Commit
Minor Commit |
|
Thanks for this — the direction is right and the net effect is positive. I checked out the branch locally, ran the new unit tests (24 passed), and diffed the runtime behavior against Four things I'd like to see before merge. 1.
|
|
Unexpected Import & Type Mismatch in rag/flow/parser |
|
Thanks for turning these around so quickly — I re-checked 1. Media blocks break document order in the DSL flow pathThis is the one thing I'd block on. The mechanismFour facts combine into the regression:
Net result: the markdown writer at Why this matters more than it might lookThe markdown output is a straight concatenation, so a 40-page report becomes 40 pages of prose followed by an undifferentiated pile of tables — each one detached from the paragraph that introduced it. For the Why the trade is specifically unfavourable hereThe flow path was already classifying MinerU media correctly before this PR. So on the flow path the PR trades a real ordering regression for a marginal gain: MinerU's native RecommendationOption A — smallest change, removes the regression entirely (my preference). Option B — if you want the flow to use MinerU's native images too. Either way, please add a test asserting that a 2.
|
Implementing this feature has been significantly more difficult than I initially expected, as I didn’t fully account for several production-specific details. Thank you for your review! While it may take some time, I’ll keep working on it. As for the logging module issue, I’ve already opened a new PR (#17722). |
|
Please help to resolve conflicts. Thank you. |
I've been very busy with work these days, can someone take over this task, or can it be done in a few days? |
|
@Aeovy Fine to wait. |
f701497 to
c003c77
Compare
|
@Aeovy Seems like CI issues - Lefthook |
c18fd5d to
149beb4
Compare
149beb4 to
d01f283
Compare
|
LGTM @yuzhichang Please have a second eye. |
I’ll continue testing and addressing the Mineru parsing issues. After this PR, I’ll be submitting a few more as there are still some bugs left to fix |
|
@Aeovy Appreciate for your contribution! We're actively porting RAGFlow from python to golang. Suggest submit golang part change (if necessary) in the same PR in future work. |
|
@yuzhichang I haven't learned Go yet, but once the Python version stabilizes, I might take the opportunity to learn it or use AI to migrate the feat to Go. |





Fix MinerU table and image chunk classification
Summary
This PR fixes two issues with MinerU PDF parser where table and image chunks were not properly classified or associated:
textinstead oftabletextBackground
#16118 fixed table HTML tag sanitization, but did not add chunk type parsing in
mineru_parser, so table chunks were still classified astext.#14946 implemented VLM-based image description for MinerU, but did not mount image resources to Chunks.
This PR connects the missing piece: processing
mineru_media_blocksin the parser pipeline to properly classify and associate table and image chunks.Changes
deepdoc/parser/mineru_parser.pyparse_pdf()<table>tags) are now returned with proper type information<img>tags) are extracted with position data and associated with their VLM-generated captionsrag/flow/parser/parser.pymineru_media_blocksreturn valuelayout_type: "table",textcontains HTML contentlayout_type: "figure",textcontains VLM description,imagestores the image objectBefore & After
Table Classification
Table Before (v0.26.3)
Table After
Tables are now correctly classified as
tabletype instead oftext.Image Association
Image Before (v0.26.3)
Image After
Images are now properly associated with their resources and classified as
imagetype.