Codeficum 42

Measured notes from the workshop and the rack.

Chunking about 5,000 pages of reference documentation: what changed when the token counter stopped guessing

Corrected 2026-10-08, 2026-10-10 and 2026-10-14. The corpus is about 5,000 pages, manual plus datasheet, not one manual. The fixed-window context effect is +0.033, not zero. An 80 % chance of qualifying needs 71 and 81 questions, not 35 and 40. The method interval ends at +0.133, not +0.117. The text layer the chunks were cut from has no freeze record. The question counts and the estimate-era interval are calculated from measured data, not measured. Corrections, at the end, lists the changes.

We built a factorial benchmark for PDF chunking and retrieval and ran 24 configurations on about 5,000 pages of microcontroller reference documentation. We scored them on 30 questions frozen before any result was seen. Partway through, the benchmark turned out to be measuring its own defect: the token counter was never pinned, so a metric denominated in tokens was counting an estimate, and the arm named "fixed 512-token windows" was cutting by word count.

Fixing that changed the results. A metric we had written off turned out to carry information. An effect we had called the run's only near-signal halved. The three fixed-window RRF configurations reversed their order. This post reports the corrected numbers and what the correction moved, because the second is the more useful half.

The headline, unchanged by any of it: none of the 23 comparisons is statistically distinguishable at 30 questions.

1. What was measured

The corpus is a microcontroller reference manual of about 4,800 pages plus a datasheet of about 120 pages, about 5,000 pages in all. The manual is register-dense. Every page has a real embedded text layer, and zero pages needed an OCR fallback. The documents are third-party copyright, so nothing from them appears here: no excerpt, no question text, no retrieved span. Metrics and method only.

The grid. Extraction, treatment and form are held at one level; boundary, context, embedder and retrieval method vary. 6 chunk sets and 12 vector indexes give 6 × (BM25, 0.6 B dense, 568 M dense, 0.6 B RRF) = 24 scored series. RRF with the 568 M embedder was not run.
FactorLevelsStatus
Extractiontxt — embedded text layerfixed (1)
Boundaryfix 512-token windows · par paragraph groupsvaried (2)
Contextnone · sec · chapvaried (3)
Embedder0.6 B dense · 568 M densevaried (2)
Retrievalbm25 · dense · rrfvaried (3)

The primary metric is recall@B1024: was the gold answer span retrieved within a 1,024-token budget, counting the actual tokens of the chunks returned rather than a fixed k. A budget metric is the honest one when chunk sizes differ between arms — ranking by k silently rewards whichever arm ships bigger chunks. That choice is what made the token counter load-bearing, and therefore what made its being wrong matter.

The scorer takes chunks in rank order until the running total reaches 1,024. The last chunk can overrun the budget by up to one chunk: three 400-token chunks deliver 1,200 tokens. The overrun favours larger chunks.

A gold span counts as retrieved when one returned chunk covers at least half of it. Four of the 30 questions have two gold spans, so a question scores 0, 0.5 or 1. Recall is the mean over questions.

Configuration, as run. The same settings apply to every series that uses them.
SettingValue
fix boundary512-token windows with a 64-token overlap, cut on the pinned tokenizer
par boundaryparagraphs split per page at blank lines, at headings, bullets and table lead words, after short lines and at indent changes. Runs of three or more one-line paragraphs with no blank line between them merge into one. Up to two paragraphs per chunk. The fix rule re-splits any chunk over 512 tokens.
Pagesno chunk crosses a page, in either rule
sec contextthe last numbered heading on the chunk's page at or before the chunk's start; the chapter title when there is none
chap contextthe chapter title from each document's outline
Context prefixjoined to the chunk text, counted in the chunk's tokens, never truncated
Token counterQwen3.5 tokenizer, vocabulary 248,070, pinned by SHA-256
Dense searchexact cosine over the whole index, no approximate search

2. The counter was an estimate, and the window was not a window

Two defects, found only by re-deriving results from what was on disk.

