CheneyWong's picture
Upload README.md with huggingface_hub
a8117cb verified
|
Raw History Blame Contribute Delete
12.7 kB
---
license: apache-2.0
pretty_name: Table Recognition Benchmark (17 sources, 184,074 tables)
tags:
- table-recognition
- table-structure-recognition
- document-image-analysis
- ocr
- document-understanding
- cv
- computer-vision
- teds
- paddleocr-vl
language:
- en
- zh
- ja
- de
- fr
- ar
- hi
configs:
- config_name: default
data_files:
- split: test
path: "*.parquet"
---
# Table Recognition Benchmark
17 public and self-built table sources merged into **64 uniformly sized shards**
(**184,074** tables, ~8.6 GB of images). Every row carries **both** an OTSL
and an HTML ground truth, plus a flag marking the tables that carry no cell
text at all.
## Layout
```
shard_0000.parquet ... shard_0063.parquet # 64 evenly-sized shards
overlong.parquet # oversized / over-long tables
README.md # you are here
scripts/fill_otsl.py # html -> otsl
scripts/fill_html.py # otsl -> html
```
Shards are balanced by **total image bytes, not row count** — each holds
~169 MB of images, and every shard mixes 15–17 different sources, so a single
shard already gives broad coverage.
## Schema
| column | type | meaning |
|---|---|---|
| `bytes` | binary | the table image, as stored (PNG/JPEG) |
| `source` | string | fine-grained original dataset name |
| `benchmark` | string | which of the 16 sources this row came from |
| `sample_id` | string | original sample identifier (may be empty) |
| `rows` / `cols` | int64 | table grid dimensions |
| `otsl` | string | OTSL ground truth |
| `html` | string | HTML ground truth |
| `resolution` | string | `WIDTHxHEIGHT` |
| `width` / `height` | int64 | image dimensions |
| `structure_only` | bool | true when the table has **no cell text at all** |
---
## What is OTSL
**OTSL = Optimized Table Structure Language**, the compact token language
PaddleOCR uses to represent table structure. A table is a flat token stream —
no nesting, no closing tags:
| token | meaning |
|---|---|
| `<fcel>` | a new (filled) cell starts here |
| `<ecel>` | an empty cell |
| `<lcel>` | continuation **to the left** (horizontal merge) |
| `<ulcel>` | continuation **above** (vertical merge) |
| `<xcel>` | continuation both left and above |
| `<nl>` | end of row |
Cell text is inlined directly after its `<fcel>`, so the stream alternates
structure and content:
```
<fcel>Year<fcel>Division<ecel><ecel><nl>
<fcel>2023<fcel>A<ecel><ecel><nl>
```
Compare with HTML for the same table — six characters per cell of pure
syntax, and every merge costs a `colspan`/`rowspan` attribute:
```html
<table><tr><th>Year</th><th>Division</th><td></td><td></td></tr>
<tr><td>2023</td><td>A</td><td></td><td></td></tr></table>
```
OTSL's advantage is that structure and text live in one linear sequence, which
is what a sequence-to-sequence table recogniser predicts directly.
## What is TEDS and TEDS-S
**TEDS = Tree-Edit-Distance-based Similarity** (PubTabNet). Both tables are
turned into ordered trees — `<table>` → `<tr>` → `<td>` — and scored as
`1 - normalized_tree_edit_distance`:
```
TEDS = 1 - TD / max(N_pred, N_gt)
```
where `TD` is the tree edit distance and `N` the node count. It combines two
signals into one number:
- **structure** — did you get the rows, columns, and merges right?
- **text** — did you get the cell *contents* right?
**TEDS-S** is the structure-only variant: cell text is erased before the
trees are compared, while spans (`colspan`/`rowspan`) are preserved. So
`TEDS-S = 1 - TD_struct / max(N_pred, N_gt)`.
The two bracket each other:
| | TEDS | TEDS-S |
|---|---|---|
| table structure wrong | penalised | penalised |
| cell text wrong | penalised | **ignored** |
| use for | full-fidelity output | structure/topology comparison |
A model that nails the grid but hallucinates cell contents scores high on
TEDS-S and low on TEDS — that gap is the diagnostic.
## Why `structure_only` matters, and how to score it
**31,429 rows (13.8%)** are *pure structure*: every cell is empty and only the
grid and span layout is annotated (`synthtabnet` 29,990, `sprint_mustard`
1,429, `tabrecset` 7, `tableverse` 3).
TEDS always compares cell text. Against an all-empty ground truth, that half
of the metric degenerates into *"did the model correctly output nothing"* —
which is not a meaningful quantity, and a model is rewarded for hallucinating
text into a cell that should be blank.
The rule used for this benchmark:
- `structure_only == true` → score with **TEDS** (TEDS-S is redundant there)
- `structure_only == false` → score with **TEDS-S** (structure is the
comparable signal across corpora)
```python
ds = load_dataset("CheneyWong/table_recognition_eval",
data_files="shard_*.parquet", split="test")
headline = [TEDS if r["structure_only"] else TEDS_S for r in ds]
```
Report the two groups **separately**. Averaging them into one number mixes
incompatible metrics and the ranking stops meaning anything.
## OTSL ↔ HTML are interconvertible
Both formats encode the same table, so either can be derived from the other.
Where a source shipped only one, the other was generated here:
- **`otsl` derived from `html`** for `pubtables1m`, `mmsci`, `pubtablesv2`,
`tableverse`, `hitab`, `scitsr`, `sprint_mustard`, `pubtabnet_val`,
`pubtabnet_icdar21`, `omnidocbench`
- **`html` derived from `otsl`** for `tabrecset_zh`, `tabrecset_en`
- **native to the source** for `fintabnet`, `synthtabnet`, `tablet`,
`ccocr`, `ocrbenchv2`
**All rows have both fields populated.** Rows left with neither after
conversion were dropped rather than shipped without ground truth.
Round-trip fidelity, measured on a 2,500-row sample:
| check | result |
|---|---|
| byte-identical `otsl → html → otsl` | 41.2% |
| identical after ignoring the normalisations below | 72.8% |
| span tokens (`colspan`/`rowspan`) fully preserved | 91.0% |
The conversion is **structurally faithful but not byte-stable**. Three known
normalisations account for the gap:
1. **Row padding.** HTML has no ragged rows — a short row must be padded to the
grid width, so converting back yields trailing `<ecel>`.
2. **Empty-cell spelling.** `<fcel>` with no text and a bare `<ecel>` mean the
same thing; we canonicalise to `<ecel>`.
3. **Irregular rowspan layout.** On tables whose vertical merges do not tile
cleanly, span placement is re-derived rather than preserved verbatim.
If you need exact span placement, keep `otsl` as the source of truth — it is
never generated from HTML for the sources that ship it natively.
### Conversion scripts
Two scripts, both multi-worker:
- [`scripts/fill_otsl.py`](scripts/fill_otsl.py) — HTML → OTSL. Walks the
parquet row group by row group (memory stays bounded), collects the rows
whose `otsl` is empty but whose `html` is not, converts them across a
worker pool, and rewrites the file. Recomputes `structure_only` afterwards,
since it is derived from `otsl`.
```bash
python scripts/fill_otsl.py shard_0000.parquet --workers 128
```
- [`scripts/fill_html.py`](scripts/fill_html.py) — OTSL → HTML, the mirror
image: fills `html` wherever it is missing but `otsl` is present.
```bash
python scripts/fill_html.py shard_0000.parquet --workers 128
```
Neither loads the whole file into memory: rows are processed per row group
and converted in a `multiprocessing.Pool`, so `--workers 128` is safe on a
machine with many cores.
---
## Sources
| benchmark | rows | share | origin | OTSL from |
|---|---:|---:|---|---|
| `pubtables1m` | 93,834 | 41.1% | PubTables-1M test split | HTML |
| `mmsci` | 12,129 | 6.6% | MMSci-Table **test** split | HTML |
| `synthtabnet` | 29,990 | 13.2% | SynthTabNet test | native |
| `fintabnet` | 10,397 | 4.6% | FinTabNet_OTSL test | native |
| `pubtabnet_icdar21` | 9,064 | 4.0% | ICDAR 2021 official test | HTML |
| `pubtablesv2` | 7,680 | 3.4% | PubTables-v2 test split | HTML |
| `tableverse` | 4,951 | 2.2% | TableVerse-5K | HTML |
| `hitab` | 3,597 | 1.6% | HiTab | HTML |
| `scitsr` | 3,000 | 1.3% | SciTSR | HTML |
| `sprint_mustard` | 1,429 | 0.6% | SPRINT-MUSTARD | HTML |
| `tabrecset_en` | 4,394 | 2.4% | TabRecSet-en | native |
| `tabrecset_zh` | 1,065 | 0.6% | TabRecSet-zh | native |
| `tablet` | 909 | 0.4% | TABLET test split | native |
| `omnidocbench16` | 665 | 0.4% | OmniDocBench v1.6 | HTML |
| `omnidocbench15` | 512 | 0.3% | OmniDocBench v1.5 | HTML |
| `ccocr` | 300 | 0.1% | CC-OCR | native |
| `ocrbenchv2` | 158 | 0.1% | OCRBench-v2 table-parsing tasks | HTML |
| **total** | **184,074** | 100% | | |
## Deliberate exclusions
- **TABLET train pool** (17,720 rows) — replaced by the 909-row test split,
since the train pool overlaps the evaluation set.
- **OCRBench-v2 non-table tasks** (9,300) — OCRBench-v2 is a general document-VQA
benchmark. POIE, ChartQA, MMMU, textvqa and the rest carry no table annotation
at all, so they cannot score a table recogniser. Of the 700 genuinely
table-parsing tasks, 542 say "all tables in the image" with no region to
crop to; only the 158 with an explicit bbox are included.
Rows that ended up with neither OTSL nor HTML were dropped rather than shipped
without ground truth. **As of this version there are none: all 184,074 rows
carry both.**
## Related datasets in this org
The individual source corpora are published separately, so you can pull just the
ones you need without downloading the merged 184k-row set above:
| dataset | what it is |
|---|---|
| [`FinTabNet-OTSL`](https://huggingface.co/datasets/CheneyWong/FinTabNet-OTSL) | financial statement tables, OTSL annotations |
| [`HiTab`](https://huggingface.co/datasets/CheneyWong/HiTab) | hierarchical tables with dense row/column spans |
| [`MMSci-Table`](https://huggingface.co/datasets/CheneyWong/MMSci-Table) | scientific tables from recent papers |
| [`PubTabNet`](https://huggingface.co/datasets/CheneyWong/PubTabNet) | the original PubTabNet release |
| [`PubTabNet-ICDAR-test-GT`](https://huggingface.co/datasets/CheneyWong/PubTabNet-ICDAR-test-GT) | official ICDAR 2021 challenge ground truth |
| [`PubTables-1M`](https://huggingface.co/datasets/CheneyWong/PubTables-1M) | 1M scientific tables, structure annotations |
| [`PubTables-v2`](https://huggingface.co/datasets/CheneyWong/PubTables-v2) | PubTabNet + PubTables-1M combined |
| [`SPRINT-MUSTARD`](https://huggingface.co/datasets/CheneyWong/SPRINT-MUSTARD) | structure-only tables, 13 languages |
| [`SynthTabNet`](https://huggingface.co/datasets/CheneyWong/SynthTabNet) | synthetic tables |
| [`TABLET`](https://huggingface.co/datasets/CheneyWong/TABLET) | table QA benchmark, 9 subsets |
| [`TableVerse-5K`](https://huggingface.co/datasets/CheneyWong/TableVerse-5K) | 5K complex Chinese tables |
| [`SciTSR`](https://huggingface.co/datasets/CheneyWong/SciTSR) | SciTSR train/val/test tars |
| [`rebuilt_table_sources`](https://huggingface.co/datasets/CheneyWong/rebuilt_table_sources) | the four rebuilt sources on their own: OmniDocBench v1.5/v1.6, CC-OCR, OCRBench-v2 tables |
| [`table_recognition_eval`](https://huggingface.co/datasets/CheneyWong/table_recognition_eval) | this merged benchmark |
Full list: https://huggingface.co/CheneyWong/datasets
## Code
Pipeline code, the batch evaluation harness, and the vLLM environment notes
live in the GitHub project:
**[`Cheney20/paddleocr-vl-table-recognition`](https://github.com/Cheney20/paddleocr-vl-table-recognition)**
This repository holds the data only. The converters referenced above
(`scripts/fill_otsl.py`, `scripts/fill_html.py`) are mirrored there, together
with the evaluation runner and the offline vLLM image instructions.
The offline vLLM image for PaddleOCR-VL-1.6 (7.34 GB) is on Baidu Netdisk:
```
file : paddleocrvl-docker
link : https://pan.baidu.com/s/1Vwt9XtYP5aBPjfdXzxBRAA?pwd=y8na
code : y8na
sha256 : f40e1d785c7c09c29ff1118cdf7edffec500459c3964ca05c419657d2107a364
```
## Loading
```python
from datasets import load_dataset
ds = load_dataset("CheneyWong/table_recognition_eval",
data_files="shard_*.parquet", split="test")
print(len(ds)) # 184074
print(ds.filter(lambda r: r["benchmark"] == "hitab"))
# structure-only rows, score these with TEDS
struct = ds.filter(lambda r: r["structure_only"])
print(len(struct))
```
`overlong.parquet` holds oversized tables kept out of the 64 so they do not
distort their image-byte balance. Load it separately.
## Citation
Please cite the original datasets you use. This repository only re-packages
them under a unified schema.