Downstream code needs a JSON object with fixed fields from the model. What helps most?
- Exam domain
- LangChain for AI agents
- Difficulty
- Hard
- In this mock
- 5 questions on this domainPractise this domain
Why D is the answer
Ask for a schema and validate with a parser
Give the model a schema for structured output and validate the result with a parser, retrying or repairing when it fails. That turns free text into a typed object your code can trust.
Remember: Schema plus validation.
In detail
- Schema in, validated object out.
- Handle failures with a retry or repair.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. Raise the temperature for more varied JSONWrong
More randomness makes malformed output more likely.
B. Ask the model nicely to be careful with commasWrong
Polite wording is not validation.
C. Add more tools so the model has more optionsWrong
More tools do not shape the output format.
D. Ask for a schema and validate with a parserRight
Schema plus validation.
Use case
An illustrative scenario, not a real incident.
Illustrative: an intake agent fills a fixed claim form, and the parser rejects any reply missing the policy number.
See it in different ways
flowchart LR S0["Schema"] --> S1["Model output"] --> S2["Parser validates"] --> S3["Typed object"]
How to read this chart
- Read it in order: Schema, then Model output, then Parser validates, then Typed object.
flowchart TD
Q{"Is the output valid?"}
Q -->|"Yes"| A0["Pass it on"]
Q -->|"No"| A1["Retry or repair"]How to read this chart
- At "Is the output valid?": if "Yes", go to "Pass it on"; if "No", go to "Retry or repair".