When correct isn’t
usable.
Small language models often get the answer right and still return something a program can’t read. We measured that gap on two math benchmarks, then closed most of it without touching the weights, by letting an optimizer watch each model fail and rewrite its system prompt.
When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Models · arXiv:2605.02363
- 0%
- output accuracy without a system prompt, at up to 85% task accuracy
- 84–87%
- output accuracy with AloLab on GSM8K, across three open 7–9B models
- 3.6–8.2×
- the latency of constrained decoding, which still scores lower
- 29 / 30
- runs significantly better than a hand-written prompt
01Right answer, unusable output
A model in production answers to two judges. The first checks whether the answer is right. The second is a parser, and it only checks whether the response has the agreed shape. Fail the parser and the answer never arrives, however good it was. Most benchmarks only ask the first question.
The failure is easiest to see in one example. Asked for JSON, Gemma 2-9B solves the problem, writes a clean object, and then wraps it in a markdown code fence. To a human reader the fence is harmless; to JSON.parse it is a syntax error. Switch the prompt below and the parser runs live in your browser.
You are a math expert. Solve the problem step by step, then give the final numeric answer. Respond with a JSON object with keys “reasoning” (string) and “answer” (number).
```json
{
"reasoning": "Janet uses 3 eggs for breakfast and 4 for muffins, leaving 9 to sell at $2 each: 9 x $2 = $18.",
"answer": 18
}
```JSON.parse, run on the text shown. Under the Reference prompt the answer is right and the response is still unusable, on every one of the 1,319 GSM8K test samples (json_valid = 0%). The Optimizer’s epoch-2 rules took validation output accuracy from 0% to about 80%. The right-hand output in the second view is the paper’s example with the fence removed, for illustration, not a logged response.We call the joint condition output accuracy: the answer is correct and the response is valid JSON with every required field. It is the primary metric throughout this work, and a harder bar than it sounds. §2.2
02A controlled test bed
We use mathematics as an instrument, not as the subject. A math problem has one checkable answer, so a mistake in reasoning can never be confused with a mistake in format. We pair it with a strict contract: a JSON object with a reasoning string and a numeric answer. §1, §2.1
03The 0% baseline
With no system prompt, every model does respectable math: 77–85% task accuracy on GSM8K. Not one returns a single valid JSON response. Output accuracy is zero for every model on both datasets. The bottleneck is not reasoning. It is format. §4.1
That changes what “small models can’t do it” often means. The capability is there. It just doesn’t arrive in a form the rest of the system can use.
04Optimizing the prompt, not the model
AloLab treats the target model as a black box. It sees what goes into the inference API and what comes back, nothing more: no weights, no gradients, no labelled demonstrations. Each epoch it runs the current system prompt on a training split, scores every reply, and hands the traces to a stronger model that diagnoses what went wrong and rewrites the prompt. §2.4

Most of the gain arrives early. On GSM8K, Llama and Gemma converge within two to three epochs. Gemma is the sharpest case: its first epoch scores 0% in all five runs, because the Reference prompt yields fenced JSON. At epoch 2 the optimizer identifies the fence, suppresses it, and output accuracy breaks through in a single step. On the harder MATH set progress is more gradual, and Qwen sometimes takes a wrong turn that later epochs don’t undo. §4.4

05Five strategies, compared
On GSM8K, AloLab has the highest output accuracy for every model, between 84% and 87%. The hand-written Reference prompt is erratic: 74.3% for Qwen, 44.4% for Llama, and 0% for Gemma, whose fenced replies never parse even though the answers inside are right 88.4% of the time. On MATH the gap widens. Reference is near zero for two of three models, and AloLab is the only strategy that reliably clears 30%. §4.2
- Reference: Gemma wraps every JSON response in markdown fences, so nothing parses. The fallback parser recovers 88.4% task accuracy.
- Constrained: 52.4% of outputs are exact duplicates.
- Generalization probe, GSM8K only. Constrained strategies were not run.
- Reference: the same markdown-fence wrapping as Gemma. The fallback parser recovers 95.7% task accuracy.
GPT-4o shows this is not only a small-model problem. Under the Reference prompt it, too, wraps its JSON in markdown fences and scores 0%. AloLab finds the same fix and reaches 95.22%, with a standard deviation of 0.55 points across five runs. §4.7
06The price of constraints
Constrained decoding attacks the problem from the other side. It restricts generation to a grammar, so the output is valid JSON by construction. The guarantee is real, and so is the bill: on GSM8K the constrained strategies run 3.6–8.2× slower than Naive, on every call, and still score below AloLab. They can also damage the content. Under Constrained decoding, 52.4% of Gemma’s outputs were exact duplicates. §4.2, §4.3
AloLab pays once, at optimization time. What ships is a prompt that runs at near-Naive latency, and on MATH slightly faster, since the optimized prompts are shorter. Plotted together, the trade-off has a clear frontier. §4.3

