← All posts

Measuring without fooling ourselves

Tune a program on the same documents over and over and it ends up perfect on those and mediocre on everything else. The rules we follow so our numbers mean something, and the times we nearly fooled ourselves.

Hernán Díaz Rodríguez··4 min read

In another post I explained how we measure the converter: the share of words that land in the Word file within 3 points of where they were in the PDF. A metric like that has a catch: it tells you exactly what you want to hear if you always look at it with the same documents.

This post is about that: how we try not to fool ourselves.

The problem: learning the examples by heart

The work loop is simple: measure, look at the worst documents, understand why they fail, fix it, measure again. It works. But every fix starts from one specific document, and it is very easy to write a rule that only helps that document: "if the line starts with a Roman numeral and the page has two columns, then…".

Each rule like that nudges the score up, and together they look like progress. But the converter is learning the examples by heart, like a student who memorised last year's exam. On a new document those rules don't help, or even get in the way.

And the numbers mislead more than you'd think. With around 60 diagnostic documents, the uncertainty of the average score is about 3 points. A change that "gains half a point" because it fixes one document may just be noise.

Three piles of documents

The classic answer is to split the data, and we stick to it:

And one rule for writing fixes: it has to help several documents from several families (papers, laws, manuals, patents…), not one. A general mechanism (using the fonts' real metrics, measuring how Word lays out text) beats a rule for one case.

What the sealed pile said

Early this month we asked ourselves seriously whether all that rule work was overfitted. We built the sealed set and scored several versions of the converter on it, old and new, all with the same metric:

VersionWords within 3 pt (sealed)
Starting version88.5%
After a few dozen fixes93.1%
Latest at the time93.4%

Of those documents, 102 improved and 3 got worse. The rules generalised: it wasn't memory. But there was a gap: on diagnostic documents the score was around 97–99%, on unseen ones 93–94%. That gap is the honest measure of how much knowing the documents helps us, and it's the number to watch.

A practical detail: the metric evolves too (bugs in the measurement itself get fixed). To compare old and new versions you have to rescore all of them with today's metric. Otherwise you're comparing two different rulers.

When an AI model was "more right" and did worse

Our best example of fooling ourselves with the wrong metric came from AI. We trained a small classifier to decide where a paragraph ends, using as ground truth the structure that scientific papers ship in XML. It agreed with that XML 99.35% of the time, against 96.96% for our rule. It looked like a clear win.

With it, the words-in-place score fell from 96.2% to 73.3%.

The XML says what a paragraph is to the person who wrote it. But a Word paragraph has only one indent and one line spacing: if the original changes line spacing mid-paragraph, it has to be split in two for every line to land in place. Our rule was "wrong" in those cases on purpose. The model was answering the wrong question correctly.

The lesson: before training anything, check that the answer you teach is the one the final result needs, not the one that looks more "correct".

Measure the ceiling before building

Another way not to fool yourself: before starting something big, measure the most it could possibly gain. Before training models to detect formulas and columns, we classified the misplaced words by cause. Of the 5.4 points lost on the holdout, what such a model could fix added up to less than one. Most of the loss was in plain text.

Not an exciting conclusion, but it saved weeks.

Seals wear out

A sealed set stops being sealed the moment you look inside. A few times the holdout score dropped because of a single document, and understanding why meant opening it. We did that three times, knowing the cost: those sets are now slightly contaminated. When we need a truly clean check, we'll have to build a new pile. What matters is knowing it and saying so.

What I take away

None of this is new: split your data, don't peek at the exam, distrust small gains. The hard part is sticking to it when a ten-line fix adds half a point and you'd like to keep it. The numbers we publish (around 95% on real documents the converter has never seen) come from the piles we don't look at. You can check with your own documents at PDF to Word.

Comments or ideas? Message me on LinkedIn. LinkedIn →