Skip to content

BIRD: floating-point ratios and a joined-columns result check - #34

Merged
Parth-Vasave merged 5 commits into
mainfrom
bird-sql-correctness
Oct 14, 2026
Merged

Parth-Vasave merged 5 commits into
mainfrom
bird-sql-correctness

Conversation

@Parth-Vasave

@Parth-Vasave Parth-Vasave commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Third of six, on top of #33.

  • Floating-point ratios: the validator rewrites CAST(... AS NUMERIC/DECIMAL) without a precision to DOUBLE PRECISION when it only serves a division, and records the rewrite count in the trace. Replayed on earlier answers: Mini-Dev 16 fixed, 1 broken. The prompt rule that asked for this was dropped again, since it also made the model cast AVG (sql-generator/9).
  • Definition-formula rule tried and reverted: eec2715 and its revert a56aee7 are both kept for the record. The rule scored 28/60 vs 33/60 on formula questions.
  • joined_columns result check: an output column that concatenates two or more columns goes back through repair with a hint to return them separately (sql-repair/4). Replayed without an LLM, it fires on the 3 Mini-Dev answers that concatenate and on none of the 491 dev answers.

Testing

Run locally on the top of the stack (readme-bird-results): ruff check, ruff format --check, mypy clean; backend 340 passed, scripts + evaluation 115 passed (database integration tests skipped locally, run in CI); frontend lint and 57 tests pass. CI runs on each PR.

@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai-sql-analyst-agent Ready Ready Preview Oct 14, 2026 5:47am UTC

Base automatically changed from bird-schema-linking to main October 14, 2026 05:46
To avoid integer division the model casts to NUMERIC, and the ratio
then comes back as an arbitrary-precision decimal. BIRD's answers are
floats, and its execution accuracy compares values exactly, so the
same number scored as wrong (26 of the 28 "value format" misses on the
Mini-Dev run).

The validator now rewrites a CAST to NUMERIC/DECIMAL without precision
to DOUBLE PRECISION when it only serves a division, and records how
many it rewrote in the trace. A cast with a chosen precision, or one
outside a division, is left alone. The prompt (sql-generator/8) asks
for DOUBLE PRECISION in such calculations.

Replayed read-only on earlier answers: Mini-Dev 16 fixed, 1 broken;
dev sample 1 fixed, 1 broken. Both broken ones are gold queries that
use a 1.0 literal and so return a decimal themselves.
The rule asked for DOUBLE PRECISION in "ratios, percentages and
averages you divide yourself". On the dev sample the model also cast
AVG(...) results to float (D1210), which then no longer matched an
answer computed with AVG. The validator's rewrite of NUMERIC casts in
divisions does the intended part on its own and never touches AVG; it
is the variant measured on earlier answers (Mini-Dev 16 fixed,
1 broken). Prompt is sql-generator/9.
On the dev runs, answers missed where the model kept its own reading of
the question over the definition given with it: it counted atoms where
the formula divides bonds, filtered subtypes where the definition names
the language, summed ids for SUM(id where ...) and left NULL rows out of
a percentage's denominator. A percentage computed as (a / b) * 100 also
differs in the last digit from a * 100 / b, which exact comparison
counts as a different value.

The rule now says to follow the definition where it and the question
seem to differ, to use the columns and values it names, that
COUNT(condition) and SUM(condition) count rows, and to compute a
percentage as CAST(numerator AS DOUBLE PRECISION) * 100 / denominator
over every row of the group. The examples are invented, not taken from
BIRD. Prompt is sql-generator/10.
This reverts commit eec2715. Measured on dev with Cerebras gpt-oss-120b:
on 60 questions whose hints contain a formula it scored 28/60 against
33/60 before (1 fixed, 6 broken), and 65/100 against 66/100 on the
fixed dev sample.

Three of the broken answers come from the percentage rule itself: an
answer the gold computes in single precision was recomputed in double
precision, the gold for another question computes (a / b) * 100, which
the rule replaced by a * 100 / b, and a plain average was multiplied by
100. The row-count reading of COUNT(condition) also made the model
count rows where the gold counts distinct patients. Prompt is back to
sql-generator/9.
The prompt already asks for each stored column as its own result
column, yet the model still sometimes returns first_name || ' ' ||
last_name as one value. A new result check, joined_columns, reports an
output column that concatenates two or more columns (||, CONCAT,
CONCAT_WS) and sends it back through the repair loop with a hint to
return the columns separately. A single column with a label ('$' ||
price), a concatenation inside an aggregate or a subquery, and a key
built inside a CTE are not reported.

Replayed on every recorded BIRD answer without an LLM, it fires on the
three Mini-Dev test answers that concatenate (all misses) and on none
of the 491 dev answers. Repair prompt is sql-repair/4.
@Parth-Vasave
Parth-Vasave merged commit d0be54d into main Oct 14, 2026
12 checks passed
@Parth-Vasave
Parth-Vasave deleted the bird-sql-correctness branch October 14, 2026 05:48

This branch was successfully deployed

1 active deployment
Preview — 08544fa8 Deployed Oct 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant