Topic 7
Measuring the parse rate, and wrap-up
"It usually returns JSON" is not a number. Run the prompt over a fixed set of inputs and count three rates, each harder to pass than the last:
- Parse rate: the share of outputs your parser accepts.
- Valid rate: the share that also pass the schema.
- Correct rate: the share whose values are right, checked against labelled answers.
The lab's illustrative set shows why one isn't enough: 50% parse, 10% valid. With repair, 90% parse and still only 50% valid. Report each rate with and without repair, so a parser fix can't hide a prompt problem. And keep the failing outputs: they show which fix to try.
Retries raise the valid rate, at a price.
Predict first
What retries buy, and what they cost
Arithmetic · assumes every attempt is independent
Valid after 3 attempts
99.90%
Expected calls per input
1.11
This is a best case. Retries are independent only if failures are random, but the book notes a model "tends to repeat similar mistakes". Measure how often a retry actually succeeds on your own failing inputs.
What to keep
- Few-shot examples teach in context; stronger models need fewer, but domain-specific tasks still benefit. Each shot costs tokens on every call.
- Pick examples that cover the labels, keep them compact, end on a marker, and test the order.
- Specify keys, types and allowed labels, then validate anyway.
- Parsing catches syntax; only a schema check catches wrong types and invented labels.
- Repair fixes syntax; content failures need a retry. Constrained sampling and finetuning make the format reliable, not the values right.
- Measure parse, valid and correct rates on a fixed set.
Quick check