IN THIS BREAKDOWN · 10 SECTIONS
You can read 22% of this breakdown.
The paper in one minute
Language models generate text one token at a time, choosing from their whole vocabulary at every step. That is fine for prose and a problem for structure. Ask a model to list facts using only entities from Wikidata and it will write a plausible name that is not in Wikidata. Ask it for a parse tree and the brackets may not balance. The usual fixes were fine-tuning a model per task or validating after the fact and retrying.
The EPFL team used grammar-constrained decoding instead. You write a formal grammar describing every valid output. At each step, an incremental parser looks at what has been generated so far and returns the set of tokens that could still lead to a valid output. Every other token is masked before the model chooses. The output is valid by construction.
Their contribution is showing how general this is and adding one idea: input-dependent grammars. Instead of one grammar for all inputs, build the grammar from the input, for example listing only the candidate entities for this particular mention. With four examples in the prompt and no fine-tuning, LLaMA models improved sharply on closed information extraction and entity disambiguation, and LLaMA-33B beat a purpose-built extractor on extraction F1. On constituency parsing, constraints guaranteed 100% valid trees, though accuracy stayed far below dedicated parsers.
They also found a problem nobody had described: under constraints, the model's highest-scoring output was often the empty string.
Research notes: the problem, approach and results
entity disambiguation accuracy for LLaMA-33B, unconstrained against a grammar built per input
valid parse trees with an input-dependent grammar, while parse accuracy stayed near 55% F1
closed information extraction for LLaMA-33B, past a weakly supervised extractor at 34.8
Models asked for structured output (entity lists, typed fields, parse trees) produced near-misses: invented entity names, invalid structure, wrong formats.
At each decoding step, ask a parser which tokens could still lead to a valid output under a formal grammar, and mask everything else. Build the grammar from the input when the valid answers depend on it.
Large gains on information extraction and entity linking with no fine-tuning, beating a trained extractor; guaranteed valid parse trees; and a newly documented failure where the best valid output is empty.
Why it matters to an FDE
Most enterprise LLM work ends in structure: extracted fields that go into a database, function calls with typed arguments, JSON consumed by another service. Hosted APIs now offer "structured outputs" that constrain generation to a JSON Schema, and open-source servers support grammars. This paper explains what those features do and what they cannot do.
Valid is not correct. The constituency parsing results make the point starkly: constraints produced valid parse trees every time, and the trees were right about 55% of the time by F1, against 95% for supervised parsers. A schema guarantees that a field called amount contains a number. It does not guarantee that it is the right number. Your evaluation still has to check content.
Constrain to the input, not just the type. The biggest gains came from building the grammar from the input. Entity linking jumped from 68.2% with one grammar for all inputs to 80.3% when each input got its own candidate list. On a deployment, that means enums of the customer's actual product codes, account IDs from the record being processed, or the list of valid statuses for this workflow, rather than "any string".
Watch for valid but empty. If the schema allows an empty list or optional fields, constrained decoding can prefer the empty answer, because forcing the model through an unnatural structure lowers the probability of every full answer. The paper's fix is a decoding setting; the deployment fix is to monitor the rate of empty outputs.
Understand the mechanism. Try it on a real problem.
Unlock this breakdown and 49 more papers.
Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.
6 months · One payment · No auto-renewal
- ◇1 architecture diagram
- </>1 runnable code experiment
- ▦3 results tables
- ?5 interview questions with answers
- 03Key takeaways
The ideas to keep, how a grammar masks tokens, the results by task and the misreadings to avoid
Free account - 04How it works
Grammars, the incremental parser, input-dependent grammars and the empty-output trap, with a diagram
Premium - 05The numbers that matter
Every result by task and model size, the latency cost, and where the method fell short
Premium - 06Try it yourself
A toy constrained decoder that shows the invented-entity fix and reproduces the empty-output trap
Premium - 07Where it breaks
The limits the authors list, and what changed once providers shipped structured output
Premium - 08Using it on a deployment
Schemas from the input, monitoring empties, and validating content after the format is guaranteed
Premium - 09Interview angles
Five questions this paper prepares you for, with answer hints
Premium - 10Read next
Where to go from here on this site
Premium
