Skip to main content

Table-aware chunking: does keeping tables whole help retrieval?

ci

Project page & proof: zuhalsicimkaradavut.com/projects/table-aware-chunking · Author: Zuhal Karadavut (Zuhal Sicim · @zuhalsicim)

Does a chunker that keeps tables whole find the evidence for a question more often than one that cuts by length? Against fixed token windows, yes: +9.3 points recall@5 at 256 tokens (95 % interval +5.7 to +13.0) and +11.7 at 128 tokens (+8.1 to +15.3), on all 1,147 FinQA test questions. Against a recursive splitter it depends on the size: no measurable gain at 256 tokens (+1.2, interval -0.6 to +3.1), +3.3 at 128 tokens (+1.6 to +5.0). Every figure comes from results/comparisons.json and the files in results/e5-small/.

To reproduce: python -m tachunk all on a CPU with Python 3.12 and about 3 GB of free disk (setup under How to reproduce).

A RAG knowledge base starts by cutting documents into chunks. Most pipelines cut by length: fixed token windows, or a recursive splitter that prefers paragraph and line breaks. Financial and technical documents are full of tables, and a length-based splitter can cut a table in the middle of a row or separate a row from its header. This repository measures whether a structure-aware chunker, which keeps every table whole (or in groups of whole rows, each with the header repeated), finds the evidence for a question more often than the two common defaults, at the same size budget, with the same embedding model, on the same questions.

Kurzfassung

  • Frage: Findet eine Suche die Belege für eine Frage öfter, wenn beim Zerlegen der Dokumente (Chunking) Tabellen ganz bleiben? Verglichen wurden feste Token-Fenster, ein rekursiver Splitter (wie LangChains RecursiveCharacterTextSplitter) und ein strukturbewusster Chunker, bei gleicher Größe (256 und 128 Tokens) und gleichem Embedding-Modell (multilingual-e5-small).
  • Daten: FinQA (MIT-Lizenz), 2789 Seiten aus Finanzberichten mit je einer Tabelle als Suchraum, 1147 Testfragen mit annotierten Belegen (Tabellenzeilen und Sätze). Die 7134 Fragen aus Train und Dev dienen als Wiederholung.
  • Gegen feste Fenster gewinnt der strukturbewusste Chunker klar: +9,3 Punkte Evidence Recall@5 bei 256 Tokens (95-%-Intervall +5,7 bis +13,0) und +11,7 bei 128 Tokens (+8,1 bis +15,3). Alle Belege in einem einzigen Chunk („intact@5“) findet er rund 16 Punkte öfter. Die Wiederholung bestätigt beides, bei 256 Tokens mit kleinerem Abstand (+4,3).
  • Gegen den rekursiven Splitter hängt es an der Größe: Bei 256 Tokens ist kein Unterschied messbar (+1,2, Intervall −0,6 bis +3,1; Wiederholung −0,1). Dann passen die meisten Tabellen ohnehin in einen Chunk (nur 327 von 2789 sind größer), und der rekursive Splitter trennt Markdown-Tabellen schon zwischen den Zeilen. Bei 128 Tokens, wo 57 % der Tabellen geteilt werden müssen, bringt die wiederholte Kopfzeile +3,3 Punkte (+1,6 bis +5,0; Wiederholung +2,5), bei Fragen mit reinen Tabellenbelegen +5,8.
  • Ein Satz Kontext vor jedem Tabellenstück hilft bei 256 Tokens zusätzlich: +3,1 Punkte (+0,0 bis +6,1, knapp gesichert), in der Wiederholung +7,0 (+5,7 bis +8,4). Bei 128 Tokens nimmt der Satz den Zeilen Platz weg; der Gewinn ist im Test nicht gesichert (+1,0).
  • Preis der Trennung: Braucht eine Frage Text und Tabelle zusammen, liegt beim strukturbewussten Chunker nie alles in einem Chunk (intact@5 = 0). Der Recall ist dabei nicht messbar schlechter.
  • Grenzen: eine Domäne (Finanzberichte), ein kleines Embedding-Modell, nur Englisch, nur Retrieval, keine Antworten eines Sprachmodells.

Results

Every figure below comes from a file in results/; python -m tachunk report prints these tables. Percentages; "points" are percentage points. The primary set is the 1147 test questions (380 pages), searched against all 2789 pages.

Quality on the test questions

Budget 256 tokens:

Chunker Chunks Mean tokens Recall@1 Recall@3 Recall@5 Recall@10 Intact@5 nDCG@10 MRR@10 Page@5 Ceiling recall Ceiling intact
fixed 13501 233 19.2 31.9 38.4 47.0 26.4 33.2 31.6 52.4 97.9 59.0
recursive 15193 189 22.5 39.5 46.5 54.5 40.5 38.5 35.8 59.3 100.0 78.9
structure 16030 180 23.6 40.9 47.8 55.1 42.1 39.7 37.2 61.5 100.0 80.3
structure+context 16321 186 28.3 43.6 50.8 59.2 45.0 43.3 41.0 61.6 100.0 82.2

Budget 128 tokens:

Chunker Chunks Mean tokens Recall@1 Recall@3 Recall@5 Recall@10 Intact@5 nDCG@10 MRR@10 Page@5 Ceiling recall Ceiling intact
fixed 26034 122 16.7 27.8 32.6 39.0 19.0 29.1 28.2 58.9 88.2 32.8
recursive 29541 96 21.7 35.7 41.0 48.2 31.5 35.9 35.5 62.2 99.5 55.8
structure 30437 97 23.3 38.6 44.3 51.9 34.9 38.7 38.0 62.4 99.5 66.2
structure+context 32129 99 24.0 39.4 45.3 53.1 33.0 39.9 39.4 59.9 99.5 64.1

