<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw" -->

---
title: Structured outputs and few-shot examples: getting...
description: Strict JSON Schema decoding guarantees valid JSON shape, but not correct classifications. In a 150-call release-note benchmark on gpt-4.1-mini, prompt-only...
canonical: https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Structured outputs and few-shot examples: getting reliable data from LLMs | daily.dev
og:description: Strict JSON Schema decoding guarantees valid JSON shape, but not correct classifications. In a 150-call release-note benchmark on gpt-4.1-mini, prompt-only...
og:url: https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw
og:image: https://api.daily.dev/og/posts/QXjxVlicw.png
og:image:alt: Structured outputs and few-shot examples: getting reliable data from LLMs
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Structured outputs and few-shot examples: getting reliable data from LLMs

**[Flavio Copes](https://daily.dev/sources/flaviocopes)** · 36 min read · 2 upvotes · 1 comments

## Summary

Strict JSON Schema decoding guarantees valid JSON shape, but not correct classifications. In a 150-call release-note benchmark on gpt-4.1-mini, prompt-only JSON failed raw parsing on 30 of 30 responses because of Markdown fences. A strict schema reached 100% valid JSON yet misclassified 4 of 30 entries. Putting a short rationale field first and adding four boundary few-shot examples gave 30/30 exact match, 37% fewer output tokens and 111ms lower median latency. Required string fields produced empty strings on 10 of 10 entries lacking data, where nullable fields returned null, and one strict-mode call on another model still returned an empty string.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://flaviocopes.com/structured-outputs-few-shot>

## Questions this post answers

### Why does my LLM return empty strings for fields missing from the input when using strict JSON Schema?

When a field is typed as a required string, the grammar forbids null, so the model must invent a value. In a 10-entry test with no issue number, a required string field produced an empty string on 10 of 10 entries. Declaring it nullable (type ["string","null"]) returned null on all 10.

_Developers shipping LLM extraction pipelines track failure modes like this on daily.dev._

### Does adding few-shot examples to a structured output prompt make requests slower?

Not necessarily. In a 30-entry release-note benchmark on gpt-4.1-mini, adding four boundary few-shot examples raised input tokens from 255 to 460 but cut average output tokens from 60 to 38 (37% fewer). Median latency fell from 938ms to 827ms, with accuracy unchanged at 30/30, because the examples also calibrated rationale length.

_If you're tuning prompt cost and latency, daily.dev covers practical LLM benchmarks._

### Why does field order in a JSON Schema matter for LLM structured outputs?

Models generate JSON left to right, so schema key order becomes thinking order. Placing a short rationale before the category lets the model state relevant facts first. In a release-note benchmark, verdict-first with no rationale scored 86.7% exact match (26/30), while rationale-first reached 100% (30/30).

_Anyone designing schemas for LLM classifiers will find daily.dev useful for staying sharp on this._

## Community discussion

Top comments from developers on daily.dev.

**@diyweb** · 0 upvotes

> The rationale-first field beating strict schema alone is a good find. Schema guarantees shape, not correctness. Useful note on nullable fields too: empty strings quietly pass validation and break downstream logic.

## Similar posts on daily.dev

- [Your LLM Can Return Perfect JSON and Still Be Wrong](https://daily.dev/posts/your-llm-can-return-perfect-json-and-still-be-wrong-o3ogkexgv) · Towards Data Science · 1 upvotes · 0 comments
- [Structured Outputs Create False Confidence](https://daily.dev/posts/structured-outputs-create-false-confidence-nukgaru4e) · Hacker News · 3 upvotes · 0 comments
- [Structured Output Reliability at Scale: When JSON Schema Validity Breaks Down Under Concurrency](https://daily.dev/posts/structured-output-reliability-at-scale-when-json-schema-validity-breaks-down-under-concurrency-vhkoljwe3) · DigitalOcean Community · 1 upvotes · 0 comments
- [Structured Outputs in 2026: A Developer Guide](https://daily.dev/posts/structured-outputs-in-2026-a-developer-guide-4qqi5lmpc) · Alex CloudStar · 1 upvotes · 0 comments

---

Tags: [#llm](https://daily.dev/tags/llm), [#zod](https://daily.dev/tags/zod)

[View this post on daily.dev](https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Structured outputs and few-shot examples: getting reliable data from LLMs","url":"https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw"},"datePublished":"2026-11-28T08:05:43.751Z","dateModified":"2026-11-28T08:06:09.236Z","description":"Strict JSON Schema decoding guarantees valid JSON shape, but not correct classifications. In a 150-call release-note benchmark on gpt-4.1-mini, prompt-only...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/532c11f4acb001b014d3980fc71047ff?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/532c11f4acb001b014d3980fc71047ff?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Flavio Copes","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Flavio Copes","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/1f2dbd275797411bbd37bfdaaf0951a9","url":"https://daily.dev/sources/flaviocopes"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"llm,zod","timeRequired":"PT36M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Flavio Copes","item":"https://daily.dev/sources/flaviocopes"},{"@type":"ListItem","position":3,"name":"Structured outputs and few-shot examples: getting reliable data from LLMs"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw","comment":[{"@type":"Comment","text":"The rationale-first field beating strict schema alone is a good find. Schema guarantees shape, not correctness. Useful note on nullable fields too: empty strings quietly pass validation and break downstream logic.","datePublished":"2026-11-28T11:23:26.644Z","url":"https://daily.dev/posts/QXjxVlicw#c-Hy6v6G2Qu","author":{"@type":"Person","name":"DiyWeb","url":"https://daily.dev/diyweb","image":"https://media.daily.dev/image/upload/s--dgS6jDeN--/f_auto/v1790879420/avatars/avatar_774zDwMaRTNS1fv5OKStX?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/structured-outputs-and-few-shot-examples-getting-reliable-data-from-llms-qxjxvlicw#faq","mainEntity":[{"@type":"Question","name":"Why does my LLM return empty strings for fields missing from the input when using strict JSON Schema?","acceptedAnswer":{"@type":"Answer","text":"When a field is typed as a required string, the grammar forbids null, so the model must invent a value. In a 10-entry test with no issue number, a required string field produced an empty string on 10 of 10 entries. Declaring it nullable (type [\"string\",\"null\"]) returned null on all 10. Developers shipping LLM extraction pipelines track failure modes like this on daily.dev."}},{"@type":"Question","name":"Does adding few-shot examples to a structured output prompt make requests slower?","acceptedAnswer":{"@type":"Answer","text":"Not necessarily. In a 30-entry release-note benchmark on gpt-4.1-mini, adding four boundary few-shot examples raised input tokens from 255 to 460 but cut average output tokens from 60 to 38 (37% fewer). Median latency fell from 938ms to 827ms, with accuracy unchanged at 30/30, because the examples also calibrated rationale length. If you're tuning prompt cost and latency, daily.dev covers practical LLM benchmarks."}},{"@type":"Question","name":"Why does field order in a JSON Schema matter for LLM structured outputs?","acceptedAnswer":{"@type":"Answer","text":"Models generate JSON left to right, so schema key order becomes thinking order. Placing a short rationale before the category lets the model state relevant facts first. In a release-note benchmark, verdict-first with no rationale scored 86.7% exact match (26/30), while rationale-first reached 100% (30/30). Anyone designing schemas for LLM classifiers will find daily.dev useful for staying sharp on this."}}]}
```

