CheneyWong commited on
Commit
b46d057
·
verified ·
1 Parent(s): 0e90373

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +183 -86
README.md CHANGED
@@ -4,8 +4,11 @@ pretty_name: Table Recognition Benchmark (16 sources, 228,099 tables)
4
  tags:
5
  - table-recognition
6
  - table-structure-recognition
 
7
  - ocr
8
- - document-ai
 
 
9
  - teds
10
  - paddleocr-vl
11
  language:
@@ -20,141 +23,235 @@ configs:
20
  - config_name: default
21
  data_files:
22
  - split: test
23
- path: benchmarks_v2/*
24
  ---
25
 
26
  # Table Recognition Benchmark
27
 
28
- 16 public + self-built table sources merged into **64 uniformly sized shards**
29
- (**228,099** tables, ~9.2 GB of images). Every row carries both an **OTSL**
30
- and an **HTML** ground truth so you can score with whichever you prefer.
 
31
 
32
- The repository also keeps the original `eval/` directory (129 shards,
33
- 105,311 rows) untouched, for backward compatibility.
34
 
35
- ## Why 64 shards
36
-
37
- Shards are balanced by **total image bytes, not row count** — each one holds
38
- ~169 MB of images, and every shard mixes 15–17 different sources. Loading a
39
- single shard gives you broad source coverage instead of one narrow corpus.
40
 
41
  ```
42
- benchmarks_v2/shard_0000.parquet ... shard_0063.parquet
 
 
 
43
  ```
44
 
 
 
 
 
45
  ## Schema
46
 
47
  | column | type | meaning |
48
  |---|---|---|
49
- | `bytes` | binary | image, as stored (PNG/JPEG) |
50
  | `source` | string | fine-grained original dataset name |
51
- | `benchmark` | string | one of the 16 sources below |
52
- | `sample_id` | string | original sample identifier (empty for some sources) |
53
  | `rows` / `cols` | int64 | table grid dimensions |
54
- | `otsl` | string | OTSL ground truth (PaddleOCR token format) |
55
  | `html` | string | HTML ground truth |
56
  | `resolution` | string | `WIDTHxHEIGHT` |
57
  | `width` / `height` | int64 | image dimensions |
58
  | `structure_only` | bool | true when the table has **no cell text at all** |
59
 
60
- ### OTSL ↔ HTML
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
- The two representations are interconvertible. Where a source shipped only
63
- one, the other was generated here:
 
 
64
 
65
- - `otsl` derived from `html` for: `pubtables1m`, `mmsci`, `pubtablesv2`,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  `tableverse`, `hitab`, `scitsr`, `sprint_mustard`, `pubtabnet_val`,
67
- `pubtabnet_icdar21`
68
- - `html` derived from `otsl` for: `tabrecset`
69
- - native to the source for: `fintabnet`, `synthtabnet`, `tablet`,
70
- `omnidocbench`, `ccocr`, `ocrbenchv2`
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
- **All 228,099 rows have both fields populated.** Rows that had neither after
73
- conversion were dropped rather than shipped without ground truth.
 
74
 
75
- ### `structure_only`
 
76
 
77
- 31,429 rows (13.8%) are *pure structure*: every cell is empty and only the
78
- grid/span layout is annotated (`synthtabnet` 29,990, `sprint_mustard` 1,429,
79
- `tabrecset` 7, `tableverse` 3).
80
 
81
- This matters for scoring. TEDS compares **both** structure and cell text; on
82
- an all-empty ground truth the text half degenerates into "did the model
83
- correctly output nothing", which is not a meaningful number. For those rows
84
- use **TEDS** as the headline metric; for the rest use **TEDS-S**. Filter on
85
- this column to apply the rule.
86
 
87
  ## Sources
88
 
89
- | benchmark | rows | share | origin | GT |
90
  |---|---:|---:|---|---|
91
- | `pubtables1m` | 93,834 | 41.1% | PubTables-1M **test** split | from html |
92
- | `mmsci` | 52,098 | 22.8% | MMSci-Table (train split) | from html |
93
- | `synthtabnet` | 29,990 | 13.2% | SynthTabNet test (token lists rejoined) | native |
94
- | `fintabnet` | 10,397 | 4.6% | FinTabNet_OTSL **test** | native |
95
- | `pubtabnet_val` | 9,115 | 4.0% | PubTabNet **val** split | from html |
96
- | `pubtabnet_icdar21` | 9,064 | 4.0% | **ICDAR 2021 official test** (HF images + `final_eval.json`) | from html |
97
- | `pubtablesv2` | 7,680 | 3.4% | PubTables-v2 **test** split | from html |
98
- | `tableverse` | 4,951 | 2.2% | TableVerse-5K | from html |
99
- | `hitab` | 3,597 | 1.6% | HiTab | from html |
100
- | `scitsr` | 3,000 | 1.3% | SciTSR | from html |
101
- | `sprint_mustard` | 1,429 | 0.6% | SPRINT-MUSTARD | from html |
102
- | `tabrecset` | 1,065 | 0.5% | TabRecSet-zh (local cohort) | native otsl |
103
- | `tablet` | 909 | 0.4% | TABLET **test** split | native |
104
- | `omnidocbench` | 512 | 0.2% | OmniDocBench v1.5, recropped from `poly` | from html |
105
- | `ccocr` | 300 | 0.1% | CC-OCR | from html |
106
- | `ocrbenchv2` | 158 | 0.1% | OCRBench-v2 table-parsing tasks, cropped by bbox | from html |
107
  | **total** | **228,099** | 100% | | |
108
 
109
  ## Deliberate exclusions
110
 
111
- These were left out on purpose, not by accident:
112
-
113
- - **TABLET train pool** (17,720 rows) — replaced by the 909-row test split.
114
- The train pool overlaps the evaluation set, so shipping it would leak.
115
- - **OCRBench-v2 rows without a bbox** (542) — the question text says "all
116
- tables in the image", so there is no region to crop to. Only the 158 rows
117
- with an explicit, parseable bbox are included.
118
  - **OmniDocBench v1.6** (665) — no public annotation file ships the table
119
- HTML; images alone would be unscorable.
120
  - **Rows with neither OTSL nor HTML** (11,177) — no ground truth at all.
121
 
122
- ## De-duplication
123
-
124
- The merged pool was de-duplicated against a 345,915-entry test blocklist
125
- covering the val/test splits of every public table dataset. Matching was done
126
- on **both** `sample_id` and `image_sha256`, the latter computed from the
127
- packed image bytes:
128
-
129
- ```
130
- blocklist entries 345,915 (344,334 distinct image hashes)
131
- matched on sample_id 0
132
- matched on image_sha256 0
133
- internal duplicates 2,449 removed
134
- ```
135
-
136
- So this pool is disjoint from the val/test splits of the datasets it draws
137
- from.
138
-
139
  ## Loading
140
 
141
  ```python
142
  from datasets import load_dataset
143
 
144
  ds = load_dataset("CheneyWong/table_recognition_eval",
145
- data_files="benchmarks_v2/*.parquet", split="train")
146
- print(len(ds)) # 228099
147
  print(ds.filter(lambda r: r["benchmark"] == "hitab"))
148
- ```
149
 
150
- Scoring only the pure-structure rows:
151
-
152
- ```python
153
  struct = ds.filter(lambda r: r["structure_only"])
154
- # -> use TEDS on these
155
  ```
156
 
 
 
 
157
  ## Citation
158
 
159
  Please cite the original datasets you use. This repository only re-packages
160
- them with a unified schema.
 
4
  tags:
5
  - table-recognition
6
  - table-structure-recognition
7
+ - document-image-analysis
8
  - ocr
9
+ - document-understanding
10
+ - cv
11
+ - computer-vision
12
  - teds
13
  - paddleocr-vl
14
  language:
 
23
  - config_name: default
24
  data_files:
25
  - split: test
26
+ path: "*.parquet"
27
  ---
28
 
29
  # Table Recognition Benchmark
30
 
31
+ 16 public and self-built table sources merged into **64 uniformly sized shards**
32
+ (**228,099** tables, ~9.2 GB of images). Every row carries **both** an OTSL
33
+ and an HTML ground truth, plus a flag marking the tables that carry no cell
34
+ text at all.
35
 
36
+ The legacy `eval/` directory (129 shards, 105,311 rows) is kept untouched for
37
+ backward compatibility.
38
 
39
+ ## Layout
 
 
 
 
40
 
41
  ```
42
+ shard_0000.parquet ... shard_0063.parquet # 64 evenly-sized shards
43
+ overlong.parquet # oversized / over-long tables
44
+ README.md # you are here
45
+ eval/ # legacy, 129 shards, unchanged
46
  ```
47
 
48
+ Shards are balanced by **total image bytes, not row count** — each holds
49
+ ~169 MB of images, and every shard mixes 15–17 different sources, so a single
50
+ shard already gives broad coverage.
51
+
52
  ## Schema
53
 
54
  | column | type | meaning |
55
  |---|---|---|
56
+ | `bytes` | binary | the table image, as stored (PNG/JPEG) |
57
  | `source` | string | fine-grained original dataset name |
58
+ | `benchmark` | string | which of the 16 sources this row came from |
59
+ | `sample_id` | string | original sample identifier (may be empty) |
60
  | `rows` / `cols` | int64 | table grid dimensions |
61
+ | `otsl` | string | OTSL ground truth |
62
  | `html` | string | HTML ground truth |
63
  | `resolution` | string | `WIDTHxHEIGHT` |
64
  | `width` / `height` | int64 | image dimensions |
65
  | `structure_only` | bool | true when the table has **no cell text at all** |
66
 
67
+ ---
68
+
69
+ ## What is OTSL
70
+
71
+ **OTSL = Optimized Table Structure Language**, the compact token language
72
+ PaddleOCR uses to represent table structure. A table is a flat token stream —
73
+ no nesting, no closing tags:
74
+
75
+ | token | meaning |
76
+ |---|---|
77
+ | `<fcel>` | a new (filled) cell starts here |
78
+ | `<ecel>` | an empty cell |
79
+ | `<lcel>` | continuation **to the left** (horizontal merge) |
80
+ | `<ulcel>` | continuation **above** (vertical merge) |
81
+ | `<xcel>` | continuation both left and above |
82
+ | `<nl>` | end of row |
83
+
84
+ Cell text is inlined directly after its `<fcel>`, so the stream alternates
85
+ structure and content:
86
+
87
+ ```
88
+ <fcel>Year<fcel>Division<ecel><ecel><nl>
89
+ <fcel>2023<fcel>A<ecel><ecel><nl>
90
+ ```
91
+
92
+ Compare with HTML for the same table — six characters per cell of pure
93
+ syntax, and every merge costs a `colspan`/`rowspan` attribute:
94
+
95
+ ```html
96
+ <table><tr><th>Year</th><th>Division</th><td></td><td></td></tr>
97
+ <tr><td>2023</td><td>A</td><td></td><td></td></tr></table>
98
+ ```
99
+
100
+ OTSL's advantage is that structure and text live in one linear sequence, which
101
+ is what a sequence-to-sequence table recogniser predicts directly.
102
+
103
+ ## What is TEDS and TEDS-S
104
+
105
+ **TEDS = Tree-Edit-Distance-based Similarity** (PubTabNet). Both tables are
106
+ turned into ordered trees — `<table>` → `<tr>` → `<td>` — and scored as
107
+ `1 - normalized_tree_edit_distance`:
108
+
109
+ ```
110
+ TEDS = 1 - TD / max(N_pred, N_gt)
111
+ ```
112
+
113
+ where `TD` is the tree edit distance and `N` the node count. It combines two
114
+ signals into one number:
115
+
116
+ - **structure** — did you get the rows, columns, and merges right?
117
+ - **text** — did you get the cell *contents* right?
118
+
119
+ **TEDS-S** is the structure-only variant: cell text is erased before the
120
+ trees are compared, while spans (`colspan`/`rowspan`) are preserved. So
121
+ `TEDS-S = 1 - TD_struct / max(N_pred, N_gt)`.
122
+
123
+ The two bracket each other:
124
+
125
+ | | TEDS | TEDS-S |
126
+ |---|---|---|
127
+ | table structure wrong | penalised | penalised |
128
+ | cell text wrong | penalised | **ignored** |
129
+ | use for | full-fidelity output | structure/topology comparison |
130
+
131
+ A model that nails the grid but hallucinates cell contents scores high on
132
+ TEDS-S and low on TEDS — that gap is the diagnostic.
133
+
134
+ ## Why `structure_only` matters, and how to score it
135
+
136
+ **31,429 rows (13.8%)** are *pure structure*: every cell is empty and only the
137
+ grid and span layout is annotated (`synthtabnet` 29,990, `sprint_mustard`
138
+ 1,429, `tabrecset` 7, `tableverse` 3).
139
 
140
+ TEDS always compares cell text. Against an all-empty ground truth, that half
141
+ of the metric degenerates into *"did the model correctly output nothing"* —
142
+ which is not a meaningful quantity, and a model is rewarded for hallucinating
143
+ text into a cell that should be blank.
144
 
145
+ The rule used for this benchmark:
146
+
147
+ - `structure_only == true` → score with **TEDS** (TEDS-S is redundant there)
148
+ - `structure_only == false` → score with **TEDS-S** (structure is the
149
+ comparable signal across corpora)
150
+
151
+ ```python
152
+ ds = load_dataset("CheneyWong/table_recognition_eval",
153
+ data_files="shard_*.parquet", split="test")
154
+
155
+ headline = [TEDS if r["structure_only"] else TEDS_S for r in ds]
156
+ ```
157
+
158
+ Report the two groups **separately**. Averaging them into one number mixes
159
+ incompatible metrics and the ranking stops meaning anything.
160
+
161
+ ## OTSL ↔ HTML are interconvertible
162
+
163
+ Both formats encode the same table, so either can be derived from the other.
164
+ Where a source shipped only one, the other was generated here:
165
+
166
+ - **`otsl` derived from `html`** for `pubtables1m`, `mmsci`, `pubtablesv2`,
167
  `tableverse`, `hitab`, `scitsr`, `sprint_mustard`, `pubtabnet_val`,
168
+ `pubtabnet_icdar21`, `omnidocbench`
169
+ - **`html` derived from `otsl`** for `tabrecset`
170
+ - **native to the source** for `fintabnet`, `synthtabnet`, `tablet`,
171
+ `ccocr`, `ocrbenchv2`
172
+
173
+ **All 228,099 rows have both fields populated.** Rows left with neither
174
+ after conversion were dropped rather than shipped without ground truth.
175
+
176
+ ### Conversion scripts
177
+
178
+ Two scripts, both multi-worker:
179
+
180
+ - [`scripts/fill_otsl.py`](scripts/fill_otsl.py) — HTML → OTSL. Walks the
181
+ parquet row group by row group (memory stays bounded), collects the rows
182
+ whose `otsl` is empty but whose `html` is not, converts them across a
183
+ worker pool, and rewrites the file. Recomputes `structure_only` afterwards,
184
+ since it is derived from `otsl`.
185
 
186
+ ```bash
187
+ python scripts/fill_otsl.py shard_0000.parquet --workers 128
188
+ ```
189
 
190
+ - [`scripts/fill_html.py`](scripts/fill_html.py) — OTSL → HTML, the mirror
191
+ image: fills `html` wherever it is missing but `otsl` is present.
192
 
193
+ ```bash
194
+ python scripts/fill_html.py shard_0000.parquet --workers 128
195
+ ```
196
 
197
+ Neither loads the whole file into memory: rows are processed per row group
198
+ and converted in a `multiprocessing.Pool`, so `--workers 128` is safe on a
199
+ machine with many cores.
200
+
201
+ ---
202
 
203
  ## Sources
204
 
205
+ | benchmark | rows | share | origin | OTSL from |
206
  |---|---:|---:|---|---|
207
+ | `pubtables1m` | 93,834 | 41.1% | PubTables-1M test split | HTML |
208
+ | `mmsci` | 52,098 | 22.8% | MMSci-Table | HTML |
209
+ | `synthtabnet` | 29,990 | 13.2% | SynthTabNet test | native |
210
+ | `fintabnet` | 10,397 | 4.6% | FinTabNet_OTSL test | native |
211
+ | `pubtabnet_val` | 9,115 | 4.0% | PubTabNet val split | HTML |
212
+ | `pubtabnet_icdar21` | 9,064 | 4.0% | ICDAR 2021 official test | HTML |
213
+ | `pubtablesv2` | 7,680 | 3.4% | PubTables-v2 test split | HTML |
214
+ | `tableverse` | 4,951 | 2.2% | TableVerse-5K | HTML |
215
+ | `hitab` | 3,597 | 1.6% | HiTab | HTML |
216
+ | `scitsr` | 3,000 | 1.3% | SciTSR | HTML |
217
+ | `sprint_mustard` | 1,429 | 0.6% | SPRINT-MUSTARD | HTML |
218
+ | `tabrecset` | 1,065 | 0.5% | TabRecSet-zh | native |
219
+ | `tablet` | 909 | 0.4% | TABLET test split | native |
220
+ | `omnidocbench` | 512 | 0.2% | OmniDocBench v1.5 | HTML |
221
+ | `ccocr` | 300 | 0.1% | CC-OCR | native |
222
+ | `ocrbenchv2` | 158 | 0.1% | OCRBench-v2 table-parsing tasks | HTML |
223
  | **total** | **228,099** | 100% | | |
224
 
225
  ## Deliberate exclusions
226
 
227
+ - **TABLET train pool** (17,720 rows) — replaced by the 909-row test split,
228
+ since the train pool overlaps the evaluation set.
229
+ - **OCRBench-v2 rows without a bbox** (542) — their prompt says "all tables
230
+ in the image", so there is no region to crop to. Only the 158 rows with an
231
+ explicit bbox are included.
 
 
232
  - **OmniDocBench v1.6** (665) — no public annotation file ships the table
233
+ HTML, so the images alone would be unscorable.
234
  - **Rows with neither OTSL nor HTML** (11,177) — no ground truth at all.
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  ## Loading
237
 
238
  ```python
239
  from datasets import load_dataset
240
 
241
  ds = load_dataset("CheneyWong/table_recognition_eval",
242
+ data_files="shard_*.parquet", split="test")
243
+ print(len(ds)) # 228099
244
  print(ds.filter(lambda r: r["benchmark"] == "hitab"))
 
245
 
246
+ # structure-only rows, score these with TEDS
 
 
247
  struct = ds.filter(lambda r: r["structure_only"])
248
+ print(len(struct)) # 31429
249
  ```
250
 
251
+ `overlong.parquet` holds oversized tables kept out of the 64 so they do not
252
+ distort their image-byte balance. Load it separately.
253
+
254
  ## Citation
255
 
256
  Please cite the original datasets you use. This repository only re-packages
257
+ them under a unified schema.