TableFormer (accurate) generates degenerate OTSL at max_steps cap → cell matcher drops table data rows (regression in 2.118.0+)
Summary
With TableFormerMode.ACCURATE, some financial-report tables lose all of their data
rows while keeping the surrounding frame (title/header/label cells). The table is still
emitted with the same table count, but the merged digit text is gone.
Root cause on our side of the boundary: the TableFormer token generator emits a
degenerate OTSL sequence that runs to predict.max_steps (1023 of 1024 steps) with
zero content tokens, producing an all-empty grid; MatchingPostProcessor then drops
98 of 174 page cells as "matched neither a row nor a column band".
This is a regression introduced in docling 2.118.0 (2.117.0 is good, 2.118.0 is bad,
with an identical docling-ibm-models 3.15.0 and docling-parse 7.20.0 on both sides).
Environment
- docling: 2.127.0
- docling-ibm-models: 4.0.2
- docling-core: 2.96.0
- docling-parse: 7.20.0
- Python 3.11, macOS arm64 (Apple Silicon), CPU/MPS
- TableFormer artifacts revision:
v2.3.0(docling-project/docling-models)
Minimal reproduction
Single page extracted from a public annual report (Pop Mart International Group
Limited, 2025 Annual Report, page 330). Attached: popmart-2025-annual-report-p331.pdf.
from docling.datamodel.accelerator_options import AcceleratorOptions, AcceleratorDevice
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions, TableFormerMode
from docling.document_converter import DocumentConverter, PdfFormatOption
pipeline_options = PdfPipelineOptions()
pipeline_options.do_ocr = True
pipeline_options.do_table_structure = True
pipeline_options.accelerator_options = AcceleratorOptions(device=AcceleratorDevice.AUTO)
pipeline_options.table_structure_options.mode = TableFormerMode.ACCURATE
pipeline_options.table_structure_options.do_cell_matching = True
converter = DocumentConverter(
format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)}
)
result = converter.convert("popmart-2025-annual-report-p331.pdf")
print(result.document.export_to_dict()["tables"][0]["data"]["table_cells"])
Expected: the "Movements in issued and fully paid ordinary shares" table contains its
data rows, e.g. 1,348,243,150, 5,300,000, (4,700,000), (10,468).
Actual (2.127.0): only framework cells are emitted (USD'000 RMB'000,
普通股面值 普通股面值 庫存股數目 (附註, 27 ), ...). The data values are absent from
both texts and table_cells.
Control: with table_structure_options.mode = TableFormerMode.FAST on the same page
and same version, all data cells are recovered.
Version bisect (same single page, same pipeline options)
| docling | docling-ibm-models | docling-parse | result |
|---|---|---|---|
| 2.110.0 | 3.15.0 | 7.20.0 | good — 18 cells incl. all data rows |
| 2.115.0 | 3.15.0 | 7.20.0 | good |
| 2.117.0 | 3.15.0 | 7.20.0 | good |
| 2.118.0 | 3.15.0 | 7.20.0 | bad — 19 framework-only cells |
| 2.120.3 | 4.0.2 | 7.20.0 | bad |
| 2.126.0 | 4.0.2 | 7.20.0 | bad |
| 2.127.0 | 4.0.2 | 7.20.0 | bad |
Note the good/bad boundary sits inside docling itself, not in docling-ibm-models:
2.117.0 and 2.118.0 both resolve docling-ibm-models==3.15.0 and
docling-parse==7.20.0.
Isolation evidence (2.117.0 vs 2.118.0, instrumented TFPredictor.multi_table_predict)
| observed | 2.117.0 (good) | 2.118.0 (bad) |
|---|---|---|
| TableFormer weights revision | v2.3.0 | v2.3.0 (same) |
| input word tokens | 174 (91 unique texts) | 174 (same texts, same order, same bboxes) |
| table crop passed in (2x coords) | [138, 282, 1086, 1222] | [138, 282, 1088, 1222] (2pt wider on the right) |
generated rs_seq length |
1023 | 1023 (both at the max_steps cap) |
| resulting grid / cells | 16×12 → 18 cells incl. data rows | 14×16 → 19 framework-only cells |
So: identical model weights, identical inference package, identical parse backend, and token-for-token identical model input — yet different post-processing outcome. The only difference we can see is a 2pt-wider table crop (and whatever layout/pipeline changes produce it) between 2.117.0 and 2.118.0, plus a differing interpretation of the same 1023-step sequence.
Mechanism detail (2.127.0 / docling-ibm-models 4.0.2)
The generator's OTSL sequence for this table:
- length 1023 (cap is
predict.max_steps = 1024in the accuratetm_config.json) - token histogram:
lcel691,fcel115,nl110,ecel107 - zero content tokens — the sequence is structurally degenerate, and it does not terminate early
Decoding this sequence yields an all-empty grid. MatchingPostProcessor then logs:
MatchingPostProcessor WARNING 98 of 174 pdf cells matched neither a row nor a
column band of the 111x5 grid and were dropped from the table
i.e. all real content (including every data-row value) is discarded, and the survivors are compressed into the 19 framework cells that appear in the output.
Impact
Multi-page financial statements lose entire data rows while the table frame survives, so downstream consumers read a structurally valid but numerically empty table — arguably worse than a missing table, because nothing signals the loss. We found this in production document processing (250-document corpus); the single page above reproduces it exactly.
Two related observations from a 40-document A/B (accurate vs fast) that may help scope
the issue: fast recovers the affected table completely on this sample, but we did
observe a small number of reverse losses on scanned pages with fast, so this is not
a simple "use fast instead" recommendation — the accurate path's handling of
max-steps-capped sequences looks like the thing to fix.
Attachments
popmart-2025-annual-report-p331.pdf— single page, public annual reportp331-text-layer.txt— raw text layer of that page (shows the values are real text, not OCR/bitmap artifacts)tableformer-probe-2.127.json— instrumentedmulti_table_predictinput (174 tokens with bboxes) and output (rs_seq stats, cell list) on 2.127.0tf-input-comparison-2117-vs-2118.json— the same instrumentation on 2.117.0 vs 2.118.0, showing identical tokens and the differing outcomebisect-results.md— version bisect tablep331-rendered-216dpi.png— rendered page for visual reference
bisect-results.md
p331-text-layer.txt
popmart-2025-annual-report-p331.pdf
tableformer-probe-2.127.json
tf-input-comparison-2117-vs-2118.json
Hi, I’d like to work on this issue. I’ll first reproduce the regression between 2.117.0 and 2.118.0, identify the relevant change, and add a regression test before proposing a fix.
Thanks for the detailed report and the single-page repro. I reproduced it with docling 2.117.0, 2.118.0 and 2.127.0 in clean venvs (macOS arm64, AcceleratorDevice.AUTO, torch 2.14.0, docling-core 2.97.0, docling-parse 7.20.0). I think the root cause is further upstream than 2.118.0, and the 2.117.0 output wasn't correct either.
@AbarnaaSree, before you spend time on the 2.117.0 → 2.118.0 bisect: the findings below suggest it leads to a crop shift that only flips an already-degenerate prediction, so a regression test pinned to the 2.117.0 crop would lock in a coin flip rather than a fix.
This also overlaps heavily with #4181, which describes the same mechanism on a different document (a capped sequence, then orphan cells dropped), and with #4182, which preserves the dropped words as text during page assembly. #4182 stops the content loss but leaves both the broken structure and the silent cap in place, so I think it is complementary to a decoder-level fix rather than a replacement for one.
1. Layout emits one table for most of the page. The raw layout predictions include both a page-sized table cluster (l=69 t=139 r=543 b=611, conf 0.73 on 2.117.0 / 0.84 on 2.127.0) and the two real tables inside it: "Authorised" (t=168 b=333, conf 0.38–0.45) and "Movements" (t=378 b=610, conf 0.46–0.58). LayoutPostprocessor keeps only the large cluster in both versions. That region also covers the note heading, the "Movements in issued…" sentence, and both tables.
2. TableFormer accurate degenerates on that region in every version. As your probe already shows, 2.117.0 also runs to 1023 steps. The model repeats row patterns until it reaches max_steps, producing a grid of roughly 110 rows. In 2.117.0 the data survives only because entire rows are merged into single cells (e.g. At 1 January 2024 於 2024 年 1 月 1 日 1,348,243,150 136 885), and (78,031) is still missing.
3. On that region the outcome is very sensitive to the crop. On 2.127.0, patching TFPredictor.multi_table_predict to override only the right edge of the table bbox (2x page coords, top 282, bottom 1222):
| right edge | TableFormer grid | page cells dropped | data rows present |
|---|---|---|---|
| 1084 | 1×1 | 169 / 174 | no |
| 1086 | 16×2 | 33 / 174 | yes (merged into row cells) |
| 1088 | 18×2 | 26 / 174 | yes (merged into row cells) |
| 1090 | 19×3 | 0 | yes (merged into row cells) |
All four runs hit the 1023-step cap. On my machine 1088 kept the data where it lost it for you, so the result also varies by device. The 2pt shift between 2.117.0 and 2.118.0 comes from #3914, which moved layout inference to the object-detection path and clamps boxes to the page. That change moved the crop across one of these flip points. On current main the crop top is 278 instead of 282, and the unpatched 2.127.0 run keeps 1,348,243,150 here.
4. With per-table crops, accurate mode produces sensible structure. With the same page and model, crops matching the two inner clusters give short sequences that terminate normally:
- Movements
[138, 780, 1088, 1222]: 5×7 grid in 40 tokens. Every data value lands in its own cell, e.g.1,348,243,150|136|885|(600,000)|(10,468), and(4,700,000)|(78,031). - Authorised
[138, 400, 1088, 690]: 4×4 grid in 20 tokens.
(This patch replaces only the crop passed to the model. The matcher still receives all 174 tokens from the original region, so text outside the crop gets folded into the edge cells. For Authorised, that makes the cell contents meaningless. A real per-table layout cluster would pass only its own tokens.)
TableFormerMode.FAST on the large region finishes in 160 tokens (20×7) and recovers the values on this page. That probably explains why fast looked better here, and why it isn't reliably better elsewhere.
5. How often this happens, and what a split-and-retry fallback recovers. To see whether the page in this issue is an outlier, I ran 2.127.0 in accurate mode over 588 pages (662 tables): DocLayNet and OmniDocBench page images, all 448 OmniDocBench pages that carry at least one annotated table, and the 40 largest PubTabNet tables.
| corpus | pages | tables | reached max_steps |
|---|---|---|---|
| DocLayNet + OmniDocBench (mixed) | 100 | 60 | 1 |
| PubTabNet (40 largest tables) | 40 | 38 | 0 |
| OmniDocBench, table-bearing pages | 448 | 564 | 5 |
| total | 588 | 662 | 6 (0.9%) |
Two observations:
- No genuinely large table came close to the cap. The longest normal sequence was 905 steps, and PubTabNet's ground truth puts its largest table at an estimated 720 OTSL tokens. All six capped sequences were degenerate rather than truncated.
- The damage is total, but not always visible as missing text. Four of the six kept every word while collapsing the structure (7×1, 9×1, 39×16 → repeating grids); one kept 36% of words, and the DocLayNet table of contents kept 2% in a single 1×1 cell. Counting dropped cells alone would miss the majority of these.
As a prototype fallback, when a region hits the cap I re-run it on halves split at a horizontal whitespace gap near the middle of the region, recursing up to 4 levels. On all 6 cases every band terminated normally and every input word landed in a cell:
| case | original | after split-and-retry |
|---|---|---|
| Popmart p331 (this issue) | 14×2, 75% of words | 4×4 + 5×7, 100% |
| DocLayNet table of contents | 1×1, 2% | 28×2 + 27×5, 100% |
| 3 newspaper stock listings | 7×1/8×1/9×1, 36–100% | 2 bands each, 100% |
| scihub table | 39×16, 100% | 3 bands, 100% |
The cost is about one extra inference per band, and only on regions that already hit the cap: roughly 40 s per case on my CPU/MPS machine, against 0.9% of tables.
Suggested directions:
- Detect the degenerate case. A sequence that reaches
max_stepswithout an end token isn't a usable structure. Today the only signal available to docling islen(rs_seq) == max_steps - 1; an explicit "sequence terminated" flag from docling-ibm-models would be cleaner. At minimum this should log a warning, since the failure is currently silent. #4181 makes the same point for the zero-nlcase. - Fall back deterministically. Splitting at whitespace gaps recovered every case above. Because greedy decoding differs across devices (the same crop gave different results on your machine and mine), the last resort should be geometric: rows from line clusters, columns from vertical whitespace gaps, which is reproducible and never drops a word. Checking that every input word ends up in exactly one cell makes the fallback chain verifiable rather than best-effort.
- Layout postprocessing. When a large
tablecluster contains separatetabledetections plus section headers, preferring the inner tables would avoid giving TableFormer multi-table regions at all. In the corpus above, 10 layout regions covered two or more annotated tables, so this is not unique to the page in this issue. This may be worth its own issue.
Restoring the 2.117.0 crop would fix this page, but other pages would still land on the wrong side of the same flip point.
@noho Thank you for the unusually detailed reproduction. I am studying a narrow read-only check that compares numbers/rows in a source PDF with the final extracted or chunked output, rather than trying to repair TableFormer itself. In your last production occurrence, how was the missing data first noticed, roughly how long did it take to locate the cause, and would a page-specific “source value absent from final output” finding have changed your workflow? Or would an upstream Docling warning/fix be sufficient? I am not asking for the production corpus or any confidential document.
@denis-samatov Thanks for looking into this. Thanks for looking into this. A read-only, page-specific completeness check would be useful for our workflow. We extract financial statements and their notes into structured data for investment research. In this case, the missing values were identified during a comparison of the old and new Docling outputs following an upgrade. We then checked the original PDF’s text layer and confirmed that the numbers were present in the source but absent from the new extraction. The page and table counts had not changed, so those checks alone would not have caught it. I don’t have a reliable elapsed-time measurement. The investigation involved source verification, version comparisons, decoder instrumentation, and testing configuration alternatives—not just locating the affected page. A finding such as “these source values on page 331 are absent from the extracted output,” with the relevant table or bounding box, would have helped us isolate the problem earlier and hold the affected data for review before downstream calculations. For our use case, two distinctions matter:
- Presence versus correctness: retaining every number is not sufficient if it is attached to the wrong row, period, or column.
- Extraction versus intentional selection: we intentionally select only some financial metrics downstream. A check against the full extraction would be useful by default; checking the final selected dataset would need to understand that scope to avoid flagging deliberate exclusions. Ideally, findings would include the source location, missing value or row, and the output stage where it disappeared, without modifying the extraction automatically. An upstream warning or fix would certainly help, but an independent source-to-output check would still be valuable as an additional safeguard against other silent losses.
@noho Thank you — the distinction between full extraction and intentionally selected metrics is especially helpful. I made two synthetic counterexamples before extending the prototype: swapping two amounts between rows passes a number-presence check, while comparing a selected metric to the whole PDF creates false alarms. I will keep this first check scoped to PDF → full extraction and label row/period/column correctness as unchecked.
For a first read-only hold-for-review decision, would a finding with the source page, missing literal, and candidate text-layer bounding box be sufficient, or would table/row/period context be required before your team could act on it? For example: REVIEW: source page 331, value 1,348,243,150 absent from full extraction; source bbox available; presence check only. A short answer is enough; no production or client files are needed.
I read the decode loop for this: TableModel04_rs.predict exits silently when it reaches max_steps without <end>, and TFPredictor passes the sequence on as if it had terminated. I can send the small first step from the list above to docling-ibm-models: a warning plus a reached_max_steps flag in the predict details, with a test, and no change to the output. Is anyone already on that part? If not I’ll open it.
@sibisrinivasb
reaches max_steps without , and
I think you lost a key phrase to formatting.
Thanks, you're right: GitHub swallowed the token as an HTML tag. It was the <end> token; I've fixed the comment above.
The change is open as docling-project/docling-ibm-models#211: when the decode loop reaches max_steps without <end>, predict now logs a warning and sets reached_max_steps in its details, so docling can detect the degenerate case instead of comparing lengths. No output changes; three tests. It is the "detect the degenerate case" step from your list, nothing more.
I checked docling-project/docling-ibm-models#211 at 14e4e42. All three tests in test_tf_predictor_max_steps.py passed locally with the PR's predictor code and the already installed dependencies. The tests confirm that reached_max_steps and the warning flag a non-empty tag sequence that ends without <end>.
This confirms the diagnostic signal. I did not rerun the PDF from this issue or verify recovery of the missing table rows.
I ran the attached popmart-2025-annual-report-p331.pdf end to end on CPU with Docling 2.123.0, swapping only the TableFormer source between the base (4419794) and docling-project/docling-ibm-models#211 (14e4e42). OCR and cell matching were enabled.
- ACCURATE: The problematic table hit the 1,024-step limit without
<end>in both runs. With the PR,predict_details.reached_max_stepswasTrueand the warning appeared. The exported document JSON was identical before and after the PR. The matcher dropped 44 of 174 input cells in both runs, and(10,468),(78,031), and88,499were still missing from the export. This reproduced a partial loss on my setup. - FAST: On the same PDF with the PR, the decoder emitted
<end>and the flag wasFalse. All six checked values were present in the exported table:1,348,243,150,5,300,000,(4,700,000),(10,468),(78,031), and88,499. This was a presence check. I did not verify their row and column assignments.
Follow-up to my FAST run above: I reran the same attached PDF with docling-project/docling-ibm-models#211 (14e4e42) on CPU with Docling 2.123.0. The document JSON matched the earlier FAST export. I checked the source PDF against the exported row labels, column headers, and cell bounding boxes. All six previously checked values are in the right cells. The parenthesized occurrence of 5,300,000 is also in the right cell.
| Source row | Number of ordinary shares | Number of treasury shares | Carrying value of treasury shares (RMB thousands) |
|---|---|---|---|
| At 1 January 2024 | 1,348,243,150 |
(10,468) |
|
| Purchase of own shares | (4,700,000) |
(78,031) |
|
| Cancellation of repurchased shares | (5,300,000) |
5,300,000 |
88,499 |
One structural issue remains in this FAST output. The closing balance label At 31 December 2024 and 2025 is on exported row 19, while its amounts (1,342,943,150, 135, 882) are on row 20 (1-based row numbers).
I traced the closing-balance row in FAST on the same attached PDF. In the source, the English label At 31 December 2024 and 2025 is on the upper text line, while the continuation of the Chinese label and the amounts are about 14 pt lower, all within the same logical row.
The TableFormer prediction already contains an OTSL nl between those lines before cell matching. The matcher assigns the English label to R19C1 and the three amounts (1,342,943,150, 135, 882) to R20C3–C5. Post-processing and row renumbering preserve those positions (1-based).
I reproduced this on CPU with Docling 2.123.0 using both the TableFormer base commit (4419794) and docling-project/docling-ibm-models#211 (14e4e42). The matching traces and exported document JSON were identical.
I reran FAST on the PDF attached to this issue with Docling 2.123.0 on CPU and the TableFormer source from docling-project/docling-ibm-models#211 (14e4e42). A targeted post-processing step reconstructed the closing balance in row 19 of the export (1-based). The English label, the complete Chinese label, 1,342,943,150, 135, 882, and both dashes now appear together in the same row.
All 66 cells in rows 1–18 and the English label in R19C1 were unchanged. The five entries moved up from row 20 kept their column indices and PDF bounding boxes. I verified the result in both the structured document and its Markdown export. This check covers only the attached PDF.
Classification labels added: bug, priority:medium, pdf.
These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.
@denis-samatov Thanks for testing #211 so thoroughly, and sorry for the slow reply.
Your result is what the PR is meant to do and no more: in the ACCURATE run the flag is set and the warning appears, and the export is unchanged. It only makes the degenerate case detectable. Recovering the rows (a retry in FAST, or splitting the region, as in the list above) is a separate step for docling to decide.
One data point that supports using the flag as the trigger. I ran TableFormer accurate (docling-ibm-models 4419794, CUDA, predict_dummy on cropped tables) over four public benchmarks, 20,498 tables. The decoder reached max_steps on 26 of them (0.13 %): FinTabNet.c test 1 of 9,289, PubTabNet val 7 of 9,115, the OmniDocBench tables 7 of 665, MUSTARD 11 of 1,429. Those 26 have a mean structure TEDS between 4 and 17, so a capped sequence was almost always a broken table, not a long table cut short. That agrees with the 6 of 662 reported above on full pages.
The split closing-balance row you traced in FAST looks like a separate issue, since the row break is already in the model's prediction. It may be worth its own report.
I opened a separate issue for the split closing-balance row in FAST: #5454.
I ran your public page on CPU with Docling 2.154.0. FAST puts the closing label in CSV row 19 and its figures in row 20. An explicitly selected delivery of just the two share-count columns passes all eight positions while the upstream warning is retained. Here is a read-only checker for this table and the adjacent award table: https://gist.github.com/kangyishuai/28ebac140e96bff9b0f77c66015690c7/afeb61a04a8c4d23c36ce6b89e333ea003e94b96
If you try it on one of your saved exports, did it flag a row you would hold or override, and would you use it again? A row reference is enough.