Recall@k and Intact@5 are about the gold evidence (see Metrics); Page@5 only asks whether any chunk of the right page is among the first five; the two ceilings are what a perfect ranking could reach with these chunks.

Paired comparisons on the test questions

Comparison (A - B) Budget Metric Questions Pages Difference (points) 95 % interval, by page 95 % interval, per question p (by page) Resolved? Questions A better / B better
structure - fixed 256 recall@5 1147 380 +9.3 +5.7 to +13.0 +6.4 to +12.2 0.0001 yes 246 / 140
structure - fixed 256 intact@5 1147 380 +15.7 +11.8 to +19.7 +12.6 to +18.7 0.0001 yes 262 / 82
structure - fixed 256 ndcg@10 1147 380 +6.5 +3.6 to +9.4 +4.2 to +8.8 0.0001 yes 401 / 263
structure - recursive 256 recall@5 1147 380 +1.2 -0.6 to +3.1 -0.3 to +2.8 0.1941 no 54 / 41
structure - recursive 256 intact@5 1147 380 +1.6 -0.3 to +3.5 +0.0 to +3.1 0.1201 no 51 / 33
structure - recursive 256 ndcg@10 1147 380 +1.2 -0.4 to +2.8 -0.1 to +2.5 0.1453 no 132 / 137
structure+context - structure 256 recall@5 1147 380 +3.1 +0.0 to +6.1 +0.7 to +5.6 0.0485 yes 150 / 104
structure+context - structure 256 intact@5 1147 380 +2.9 -0.1 to +5.8 +0.5 to +5.3 0.0665 no 117 / 84
structure+context - structure 256 ndcg@10 1147 380 +3.6 +1.1 to +6.1 +1.7 to +5.6 0.0044 yes 266 / 220
structure+context - recursive (added after the run) 256 recall@5 1147 380 +4.3 +1.6 to +7.2 +2.0 to +6.7 0.0027 yes 148 / 90
structure+context - recursive (added after the run) 256 intact@5 1147 380 +4.4 +1.7 to +7.2 +2.2 to +6.8 0.0022 yes 119 / 68
structure+context - recursive (added after the run) 256 ndcg@10 1147 380 +4.8 +2.4 to +7.2 +2.9 to +6.7 0.0001 yes 274 / 199
structure - fixed 128 recall@5 1147 380 +11.7 +8.1 to +15.3 +8.8 to +14.5 0.0001 yes 292 / 127
structure - fixed 128 intact@5 1147 380 +15.9 +12.8 to +19.1 +13.2 to +18.6 0.0001 yes 230 / 48
structure - fixed 128 ndcg@10 1147 380 +9.6 +6.7 to +12.6 +7.3 to +12.0 0.0001 yes 426 / 229
structure - recursive 128 recall@5 1147 380 +3.3 +1.6 to +5.0 +1.8 to +4.7 0.0003 yes 84 / 33
structure - recursive 128 intact@5 1147 380 +3.4 +1.7 to +5.2 +1.9 to +4.9 0.0003 yes 57 / 18
structure - recursive 128 ndcg@10 1147 380 +2.9 +1.5 to +4.2 +1.7 to +4.0 0.0001 yes 139 / 120
structure+context - structure 128 recall@5 1147 380 +1.0 -2.0 to +4.0 -1.4 to +3.5 0.5149 no 147 / 126
structure+context - structure 128 intact@5 1147 380 -1.9 -4.7 to +0.8 -4.3 to +0.4 0.1916 no 79 / 101
structure+context - structure 128 ndcg@10 1147 380 +1.2 -1.2 to +3.6 -0.7 to +3.1 0.3166 no 235 / 227
structure+context - recursive (added after the run) 128 recall@5 1147 380 +4.3 +1.4 to +7.2 +1.9 to +6.8 0.0054 yes 175 / 105
structure+context - recursive (added after the run) 128 intact@5 1147 380 +1.5 -1.2 to +4.1 -0.8 to +3.8 0.3116 no 99 / 82
structure+context - recursive (added after the run) 128 ndcg@10 1147 380 +4.1 +1.7 to +6.5 +2.1 to +6.0 0.0011 yes 272 / 213

File: results/comparisons.json. "Pages" is the number of clusters. The last column counts the questions on which A scored higher and on which B did; all other questions are ties.

Replication: the train and dev questions

Nothing is trained or tuned here, so the 7134 train and dev questions (2409 pages) are a second, independent test of the same comparisons, with about six times as many questions.

