Naveed Ali
‹ All work

Agents · RAG · enterprise data

Asking a database a question in plain English

A capital-markets platform held its data across a very large number of tables: trades, orders, buyers and sellers, symbols and markets, indexes, clients, brokers, users. Getting an answer out of it meant knowing the schema or waiting for someone who did. I built the layer that lets people ask in plain English and get the data back. It understands what a question means in this business and which tables hold the answer.

Role
AI/ML Software Engineer, natural-language and retrieval layer
Period
Oct 2025 to Jun 2026
Team
Large team
Validatedbefore any query runs
DOCX, CSVexport formats

This work was done for a client under confidentiality. Client names and internal tooling are not shown.

The problem

Natural language and a trading database don't share a vocabulary. People ask about the best market, a client's repo positions or one broker's orders; the data lives under system naming conventions spread across many tables, with the same concept, such as a symbol, a client or a broker, appearing in dozens of them. A model that sees only the schema guesses at that mapping, and a wrong join returns an answer that looks right.

A confident wrong answer costs more than a null, so nothing runs until it has been checked.

Constraints

Domain language firstTerms have to mean what the business means by them.
ScaleFar too many tables for a prompt, so the right ones have to be found.
Checked before useAn answer is verified before anyone acts on it.
Usable outputResults export to DOCX and CSV, and the service deploys internally as a Dockerised pipeline.

Architecture

Intentwhat is asked
Plannerwhat data it needs
Retrievalterms to tables
Executionfetch the data
Verifiercheck, then export
A question moves through a chain of specialised agents. Each has a narrow job and a checkable output. Hover a stage to trace it.

Teach the system the business's vocabulary

Context
Schema names alone don't tell a model what a trader means by a term, or which of many similar tables holds the answer.
Decision
Retrieval across internal domain knowledge maps business terms to the right tables and fields before any query is formed.
Trade-off
The knowledge base becomes part of the system and has to be maintained as the data estate changes.

Engineering decisions

Benchmark models before committing to one

Decision
Several open-weight model families measured against closed APIs on this workload.
Trade-off
Time spent up front, in exchange for a model choice backed by measurements.

Separate agents with one narrow job each

Decision
Intent, planning, retrieval, execution and verification each have a narrow job and a checkable output.
Trade-off
More moving parts to orchestrate, but each failure is visible at the step where it happens.

What broke

Three problems showed up repeatedly.

  • The wrong table. Many tables look alike, and the retrieval step sometimes picked a neighbour of the one that held the answer.
  • Orders and trades. The two sound close in everyday speech and mean different things in the data. A question about one could be answered from the other.
  • Expensive queries. Some generated queries took the costly route and scanned very long tables.

Each of these surfaced at a particular step, which is the reason the steps are separate.

Where it landed

Shipped as a Dockerised pipeline for internal use: a plain-English question in, the relevant data out, verified, and exportable as DOCX or CSV.

The specifics stay with the client. Happy to talk through the approach in more depth.

What I'd do differently

I would follow what is now standard industry practice for retrieval-augmented systems. The field has settled on better patterns since this was built, and I would start from those.

References

Have a project in mind? Let’s talk.

Open to contract and full-time work. Based in Lahore, working with teams in the UK, EU and US.