# LLMs double count in text-to-SQL, and so does some of BIRD's gold

A single-author preprint shows how SQL joins silently inflate totals, finds the error in a slice of the BIRD benchmark's answer key, and shows that telling LLM agents what each number is recorded per cuts such errors by about a quarter.

- Category: Code
- Readiness level: III (Open source) on Science Underway's four-step scale, as proposed
- Published: 2026-11-24
- Editor: Stefan Perdal
- URL: https://scienceunderway.com/articles/llms-double-count-in-text-to-sql-and-so-does-some-of-bird-s-gold

## The study

Mind the Trap As LLMs Guess the Data Model: Grain-Aware Guards Against Fan-out in Text-to-SQL and Its Benchmarks (preprint, not peer reviewed). arXiv 2611.29009. https://arxiv.org/abs/2611.29009

## At a glance

- What it shows: When an AI assistant turns a question into a database query, it often adds up the same figure more than once, and the answer still looks plausible. Giving the AI simple facts about how often each record repeats cut these errors from about 18% of attempts to about 13% on a widely used test.
- What it does not show: It does not show the fix working inside a real company system, and overall accuracy rose only about 3 points. It also does not show how common the problem is in test sets other than BIRD.
- Why it matters: Wrong totals that look right are the hardest errors to catch in AI data assistants. The study also finds that a popular test sometimes marks the wrong total as the correct one.

## What the study shows

Text-to-SQL systems turn a plain question into a database query. The paper studies one classic failure, called fan-out. A join, which combines two tables, can repeat rows. A shipping fee stored once per order then appears once per order line. A SUM or COUNT over those rows counts it twice, but the query runs and returns a believable number.

The author, from the analytics company Incorta, frames this as one condition. A total is right only if each item appears once at its own level of detail, which the paper calls its grain. A schema does not show either the grain or how much a join repeats rows. Both can be measured from the data.

First, the author built an audit that runs probe queries on the data to test whether the rows a total reads repeat. It finds that 4.2% of the answer key on the dev set of BIRD, a common text-to-SQL benchmark, is distorted by fan-out. As an outside check, BIRD's own later cleaned release changed 44% of the answers the audit flagged, against 16% of unflagged ones. That revision was made without the audit.

Second, eight LLM agents answered questions while querying the database through a tool, across 38,232 runs. They received different kinds of evidence computed from the data. Plain dependency labels such as "each order can have many lines" helped little beyond basic column counts. Grain-aware evidence, which states each measure's grain and how many times a join repeats each row, cut fan-out errors on BIRD from 18.4% of runs to about 13%. The cut held on 183 questions not used to design the evidence, and without LLM judges doing the scoring.

Third, accuracy rose only about 3 points. The authors report two reasons. Most remaining errors are not fan-out. And BIRD's hints, written for the old answers, often tell the model to use the over-counting formula. The paper is a preprint and has not been peer reviewed.

## Our reading

In our reading, the most useful finding is not the error cut but the diagnosis. The useful fact is not "this join can repeat rows". It is "this fee repeats about 3.5 times per order, so a sum counts it that often". Labels that only warn of repetition did little. Labels that name the measure and the multiplier did most of the work.

A concrete case: a finance assistant asked for total shipping fees per customer segment over an order-line table. Without help, a model sums the fee on every line. With the grain stated, it is told plainly that each fee sits on several rows. That is the kind of silent error that ends up in a board report.

The benchmark finding matters as much. If the answer key over-counts, a model that avoids the trap is scored as wrong. The check against BIRD's independent revision gives the audit some outside support, though a changed answer is not always a fan-out fix.

The rest of the article (what it means, limits, what to watch) is free for members: https://scienceunderway.com/articles/llms-double-count-in-text-to-sql-and-so-does-some-of-bird-s-gold

## How this was made

An AI model read the study and wrote this article in the structure Science Underway uses. An editor reviewed it and approved it for publication. Check the original study before you rely on the details.

---
Source: Science Underway, https://scienceunderway.com/. Please link to the article when you cite it.
