When our natural-language query assistant gave a wrong answer, we used to assume the model had written bad SQL. After months of reading traces from a multi-plant manufacturer, we can say that almost never happened. The syntax was fine. The definitions were not.
A failure map, not a benchmark
We keep a fixed set of real questions from the floor and run it on every release. When an answer is wrong we classify why. The classes that dominate have nothing to do with language models:
- A state word defined by a proxy or too narrowly. Open, pending, incoming, completed and current stage each meant something slightly different to the people who used them.
- The right period on the wrong date column. This week against an order date when the user meant a dispatch date.
- Snapshot tables summed over time. A monthly performance snapshot added up across months gives a number that looks real and is not.
- An analytical shape asked for, a data dump produced. The user said trend or what changed; the query returned rows.
- A same-named column on the wrong table. Two tables carried an invoiced quantity at different grains.
Every one of these is a definitions problem. None is a syntax problem. That changed what we built.
The rulebook contradicted itself
The second discovery was more embarrassing. We had written business rules into several prompts over several months. In two places open orders meant one thing and in two others it meant something stricter. The generating model followed one rule, the validating model followed the other, and a correct query was rejected for obeying the rulebook. The retry then learned the opposite rule and failed differently.
Conflicting guidance is now the first thing we look for when accuracy drops. Models are remarkably obedient. If the instructions disagree, the output will too.
What fixed it
The result on the floor is a system that answers correctly end to end 92.4% of the time, and that says it does not know for most of the rest. We publish that number to the client on every release. It moves when the definitions move, far more than when the model does.
If you are starting a project like this, spend the first weeks with the people who answer these questions today. Write down what the words mean. The model will do what you tell it. The hard part is agreeing on what to tell it.