Comparison (A - B) Budget Metric Questions Pages Difference (points) 95 % interval, by page 95 % interval, per question p (by page) Resolved? Questions A better / B better
structure - fixed 256 recall@5 7134 2409 +4.3 +2.8 to +5.8 +3.1 to +5.5 0.0001 yes 1379 / 1122
structure - fixed 256 intact@5 7134 2409 +8.9 +7.3 to +10.4 +7.7 to +10.1 0.0001 yes 1368 / 734
structure - fixed 256 ndcg@10 7134 2409 +4.3 +3.1 to +5.5 +3.4 to +5.3 0.0001 yes 2344 / 1896
structure - recursive 256 recall@5 7134 2409 -0.1 -0.9 to +0.8 -0.7 to +0.6 0.8836 no 376 / 394
structure - recursive 256 intact@5 7134 2409 -0.3 -1.2 to +0.5 -1.0 to +0.4 0.5158 no 303 / 324
structure - recursive 256 ndcg@10 7134 2409 +0.2 -0.5 to +0.9 -0.3 to +0.8 0.5000 no 854 / 1028
structure+context - structure 256 recall@5 7134 2409 +7.0 +5.7 to +8.4 +6.0 to +8.1 0.0001 yes 1212 / 628
structure+context - structure 256 intact@5 7134 2409 +7.1 +5.8 to +8.4 +6.0 to +8.1 0.0001 yes 997 / 493
structure+context - structure 256 ndcg@10 7134 2409 +5.4 +4.4 to +6.5 +4.6 to +6.2 0.0001 yes 1883 / 1396
structure+context - recursive (added after the run) 256 recall@5 7134 2409 +7.0 +5.7 to +8.3 +6.0 to +8.0 0.0001 yes 1142 / 580
structure+context - recursive (added after the run) 256 intact@5 7134 2409 +6.8 +5.5 to +8.0 +5.7 to +7.8 0.0001 yes 939 / 456
structure+context - recursive (added after the run) 256 ndcg@10 7134 2409 +5.6 +4.6 to +6.7 +4.9 to +6.4 0.0001 yes 1900 / 1347
structure - fixed 128 recall@5 7134 2409 +10.8 +9.4 to +12.3 +9.7 to +12.0 0.0001 yes 1738 / 905
structure - fixed 128 intact@5 7134 2409 +17.9 +16.4 to +19.3 +16.8 to +19.0 0.0001 yes 1607 / 332
structure - fixed 128 ndcg@10 7134 2409 +8.4 +7.2 to +9.6 +7.5 to +9.4 0.0001 yes 2549 / 1608
structure - recursive 128 recall@5 7134 2409 +2.5 +1.7 to +3.2 +1.9 to +3.1 0.0001 yes 471 / 233
structure - recursive 128 intact@5 7134 2409 +3.0 +2.3 to +3.7 +2.4 to +3.6 0.0001 yes 347 / 132
structure - recursive 128 ndcg@10 7134 2409 +2.1 +1.5 to +2.6 +1.6 to +2.5 0.0001 yes 798 / 795
structure+context - structure 128 recall@5 7134 2409 +2.7 +1.5 to +4.0 +1.7 to +3.7 0.0001 yes 1043 / 800
structure+context - structure 128 intact@5 7134 2409 +0.1 -1.1 to +1.3 -0.9 to +1.1 0.8765 no 651 / 643
structure+context - structure 128 ndcg@10 7134 2409 +2.1 +1.1 to +3.1 +1.3 to +2.9 0.0002 yes 1698 / 1547
structure+context - recursive (added after the run) 128 recall@5 7134 2409 +5.2 +3.9 to +6.5 +4.2 to +6.2 0.0001 yes 1192 / 737
structure+context - recursive (added after the run) 128 intact@5 7134 2409 +3.1 +1.9 to +4.3 +2.1 to +4.1 0.0001 yes 784 / 561
structure+context - recursive (added after the run) 128 ndcg@10 7134 2409 +4.2 +3.1 to +5.2 +3.4 to +5.0 0.0001 yes 1797 / 1470
Quality on the replication questions

Budget 256 tokens:

Chunker Chunks Mean tokens Recall@1 Recall@3 Recall@5 Recall@10 Intact@5 nDCG@10 MRR@10 Page@5 Ceiling recall Ceiling intact
fixed 13501 233 20.6 35.1 42.2 50.9 31.5 35.6 33.1 54.8 97.9 63.7
recursive 15193 189 24.2 39.7 46.5 55.7 40.7 39.7 37.0 59.6 99.9 80.5
structure 16030 180 24.8 39.6 46.5 55.4 40.4 39.9 37.6 61.0 99.9 80.6
structure+context 16321 186 29.7 46.2 53.5 62.0 47.4 45.4 43.0 63.1 99.9 82.5

Budget 128 tokens:

Chunker Chunks Mean tokens Recall@1 Recall@3 Recall@5 Recall@10 Intact@5 nDCG@10 MRR@10 Page@5 Ceiling recall Ceiling intact
fixed 26034 122 17.4 28.8 33.8 40.8 17.6 30.9 30.0 58.7 88.6 32.0
recursive 29541 96 23.5 36.9 42.2 49.4 32.5 37.2 36.8 62.1 99.6 57.8
structure 30437 97 24.4 38.8 44.6 52.2 35.5 39.3 38.4 62.9 99.6 66.8
structure+context 32129 99 25.3 40.7 47.4 55.3 35.6 41.4 40.6 62.2 99.6 63.3

By kind of evidence (test questions)

FinQA's test questions need table rows only (706), sentences only (283), or both (158).

Budget 256 tokens:

Chunker table: Recall@5 table: Intact@5 text: Recall@5 text: Intact@5 mixed: Recall@5 mixed: Intact@5
fixed 39.8 27.6 41.2 34.6 27.2 6.3
recursive 49.4 47.5 49.8 44.5 27.7 2.5
structure 51.8 50.7 49.5 44.2 26.6 0.0
structure+context 55.5 53.7 49.4 44.2 32.5 7.6

Budget 128 tokens:

Chunker table: Recall@5 table: Intact@5 text: Recall@5 text: Intact@5 mixed: Recall@5 mixed: Intact@5
fixed 29.4 14.7 47.0 39.6 21.2 1.3
recursive 38.3 31.7 57.3 48.4 23.9 0.0
structure 44.1 38.0 55.5 46.6 24.8 0.0
structure+context 44.5 33.6 56.7 47.7 28.4 3.8
Paired comparisons by kind of evidence

Table rows only:

