Why does a small FT dramatically improve strict-JSON output?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Even a few hundred FT examples can sharply improve a model's compliance with a strict JSON schema. Why is format-teaching so much more data-efficient than knowledge-teaching? Explain mechanically.
Format is a first-few token distribution shift, not new knowledge. FT collapses the opening toward `{` and autoregression locks the rest into JSON the model already knows.
Imagine a chef who already knows every recipe but keeps starting dishes at random: sometimes soup, sometimes salad. You do not teach new cooking. You just teach the one habit of always reaching for the soup pot first. After that, the rest of the meal follows naturally, because the chef already knows how soup goes. Strict JSON is the same. The model already learned what JSON looks like from huge amounts of text. It just opens its answers many different ways, like 'Sure,' or 'Here is'. A few hundred examples that always begin with a curly brace install one habit: open with the brace. Once that first token lands, each next token is almost forced, so the whole answer comes out as clean JSON without learning anything new.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: first-token distribution-shift framing + autoregressive lock-in + why it is low-dimensional versus knowledge + the no-guarantee caveat + constrained decoding and grammars + parser-based evaluation.
| Approach | Format fine-tuning | Constrained decoding |
|---|---|---|
| What it does | Shifts first-token probability toward legal openings | Masks illegal next-token logits via a grammar |
| Validity guarantee | No, a probabilistic improvement | Yes, illegal tokens are unreachable |
| Setup cost | Collect a few hundred examples, train a LoRA | Enable JSON mode or compile a schema grammar |
| Best for | Field semantics, value conventions, house style | Hard structural guarantees, exact schema shape |
| Evaluation | Parser plus schema validation on a holdout | Parser plus schema validation on a holdout |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Claiming a small format fine-tune guarantees valid JSON. It only shifts probability mass; it never masks an illegal token. For hard guarantees you still add a grammar constrained decoder and a parser check.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.