No tokenizer was ever pinned. The chunking spec carried a TODO placeholder, the loader returns nothing for a placeholder path, and the fallback is words / 0.75. Every token count in the campaign was that estimate. Measured against the real tokenizer on 400-chunk samples, the estimate ran at 0.677× of true on the fix arm and 0.775× on par. The error was not constant — it was arm-dependent, so it did not rescale the comparison, it tilted it, granting one arm about 15 % more real text per unit of budget than the other.

The fixed-window cutter never used a tokenizer at all. It cut by word count scaled by 0.75 and only reported counts from the pinned counter. So the manifest recorded a ceremony tokenizer that had played no part in the cut. With the real tokenizer applied to the same chunks:

The fix arm's "512-token" chunks, measured three ways. The middle row is the same cut points as the first, re-counted honestly.
Chunk setnmean maxover 512
as built, counted by estimate5,5713135120 %
as built, counted honestly5,571433122227.7 %
after the fix, cut on real tokens6,6643715120 %

A quarter of the chunks in the control arm were over the window the arm is named for, one of them by 2.4×. A third defect of the same shape sat in the paragraph rule: its oversize backstop — the split whose entire job is to enforce that window — also cut by words, leaving 138 chunks over 512 with a maximum of 1,195. All three passed a suite of 600+ tests, because every test asserted the reported count against the same estimator that produced it. An earlier adversarial review of the same harness found defects that the green suite also missed; What a green suite cannot see reports it.

When one source produces both a result and its check, an error in that source reaches both. Our post on independent verification evidence under ISO 26262 covers that failure for AI-written code and tests.

3. Results, on real tokens

24 series, 30 questions each, single run, seed 42. Baseline for deltas is fix/none/BM25.

recall@B1024 and supporting metrics, all 24 series, sorted by the primary metric. n = 30 questions. nDCG@10 normalises by the best ordering of the ten returned chunks' own coverage gains, not by an ideal ranking over the corpus.
BoundaryContextEmbedderMethod R@B1024R@B4096 R@10nDCG@10
parnone568 Mdense0.2830.3500.2830.243
parchap568 Mdense0.2830.3330.3000.276
parsec568 Mdense0.2330.3330.2330.204
fixchap568 Mdense0.2170.3330.3330.276
fixsec568 Mdense0.2170.3330.3330.268
fixsec0.6 Brrf0.1830.4170.4170.264
fixchap0.6 Brrf0.1830.3830.3830.222
fixnone568 Mdense0.1830.3170.2500.223
parchap0.6 Brrf0.1830.2500.1500.188
fixsec0.6 Bdense0.1500.3670.3000.191
parsec0.6 Brrf0.1500.2500.1500.186
parnone0.6 Brrf0.1500.2500.1500.179
parnone—bm250.1500.2500.1500.161
parsec—bm250.1500.2170.1830.147
parchap—bm250.1500.2170.1500.153
parsec0.6 Bdense0.1500.1830.1000.067
parchap0.6 Bdense0.1330.1830.1000.129
parnone0.6 Bdense0.1330.1500.1000.097
fixnone0.6 Brrf0.1170.3830.3170.240
fixchap0.6 Bdense0.1170.2830.1830.197
fixnone0.6 Bdense0.1170.2670.2000.177
fixnone—bm250.1000.2830.2830.170
fixsec—bm250.1000.2500.2500.163
fixchap—bm250.1000.2500.2500.163
Level averages against the baseline 0.00 +0.05 +0.10 embedder 568 M method dense boundary par context chap context sec context none boundary fix
Mean paired difference from the fix/none/BM25 baseline on recall@B1024, averaged over the series at each level, baseline excluded: 568 M +0.136 (6 series), dense +0.085 (12), par +0.079 (12), chap +0.071 (8), sec +0.067 (8), none +0.062 (7), fix +0.053 (11). The three context levels are the point of the chart: they sit within 0.009 of each other.

The levels hold different series. 568 M holds only dense series, while 0.6 B also holds the five BM25 and six RRF series. The chart leaves out 0.6 B at +0.042 (17 series), rrf at +0.061 (6) and bm25 at +0.030 (5). These are descriptive averages, not one-factor effects.

4. What the correction moved