Comparison (A - B) Budget Metric Questions Pages Difference (points) 95 % interval, by page 95 % interval, per question p (by page) Resolved? Questions A better / B better
structure - fixed 256 recall@5 706 331 +12.0 +6.9 to +17.2 +7.8 to +16.1 0.0001 yes 174 / 93
structure - fixed 256 intact@5 706 331 +23.1 +17.6 to +28.7 +18.7 to +27.3 0.0001 yes 220 / 57
structure - fixed 256 ndcg@10 706 331 +8.0 +3.8 to +12.1 +4.7 to +11.2 0.0003 yes 268 / 166
structure - recursive 256 recall@5 706 331 +2.4 -0.5 to +5.4 +0.0 to +4.8 0.1128 no 47 / 31
structure - recursive 256 intact@5 706 331 +3.3 +0.3 to +6.2 +0.8 to +5.7 0.0361 yes 50 / 27
structure - recursive 256 ndcg@10 706 331 +2.2 -0.4 to +4.8 +0.1 to +4.3 0.0898 no 102 / 95
structure+context - structure 256 recall@5 706 331 +3.8 -0.8 to +8.4 +0.0 to +7.6 0.1151 no 113 / 85
structure+context - structure 256 intact@5 706 331 +3.0 -1.6 to +7.5 -0.7 to +6.7 0.2220 no 100 / 79
structure+context - structure 256 ndcg@10 706 331 +5.1 +1.2 to +9.1 +2.1 to +8.2 0.0126 yes 196 / 166
structure+context - recursive (added after the run) 256 recall@5 706 331 +6.1 +2.0 to +10.3 +2.7 to +9.7 0.0058 yes 110 / 67
structure+context - recursive (added after the run) 256 intact@5 706 331 +6.2 +2.0 to +10.4 +2.7 to +9.8 0.0061 yes 102 / 58
structure+context - recursive (added after the run) 256 ndcg@10 706 331 +7.3 +3.7 to +11.0 +4.4 to +10.2 0.0002 yes 206 / 140
structure - fixed 128 recall@5 706 331 +14.8 +10.0 to +19.6 +10.9 to +18.7 0.0001 yes 194 / 80
structure - fixed 128 intact@5 706 331 +23.2 +18.9 to +27.7 +19.5 to +26.9 0.0001 yes 187 / 23
structure - fixed 128 ndcg@10 706 331 +10.6 +6.6 to +14.7 +7.4 to +13.7 0.0001 yes 269 / 142
structure - recursive 128 recall@5 706 331 +5.8 +3.3 to +8.4 +3.7 to +8.1 0.0001 yes 74 / 22
structure - recursive 128 intact@5 706 331 +6.2 +3.6 to +9.0 +4.0 to +8.6 0.0001 yes 57 / 13
structure - recursive 128 ndcg@10 706 331 +4.7 +2.5 to +6.9 +2.9 to +6.5 0.0001 yes 121 / 80
structure+context - structure 128 recall@5 706 331 +0.3 -4.2 to +5.0 -3.4 to +4.1 0.8944 no 112 / 109
structure+context - structure 128 intact@5 706 331 -4.4 -8.6 to -0.2 -7.9 to -0.8 0.0532 no 67 / 98
structure+context - structure 128 ndcg@10 706 331 +1.7 -2.0 to +5.5 -1.2 to +4.6 0.3801 no 178 / 186
structure+context - recursive (added after the run) 128 recall@5 706 331 +6.2 +1.6 to +10.7 +2.4 to +10.0 0.0075 yes 144 / 89
structure+context - recursive (added after the run) 128 intact@5 706 331 +1.8 -2.3 to +5.9 -1.7 to +5.5 0.4211 no 89 / 76
structure+context - recursive (added after the run) 128 ndcg@10 706 331 +6.4 +2.7 to +10.2 +3.3 to +9.5 0.0009 yes 219 / 167

Sentences only:

Comparison (A - B) Budget Metric Questions Pages Difference (points) 95 % interval, by page 95 % interval, per question p (by page) Resolved? Questions A better / B better
structure - fixed 256 recall@5 283 175 +8.3 +3.0 to +13.7 +3.5 to +13.1 0.0029 yes 43 / 16
structure - fixed 256 intact@5 283 175 +9.5 +3.9 to +15.2 +4.6 to +14.8 0.0025 yes 42 / 15
structure - fixed 256 ndcg@10 283 175 +6.0 +1.9 to +10.3 +2.5 to +9.6 0.0060 yes 84 / 58
structure - recursive 256 recall@5 283 175 -0.4 -1.7 to +0.7 -1.4 to +0.7 1.0000 no 1 / 2
structure - recursive 256 intact@5 283 175 -0.4 -1.7 to +0.7 -1.4 to +0.7 1.0000 no 1 / 2
structure - recursive 256 ndcg@10 283 175 -0.3 -1.3 to +0.6 -1.2 to +0.5 0.4962 no 12 / 23
structure+context - structure 256 recall@5 283 175 -0.1 -2.6 to +2.3 -2.4 to +2.2 1.0000 no 7 / 7
structure+context - structure 256 intact@5 283 175 +0.0 -2.5 to +2.4 -2.1 to +2.1 1.0000 no 5 / 5
structure+context - structure 256 ndcg@10 283 175 +0.8 -0.5 to +2.2 -0.3 to +2.0 0.2474 no 29 / 25
structure+context - recursive (added after the run) 256 recall@5 283 175 -0.4 -3.1 to +2.1 -2.8 to +1.9 0.7970 no 7 / 8
structure+context - recursive (added after the run) 256 intact@5 283 175 -0.4 -2.9 to +2.1 -2.8 to +2.1 1.0000 no 5 / 6
structure+context - recursive (added after the run) 256 ndcg@10 283 175 +0.5 -1.1 to +2.1 -0.9 to +1.9 0.5640 no 28 / 29
structure - fixed 128 recall@5 283 175 +8.5 +2.5 to +14.4 +3.0 to +13.9 0.0073 yes 57 / 26
structure - fixed 128 intact@5 283 175 +7.1 +0.7 to +13.3 +1.8 to +12.7 0.0350 yes 43 / 23
structure - fixed 128 ndcg@10 283 175 +9.2 +3.7 to +14.5 +4.5 to +13.9 0.0011 yes 97 / 59
structure - recursive 128 recall@5 283 175 -1.8 -3.4 to -0.4 -3.5 to -0.4 0.0650 no 0 / 5
structure - recursive 128 intact@5 283 175 -1.8 -3.4 to -0.4 -3.5 to -0.4 0.0650 no 0 / 5
structure - recursive 128 ndcg@10 283 175 -1.2 -1.8 to -0.5 -1.9 to -0.5 0.0005 yes 2 / 25
structure+context - structure 128 recall@5 283 175 +1.2 -1.3 to +3.8 -0.9 to +3.4 0.4366 no 8 / 4
structure+context - structure 128 intact@5 283 175 +1.1 -1.4 to +3.6 -1.1 to +3.2 0.5925 no 6 / 3
structure+context - structure 128 ndcg@10 283 175 -0.2 -1.7 to +1.0 -1.3 to +0.9 0.7502 no 21 / 17
structure+context - recursive (added after the run) 128 recall@5 283 175 -0.5 -3.6 to +2.0 -2.8 to +1.8 0.8359 no 6 / 7
structure+context - recursive (added after the run) 128 intact@5 283 175 -0.7 -3.7 to +1.8 -2.8 to +1.4 0.8353 no 4 / 6
structure+context - recursive (added after the run) 128 ndcg@10 283 175 -1.4 -3.1 to +0.1 -2.7 to -0.1 0.0875 no 15 / 26

