Skip to main content

LLMGuard CI

A local-first regression testing framework for AI systems.

Compare AI systems on the same cases, see which results changed, and catch regressions before shipping.

GitHub Actions status for release/0.3.0  •  Python 3.11–3.13  •  MIT License

Quick Start  ·  Report Preview  ·  Integrations  ·  Benchmarks

Quick Start

From a checkout or extracted source distribution, run:

python -m pip install .
python examples/quickstart.py

The demo compares two local retrievers on three synthetic cases. It runs without credentials and writes results/quickstart.json and results/quickstart.html. It reports WARN because the Hit@1 drop falls between the warning and failure thresholds.

Comparison report

The Quick Start report compares search-v1 and search-v2. Hit@1 falls from 1.0000 to 0.6667 and receives WARN, while Recall@3 stays at 1.0000.

The HTML report shows baseline and candidate scores, per-case changes, and execution details together. Download the sample HTML and open it in your browser.

Integrations

Python SDK

Use a Python callable to evaluate a retriever, language model, or classifier and turn a Quality Gate failure into a CI failure.

from llmguard import Evaluator, System

cases = [{"id": "q1", "input": "How can I return an order?", "expected": ["returns"]}]
evaluator = Evaluator(
    cases, "retrieval", ["hit@1", "recall@3"],
    quality_gate={"max_drop": {"hit@1": 0.1}},
)
baseline = System(lambda _: ["returns", "shipping"], model_version="search-v1")
candidate = System(lambda _: ["shipping", "returns"], model_version="search-v2")
result = evaluator.compare(baseline, candidate)
result.report("results/search-comparison.json")
raise SystemExit(1 if result.status == "FAIL" else 0)

Hit@1 falls from 1 to 0 while Recall@3 stays at 1. The configured Hit@1 gate returns FAIL. Use min_scores for an absolute floor, a warn and fail mapping for two levels, or on_unknown to control how missing measurements affect the verdict. A saved SDK report can serve as the baseline. See the usage guide for async execution, custom metrics, and statistics.

REST API

Install the REST extra with python -m pip install ".[rest]". The example expects a service on your machine whose response contains ranked IDs under hits.

from llmguard import Evaluator, RESTAdapter

evaluator = Evaluator("examples/suite/retrieval.jsonl", "retrieval")
with RESTAdapter(
    "http://localhost:8000/search",
    method="POST",
    request_mapping={"query": "input"},
    response_mapping={"retrieved_ids": "hits.*.id"},
    timeout=3,
) as search:
    evaluator.evaluate(search).report("results/service.json")

For an authenticated service, use HTTPS and map header names to environment variables with auth_headers. REST calls send the mapped input fields to the configured endpoint.

Saved predictions

from llmguard import Evaluator, PredictionFile

evaluator = Evaluator("examples/suite/retrieval.jsonl", "retrieval", ["hit@1", "mrr@3"])
result = evaluator.compare(
    PredictionFile("examples/suite/baseline.jsonl"),
    PredictionFile("examples/suite/candidate.jsonl"),
)
result.report("results/archived-comparison.json")

JSON, JSONL, and CSV files are joined by case ID; duplicate, missing, and unexpected IDs are rejected. Use dataset_mapping and prediction_mapping to read fields such as gold_chunks.*.chunk_id from an existing export. Replaying a file makes zero model calls.

Architecture

flowchart LR
    Data["Dataset and field mapping"] --> Eval["Evaluator"]
    Sources["Python, REST, or prediction files"] --> Eval
    Eval -. Optional local state .-> SQLite[(SQLite)]
    Eval --> Engine["Scoring and Quality Gates"]
    Engine --> Reports["JSON and HTML reports"]

The SDK supports retrieval, lexical question-answering, and classification. Optional paired inference provides bootstrap confidence intervals, permutation or McNemar tests, and Holm or Bonferroni correction. Generic SDK reports omit inputs, gold values, and predictions by default. Use opaque case IDs and metadata. Keep SQLite state private because normalized predictions are stored there. Legacy suite and BANKING77 reports include case payloads. See the data-handling notes.

Benchmark validation

Dataset Scope Agreement with reference scorer
SQuAD v1.1 100 validation questions, seed 42, two saved QA runs Exact match and token F1 agreed within floating-point precision (maximum absolute difference below 2e-16, on a 0–1 scale).
BEIR NFCorpus 323 test queries, 3,633 documents, BM25 and dense rankings at K = 1, 3, 5, 10 Hit, Recall, MRR, and nDCG agreed within the reference tool's five-decimal rounding (maximum absolute difference below 5e-6).

Identical predictions passed the regression gate. An intentionally degraded QA variant and a truncated BM25 control failed it. These checks validate the scoring and comparison paths on the recorded runs. See the benchmark methods and replay commands.

Documentation and support

The core package has no third-party runtime dependencies. Install extras for REST, statistics, OpenAI, YAML, BANKING77, public benchmarks, and development tools as needed. The test workflow runs without model credentials.

Guide What it covers
Usage SDK, mappings, caching, statistics, and data handling
Benchmarks Public datasets, scoring methods, and replay instructions
Contributing Local development, tests, and package checks
Changelog Release history
Releasing Build verification and publication

Metadata

Release files for llmguard-ci 0.3.0

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

Source distribution (sdist)

Source distribution for llmguard-ci 0.3.0
File Size Uploaded Provenance Actions
llmguard_ci-0.3.0.tar.gz 874.0 kB Without provenance Details for llmguard_ci-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llmguard-ci 0.3.0
File Interpreter ABI Platform Actions
llmguard_ci-0.3.0-py3-none-any.whl Python 3 none any Details for llmguard_ci-0.3.0-py3-none-any.whl

Total release size: 947.2 kB

Release files / llmguard_ci-0.3.0.tar.gz

Download URL llmguard_ci-0.3.0.tar.gz
Size 874.0 kB
Tags Source
SHA-256 checksum
How to use checksums
922b774239081b920e9108c0db026eacde7e79eb62cf66b506add7d527e96373
BLAKE2b-256 checksum
How to use checksums
01679b291fb8d64601d3c7ba6d89f65fe43b30ec9bafa8846ccd0e3e28608aab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.3

Release files / llmguard_ci-0.3.0-py3-none-any.whl

Download URL llmguard_ci-0.3.0-py3-none-any.whl
Size 73.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c1a063f6076d782c610d43067df9e342b54c6b49ba51911f35d97ecbb9dc4fe
BLAKE2b-256 checksum
How to use checksums
8f8ff4b19278aebb9735fa3ece08b4a556b8a901a583285b0b3a32c5540f57a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.3

Security for llmguard-ci 0.3.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.3.0 This release

2 release files No 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