llm-drift-bench
Catch silent regressions before you swap or quantize your LLM.
Offline regression checks for LLM outputs, structured responses, and model changes.
Quickstart · Examples · Architecture · Roadmap · Contribute
Release status: This checkout is prepared for 0.2.0. Registry publication is a separate step; the PyPI badge shows the published version. Read the migration notes before upgrading.
See it in 18 seconds
Watch or download the MP4 | Static preview | Demo inputs
This edited walkthrough uses actual CLI results from the 0.2.0 development checkout and handwritten fixtures. It is not a real-model benchmark or a recording of execution speed. No audio is required. Open the static preview if you prefer no animation.
A faster model is only useful if its outputs still work
A quantized model can return valid JSON while changing a price, dropping a field, or choosing a different label. A prompt revision can change output formatting without improving the underlying task. A model update can affect both.
llm-drift-bench compares saved baseline and candidate responses by prompt ID
and makes those changes inspectable. It runs locally, with no model API calls,
API keys, embedding downloads, or GPU requirement. Its runtime dependencies are
Pydantic and Rich, plus their transitive dependencies.
| Check | What it tells you |
|---|---|
| JSON conformity | Whether responses parse and satisfy the supported schema subset |
| Text similarity | Token, n-gram, and character-level agreement with your baseline |
| JSON field agreement | Changes to structure, exact leaf values, and numeric values |
| Recorded latency | P50/P95 differences when complete measurements are supplied |
| CI gates | Whether a sample or suite exceeds your configured thresholds |
Agreement is not correctness. A wrong baseline can agree perfectly with a wrong candidate. These metrics are lexical and structural, not a semantic judge.
From captured responses to a release decision
flowchart TD
A[Saved baseline responses] --> C[Match prompt IDs]
B[Saved candidate responses] --> C
C --> D[Validate and score]
D --> E{Thresholds pass?}
E -->|Yes| F[Pass CI or application test]
E -->|No| G[Inspect failed prompts and reasons]
Evaluate the output your application depends on
| Your workflow | What you can compare today | What needs separate evaluation |
|---|---|---|
| Model updates and quantization | Saved responses for the same prompts | General intelligence or factual accuracy |
| JSON extraction | Required fields, structure, field agreement, numeric changes | Whether extracted facts match the source |
| RAG applications | Saved final answers or structured extraction outputs | Retrieval relevance, grounding, and citation correctness |
| Agent workflows | Saved final responses or tool-argument JSON represented as output strings | Tool execution, intermediate traces, permissions, and task completion |
You export the captures; the benchmark evaluates them offline. See workflow recipes for examples and boundaries.
Available now and planned next
| Capability | 0.2.0 | Direction |
|---|---|---|
| Offline evaluation and JSON checks | Available | Harden schema and numeric handling |
| CLI and Python test gates | Available | Add CI-native result exports |
| Per-prompt failure inspection | Available | Canonical scores across CLI formats |
| Local HTML report | Available | Inspect a saved engine result in a browser |
| Run history and trends | Planned | Compare versioned results over time |
| Trace import and correlation | Exploratory | Connect failures to externally captured spans |
| Live production monitoring | Not implemented | Requires collection, storage, alerting, and operational design |
The next release prioritizes trustworthy results. The local HTML report shows the same engine scores and failure decision as the CLI. Live monitoring and historical dashboards remain separate future work.
Quickstart
Try this checkout from PowerShell with Python 3.10 or newer:
git clone https://github.com/anant-goel/llm-drift-bench.git
Set-Location llm-drift-bench
python -m venv .venv
& .\.venv\Scripts\python.exe -m pip install -e .
& .\.venv\Scripts\python.exe -m llm_drift_bench --version
& .\.venv\Scripts\python.exe -m llm_drift_bench run -b examples/baseline.jsonl -c examples/candidate-pass.jsonl -p examples/extraction-suite.json
Expected: 0.2.0, followed by a PASSED comparison and exit code 0.
On Linux/macOS, replace .\.venv\Scripts\python.exe with .venv/bin/python.
No virtual-environment activation is needed.
Now catch a regression:
& .\.venv\Scripts\python.exe -m llm_drift_bench run -b examples/baseline.jsonl -c examples/candidate-drift.jsonl -p examples/extraction-suite.json --output drift-report.json
$LASTEXITCODE # Expected: 1
These fixtures are handwritten demonstrations, not measurements of any real model or quantization. Inspect the inputs and expected reports.
To install the published version instead:
python -m pip install "llm-drift-bench==0.1.0"
python -m llm_drift_bench --help
Published 0.1.0 does not include all changes documented on this branch.
Bring your own captures
Create a JSON or JSONL file for each comparison target. Each record contains a
unique, nonempty prompt_id and the captured response as an output string:
{"prompt_id":"invoice-01","model_name":"my-baseline","output":"{\"total\":100}"}
Optionally include measured latency_ms and tokens_generated. Missing
measurements remain unavailable; the tool does not estimate them from text.
Baseline and candidate must have exactly matching prompt IDs. A supplied suite
must cover the same IDs, with no duplicates or extra cases.
A suite associates those IDs with prompts and schemas:
[{"prompt_id":"invoice-01","prompt":"Extract the invoice total.","schema":{"type":"object","required":["total"],"properties":{"total":{"type":"number","minimum":0}}}}]
JSON Schema support is intentionally limited. Unsupported keywords fail explicitly. See current limitations before using complex schemas or untrusted regex patterns.
Use it in CI
& .\.venv\Scripts\python.exe -m llm_drift_bench run -b baseline.jsonl -c candidate.jsonl -p prompts.json --max-drift 0.15 --min-conformity 0.98 --max-numeric-drift 0.05 --max-latency-regression 25 --format json --output drift-report.json
exit $LASTEXITCODE
| Exit code | Meaning |
|---|---|
0 |
Passed |
1 |
Drift or a threshold failure |
2 |
Usage or input error |
--fail-on-drift explicitly enables the default. --no-fail-on-drift makes a
run informational, but its report still records failure. Input errors remain
errors. A failed individual sample fails the suite even if the mean is low.
| Threshold | Default |
|---|---|
--max-drift |
0.25 |
--min-conformity |
0.95 |
--max-numeric-drift |
0.15 |
--max-latency-regression |
50 percent |
Calibrate thresholds using your own tasks. Missing timings skip the latency gate, so a passing report does not necessarily certify latency performance.
Python API
from llm_drift_bench import DriftBenchmarkEngine, ModelSample, PromptCase
suite = [PromptCase(prompt_id="invoice-01", prompt="Extract total.",
schema={"type": "object", "required": ["total"]})]
baseline = [ModelSample(prompt_id="invoice-01", output='{"total":100}')]
candidate = [ModelSample(prompt_id="invoice-01", output='{"total":100}')]
report = DriftBenchmarkEngine().evaluate(baseline, candidate, suite)
assert report.passed, report.failure_reasons
Turn a benchmark into an automated test
The development version includes assert_no_drift, usable with pytest,
unittest, or ordinary Python. It uses the canonical engine report and raises
AssertionError when a sample or suite gate fails.
from pathlib import Path
from llm_drift_bench import (
DriftBenchmarkEngine, assert_no_drift, load_model_samples, load_prompt_cases,
)
def test_saved_outputs_do_not_regress():
fixtures = Path("examples") # Run from the repository root.
report = DriftBenchmarkEngine().evaluate(
load_model_samples(fixtures / "baseline.jsonl"),
load_model_samples(fixtures / "candidate-pass.jsonl"),
load_prompt_cases(fixtures / "extraction-suite.json"),
)
assert_no_drift(report)
Switch the candidate to candidate-drift.jsonl to see a failing assertion.
Failure messages include suite reasons and up to five failed prompt IDs, without
printing captured response bodies. The helper does not recompute scores or
add new checks; missing timings still mean the latency gate may be skipped.
It is not available in published 0.1.0.
Commands and reporting
| Command | Purpose |
|---|---|
run |
Compare captured baseline and candidate outputs |
validate --strict |
Fail when captured outputs do not conform |
report |
Render an existing result |
init-sample --dir demo |
Create illustrative starter files |
All run formats now render the same engine result: table, JSON, Rich, Markdown,
and HTML. Saved engine reports preserve scores, thresholds, and failure reasons.
Legacy evaluator reports retain their original scoring semantics and are not
converted into engine reports.
For all options, run python -m llm_drift_bench <command> --help.
Inspect results in your browser
Generate a report, then render it as a standalone HTML file:
& .\.venv\Scripts\python.exe -m llm_drift_bench run -b examples/baseline.jsonl -c examples/candidate-drift.jsonl -p examples/extraction-suite.json -o drift-report.json
# Exit 1 is expected for this failing fixture; the JSON report is still saved.
& .\.venv\Scripts\python.exe -m llm_drift_bench report -i drift-report.json --format html -o drift-report.html
Start-Process -FilePath (Resolve-Path -LiteralPath drift-report.html).Path
The report includes the pass/fail result, summary metrics, per-prompt rows,
thresholds, failure reasons, and skipped-latency notices. It contains no scripts
or external assets and works offline. This is a saved report, not a live dashboard.
run --output always saves JSON, regardless of its stdout format; use
report --format html --output to save HTML.
Download an example HTML report.
Help make model changes safer
Check an agent's workflow offline
The development Python API includes check_read_before_edit: verify that a
required file section was returned before an agent's first edit attempt.
It consumes normalized tool events and returns PASS, FAIL, or UNKNOWN.
Repeated reads count only once; incomplete traces cannot pass.
This checks content delivery, not comprehension, and does not collect live traces.
Run it with llm-drift-bench check-tools, then attach the saved verdict to HTML or
Markdown reports with --tool-check. See the
tool-event guide and example.
Useful contributions include a small failing capture, a reproducible bug report, a tested edge-case fix, or clearer documentation. Start with the contributor guide and roadmap.
If the tool catches a real regression, share a sanitized reproduction and the benchmark version. Reproducible examples help other users more than a score without its inputs.
Metadata
Release files for llm-drift-bench 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_drift_bench-0.2.0.tar.gz | 1.5 MB | With provenance | Details for llm_drift_bench-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_drift_bench-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for llm_drift_bench-0.2.0-py3-none-any.whl |
Total release size: 1.6 MB
Release files / llm_drift_bench-0.2.0.tar.gz
| Download URL | llm_drift_bench-0.2.0.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7979cd25528577d55e0ef37d38e685ef2d4a0259f5363c49b73acd289bb1a134
|
|
BLAKE2b-256 checksum How to use checksums |
5fb01aa341d658e969cb1a05222d95c44e3ee938ef923d424703650f3db73d94
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 15, 2026.
Transparency logRelease files / llm_drift_bench-0.2.0-py3-none-any.whl
| Download URL | llm_drift_bench-0.2.0-py3-none-any.whl |
|---|---|
| Size | 53.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9297b45e63962fc9ba514d000598834786175e7fff429fd0a92253676d3a0b70
|
|
BLAKE2b-256 checksum How to use checksums |
080d460e1ec911b331b861b4b4b06ad6789f144f89099ffa40c7aa687836af92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 15, 2026.
Transparency logSecurity for llm-drift-bench 0.2.0
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.
Attestation for llm_drift_bench-0.2.0.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 15, 2026.
Transparency logA 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.