Both:

Comparison (A - B) Budget Metric Questions Pages Difference (points) 95 % interval, by page 95 % interval, per question p (by page) Resolved? Questions A better / B better
structure - fixed 256 recall@5 158 104 -0.6 -7.3 to +6.1 -6.0 to +4.8 0.8582 no 29 / 31
structure - fixed 256 intact@5 158 104 -6.3 -11.6 to -1.9 -10.1 to -2.5 0.0145 yes 0 / 10
structure - fixed 256 ndcg@10 158 104 +1.0 -3.9 to +6.0 -3.0 to +5.0 0.6699 no 49 / 39
structure - recursive 256 recall@5 158 104 -1.1 -3.7 to +1.4 -3.5 to +1.1 0.4197 no 6 / 8
structure - recursive 256 intact@5 158 104 -2.5 -5.3 to -0.6 -5.1 to -0.6 0.1299 no 0 / 4
structure - recursive 256 ndcg@10 158 104 -0.5 -2.0 to +0.9 -1.9 to +0.9 0.4988 no 18 / 19
structure+context - structure 256 recall@5 158 104 +5.8 +0.4 to +11.4 +1.3 to +10.4 0.0437 yes 30 / 12
structure+context - structure 256 intact@5 158 104 +7.6 +3.0 to +13.0 +3.8 to +12.0 0.0042 yes 12 / 0
structure+context - structure 256 ndcg@10 158 104 +1.9 -1.3 to +5.2 -0.9 to +4.7 0.2394 no 41 / 29
structure+context - recursive (added after the run) 256 recall@5 158 104 +4.7 -0.8 to +10.3 -0.2 to +9.5 0.1074 no 31 / 15
structure+context - recursive (added after the run) 256 intact@5 158 104 +5.1 -0.6 to +10.9 +0.0 to +10.1 0.1384 no 12 / 4
structure+context - recursive (added after the run) 256 ndcg@10 158 104 +1.4 -2.0 to +4.8 -1.6 to +4.3 0.4225 no 40 / 30
structure - fixed 128 recall@5 158 104 +3.6 -1.6 to +8.6 -1.3 to +8.3 0.1766 no 41 / 21
structure - fixed 128 intact@5 158 104 -1.3 -3.3 to +0.0 -3.2 to +0.0 0.4998 no 0 / 2
structure - fixed 128 ndcg@10 158 104 +6.3 +2.0 to +10.6 +2.5 to +10.1 0.0046 yes 60 / 28
structure - recursive 128 recall@5 158 104 +0.9 -1.5 to +3.1 -1.5 to +3.2 0.4737 no 10 / 6
structure - recursive 128 intact@5 158 104 +0.0 +0.0 to +0.0 +0.0 to +0.0 1.0000 no 0 / 0
structure - recursive 128 ndcg@10 158 104 +1.8 +0.2 to +3.5 +0.2 to +3.5 0.0360 yes 16 / 15
structure+context - structure 128 recall@5 158 104 +3.6 -0.0 to +7.3 +0.1 to +7.1 0.0558 no 27 / 13
structure+context - structure 128 intact@5 158 104 +3.8 +1.2 to +7.0 +1.3 to +7.0 0.0298 yes 6 / 0
structure+context - structure 128 ndcg@10 158 104 +1.7 -1.2 to +4.6 -0.8 to +4.3 0.2590 no 36 / 24
structure+context - recursive (added after the run) 128 recall@5 158 104 +4.4 +1.1 to +7.9 +1.2 to +7.7 0.0127 yes 25 / 9
structure+context - recursive (added after the run) 128 intact@5 158 104 +3.8 +1.2 to +7.0 +1.3 to +7.0 0.0298 yes 6 / 0
structure+context - recursive (added after the run) 128 ndcg@10 158 104 +3.5 +1.1 to +6.0 +1.2 to +5.8 0.0089 yes 38 / 20

Chunks, tables and cost

