Figures

Figures FIG. 01

plumb won't write a number it can't find

Why every number in a plumb answer is checked against the rows the query returned, and why "the data can't answer that" is a real answer.

· 2 min read · plumb, LLMs, data

Ask a spreadsheet a question in English and a language model will happily answer. The trouble is that the answer reads just as well whether or not the number in it is real. A total off by a few rows, a percentage worked out from the wrong column, a figure the model filled in on its own: in a tidy sentence they all look the same.

So when I built plumb, I set one rule before anything else. plumb never writes a number it can't find in the data.

Where the numbers come from

Every sheet you load becomes a table in one DuckDB database. When you ask a question, the model does not answer it directly. It writes SQL, and that SQL is the only way a number gets into the answer.

Before the SQL runs, a guard parses it with sqlglot and checks it against the schema. A query that does not fit the tables you actually loaded never touches the data.

The check after the answer

The query runs and the rows come back. Then the model writes the answer in plain English, and this is the step I trust least, because this is where a model rounds, adds things up in its head, or fills a gap.

So the written answer goes through one more check. Every number in the text is looked up in the rows that came back. If a number isn't there, the text is replaced. You never see a sentence with a figure the query did not produce.

It is a blunt check, and that is the point. It does not try to judge whether the prose is good. It asks one question anyone can verify: is this number in the result?

"The data can't answer that" is an answer

Not every question should become a query. A planner sends each one down one of five routes: answer it, ask back what an unclear term means, say what the data is missing, just chat, or build a dashboard of several panels.

The two quiet routes matter as much as the loud one. If the sheet has revenue but no costs and you ask for profit, the honest reply is that the columns can't answer it, not a number that sounds right.

Show the work

The SQL is shown under every answer. Charts come back as Vega-Lite and pass their own guard. If you doubt an answer, you can read exactly what ran and check it yourself.

That is the idea behind most of what I build: a system that does the work should also show it. A number you can trace back to the rows is worth more than a fluent paragraph you have to take on trust.

You can try plumb at plumb.iamabhinay.com. The source is on GitHub.

Questions about FIG. 01

What does plumb do?

It answers questions about a spreadsheet in plain English by writing SQL, running it on DuckDB, and showing the query under every answer.

How does plumb stop made-up numbers?

After the query runs, every number in the written answer is looked up in the rows that came back. If a number is not there, the text is replaced.

What happens when the data cannot answer?

A planner sends each question one of five ways: answer, ask what an unclear term means, say what is missing, chat, or build a dashboard. If the columns cannot answer, plumb says so.

How is the SQL kept safe?

Before any SQL runs, a guard parses it with sqlglot and checks it against the schema of the sheets you loaded.

Can I try plumb?

Yes, at plumb.iamabhinay.com. The source is on GitHub at github.com/abhinay-hat/plumb.