Results
On a 48-question benchmark I designed with gold SQL, the agent answered 87.5% correctly, up from 83% without examples. Table retrieval reached 95% top-k with hybrid search. Giving each task a suitable model cut the cost per query about 20× compared with o3, at similar accuracy.
Approximate figures.
The problem
The data referential team needed answers from an internal Oracle financial database without writing SQL, in English, French or Spanish. The evaluation subset alone has 30 core tables; the full database is larger, so the agent first has to find the right tables.
What I did
- Built a LangGraph agent with 7 tools: o4-mini plans the steps, GPT-4.1 writes the SQL and judges answers, GPT-4.1-nano filters context.
- Designed the 48-question benchmark with gold SQL from about 12 starter questions, and scored runs with an LLM judge.
- Built table retrieval with BM25 and ChromaDB embeddings, merged with reciprocal rank fusion, plus a Redis lookup tool for financial product names.
- Added validated question–SQL examples to the model's context, from a set kept separate from the benchmark questions.
- Built the Streamlit interface and part of the FastAPI backend; traced and evaluated runs in LangSmith and validated outputs with Pydantic.
Results
Accuracy rose from 83% to 87.5% on the benchmark, table retrieval reached 95% top-k, and giving each task a suitable model cut the cost per query about 20 times compared with o3, at similar accuracy.
The code and final architecture belong to CFM. The internship report, approved for sharing, has more detail on the method.