Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
103 changes: 103 additions & 0 deletions bench/accuracy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Spider2 and BIRD execution accuracy

This experiment measures the real `ContextConcierge → agent_loop → ExplorerPort`
path. It is **not** a Codex MCP end-to-end measurement, Oracle dialect score,
long-term-memory evaluation, or proof of the semantic layer's causal benefit.
Each case starts with an isolated memory/store. There is no answer-key retrieval,
model fallback, multi-sample oracle selection, or user simulator.

## Protocol fixed before inference

- Spider **2.0-Lite SQLite**, all 135 local tasks, upstream
`cafb867313aab4e674652054198f383cf4018943`. This is not Spider 1.0 or the full
Spider2 cloud-database benchmark. The official execution-result grader is reused.
- BIRD **Mini-Dev SQLite 500**, annotations at
`5b256b5a9c17478f06ed6912612e9a14d17065c8` (2026-10-25 corrections).
This is not BIRD's hidden test set or its full development set.
- Fixed seed 20261126: 20 development questions per benchmark, then 115/480
evaluation questions. Selection is before inference and is not based on
difficulty or success. These are question-level splits, not unseen-database
splits; public data may also have appeared in foundation-model training.
- Development examples may guide general changes and model selection. Evaluation
examples must not be used for tuning. Never add their gold SQL to any model
input. Report development and evaluation separately, including every attempt.
- Pass@1: one agent trajectory per question, up to 16 model calls including
auxiliary tools, 8192 output tokens/call, high reasoning effort, 180 seconds
per API call, 900 seconds/agent loop, 30 seconds/SQL, 100,000 result rows. Final runs allow one logged retry for timeout/connection/rate-limit failures
using identical input; retries count toward the 16-call budget. Successful
responses and SQL mistakes are never retried for answer selection. No excluded failed predictions or last-tool fallback.
- SQL queries execute in read-only SQLite connections with a query deadline.
A final answer must contain one SELECT/WITH SQL block. Clarification and missing
final SQL count as incorrect on these noninteractive benchmarks.
- Preserve question/DB/grader/gold hashes, product revision, runner/provider
hashes, generated SQL, full transcripts, API usage, errors and elapsed time.
Raw databases, credentials and provider error messages are never committed.
- BIRD inference manifest is an explicit allowlist of question/evidence fields;
`SQL` is rejected. Gold is loaded only by `score`. The pinned upstream
`calculate_ex` function is extracted unchanged and applied to SQLite row tuples:
set equality, including its official disregard for row order and duplicates.
No CSV string conversion or custom rounding is used for BIRD scoring.
- A broken gold/database pairing fails scoring. A missing record prevents final
publication. A failed model/SQL prediction remains in the planned denominator.

## Data provenance and attribution

BIRD DBs were extracted without running the image's entrypoint from
`3036197201/bird-mini-dev-sqlite@sha256:f5e2746e284fdf4bc5d7a168a42d951bdf3d429d6db91b9928308e8261d0b75e`,
path `/bird/mini_dev/dev_databases`. All 11 DB SHA prefixes match the current
per-database Harbor tags. The California DB was also extracted from the current
Harbor image and its full hash matched. All 500 reference SQL queries executed
and returned nonempty results; this is a dataset health check, not model accuracy.