07What the optimizer changed
AloLab does not apply a standard fix. It reads what a particular model gets wrong and writes the instruction that model needs. Two trajectories from the appendix show how different those instructions can be. Appendix A
Under the Reference prompt, every reply arrives fenced. At epoch 2 the optimizer adds explicit rules against markdown and code blocks, and validation output accuracy jumps from 0% to about 80%. Nobody writing a prompt from scratch would think to forbid the fence without first watching this model use it.
The Reference prompt asks for answers in LaTeX. Inside a JSON string every LaTeX backslash must be escaped, and the model often doesn’t.
You are a math expert. Solve the problem step by step, then give the final answer.
Respond with a JSON object with keys “reasoning” (string) and “answer” (string).
Your final answer must be a mathematical expression. Use LaTeX notation if needed
(e.g. \frac{1}{2}, \sqrt{3}).Rather than ask for more careful escaping, the optimizer removes LaTeX from the answer altogether:
ANSWER FORMAT RULES: – For fractions: use “a/b” format (e.g. “3/4”) – For square roots: use “sqrt(n)” format (e.g. “sqrt(5)”) – For expressions: use plain text algebra (e.g. “x^2 + 2x + 1”)
Two checks confirm where the gains come from. Hiding the model’s identity (name, family, size, quantization) from the optimizer changes mean output accuracy by only −0.7 points, with no significant effect: the signal is in the traces, not in knowing which model produced them. And the fixes track observed behaviour. Nothing about GSM8K predicts that a model will fence its JSON; you have to see it happen. §5
08The optimizer’s own model matters
The loop is only as good as the model reading the traces. Swap Claude Sonnet 4.5 for the much smaller Claude 3 Haiku, keep everything else fixed, and mean output accuracy for Llama on GSM8K falls from 84.15% to 61.0%. The spread between runs grows from under one point to 21.8. §4.8
The drop is bimodal, not uniform. Two Haiku runs find an effective prompt and match Sonnet; three fail or collapse. The loop works in principle. A weaker meta-agent just can’t find the fix reliably.

09How reliable the gains are
Every AloLab number is the mean of five independent runs, reported with a bootstrap confidence interval. We also tested each run against the Reference prompt on matched samples: 29 of 30 comparisons are significant at p < 0.05. §4.6
Qwen is the least stable model. On MATH its interval spans 20.8–47.7%, because in two of five runs it settles on double-escaped LaTeX that the parser doesn’t recognise. Qwen produces that pattern under any prompt that allows LaTeX, Reference included; AloLab removes it in three runs out of five. §6
10Where it falls short
Output accuracy falls as problems get harder, and it falls the same way for all three models. That points to the difficulty of the task, not to a quirk of any one model. §4.5
One failure survives optimization. Sometimes the JSON is valid and the reasoning field works toward the right answer, but the answer field holds a different value. A regex scan puts an upper bound of 15–21% on this among AloLab’s failures but over-counts; an independent LLM judge (Gemini 3 Flash) puts the true rate at 1.5–1.8%. It stands out under AloLab only because the simpler format errors are gone. §5
- The optimizer needs a capable model. Reliable results depend on the meta-agent, and optimization is a one-time setup cost.
- Both benchmarks are mathematical. Other tasks and other schemas are the next test.
- MATH ran with a fixed 8,192-token context, which may cap what the models could reach.
- Some ablations are narrow. The history-only and meta-agent ablations, and the GPT-4o probe, cover GSM8K only.
Under strict output contracts, the practical limits of small models are often not limits of reasoning. They are limits of structured communication, and that is the gap iterative, black-box prompt optimization is built to close. §7
—Citation
This page retells the paper for a wider audience. The paper on arXiv is the reference for every method detail, number and caveat.
Galeone, C., Park, M., Ettorre, G., & Ligorio, D. (2026). When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Models. arXiv:2605.02363.
@misc{galeone2026when,
title = {When Correct Isn't Usable: Improving Structured Output Reliability in Small Language Models},
author = {Galeone, Cosimo and Park, Minsu and Ettorre, Giuseppe and Ligorio, Daniele},
year = {2026},
eprint = {2605.02363},
archivePrefix = {arXiv},
primaryClass = {cs.CL},
url = {https://arxiv.org/abs/2605.02363}
}Photographs from Unsplash. Figures marked with a figure number are reproduced from the paper.