B2reading roomNote16 September 20262-minute read

JSON Schema is the cheapest reviewer an LLM will ever get

Every answer from a language model should be checked by something that isn't a language model. The cheapest thing I know for the job is a JSON Schema.

It's a file. It costs no tokens, runs in a blink and never has an off day. In the PDF reader I built, one schema does two jobs: it's sent to the model as the response format, so the answer comes back in the right shape, and it's checked again when the answer arrives, because asking for the right shape and getting it aren't the same thing.

A good schema says more than field names. Which fields are required, currency codes as three capital letters, dates that are dates, a star rating between 0 and 5, flags that are 0 or 1. Every rule you write is a mistake that can't get through quietly.

When an answer fails, fail loudly. Log the errors next to the answer, and don't patch it up and carry on. A quiet fix hides exactly the cases you need to see.

Two things to keep in mind. A schema checks shape, not truth: a wrong date in the right format passes, so a person still looks at the result. And test the reviewer itself. Feed it an answer you know is wrong and make sure it says no. A validator that's wired up slightly wrong will approve everything, cheerfully, for months.

Ring the bell

Got a question one of these didn't answer? Ask me directly.

Get in touch