Configuration Chunks Mean tokens Median / max tokens Tokens encoded (M) Encoding (s) Chunks/s Tokens/s
fixed-256 13501 233 256 / 256 3.14 725 18.6 4339
recursive-256 15193 189 216 / 256 2.88 896 16.9 3210
structure-256 16030 180 209 / 256 2.89 1068 15.0 2710
structure+context-256 16321 186 213 / 256 3.03 843 19.4 3591
fixed-128 26034 122 128 / 128 3.17 684 38.1 4643
recursive-128 29541 96 104 / 128 2.83 660 44.8 4291
structure-128 30437 97 105 / 128 2.95 694 43.9 4256
structure+context-128 32129 99 106 / 128 3.17 773 41.6 4109
Configuration Units no chunk holds whole Tables split into row groups Table pieces without the context sentence Rows that do not fit with the header (tables) Rows cut
fixed-256 2604 of 80941 - - - -
recursive-256 40 of 80941 - - - -
structure-256 40 of 80941 327 - 7 (1) 1
structure+context-256 40 of 80941 516 3 7 (1) 1
fixed-128 12089 of 80941 - - - -
recursive-128 451 of 80941 - - - -
structure-128 451 of 80941 1584 - 322 (60) 4
structure+context-128 451 of 80941 2016 788 322 (60) 4

"Units no chunk holds whole" counts sentences and table rows of all 2789 pages that no chunk contains completely. For the recursive and structure-aware chunkers these are sentences longer than the budget; the fixed windows also cut ordinary sentences and rows at their edges. Encoding times were measured once on one laptop CPU (see Limits), while lighter work ran on the machine at times; the throughput varied between 2710 and 4643 tokens per second for the same model, so the number of tokens encoded is the better measure of cost.

What the numbers say, and what they do not say

  • Fixed token windows are clearly the worst choice for pages with tables. The structure-aware chunker finds 9.3 points more of the evidence in the first five chunks at 256 tokens (interval +5.7 to +13.0) and 11.7 points more at 128 (+8.1 to +15.3), and it holds all evidence of a question in one chunk 15.7 and 15.9 points more often. The replication set confirms all four, with a smaller gap in recall@5 at 256 tokens (+4.3, +2.8 to +5.8). The fixed windows leave 2604 of the 80941 sentences and rows without any chunk that holds them whole at 256 tokens, and 12089 at 128.
  • At 256 tokens, keeping tables whole adds nothing measurable over a recursive splitter. +1.2 points on the test questions (interval -0.6 to +3.1, p = 0.19), -0.1 on the replication set (-0.9 to +0.8). Two reasons are visible in the tables: only 327 of the 2789 tables need more than 256 tokens, and the recursive splitter already cuts a Markdown table only between its rows. Most of the gain over fixed windows comes from cutting at the structure the page already has, not from a special rule for tables.
  • When tables do not fit, the repeated header pays. At 128 tokens 1584 of the 2789 tables must be split. There the structure-aware chunker is 3.3 points ahead of the recursive splitter (+1.6 to +5.0), 2.5 in the replication set (+1.7 to +3.2), and 5.8 points on questions whose evidence is only table rows (+3.3 to +8.4). Every table piece starts with the header, so a row can be read (except in the 60 tables whose header is too long to repeat with a row); in the recursive splitter only the first piece has it.
  • A table chunk needs words that say what the table is about. Putting the sentence right before the table in front of every table piece added 3.1 points at 256 tokens on the test questions (+0.0 to +6.1, p = 0.049, just resolved) and 7.0 on the replication set (+5.7 to +8.4). At 128 tokens the sentence takes room from the rows: the test gain is not resolved (+1.0, -2.0 to +4.0), the replication gain is smaller (+2.7), and intact@5 does not improve (-1.9 on test, +0.1 on replication, neither resolved). Compared with the recursive splitter directly (a comparison added after the first results, so it was not planned), the chunker with the context sentence is 4.3 points ahead at both budgets on the test questions.
  • Separating tables from text has a price for questions that need both. For the 158 test questions with evidence in text and table, the structure-aware chunker never holds all of it in one chunk (intact@5 = 0 at both budgets), because text and table go to different chunks; only the context sentence brings some back (7.6 at 256). Its recall@5 on these questions is not measurably worse (all its differences in recall@5 to fixed and recursive are unresolved), so a reader model still gets the evidence, but in two chunks.
  • On text-only questions the chunkers that respect lines are alike. The structure-aware chunker splits text exactly as the recursive splitter does and differs only in never putting text and table into one chunk. At 128 tokens it was 1.8 points behind on text-only questions (-3.4 to -0.4, p = 0.065, not resolved).
  • Finding the right page is the larger problem. Even the best configuration has a chunk of the right page among the first five for only 61.6 % of the test questions at 256 tokens (Page@5). Chunking decides what happens after that, and it moves evidence recall@5 between 32.6 % and 50.8 %.
  • Cost. The structure-aware chunker makes more, slightly shorter chunks than fixed windows (16030 against 13501 at 256 tokens), but encodes fewer tokens, because the fixed windows overlap blindly: 2.89 million against 3.14 million at 256, 2.95 against 3.17 at 128. The context sentence adds tokens back (3.03 and 3.17 million).

What this means for building a RAG knowledge base

These are conclusions from one data set and one small embedding model; see Limits.

  1. Do not cut documents with tables by fixed token windows. Convert tables to Markdown (or another line-per-row form) and split at document structure. On these pages the structure-aware chunker found 9.3 and 11.7 points more of the evidence in five retrieved chunks than fixed windows (test questions, 256 and 128 tokens; 4.3 and 10.8 on the replication set).
  2. Give tables their own chunks, with the header in every piece, when tables can be larger than the chunk budget. With small chunks this measurably helps; with chunks large enough for most tables, a good recursive splitter was not measurably worse.
  3. Put a short description in front of every table chunk. Here a single sentence from before the table, in FinQA often just the table's column labels as text, gained more at 256 tokens than keeping tables whole did. A real title, caption or section heading is the natural next thing to test.
  4. Size the budget for the tables. At 128 tokens more than half of the tables had to be split, and the context sentence then competed with the rows for room. Measuring how large the tables of one's own documents are is cheap and tells which of these effects matters.
  5. Measure evidence, not only page hits. "Evidence intact" (all evidence plus the table header in one chunk) separated the chunkers more sharply than nDCG or page hits did, and it is what a reader model needs.

