{"slug": "show-hn-unlimited-ocr-2-on-dual-panel-lab-tables-what-works-what-breaks-how", "title": "Show HN: Unlimited-OCR-2 on Dual-Panel Lab Tables: What Works, What Breaks, How", "summary": "Baidu released Unlimited-OCR-2, a small open-weights document vision-language model, on Hugging Face and ModelScope, and a local test on Apple Silicon found it handled a dense Chinese hospital CBC plus 5-part differential sheet well outside the results grid but merged the page's two side-by-side result lists into a single HTML table. Running in Transformers on MPS after patching two .cuda() calls in masked_scatter_ and forcing image tensors to fp32, the model loaded in about 19 seconds and processed one dense page in about 9 minutes on an M4-class Mac. The tester's fix was to crop the table bounding box at the vertical middle and run each pane through the same model with the built-in \"Free OCR.\" prompt.", "body_md": "Baidu released [Unlimited-OCR-2](https://huggingface.co/baidu/Unlimited-OCR-2) as open weights (also on [ModelScope](https://modelscope.cn/models/PaddlePaddle/Unlimited-OCR-2)). It is a small document [vision-language model](https://zlu.me/ai-glossary/vision-language-model/). It reads pages and returns text with layout tags, reading order, tables, and multi-page context. The model card describes Sparse Reference Sliding Window Attention (SR-SWA), which keeps long-document decoding cost from growing as fast as plain full attention.\n\nI ran Unlimited-OCR-2 locally on Apple Silicon (MPS, fp32). The PDF stayed on my machine. The test page was a Chinese hospital **[CBC](https://zlu.me/med-glossary/全血细胞计数/) (complete blood count) + 5-part differential** sheet: one page, dense header, then a results grid. Below I describe the layout only. No patient identifiers and no real lab values from that file.\n\n## What worked without extra code\n\nOn that page, full-page [inference](https://zlu.me/ai-glossary/inference/) was already useful for everything *outside* the results grid:\n\n- hospital title (Chinese and English)\n- section labels (name, sex, age, specimen type, department, order item)\n- timestamps and footer notes\n- a `table[...]` block with a page-normalized bounding box\n\nRuntime on an M4-class Mac: model load about 19 s, one dense page about 9 minutes in Transformers on MPS. The official docs assume NVIDIA CUDA. On Mac I patched two `.cuda()` calls in `masked_scatter_` and forced image tensors to fp32 (bf16 on MPS drifted). After that, local runs worked.\n\nThe output is not only a flat string. It returns text blocks, titles, an HTML `<table>`, and boxes. That structured markup is what I parse next.\n\n## Where it failed: dual-panel CBC grids\n\n*Example photo only. This is not the PDF I ran. It shows the same kind of [CBC](https://zlu.me/med-glossary/全血细胞计数/) printout: one big rectangle, two result lists side by side, the same column headers on left and right, one vertical line between the lists, and almost no lines inside each list. Copies in a paper stack also overlap. That is why reading the whole page as one table fails.*\n\nHospital lab reports are often printed by a [lab computer system (LIS)](https://zlu.me/med-glossary/实验室信息系统/). Many of those printouts put **two separate result lists on one page**. The left list is long ([WBC](https://zlu.me/med-glossary/白细胞/) through [RDW-CV](https://zlu.me/med-glossary/红细胞分布宽度/)). The right list is short ([RDW-SD](https://zlu.me/med-glossary/红细胞分布宽度/) through [P-LCR](https://zlu.me/med-glossary/大血小板比例/)). Both sides use the same headers: item, result, unit, reference range. The row counts do not match. People read left, then right. The model still tried to build **one** HTML table.\n\nUnlimited-OCR-2 did that. Paddle-style table tools I tried on the same kind of sheet did the same. The print layout is the problem, not only one OCR tool.\n\nA schematic of the bad HTML (synthetic values):\n\n```\n<tr>\n  <td>WBC</td><td>★白细胞计数</td><td>9.20↑</td><td>10^9/L</td>\n  <td>3.5-9.5</td>\n  <td>RDW-SD 红细胞分布宽度标准差</td><td>42.0</td><td>fL 40.0-53.0</td>\n</tr>\n```\n\nThe header said eight columns: item / result / unit / ref, twice. The model also split the left item into English abbr + Chinese name as two cells. Every later cell on that row moved one slot. On the right, unit and reference range sometimes landed in one cell. After the short right list ended, left-only rows continued with empty right cells. The model had joined left and right by row number.\n\nHeader text was fine. The error starts when the model is forced to invent one `<table>` for two lists of different length.\n\n## Fix 1: cut left and right, run Unlimited-OCR-2 on each crop\n\nUnlimited-OCR-2 already returns a table box on a 0-1000 page grid, for example `table[11, 247, 979, 753]`. I map that box to pixels, crop the results band, and cut it at the vertical middle. Each crop goes back into the **same** Unlimited-OCR-2 model. The prompt string is `\"Free OCR.\"` That is an instruction built into Unlimited-OCR-2, not another OCR product.\n\n```\nfull page\n   └─ table bbox\n         ├─ left panel PNG  →  Unlimited-OCR-2\n         └─ right panel PNG →  Unlimited-OCR-2\n```\n\nEach crop is one list. On the tested [CBC](https://zlu.me/med-glossary/全血细胞计数/) PDF (not the photo above) I got 18 left rows and 6 right rows, and [PLT](https://zlu.me/med-glossary/血小板/) stayed on the right. That is the membership error the full-page HTML got wrong.\n\nPanel crops alone are not enough. On the left crop, `↑` was still mixed up with the unit column, and many reference ranges were missing. The right crop was cleaner. Cutting the page stops left/right mixing. It does not fix every column mix-up inside one side.\n\n## Fix 2: repair the shifted full-page HTML\n\nThe broken full-page `<table>` still has the right words and numbers. They sit in the wrong cells. For this hospital printout the repeating pattern is:\n\n```\ncode | chinese_name | value | unit | ref | right_item | right_value | right_unit_ref\n```\n\nwhile the right list still has a row, then left-only rows after that.\n\nA small parser walks each `<tr>`. If cell 0 looks like a lab code and cell 1 is Chinese, the first five cells are one left result. The rest of the row is the right result. Synthetic example:\n\n| panel | code | name | value | flag | unit | ref | \n|---|---|---|---|---|---|---|\n| left | [WBC](https://zlu.me/med-glossary/白细胞/) | ★白细胞计数 | 9.20 | ↑ | 10^9/L | 3.5-9.5 | \n| right | [PLT](https://zlu.me/med-glossary/血小板/) | ★血小板计数 | 200 |  | 10^9/L | 125-350 | \n\nThat is enough for JSON or Markdown without another model call. The left/right crops are still useful to check that the repaired rows match the two sides.\n\n## Limits\n\n- Unlimited-OCR-2 does not know, by itself, that this printout is two lists. Extra code has to split left and right, or repair the HTML. Switching to another open OCR tool does not remove that step for this layout.\n- Mac MPS is fine for local tests. It is slower and less supported than the NVIDIA CUDA + SGLang setup in the official docs.\n- The HTML repair above matches this hospital’s column order. A different lab printout may need different repair code.\n\n## Steps I use\n\n1. Rasterize the PDF locally (I used 300 DPI).\n2. Run Unlimited-OCR-2 once on the full page. Keep the layout markup and the table box.\n3. If the HTML looks like an 8-column merge with abbr and Chinese name split apart, repair it with the row parser above.\n4. Optionally crop left and right and run Unlimited-OCR-2 again to check panel counts.\n5. Export `{code, name, value, flag, unit, ref, panel}` records. Do not send the raw merged`<table>` into clinical logic.\n\nUnlimited-OCR-2 is strong on Chinese hospital headers and boxes. On dual-panel [CBC](https://zlu.me/med-glossary/全血细胞计数/) sheets, the remaining gap is simple: the page is two lists, not one table, even when both lists sit inside one rectangle. Split the page, or repair the HTML, and keep the PDF local.\n\n## References\n\n1. Baidu ERNIE Team. “Unlimited OCR Works 2: Pioneering the OCR-3.0 Era: From Long- to Unlimited-Horizon Parsing.” arXiv preprint, 2026. [arXiv:2610.39308](https://arxiv.org/abs/2610.39308) .\n Read in[BetterReads](https://www.betterreads.dev/reader?bookId=unlimited_ocr_works_2&type=pdf&preview=1)", "url": "https://wpnews.pro/news/show-hn-unlimited-ocr-2-on-dual-panel-lab-tables-what-works-what-breaks-how", "canonical_source": "https://zlu.me/2026/11/16/unlimited-ocr-2-dual-panel-lab-tables.html", "published_at": "2026-11-16 09:19:37+00:00", "updated_at": "2026-11-16 09:53:26.333018+00:00", "lang": "en", "topics": ["computer-vision", "large-language-models", "ai-research", "ai-tools"], "entities": ["Baidu", "Unlimited-OCR-2", "Hugging Face", "ModelScope", "PaddlePaddle", "Apple Silicon"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/show-hn-unlimited-ocr-2-on-dual-panel-lab-tables-what-works-what-breaks-how", "markdown": "https://wpnews.pro/news/show-hn-unlimited-ocr-2-on-dual-panel-lab-tables-what-works-what-breaks-how.md", "text": "https://wpnews.pro/news/show-hn-unlimited-ocr-2-on-dual-panel-lab-tables-what-works-what-breaks-how.txt", "jsonld": "https://wpnews.pro/news/show-hn-unlimited-ocr-2-on-dual-panel-lab-tables-what-works-what-breaks-how.jsonld"}}