Skip to main content

group-by-vibes — Text2SQL Evals to Deal With AI Vibes

group-by-vibes

PyPI CI Docs Python 3.10+ License: Apache-2.0 Core dependency: sqlglot only mypy: strict Ruff uv

Text2SQL (NL2SQL) is one of the most relevant agentic tasks in the enterprise, yet general-purpose LLM evaluation libraries rarely address SQL-specific failure modes.

group-by-vibes is a focused, niche Python package built specifically for deterministic Text2SQL evaluation—not a general NLP benchmark suite. It mirrors the Hugging Face evaluate interface (load, add, add_batch, compute) so teams can adopt it with familiar Metric and Measurement semantics, while providing specialized Text2SQL metrics and measurements not covered in evaluate, backed only by sqlglot with zero heavy ML runtime dependencies.

Documentation · Installation · Quickstart · Available Evaluators · Usage Patterns · Reference Benchmark · Contributing · References


Why group-by-vibes?

  • Drop-in evaluate ergonomics: Uses the same load() -> add() / add_batch() -> compute() lifecycle and Metric / Measurement terminology as Hugging Face evaluate, plus stateless compute_* functions.
  • SQL-aware, not string-based: Evaluates parsed SQL ASTs across dialects via sqlglot rather than brittle text matching.
  • Zero database or ML stack required: Ships with sqlglot as the sole runtime dependency (no evaluate, datasets, pyarrow, transformers, or torch), complementing execution accuracy (EX) in offline evals and runtime screening.
  • Built to grow for Text2SQL: Designed as an extensible catalog of reference-based Metrics and reference-free Measurements tailored to enterprise NL2SQL systems.

Installation

Install from PyPI (requires Python >=3.10).

# With uv
uv add group-by-vibes

# Or with pip
pip install group-by-vibes

Core installation pulls only sqlglot>=30.0.0,<31.0.0. For optional benchmark inference utilities under examples/:

uv sync --extra examples

Quickstart

Load evaluators by name using the same pattern as Hugging Face evaluate:

import group_by_vibes as gbv

# 1. Metric (reference-based): compare generated SQL against golden SQL
sql_bleu = gbv.load("sql_bleu", dialect="postgres")
sql_bleu.add(
    prediction="select name, age from users where status = 'active' and role = 'admin'",
    reference=["SELECT name, age FROM users WHERE role = 'admin' AND status = 'active'"],
)
sql_bleu.compute()["bleu"]
# 1.0

# 2. Measurement (reference-free): screen unlabelled SQL without executing it
valid_sql = gbv.load("valid_sql_rate", dialect="sqlite")
valid_sql.add(
    data="SELECT name, age FROM users WHERE active = 1",
    schema={"users": ["id", "name", "age", "active"]},
)
valid_sql.compute()["valid_sql_rate"]
# 1.0

Available Evaluators

Name Type Class Stateless Helper What It Evaluates
load("sql_bleu") Metric SqlBleu compute_sql_bleu, sentence_sql_bleu AST-canonicalized n-gram overlap against reference SQL (Chen et al., 2019); reports bleu, precisions, translation_length, parse_success_rate, and reference_parse_success_rate.
load("component_matching") Metric ComponentMatching compute_component_matching Clause-level exact-set precision, recall, and F1 across 12 SQL components and 5 Spider hardness buckets (Yu et al., 2018, dialect-general sqlglot AST adaptation); defaults to Spider value-blind mode with opt-in strict flags and optional schema/foreign_keys.
load("exact_matching") Metric ExactMatching compute_exact_matching Order-insensitive structural exact-match accuracy across all 12 SQL components plus canonical FROM table/subquery multisets (Yu et al., 2018, dialect-general sqlglot AST adaptation); supports Spider value-blind defaults, opt-in strict flags, and optional schema/foreign_keys.
load("valid_sql_rate") Measurement ValidSqlRate compute_valid_sql_rate Lenient dialect-aware SQL syntax validation (rejecting empty inputs, multi-statement strings, and exp.Command fallbacks) plus optional per-query schema grounding (tables & columns) with 8-key failure_counts.
load("wildcard_detector") Measurement WildcardDetector compute_wildcard_detector Projection wildcard rate (SELECT *, table.*, * EXCEPT/EXCLUDE -> 1), ignoring COUNT(*), EXISTS (SELECT * ...), RETURNING *, and * arithmetic (0).
  • Dialect support: Documentation and examples prioritize PostgreSQL ("postgres") and SQLite ("sqlite"), while all evaluators accept any dialect supported by sqlglot.Dialect.get_or_raise (plus "postgresql", "sqlite3", and generic ANSI "").
  • Scope: Evaluators execute no queries against a live database engine; they complement—rather than replace—execution accuracy (EX).

Usage Patterns

Batch Streaming & Schema Grounding

from group_by_vibes import load

# Quoted identifiers and per-query schemas
valid_sql = load("valid_sql_rate", dialect="sqlite")
valid_sql.add(
    data='SELECT "Singer(s)" FROM "1-29135051-2"',
    schema={"1-29135051-2": ["Singer(s)", "Year"]},
)
print(valid_sql.compute())