We scored all twelve fix series under both counters, on the same questions and the same retrieval code. Eight fell, two held and two rose. The two that rose are the 0.6 B RRF arms with a section or chapter prefix, +0.033 each. The budget now charges real tokens, so it admits less text. The cutter changed at the same time, so the rerun does not isolate the counter's effect:

recall@B1024 for the twelve series measured under both counters. In the last three rows the order reverses: fix.none led the two prefixed RRF arms under the estimate and trails them on real tokens.
Seriesestimatereal tokenschange
fix.chap · 568 M · dense0.2670.217−0.050
fix.sec · 568 M · dense0.2670.217−0.050
fix.none · 568 M · dense0.2000.183−0.017
fix.none · bm250.1670.100−0.067
fix.sec · bm250.1670.100−0.067
fix.chap · bm250.1670.100−0.067
fix.chap · 0.6 B · dense0.1500.117−0.033
fix.sec · 0.6 B · dense0.1500.1500.000
fix.none · 0.6 B · dense0.1170.1170.000
fix.none · 0.6 B · rrf0.1830.117−0.067
fix.chap · 0.6 B · rrf0.1500.183+0.033
fix.sec · 0.6 B · rrf0.1500.183+0.033

Three findings from the first pass did not survive.

The context effect halved on the same arm and measured zero on paragraphs. Under the estimate, attaching a chapter heading beat attaching nothing by +0.067 paired on fixed windows (568 M, dense), interval [+0.000, +0.167]. It was the only one of the first pass's four headline contrasts whose interval held no negative value. We called it the closest thing to a signal. On real tokens that same contrast is +0.033. On paragraph chunks, which the first pass never measured, it is +0.000, interval [−0.083, +0.067].

The three context level averages sit within 0.009 of each other. A prefix costs tokens; when those tokens were under-counted, the context arms were being handed text they had not paid for.

A metric that "measured nothing" turned out to measure something. The first pass reported recall@B4096 as identical to recall@10 in all 360 series-question cells, and concluded the wide budget was a rename of the rank metric. That was an artifact: word-window cutting made every chunk a similar size, so a fixed budget and a fixed rank selected the same sets. With honest cutting and two boundary rules whose chunks differ by 4×, the two metrics now disagree in 43 of 720 cells. The collapse was a property of the bug, not of the corpus.

Lexical search stopped leading on fixed windows. The first pass found BM25 (0.167) above the 0.6 B dense arm (0.117) and made something of it. On real tokens and on the same slice, fixed windows with no context, BM25 sits at 0.100 against 0.117 dense: +0.017 for dense. On paragraph chunks the order differs. With no context or with chapter context, dense trails BM25 by 0.017, and the paired interval in section 7 is [−0.150, +0.133]. On fixed windows the dense arm does not qualify against the baseline, and the paragraph interval contains zero.

5. Small chunks win a tight budget; big chunks can win a fixed rank

The one robust-looking pattern in the corrected data is a trade, and it is only visible because the two metrics stopped agreeing. Paragraph chunks average 96 tokens; fixed windows average 371.

At a 1,024-token budget par leads — 0.283 against 0.217 for the 568 M dense model with chapter context. At a fixed rank of 10 the order reverses: fix takes 0.333 against par's 0.300, because ten large chunks deliver 3.7k tokens of text where ten small ones deliver under 1k. With no context there is no reversal: par also leads at rank 10, 0.283 against 0.250.

So "which chunker is better" is not answerable without saying what is scarce. If the constraint is the context window, small chunks spend it more precisely. If the constraint is the number of retrieved items — a reranker's input, say, or a UI list — larger chunks carry more of the answer per slot. The paired par-over-fix contrast at B1024 is +0.067, interval [+0.000, +0.150]: suggestive, not decided.

6. The embedders, and what an index costs

Two dense models ran on the same consumer 16 GB GPU. The first, Qwen3-Embedding-0.6B, is a 0.6 B, 1024-dim model with last-token pooling, served through llama.cpp at Q8_0 with a 2,048-token context. The second, snowflake-arctic-embed-l-v2.0, is a 568 M, 1024-dim model with CLS pooling, un-normalised, served through vLLM at float32 with an 8,192-token context.

