Problem
A solo developer shipped Taralli, a calorie-tracking app, with a zero-shot prompt: the user's food description goes to gpt-4o-mini, which returns JSON through structured outputs. The format was almost always valid, but the numbers were not: the model often misread "quantity", so per-unit calories were multiplied by the wrong factor. Nobody knew how bad it was: there was no measurement, only mostly positive user feedback.
Example from the article: "100g of peanut butter" came back as quantity 100 with 588 kcal per unit, which gives 58,800 kcal. The correct answer sets the name to "100g of peanut butter" and the quantity to 1.
Solution in brief
Log every production call, correct the logged inputs into a golden dataset, and define a pass/fail metric in code. Score the current prompt (17%), then let DSPy pick few-shot examples from the training split. This lifted accuracy to 76% on a cheaper, faster model. New corrected examples feed the next round.
Questions this case answers
- How to measure and improve the accuracy of an LLM feature that returns structured numeric output when no ground truth exists yet
- How to turn production logs of an LLM feature into a labeled evaluation set and a repeatable improvement loop
- How to find out how accurate an LLM-powered product feature really is?
- How to build a golden dataset from real user inputs for an LLM feature?
Tools and methods
- W&B Weave — a decorator that logs each input and output of the LLM call
- Golden dataset — real user inputs with corrected structured answers
- Pass/fail metric — total calories within 10% and at least one food group in common
- DSPy — evaluation harness and
BootstrapFewShotWithRandomSearchoptimizer - Gemini 2.5 Flash — the cheaper model that carries the optimized prompt
- Pydantic, FastAPI — output schema and the serving endpoint
Google or a one-time email code. No password.