TRIKHYA INTELLIGENCE FOUNDRY
Contact us
INSIGHTS · ENGINEERING · 9 MIN

Getting correct answers from messy business data 

Most wrong answers from a natural-language query system are not wrong SQL. They are a word that means two things in two departments.

27 September 2026 · TRIKHYA INTELLIGENCE FOUNDRY

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

01One glossary, rendered everywhereBusiness definitions live in a single governed registry. Every prompt that needs them, generator and validator alike, renders from the same source. A definition changes in one place or it does not change.
02A join registry, not a schema dumpTables may only be joined along hand-written, validated paths. The model chooses among approved joins. It does not discover them.
03A verified example bankCurated question-and-query pairs, retrieved per question, go into the prompt. They teach the model the house style of a correct answer better than any rule.
04Annotated columnsThe handful of columns that keep getting confused carry a plain-English note on grain, units and what not to do with them.
05A validator that reads the same bookThe second model judges query and result against the question using the same definitions as the first. Its feedback goes back into generation verbatim.

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.

“We did not have a SQL problem. We had a definitions problem and a rulebook problem.”

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.

Keep reading.

All insights →
03SHIFT 2
FIELD NOTES · 5 MINWhat we learned taking AI from pilot to daily useA pilot proves the model can answer. Daily use proves the data arrives, the alert lands, and the answer comes in the language of the shift.
01H·AI·H
ESSAY · 6 MINWhy human-AI-human beats fully autonomous AI in operationsThe systems that survive contact with a factory floor are the ones that know when to ask, when to stop, and how to show their working.
0401
GUIDE · 7 MINChoosing the first AI use case worth fundingPick the question people already ask every day, where the data already exists, and where a wrong answer is visible. Then measure it.