# Batch screening with per-example scores
wildcards = load("wildcard_detector", dialect="postgres", include_per_example=True)
wildcards.add_batch(["SELECT u.* FROM users u", "SELECT COUNT(*) FROM users"])
print(wildcards.compute())

Stateless Functions & Raw LLM Extraction

Use extract_fenced_or_last_sql (or pass a custom regex/callable via extractor=...) to strip <think> reasoning traces and Markdown code fences before evaluation:

from group_by_vibes import (
    compute_sql_bleu,
    compute_valid_sql_rate,
    compute_wildcard_detector,
    extract_fenced_or_last_sql,
)

raw_completions = ["```sql\nSELECT name FROM users WHERE id = 1\n```"]
schemas = [{"users": ["id", "name"]}]

print(compute_valid_sql_rate(raw_completions, schemas, dialect="sqlite", extractor=extract_fenced_or_last_sql))
print(compute_wildcard_detector(raw_completions, dialect="sqlite", extractor=extract_fenced_or_last_sql))
print(compute_sql_bleu(raw_completions, ["SELECT name FROM users WHERE 1 = id"], dialect="sqlite", extractor=extract_fenced_or_last_sql))

Component & Exact Matching (Spider Defaults vs. Strict Mode)

from group_by_vibes import compute_component_matching, compute_exact_matching

# Default Spider value-blind mode with optional per-query schema and foreign keys
preds = ["SELECT u.id FROM users u JOIN orders o ON u.id = o.user_id WHERE 'A' = u.status"]
refs = ["SELECT ord.user_id FROM users usr JOIN orders ord ON usr.id = ord.user_id WHERE usr.status = 'Z'"]
schemas = [{"users": ["id", "status"], "orders": ["user_id"]}]
fks = [[("users.id", "orders.user_id")]]

print(compute_exact_matching(preds, refs, schemas=schemas, foreign_keys=fks, dialect="postgres")["exact_match"])
# 1.0

# Opt-in strict mode enforces literal values, DISTINCT, LIMIT values, and JOIN ON predicates
strict = compute_component_matching(
    preds,
    refs,
    schemas=schemas,
    foreign_keys=fks,
    dialect="postgres",
    ignore_values=False,
    ignore_distinct=False,
    include_limit_value=True,
    include_join_conditions=True,
)
print(strict["components"]["where"]["f1"])
# 0.0

Thread Safety (Out-of-Band Runtime Screening)

Stateful BaseEvaluator instances (SqlBleu, ValidSqlRate, WildcardDetector, ComponentMatching, ExactMatching) maintain single-writer accumulators without locks. When screening queries across background worker threads, either instantiate one evaluator per worker, funnel updates through a single aggregator thread, or call the stateless compute_* functions directly.


Reference Benchmark

See examples/README.md and examples/bird_eval.py for an isolated CLI evaluating birdsql/bird_mini_dev (SQLite, PostgreSQL, and MySQL) across local 3B models (qwen-3b, xiyansql-3b, finer-sql-3b), plus offline core-only scoring (score) and comparative results.


Contributing

Contributions are welcome—please open an issue before submitting a pull request. See CONTRIBUTING.md for our issue-first and fork-and-branch workflow, and docs/designs/group_by_vibes.md for the package architecture.

uv sync --group dev
uv run pytest -v --cov=group_by_vibes --cov-branch
uv run ruff check src/ tests/ examples/ .agents/skills/
uv run mypy src/group_by_vibes/

References


License

Licensed under the Apache-2.0 license.

Metadata

Release files for group-by-vibes 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for group-by-vibes 0.1.3
File Size Uploaded Provenance Actions
group_by_vibes-0.1.3.tar.gz 67.3 kB With provenance Details for group_by_vibes-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for group-by-vibes 0.1.3
File Interpreter ABI Platform Actions
group_by_vibes-0.1.3-py3-none-any.whl Python 3 none any Details for group_by_vibes-0.1.3-py3-none-any.whl

Total release size: 120.9 kB

Release files / group_by_vibes-0.1.3.tar.gz

Download URL group_by_vibes-0.1.3.tar.gz
Size 67.3 kB
Tags Source
SHA-256 checksum
How to use checksums
872732e1f467671a3a5158b14716770bfaa32744356a9977514ef5bbef353ac3
BLAKE2b-256 checksum
How to use checksums
1e0bebb44bc55a759e38e1e492cad05384fb472938f0f550410bc578cf18c532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / group_by_vibes-0.1.3-py3-none-any.whl

Download URL group_by_vibes-0.1.3-py3-none-any.whl
Size 53.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31ab69ae52d8e26b1fa16c2cfe95c7dedd488ad93afc7ca6a719d2725920911e
BLAKE2b-256 checksum
How to use checksums
9e1b48aa3409da81a774eb3fb214dad34069adb47ef5eb43997fc0aefa6d0398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for group-by-vibes 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for group_by_vibes-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page