- [Spider2](https://github.com/xlang-ai/Spider2)
- [BIRD annotations and dataset card](https://huggingface.co/datasets/birdsql/bird_mini_dev/tree/5b256b5a9c17478f06ed6912612e9a14d17065c8)
- [BIRD official EX comparator](https://github.com/bird-bench/mini_dev/blob/1c49a375e76c471e218564da3f4617513d33e371/evaluation/evaluation_ex.py)

BIRD annotations and the derived `bird-manifest.json` retain the source dataset's
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) license and attribution to the BIRD authors (Li et al., NeurIPS 2024,
*Can LLM Already Serve as A Database Interface? A BIG Bench for Large-Scale
Database Grounded Text-to-SQLs*). The manifest removes gold SQL, renames fields,
and adds fixed development/evaluation IDs. The official comparator source stays
external and is verified by hash. The Spider runner/provider were reused from
Lang2SQL's existing benchmark commit `24cff8cb1126fc017d1c68389b76213858e3a2e6`.

The Spider2 upstream MIT notice is retained in `SPIDER2-LICENSE.txt`.

The reused Spider manifest retains a historical `baseline_commit` field. Current
product identity is `settings.json.product_commit` / `frozen-final.json`, not that
legacy data-manifest annotation. The executed runner revision is `0260422`.
After measurement, unused legacy CLI entrypoints were removed; retained primitive
ASTs and the SQL instruction are identical (see `results/primitives-equivalence.json`).
As-executed bytes are retained in `results/source-final/`.

## Reproduce

Install `uv sync --extra benchmark`. Set a credential file with the key name in
`models.json`; never commit that file. Set the paths below to your local copies.
Run from the repository root. Use a fresh output directory for every attempt.

```sh
export PYTHONPATH=src:.
export LITELLM_LOCAL_MODEL_COST_MAP=True
# SPIDER, SPIDER_DB, BIRD_DB, QUESTIONS, EVALUATOR, CREDENTIALS, RUN are local paths.
uv run python -m bench.accuracy.evaluate run \
--root "$SPIDER" --db-dir "$SPIDER_DB" \
--manifest bench/accuracy/spider2-manifest.json \
--profiles bench/accuracy/models.json --env-file "$CREDENTIALS" \
--product-commit 4e1b48a --split development --output "$RUN"
uv run python -m bench.accuracy.evaluate score \
--root "$SPIDER" --db-dir "$SPIDER_DB" --output "$RUN"

# BIRD uses the same run command with its manifest and DB directory; score:
uv run python -m bench.accuracy.evaluate score --db-dir "$BIRD_DB" \
--questions "$QUESTIONS" --evaluator "$EVALUATOR" --output "$RUN"
```

Each benchmark uses concurrency 4. Spider and BIRD final runs overlap in wall
time (up to 8 requests total); latency is not reported as a model-speed benchmark.

Change `--split` to `holdout` only after selecting and freezing the final
configuration. Changing the model, prompt, budget or source creates a new
experiment; historical scores under different configurations are not paired
improvement measurements. `--split all` is for a new explicitly reported full
public-dev run, not a way to hide development-set selection.
98 changes: 98 additions & 0 deletions bench/accuracy/RESULTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Spider2 / BIRD accuracy — 2026-11-26

**99% was not reached.** These are measured execution-result accuracies, not a
claim that arbitrary business questions can be answered with 99% reliability.

## Primary: questions withheld from this development process

| Benchmark | Correct / total | EX | 95% Wilson interval | Failed predictions | API error attempts |
|---|---:|---:|---:|---:|---:|
| Spider 2.0-Lite SQLite | 71/115 | 61.74% | 52.61–70.11% | 11 | 0 |
| BIRD Mini-Dev SQLite | 416/480 | 86.67% | 83.33–89.42% | 4 | 0 |

The model/configuration was selected before scoring these 115/480 questions.
No fixes were made from their answers or scores. The Wilson intervals assume
independent Bernoulli questions; they do not establish production/Oracle accuracy
or eliminate public-benchmark training contamination. This is a question-level
split, not a previously unseen-database split.

## Full public SQLite subsets (include the 20 development questions)

| Benchmark | Correct / total | EX | 95% Wilson interval | Failed predictions | API error attempts |
|---|---:|---:|---:|---:|---:|
| Spider 2.0-Lite SQLite | 81/135 | 60.00% | 51.57–67.88% | 12 | 0 |
| BIRD Mini-Dev SQLite | 434/500 | 86.80% | 83.55–89.49% | 4 | 0 |

All 135/500 planned questions have exactly one final-config trajectory. The full
results combine the disjoint development/evaluation partitions; no best answer
was selected from the development trials. Full-subset figures include questions
used to guide prompt/model selection and must not be described as held-out test
scores. They are not official leaderboard submissions.

## What ran

- GPT-6.2 Sol (`openai/gpt-6.2-sol`, returned model ID `gpt-6.2-sol`), high reasoning,
8,192 output tokens/call. Actual `ContextConcierge → agent_loop → ExplorerPort`.
- Up to 16 API attempts including auxiliary tools and transport retries per
trajectory, API timeout 180s, agent-loop timeout 900s, each SQL timeout 30s,
result limit 100,000 rows. Final SQL export is outside the agent-loop timer.
- At most one logged retry for timeout/connection/rate-limit failure, identical
input, counted in the budget. Successful answers/SQL mistakes are not retried
for selection. Concurrency 4 per benchmark; benchmark runs overlap.
- Product source `4e1b48a`, runner/provider hashes in each settings file and
[frozen configuration](frozen-final.json). Runtime versions in
[runtime.json](results/runtime.json). Every question has isolated memory.
- Official Spider2 execution-result evaluator and unmodified, hash-pinned BIRD
`calculate_ex`. Clarification, API/SQL failure and missing final SQL remain
incorrect in the denominator. Missing records would block publication.
- [Protocol and dataset versions](README.md). Spider 2.0-Lite SQLite is not
Spider 1.0 or the full Spider2 cloud benchmark; BIRD Mini-Dev 500 is not the
full BIRD dev/hidden test set.

## Development record (all trials retained)

| Run | Model profile | Correct / total | EX |
|---|---|---:|---:|
| spider-development-v1 | gpt62-sol | 12/20 | 60.00% |
| bird-development-v1 | gpt62-sol | 17/20 | 85.00% |
| spider-development-v2 | gpt62-sol | 8/20 | 40.00% |
| bird-development-v2 | gpt62-sol | 18/20 | 90.00% |
| spider-development-astra | gpt62-astra | 8/20 | 40.00% |
| bird-development-astra | gpt62-astra | 15/20 | 75.00% |

The initial run used product `e7f0b064`. The treatment added general output-grain,
projection, join direction, filtering and numeric-type checks to the system
prompt. The second development phase suffered API timeouts; those failures were
not removed or replaced. It motivated logged transport retry support and the
final per-benchmark concurrency setting. The development results do not establish
a consistent accuracy gain from the prompt changes. No causal memory/semantic
layer benefit is claimed, and historical GPT-4.1 scores under other budgets are
not treated as a matched before/after comparison.

The held-out Spider evaluation had 11 failed predictions, including 8 trajectories
that invoked `ask_user`. The clarification safeguard was kept; these are still
incorrect under the noninteractive benchmark metric.

## Evidence and limits

[Machine-readable final report](results/final-report.json), per-run manifests,
settings, official scores, final SQL and compact records are in `results/`.
Full local transcripts/CSVs are retained and their SHA-256 hashes are published.
The ordinary harness file-ingestion tool remains present; this is input separation,
not OS-level sandboxing. Actual file-tool attempts were audited and no successful
filesystem reads occurred; `OKF_BUNDLE_DIR` was absent. See `results/file-input-audit.json`.
Source snapshots preserve initial and final as-executed bytes. After measurement,
unused copied legacy CLI entrypoints were removed; all retained execution/grading
function ASTs and the final SQL instruction are unchanged (see
`results/primitives-equivalence.json`). Executed runner revision: `0260422`. The public data
license/attribution is retained; DB files and credentials are not committed.

This measures the Lang2SQL harness on SQLite. It does **not** measure the Codex
MCP client, Oracle SQL dialect, multi-user authorization, memory retention, or
the improvement from supplying company-specific definitions. The Oracle demo
remains separate evidence for its concrete scenario.

Locked-environment tests: 222 passed, 1 optional integration skipped. Benchmark
Ruff, diff whitespace and credential-pattern checks passed. See
[implementation verification](VERIFICATION.md). PR:
https://github.com/CausalInferenceLab/Lang2SQL/pull/320
21 changes: 21 additions & 0 deletions bench/accuracy/SPIDER2-LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 bird_sql

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 31 additions & 0 deletions bench/accuracy/VERIFICATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Implementation verification

Reused `bench.spider2.evaluate` (read-only connections, final SQL extraction,
CSV export, atomic records and official Spider grader), `MeasuredLLM` (existing
Lang2SQL message/tool codecs), and the real `ContextConcierge` / `agent_loop`.
Python source delta before evidence snapshots: +882 lines, of which 418 are
adapted existing runner/provider code, 307 are runner integration/product prompt,
and 157 are integrity tests. JSON manifests and archived source snapshots are
provenance artifacts, not new product logic.

| Principle | Result | Evidence |
|---|---|---|
| Reuse first | O | Existing Spider execution and grading path reused; BIRD adds input adapter and pinned official comparator. |
| Fix evidenced causes | O | Development outputs showed extra projection/filter/type errors; only six prompt lines changed. Logged API timeouts motivated bounded transport retries. |
| Logging | O | Case-specific transcripts, SQL, state, API attempts, error classes, usage and time persist; raw record/CSV hashes accompany published summaries. |
| Error handling | O | Recoverable transport errors log warning; exhausted/nontransport errors raise into a recorded failed case. Failed cases remain in denominator. Provider messages are intentionally redacted to avoid credential leakage. |
| Configuration injection | O | Credential file read at CLI input boundary; key/profile injected into provider. No new production env variables. |
| No issue IDs in code comments | O | New code comments describe constraints, not ticket numbers. |
| Real exit codes | O | Locked environment: 222 passed, 1 skipped. Benchmark Ruff and diff whitespace checks pass. Existing system_prompt BLE001 is outside changed prompt text and explicitly excluded for that file. No CODE MAP script exists in this checkout. |
| Authorization | O | Implementation, tests and PR within user request; no merge or issue creation. |
| Explain request path | O | README identifies actual harness path and explicitly distinguishes it from Codex MCP, Oracle dialect and memory-effect claims. |
| One async logic path | O | One provider call/retry implementation; API calls and retry delay async; existing DB adapter uses worker threads. BIRD scoring is a standalone synchronous CLI. |
| Tunable values | O | Limits use CLI/profile configuration; exact settings frozen and archived. No deployment/env changes required for benchmark-only configuration. |

The integrity tests exercise fixed/disjoint splits, gold-field rejection,
read-only SQL, row budgets, official comparator hash/semantics, failed cases in
the denominator, missing-record failure, and logged/bounded transport retries.
The skipped test requires an optional external integration; no fake model output
is included in benchmark accuracy.

After measurement, unused copied legacy CLI entrypoints were removed. All eight retained execution/grading function ASTs and the final SQL instruction are unchanged; see `results/primitives-equivalence.json`. As-executed source bytes are archived under `results/source-final/`.
Loading