Method

Data

FinQA (Chen et al., EMNLP 2021), read at commit 0f16e28, MIT licence. Each FinQA example is one question about one page of a company's financial report: the text before the table, one table, and the text after it. A file name such as ETR/2016/page_23.pdf gives the company's ticker, the report year and the page. For every question FinQA's annotators marked the evidence needed to answer it (gold_inds): table rows and sentences of that page.

  • Collection: every distinct page of all three splits, 2789 pages (train 2110, dev 299, test 380; no page is in two splits). Every page is one document; for a given question, all other pages are distractors.
  • Questions: the primary set is the test split. The train and dev questions are a replication set: nothing here is trained or tuned, so they are as new to the system as the test questions, but the conclusions of this README rest on the test split.
  • Evidence units: FinQA's own ids. text_j is sentence j of the text before and after the table, table_i is row i of the table, and row 0 is the header.
  • Cleaning: FinQA keeps about 5,500 sentences that are a lone "."; they are left out of the pages. Six gold evidence units are dropped from their questions: five are such a ".", one has the invalid id text_-1. No question loses all its evidence. FinQA's text is lower-cased and tokenized (for example $ 5735); the table is taken in the same form (table, not table_ori), so text and table look alike.

python -m tachunk fetch downloads the three split files and the licence at that commit and checks their SHA-256 (tachunk/settings.py); the downloads stay in cache/ and are not part of this repository. results/manifest.json records the SHA-256 of the derived pages and questions, so a new run can show it used the same data.

One rendering for every chunker

Every chunker sees the page in the same form: one sentence per line, the table as Markdown (header line, separator line, one line per row), and a blank line between the text before the table, the table, and the text after it. Only the cutting differs.

The chunkers

All budgets count tokens of the embedding model's own tokenizer (without special tokens and without the passage: prefix). Two budgets: 256 and 128 tokens.

Chunker What it does
fixed Windows of exactly budget tokens over the rendered page; each window starts budget / 8 tokens before the last one ended (32 or 16 tokens of overlap). Blind to structure.
recursive The algorithm of LangChain's RecursiveCharacterTextSplitter, written here without LangChain, with tokens as the length: split at blank lines, then line breaks, then ". ", then spaces, and merge neighbouring pieces back up to the budget, carrying up to budget / 8 tokens of overlap. Because the table is a block of lines between blank lines, it already cuts tables only between rows (unless one row alone is longer than the budget); but it merges a small table with the text around it, and when it must split a table, only the first piece has the header.
structure The text before and after the table is split exactly as recursive splits it. The table becomes chunks of its own: the whole table if it fits; otherwise groups of whole rows, filled in order, each with the header line and the separator line repeated.
structure+context As structure, and the sentence right before the table is put in front of every table chunk (cut to at most budget / 4 tokens).

The structure-aware chunker never cuts a row, with two exceptions that are counted in the results (second table under "Chunks, tables and cost"): a row that does not fit together with its header is grouped with its neighbours without the header (the header then gets a chunk of its own if no other chunk holds it), and a row longer than the whole budget is cut into token windows.

The comparisons were fixed in tachunk/settings.py before the full run: structure - fixed, structure - recursive and structure+context - structure, at each budget, on evidence recall@5 (the primary metric), evidence intact@5 and nDCG@10.

Retrieval

intfloat/multilingual-e5-small at revision 614241f622, with the prefixes query: and passage: that its card asks for. Vectors are normalized; every question is searched against all chunks of all 2789 pages by exact dot product (no approximate index). Equal scores keep the chunk order, so runs are deterministic.

Metrics

Per question, from its ten best chunks (tachunk/metrics.py):

  • Evidence recall@k (k = 1, 3, 5, 10): the share of the question's gold evidence units that are inside at least one of the first k chunks. A unit counts only if the chunk holds its whole text: half a table row is not evidence. recall_any@5 also counts units that are only partly inside, as a check.
  • Evidence intact@k: 1 if a single one of the first k chunks holds all the gold evidence, and, when any of it is a table row, also the table's header row; else 0. This is what a reader model needs to answer from one chunk.
  • nDCG@10: a chunk is relevant if it holds at least one whole gold unit; binary gains, and the ideal ranking puts all relevant chunks of the collection first. 0 if the chunker made no relevant chunk at all.
  • MRR@10: 1 / rank of the first relevant chunk.
  • Page@5: some chunk of the right page is among the first five, whatever it holds. It separates "found the page" from "found the evidence".
  • Ceilings: the evidence recall and intact a perfect ranking could reach with these chunks, i.e. whether some chunk of the page holds each unit whole, or all of them together.

Statistics

Every comparison pairs the two chunkers question by question (tachunk/stats.py, tachunk/compare.py).

  • Clustered paired bootstrap, 95 % interval. FinQA has about three questions per page, and a chunker that cuts a page badly tends to fail all of its questions. These questions are not independent, so the bootstrap draws whole pages (all questions of a page), 10,000 times. The interval that treats every question as independent is shown next to it; it is narrower and too optimistic.
  • Paired sign-flip test, clustered by page. If both chunkers were equally good, the sign of each page's summed difference would be a coin toss. p is the share of 10,000 random sign patterns whose mean difference is at least as far from 0 as the observed one; the smallest possible value is 1 / 10,001 = 0.0001.
  • Resolved means the clustered interval excludes 0 and p < 0.05. Where a difference is not resolved, these data cannot say which chunker is better.
  • There are many comparisons and no correction for multiple testing; a single p near 0.05 should be read with that in mind.

