Instructor vs JSON mode vs constrained decoding
Asking a model for JSON is not the same as getting JSON. These three approaches differ in whether they give you a guarantee or a tendency — and that difference decides whether you can retry safely.
Short answer
Use a library like Instructor for extraction work: validation, typed retry and partial streaming are worth more than an absolute guarantee.
By Lattice editorial · Licence and cost facts verified · method
- InstructorSchema validation, extraction and repair, in code.
- GuidanceConstrained decoding, control flow interleaved.
- OutlinesToken-level constraints, including regex and grammars.
| Dimension | Instructor | Guidance | Outlines |
|---|---|---|---|
| Guarantee | Validated, with typed retry | Token-level constraint — cannot be violated | Token-level constraint, schema or grammar |
| Works across providers | Yes, with capability detection | Yes | Yes, via local or hosted inference |
| Streaming | Partial objects supported | Yes | Yes |
| Handles messy extraction | Yes — its main use case | Awkward | Awkward |
| Constraint style | Post-hoc validation and repair | Token masking + control flow | Token masking, incl. JSON Schema and regex |
| Where it loses | Not a hard guarantee like token constraints | Less ergonomic for plain extraction | Most setup of the three |
Scroll the table sideways to see every tool.
What this table is not. These are editorial judgements, not benchmarks: Lattice has not run these tools head to head, and no cell uses GitHub stars or vendor benchmark claims as evidence. Licence and cost facts are re-checked on a schedule the build enforces — the receipt is public.
The recommendation
Which should you choose: Instructor, Guidance or Outlines?
Use a library like Instructor for extraction work: validation, typed retry and partial streaming are worth more than an absolute guarantee. Reach for true constrained decoding — Guidance or Outlines — when downstream code cannot tolerate a malformed response at all, because there the guarantee is worth the reduced flexibility. Treat a provider's JSON mode as a convenience rather than a contract, and validate regardless.
Rules of thumb
- Validate in code regardless of what the provider promises. Modes get relaxed without notice.
- Design the schema before the prompt. A schema that reflects how you will consume the data produces better extractions.
- Constrained decoding restricts the token space, so it can make a model look worse at reasoning than it is. Do not benchmark reasoning through it.
Quick answers
- When should you use Instructor, and when should you skip it?
- Use Instructor when: schema-validated extraction with typed retry and partial streaming. Skip it when: you need a hard token-level guarantee rather than validation.
- When should you use Guidance, and when should you skip it?
- Use Guidance when: constrained decoding with control flow interleaved into generation. Skip it when: you need better ergonomics for plain extraction.
- When should you use Outlines, and when should you skip it?
- Use Outlines when: token-level constrained generation from a JSON schema or grammar. Skip it when: post-hoc validation is enough for your use case.