LocalLLaMA
A cheap trick for reliable structured output: feed the validation error back into the retry
If you generate structured output from an LLM and validate against a schema, you know the failure mode: usually fine, occasionally a missing field or an unparseable response. The common fix is a retry, but a plain retry is the same prompt at the same temperature, so you are just re-rolling. What worked much better for me was making the retry self-correcting: when validation fails, put the validation error and the model's own previous output back into the next prompt and ask it to fix that spec...
Read the full discussion on Reddit
This article was aggregated from Reddit. Click to join the conversation.
View on Reddit