Limits

  • One domain, one data set. FinQA pages are pages of financial reports with exactly one table each, already extracted into clean rows. Real documents have several tables per page, tables across pages, merged cells, headers of several rows, and extraction errors. FinQA flattens every header to one row.
  • One embedding model, English only. multilingual-e5-small, 384 dimensions, on FinQA's lower-cased and tokenized text. A larger model, or one trained on tables, may gain less (or more) from table-aware chunks.
  • Retrieval only. No language model answers the questions. That an intact chunk leads to a better answer is plausible, but it was not measured.
  • The questions are hard to place. Most FinQA questions name neither the company nor the report; they ask, say, for the change of one line item between two years. The collection holds similar pages of the same companies from other years. So the right page is often not among the first results, for every chunker (Page@5 between 52.4 and 62.4 % on the test questions). The comparisons are fair, because every chunker faces the same questions, but absolute figures say little about other collections.
  • A chunk from the wrong page counts as a miss, even if it holds the same numbers. 19 tables appear identically on more than one page.
  • The "context sentence" is a weak form of the idea. In FinQA the sentence right before the table is often the table's own column labels, flattened into text by the extraction, rather than a sentence that introduces the table. A title or a section heading was not available.
  • Questions within a page are clustered, pages within a company are not. The statistics resample pages; pages of the same company or report are treated as independent.
  • Many comparisons, no correction for multiple testing. The conclusions rest on differences that are resolved in the test split and again in the replication set, not on single borderline values.
  • Speed is one run on one laptop CPU (AMD Ryzen 7 5800HS, 8 cores, Windows 11, PyTorch 2.15 on CPU); other work ran on the machine at times. The tables also give the number of tokens encoded, which does not depend on the machine.

How to reproduce

Python 3.12, a CPU, about 3 GB of free disk:

python -m venv .venv
.venv/Scripts/activate            # Linux: source .venv/bin/activate
pip install torch==2.15.0 --index-url https://download.pytorch.org/whl/cpu
pip install -r requirements-dev.txt
python -m tachunk all             # fetch and check FinQA, chunk, embed, search, compare, print the tables
pytest
ruff check . && ruff format --check .

python -m tachunk run writes one file per configuration to results/e5-small/, compare writes results/comparisons.json, and report prints every table of this README from those files. Vectors are stored in cache/vectors/ and reused when the chunks are exactly the same. CI (.github/workflows/ci.yml) runs lint, the unit tests and python -m tachunk smoke: 8 test questions against 32 pages, all chunkers at both budgets, then the comparisons and the report. It does not run the benchmark.

Files

File What it does
tachunk/settings.py Every fixed choice: data commit and checksums, model and revision, budgets, overlap, the planned comparisons, seeds.
tachunk/fetch.py Downloads the FinQA files at the fixed commit and checks them; loads the model at its revision.
tachunk/document.py A page as evidence units, and the one rendering all chunkers use.
tachunk/finqa.py Builds pages and questions from FinQA; the smoke subset; the data fingerprint.
tachunk/tokens.py Token counts and offsets: the model's tokenizer, and a word tokenizer for the tests.
tachunk/chunkers.py The fixed-size, recursive and structure-aware chunkers.
tachunk/metrics.py Evidence recall, intact, nDCG, MRR, page hit and ceilings for one question.
tachunk/stats.py Clustered paired bootstrap and sign-flip test.
tachunk/run.py Chunk, embed, search and score every configuration.
tachunk/compare.py The paired comparisons: the planned ones, and the one added after the first results.
tachunk/report.py Prints the README tables from the result files.
tachunk/machine.py Machine description, package versions, a timer.
tachunk/__main__.py The command line: fetch, run, compare, report, all, smoke.
results/ One JSON file per configuration with per-question values (results/questions.json gives their order), comparisons.json, manifest.json.
tests/ Unit tests for rendering, every chunker, the metrics, the statistics and the run helpers.

Sources and licences

  • Code in this repository: MIT, see LICENSE.
  • FinQA: Chen et al., FinQA: A Dataset of Numerical Reasoning over Financial Data, EMNLP 2021, https://arxiv.org/abs/2109.00122; data from https://github.com/czyssrs/FinQA at commit 0f16e28, MIT licence (the repository's LICENSE, also reported by GitHub). This repository contains none of its text: the result files hold FinQA's question ids, page file names and evidence ids, and per-question scores.
  • intfloat/multilingual-e5-small: MIT licence on its card. Its card lists MS MARCO, whose terms are for non-commercial research, among its fine-tuning data; that does not matter for a benchmark, but should be checked before any commercial use. No weights are part of this repository.

Metadata

Release files for table-aware-chunking 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for table-aware-chunking 1.0.0
File Size Uploaded Provenance Actions
table_aware_chunking-1.0.0.tar.gz 70.9 kB With provenance Details for table_aware_chunking-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for table-aware-chunking 1.0.0
File Interpreter ABI Platform Actions
table_aware_chunking-1.0.0-py3-none-any.whl Python 3 none any Details for table_aware_chunking-1.0.0-py3-none-any.whl

Total release size: 113.5 kB

Release files / table_aware_chunking-1.0.0.tar.gz

Download URL table_aware_chunking-1.0.0.tar.gz
Size 70.9 kB
Tags Source
SHA-256 checksum
How to use checksums
063de91baef853d5cb1048b3c11122da55d9dfc4a1e1f632de2ea0b35e08812b
BLAKE2b-256 checksum
How to use checksums
2b6a906dec77ee32673498ef201036a16193e8eaa4d45e7573af08fda1f01ef2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / table_aware_chunking-1.0.0-py3-none-any.whl

Download URL table_aware_chunking-1.0.0-py3-none-any.whl
Size 42.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c31a37a03e5ce3401c183e54f1320281a3f53c0f9c829819c6e8332d1f00c1a
BLAKE2b-256 checksum
How to use checksums
668c08460a35da1722a5a39cff7ef6d35dd0b12701fc7a5aa6ec895620d3cf08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Security for table-aware-chunking 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for table_aware_chunking-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page