Table Extraction and Processing#
Table handling in MinerU spans four concerns: structure detection, cross-page merging, cell-text normalization, and backend-specific accuracy differences.
Structure Detection#
PP-DocLayoutV2 (RT-DETR, 25 layout classes) locates table regions per page. Each detection becomes a type=table block in the intermediate JSON, containing table_body, table_caption, and table_footnote sub-blocks.
Two models handle cell-level structure recognition inside mineru/backend/analysis/pdf/tables.py:
| Model | Use case | Trigger |
|---|---|---|
SLANet+ (PaddleTableModel) | Borderless / wireless tables | Always run first |
UNet (UnetTableModel) | Ruled-line / wired tables | Run when classifier labels table as WiredTable, or WirelessTable with confidence < 0.9 |
Recognition flow for SLANet+: OCR is run on the table crop first (masking inline formula/image regions). OCR boxes and text are normalized, HTML-escaped, then passed to PaddleTable.predict(), which calls TableStructurer for cell-box prediction, applies adapt_slanet_plus() to reverse the 488-pixel resize scaling , then passes both the structure tokens and OCR results to TableMatch.
SLANet+ cell-to-OCR matching (matcher.py): Each OCR box is normalized to [x0, y0, x1, y1] and matched to the best cell bounding box by minimizing (1 โ IoU, distance) jointly . Boxes with IoU below 1e-8 are discarded . Multiple OCR boxes mapped to the same <td> are concatenated with a space separator; bold markup is promoted to wrap the whole cell when the first match is bold . Rowspan/colspan headers can cause misassignment when OCR box boundaries straddle a merged cell's geometry.
Both models emit HTML <table> markup with colspan/rowspan attributes stored in the block's content field. UNet applies an additional heuristic โ comparing cell counts, blank/nonblank ratio, and OCR text coverage between the wired and wireless results โ to select whichever HTML is better. If UNet raises an exception, it falls back to the SLANet+ HTML .
Cross-Page Table Merging#
Cross-page table merging is an optional LLM-aided postprocessing step controlled by the LLMAidedFeaturesConfig.cross_page_table_cell_merge flag, which defaults to false.
Call chain:
model_json_to_middle_json()inpostprocess/document.pybuilds the middle JSON (viadocvortex), then โ for PDF inputs โ callsapply_llm_aided_postprocess().llm_aided.pychecksconfig.features.cross_page_table_cell_mergeand, if enabled, dispatchesapply_llm_cross_page_cell_merge()concurrently with any enabled title-leveling.llm_cell_merge.pyruns the full merge logic:_find_continued_table_pairs()locates adjacent-page table pairs where the current page's first table hascontinues_prev is True._prepare_cell_merge_candidate()extracts the last data row of the previous table and the first data row of the current table, builds rendered cell segments, and constructs an LLM prompt .apply_llm_cross_page_cell_merge()sends all candidates concurrently to the LLM, validates the[0, 1, ...]response, expands it across colspan ranges, and writes the result intoTableBlock.cell_merge.
To enable: set in $MINERU_HOME/config.yaml:
llm_aided:
api_key: <your-key>
base_url: https://dashscope.aliyuncs.com/compatible-mode/v1
model: qwen3.5-plus
features:
cross_page_table_cell_merge: true
Or via environment variable MINERU_LLM_AIDED_FEATURES_CROSS_PAGE_TABLE_CELL_MERGE=true .
Known limitation: content_list.json can store only one img_path per table block, so cross-page merged table screenshots are incomplete in that format.
Cell Text Normalization#
Two normalizations are applied during cell comparison and header deduplication:
- Full-width โ half-width: Unicode
U+FF01โU+FF5Eshifted by0xFEE0to ASCII equivalents, implemented infull_to_half(). - Whitespace handling: structural comparison strips all whitespace; display output preserves internal whitespace.
Within SLANet+ matching, when multiple OCR boxes map to one <td>, a trailing space is appended to each fragment except the last to prevent words from being fused .
Known gap: there is no config parameter to insert spaces between OCR lines within a single table cell during pipeline processing (reported in #5262). Decimal/thousands separators are also not normalized, which can cause cell-boundary mismatches.
Output is HTML <table> markup embedded in the Markdown file. Markdown-syntax table format is not currently produced.
Backend Accuracy Differences#
| Backend | Table Accuracy | Notes |
|---|---|---|
| Pipeline | Baseline | CPU-capable; weakest on borderless/lightly-ruled tables |
Hybrid medium (-b hybrid-engine, default) | Mid | Pipeline layout fed to VLM; SaaS API locked to this level |
Hybrid high (-b hybrid-engine -e high) | High | Full two-step VLM layout + extraction; recommended for complex tables |
VLM (-b vlm-engine, pre-v2605) | Best overall | ~40% slower; hallucination risk; deprecated |
โ ๏ธ VLM merge_prev regression (model v2605 / MinerU v3.4.0): The merge_prev training flag was corrupted in model version 2605, causing VLM mode to silently skip all cross-page and cross-column table-cell merging . A maintainer confirmed the behavior is expected for that model and recommended switching to hybrid mode, which uses line-detection data for cross-column/cross-page merging with identical hardware requirements . The hosted SaaS at opendatalab.com already runs hybrid mode internally .
Migration: replace -b vlm-engine with -b hybrid-engine (or hybrid-auto-engine). No hardware changes required.
Key Files#
| File | Purpose |
|---|---|
mineru/backend/analysis/pdf/tables.py | Main table recognition dispatch (classification, SLANet+, UNet) |
mineru/model/table/rec/slanet_plus/main.py | SLANet+ model wrapper; resize scaling, OCR prep |
mineru/model/table/rec/slanet_plus/matcher.py | OCR-to-cell IoU + distance matching; HTML generation |
mineru/backend/postprocess/document.py | Document postprocess entry point; invokes LLM-aided pipeline |
mineru/backend/postprocess/llm_aided.py | Feature gate: cross_page_table_cell_merge + title_leveling dispatch |
mineru/backend/postprocess/table_merge/llm_cell_merge.py | LLM-assisted cross-page cell-merge logic |
mineru/config.py | LLMAidedConfig and LLMAidedFeaturesConfig definitions |