A cheap trick for reliable structured output: feed the validation error back into the retry
Summary
A practical technique for improving structured output generation from LLMs by feeding validation errors back into retry prompts, allowing the model to self-correct rather than blindly retrying. The method involves describing the error in model-friendly terms and providing the previous output for editing.
Similar Articles
Structured output reliability with LLMs — 3-month production learnings
The article shares production learnings for reliably generating structured JSON output from LLMs, covering methods like JSON mode, schema validation, and retry loops, achieving 99.5% validity.
When LLM Reward Design Fails: Diagnostic-Driven Refinement for Sparse Structured RL
This paper frames LLM-generated reward shaping for sparse structured RL as a debugging problem, identifying failure modes like reward flooding and semantic misunderstanding. The authors propose diagnostic-driven iterative refinement, achieving dramatic success rate improvements (e.g., DoorKey-8×8 from 2.3% to 97.6%) compared to one-shot generation.
Why Self-Correction Loops Can Degrade Reliability in LLM Pipelines (85% Down to 62%)
Adding a self-correction loop to an LLM pipeline for structured data extraction reduced consistency from 85% to 62%, due to compounding noise and regeneration drift. The article discusses potential solutions like granular diff mechanisms or deterministic gates.
@jakevin7: Sharing a god-tier review prompt methodology. The LLM self-correction survey 'When Can LLMs Actually Correct Their Own Mistakes?' concludes that without reliable external feedback such as test results or tool outputs, a model relying only on self-reflection often cannot steadily correct errors...
Shared a prompt methodology based on LLM self-correction research, emphasizing that self-checking is limited without external feedback, and recommending progressively enhanced prompting strategies such as adversarial review.
Pigeonholing: Bad prompts hurt models to collapse and make mistakes
This paper introduces 'pigeonholing,' a phenomenon where bad prompts cause LLMs to collapse and repeat errors, leading to a 38-40% performance drop. Experiments across 10 tasks and 10 models show worsening with more conversation turns, and propose RLVR with synthetic errors as a mitigation.