Skip to main content

Measuring well

The platform does the counting, and you decide what goes into it: which inputs get ground truth, how many, and when a difference between two versions is real. Here are rules of thumb for each, no statistics background needed.

Pick inputs like your real traffic​

  • Take them from production, or from the documents you'll get in production. Made-up examples are cleaner than the real thing, so they flatter the agent.
  • Keep the mix realistic. If one in ten invoices is a scan, about one in ten of the inputs in your ground truth should be too. To stress-test the hard cases, put them in a second evaluation, so the main one still tells you what production looks like.
  • Include fields that should be empty, like a purchase order number on an invoice without one, and mark them as expected to be absent. Otherwise you never find out whether the agent makes things up.
  • Keep the set stable. You can add inputs, but run every version you compare on the new ones too.

How many inputs?​

The fewer inputs, the less a score tells you. Say the agent gets 90% right:

Your agent scores 90%. How sure can you be?The range the real accuracy likely falls in (95% interval), by number of inputs with ground truth
Ground truthRange on a scale from 70% to 100%Real accuracy likely
25 inputs72.5% to 96.8%
50 inputs78.6% to 95.7%
100 inputs82.6% to 94.5%
200 inputs85.1% to 93.4%
400 inputs86.7% to 92.6%

With 25 inputs, that 90% fits an agent that's really anywhere between 72% and 97% accurate. With 100 inputs the range narrows to 83% to 95%. Rules of thumb:

  • About 50 inputs to see whether a field is in the right ballpark.
  • 100 to 200 to decide whether it's good enough to ship.
  • More for the fields where a few percent make a difference, like an amount you pay out.

Fields inside a list count per item. An invoice with ten lines gives ten values for $.lines[*].amount, so list fields get precise sooner than the inputs alone suggest.

Is the new version really better?​

A version going from 90% to 92% on 100 inputs means two inputs changed. That can be chance: models don't answer exactly the same way every time.

So don't just compare the percentages. Count the inputs that changed:

  • Fixed: wrong before, right now.
  • Regressed: right before, wrong now.

When at least six inputs changed and nearly all of them moved the same way, the change is real. Nine fixed and one regressed is very unlikely to be chance. Seven fixed and three regressed could easily be. With only a handful of changed inputs you can't tell yet: add inputs, or run the version on the same inputs again and see whether the result holds.

The fix assistant shows the fixed and regressed inputs per field for every change it tries.

Make the comparison fair​

  • Use the field type that fits. A field with a fixed set of values, like a category or a country code, should be categorical. Its confusion matrix shows which values get mixed up, which is often the quickest route to a fix.
  • Normalize formatting, not mistakes. A value normalizer that also hides real errors, like a wrong country code in an IBAN, makes the agent look better than it is.
  • Agree on the rules when people annotate. Every acceptable value any annotator enters counts, which is right for fields with more than one valid answer. When people disagree because a rule is unclear, write the rule down in the annotation comment, so the ground truth doesn't drift.

Keep measuring in production​

Your ground truth covers a sample of inputs. Corrections from your own process, sent with addToEvaluationSet, show how the agent does on real traffic. Keep them in a separate evaluation and compare it with your main one now and then. When production scores lower, your ground truth is missing a kind of input: add a few of the inputs that went wrong.