The 568 M model has the largest level average in the run, +0.136. Paired on fixed windows with chapter context, it leads by +0.100. It is also cheaper to index: 284 s against 461 s of embedding time for the same 24,540 paragraph chunks with no context.

Two caveats keep that from being a model verdict: the engines differ, so part of the speed gap is serving stack; and the 0.6 B deployment's 2,048-token context is a configuration choice rather than a model limit. What this run shows is that this deployment indexed faster and scored higher than that deployment on this sample. The accuracy gap does not clear the qualification rule.

Index build cost against accuracy. Extraction (1,137 s) is shared by all six chunk sets and identical across them, so it cannot change the ranking.
SeriesBoundary (s)Embedding (s, client wall time) VectorsR@B1024
par.none · 568 M · dense8.128424,5400.283
fix.chap · 568 M · dense3.71946,6640.217
par.none · bm258.1000.150
par.none · 0.6 B · dense8.146124,5400.133
fix.none · bm257.7000.100

BM25 still earns its place on the frontier, at zero embedding cost. On paragraph chunks with no context it scores 0.150 against 0.133 for the 0.6 B dense model. On fixed windows with no context it trails that model, 0.100 against 0.117. Section 4 sets out what the intervals show.

7. Nothing qualifies, and here is what it would take

Every series was compared with the baseline by paired bootstrap, 2,000 resamples, seed 42, on the same 30 questions. Qualification requires the 95 % interval of the paired difference to exclude zero.

0 of 23 series qualify. The best result in the run, +0.183 over baseline, has an interval whose lower bound is exactly +0.000 — the closest anything has come, and still not a pass. From the measured per-question variance, the questions each contrast would need:

Questions at which the 95 % interval's lower bound reaches zero on average, n = ⌈(1.96 · SD / Δ)²⌉, from the measured paired standard deviation at n = 30. Δ enters as the exact fraction shown. At that n a contrast has about a 50 % chance of qualifying. The Slice column names the levels held fixed. The published means identify the embedder and boundary slices exactly and fix the method slice to the levels shown. For context they also allow fixed windows; the run's record names paragraph chunks.
ContrastSlicePaired ΔSD 95 % CI at n = 30Break-even n (≈50 % power)
568 M over 0.6 B (embedder)fix · chap · dense+0.100 (6/60)0.300[+0.000, +0.200]35
par over fix (boundary)chap · 568 M · dense+0.067 (4/60)0.213[+0.000, +0.150]40
chap over none (context)par+0.0000.224[−0.083, +0.067]no detected effect
dense over bm25 (method)par · 0.6 B−0.0170.376[−0.150, +0.133]no detected effect

At the measured effect and spread, 35 and 40 questions only bring the interval's lower bound to zero on average. That gives about a 50 % chance of qualifying. For an 80 % chance the same arithmetic, n = ⌈((1.96 + 0.84) · SD / Δ)²⌉, gives 71 and 81: more than twice the current set.

That is the useful result. The benchmark did not fail; it needs more than twice its questions for an 80 % chance of answering its own two best questions. For the other two, the sample shows no detected effect at n = 30. Their intervals still allow effects up to +0.067 (context) and +0.133 (method), so the sample establishes neither a gain nor equivalence.

8. What this report does not cover

The correction is the part worth keeping. A benchmark whose headline metric is denominated in tokens will happily report five significant figures on a counter that was never connected, and a full test suite will agree with it, because the tests assert the reported number against the same estimator that produced it. The only thing that caught it was recomputing a result from the artefacts on disk and finding the pipeline disagreed with itself.

The corpus is third-party copyright and is not redistributed; the question set, the retrieved spans and the documents themselves stay private. The harness, manifests and per-question records are kept, and our evidence ledger now lists the corrected run's records with their SHA-256 digests. This is still a report you can check for internal consistency, not one you can independently reproduce today.

Corrections

The first version went live on 2026-10-07 under the dateline of 2026-08-18. Each item gives the old value first.