Office Hours — Do structured outputs from LLMs create false confidence that the response is actually correct?
A daily developer question about AI/LLMs, answered with a direct, opinionated take.
Do structured outputs from LLMs create false confidence that the response is actually correct?
Absolutely. Structured outputs are a confidence trap if you treat them as a correctness guarantee.
What structured outputs actually do is enforce schema compliance. Claude Opus 4.7 or GPT-5.5 will give you valid JSON with the right fields in the right types. That’s genuinely useful for downstream processing. But a perfectly formatted response with incorrect facts, bad reasoning, or hallucinated data is still wrong, just easier to parse.
The real danger is organizational. When you have valid JSON coming out, it’s tempting to skip validation layers. Your pipeline accepts it, your database stores it, and by the time someone notices the content is garbage, it’s in production.
Schema Compliance vs. Correctness
Here’s a concrete case. You’re using structured outputs to extract entities from customer support tickets:
{
"customer_id": "12847",
"issue_category": "billing",
"resolution": "refund $450",
"confidence": 0.92
}
The JSON is perfect. It parses, loads into your database, and your automation triggers the refund. But what if the model hallucinated the customer ID? What if that ID doesn’t exist in your system, or belongs to a different customer entirely? The confidence score of 0.92 looks solid but means nothing about whether the customer ID is real.
A minimal guard rail: validate extracted IDs against your actual customer table before processing. If the ID doesn’t exist, flag it for human review instead of silently failing or processing garbage.
# Bad: Trust the structured output
result = extract_ticket(ticket_text)
process_refund(result['customer_id'], result['resolution'])
# Better: Validate against known data
result = extract_ticket(ticket_text)
if customer_exists(result['customer_id']):
process_refund(result['customer_id'], result['resolution'])
else:
flag_for_review(result, reason="customer_id not found")
Treat structured outputs like a syntax check, not a truth check. You still need separate validation: fact-checking against your knowledge base, confidence thresholds on claims, domain-specific sanity checks. If you’re extracting entity relationships, validate that the entities actually exist. If you’re generating code, test it.
Why Confidence Scores Lie
A related trap: leaning too hard on the model’s confidence field. A model returning "confidence": 0.95 for a hallucinated fact doesn’t mean the fact is 95% likely to be correct. Confidence scores reflect the model’s uncertainty about generating the right output format or matching the schema, not about truthfulness. A model can be very confident about a completely fabricated phone number, as long as the phone number has the right format.
Use confidence scores as a ranking signal (low confidence goes to human review first), not as a reliability guarantee. If you’re processing 10,000 extractions and can only manually verify 100, sort by confidence and pick the lowest-confidence 100. You’re not using confidence to say “this is probably right.” You’re using it to say “this is probably wrong.”
Where This Matters Most
The risk scales with the cost of being wrong. Structured outputs on a customer survey response? Low stakes, validation can be lighter. Structured outputs on medical claims, financial transactions, or access control decisions? High stakes. Add explicit validation every time.
One concrete pattern: extract with structured outputs, then validate the extracted content against known good data or run it through a filtering step. Don’t skip this because the JSON parses cleanly. If you’re building an agent that reads documents and extracts structured data for compliance, every extracted value should be spot-checked against the source document or your system of record.
Bottom line: Structured outputs solve a real problem (reliable parsing), but they create zero guarantees about correctness. Validate the content independently, not just the format. Schema compliance and factual accuracy are separate concerns. Format validation happens for free. Content validation is your responsibility.
Question via Hacker News