ResearchPublication
Just ask: data insights for everyone
Earlier work, a post of September 2024 on toqan’s Data Analyst, which answers questions about a company’s data in plain language by writing SQL, and on the context and the questions back that it needed to work on real databases.

Where this comes from
This is a post on the Prosus AI Tech Blog, published on 6 September 2024 and written by Donne Stevenson, Floris Fok and Sean Kenny, as its first line names them. It is about toqan’s Data Analyst, which the team built with operational analysts at iFood, Glovo, OLX and other companies in the Prosus portfolio, and it is listed here as earlier work. What follows is from the post.
What the post asks
Every day, people at companies in food delivery, retail and payments ask analysts about their data, such as how late-night food orders compare between cities. Quick and accurate answers help people do their work, and good analysts are often costly and scarce, with the most critical tasks to see to. The team set out to see how generative AI frameworks and tools could help.
The result is the Data Analyst, a chatbot for databases that toqan’s users reach in Slack. A person types a question in a simple chat and the tool writes the SQL query that answers it, so nobody needs technical skills or to know the database well. The post reports that it had hundreds of active users and answered thousands of questions during its roll-out.
Why a language model alone falls short
The authors began with language models that write SQL. Early benchmarks of the task scored simple cases, with no joins between tables, and language models reach similar levels on them; toqan’s ProLLM leaderboard scores their SQL answers to Stack Overflow questions. Real data brought problems the benchmarks leave out: working out how to join tables, finding the right columns when the metadata is poor, and catching every way a name is spelled.
The authors name two problems. For many business users who query transactional, supply chain or financial data, even a high accuracy is not enough. And the last slice of accuracy seems to depend on the context the system has: who is asking, how the business works and how its data is laid out. A newly hired analyst who knows SQL well struggles at first for the same reason, and picks up that context from colleagues, meetings, and trial and error.
- top accuracy on WikiSQL’s leaderboards, from models before transformers, on simplified cases with no joins between tables
- Near 93%
- acceptance of the SQL answers of the best language models on the ProLLM leaderboard, on Stack Overflow data
- 85 to 90%
- accuracy the team started from, with language models used out of the box on cases of more than two tables
- Below 25%
- accuracy that is still too low for many business users, the post says
- 95%
An agent that asks
So the team widened what the system had to do: make its assumptions plain, guide users and clarify their requests, handle failed answers and know when not to answer at all. That called for the planning and tool use of agents, whose reasoning the team had seen while building toqan. Given access to a database and enough context about it, an agent writes the code that analyzes the data and answers the question.
The post names the first danger in a heading, “Helpfulness is the enemy of accuracy”. Asked for a user’s address, which it could not see, an agent offered the driver’s coordinates during the delivery, where the best answer was that it had no access to addresses. Two tools in the agent guard against this. One asks clarifying questions when a request is ambiguous, which also teaches people to ask better questions. The other states the assumptions behind an answer, such as how it defined a month, so that a user can see a shortcut and correct it or accept it.
The hidden context
What a question leaves unsaid falls into four groups of knowledge.
- Global knowledge: how the organization is built, its business and its partners, and what kind of system the database is.
- Product knowledge: the KPI or the product insight each table is there to serve.
- Table and column knowledge: whether a table changes slowly or fast, whether it is partitioned, and whether its dates are in a special format.
- Request language knowledge: a team’s jargon and acronyms.
Retrieval by embeddings matches subjects and topics, so the team did not see it as a good fit: the agent should see the rules without having to know that it needs them. It built three mechanisms that improve each request.
Business rules
The global knowledge and much of the product knowledge, always in the system prompt with the agent’s other guidelines. The simplest mechanism and, the post says, the most powerful.
Glossary
Terms, acronyms and short phrases with their definitions, added to a request when it uses them.
Table selection
A second system picks the tables a request might need, then the columns it needs from them, then drops what is duplicated or redundant, so detailed descriptions and instructions reach only the requests they are for.
Testing, and what comes next
A test case is a question and the query known to answer it, run first to fetch the latest data. The agent is asked the question several times in slightly different words, and a prompted model compares its answers for accuracy, how close they are to the expected one, and consistency, how alike they are across the wordings. The scores show the team where to improve.
Next, the team was looking at turning SQL that worked or was upvoted into snippets for similar requests, at having the agent restate a question so that it is not ambiguous before it runs, and at a supervising agent that checks each query.
The post
Just Ask: Data Insights for EveryoneDonne Stevenson, Floris Fok, Sean Kenny. Prosus AI Tech Blog, 2024Authors
Donne Stevenson
Floris Fok
Sean Kenny
References
- Just Ask: Data Insights for EveryoneDonne Stevenson, Floris Fok, Sean Kenny. Prosus AI Tech Blog, Medium, 6 September 2024
- Just Ask: Data Insights for EveryoneDonne Stevenson, Floris Fok, Sean Kenny. Prosus AI Tech Blog, Medium, 10 September 2024: the same post, published again