Skip to main content

llmcalibre

llmcalibre is an offline-first, framework-agnostic library for evaluating LLM outputs. It starts with deterministic local checks, then lets you opt into heavier NLP metrics or OpenAI-compatible judge models only when you need them.

Installation

Base install, with no runtime dependencies:

pip install llmcalibre

Install from a local checkout for development:

pip install -e ".[dev]"

Optional extras:

pip install "llmcalibre[schema]"
pip install "llmcalibre[nlp]"
pip install "llmcalibre[judge]"

Extras can be combined:

pip install "llmcalibre[schema,nlp,judge]"

Features

  • Normalized EvalResult objects with score, pass/fail status, rationale, and metadata.
  • EvalPipeline for running multiple evaluators against one output.
  • Heuristic checks for JSON format, length, required/forbidden terms, regex patterns, and JSON Schema.
  • Optional offline NLP metrics for semantic similarity and ROUGE.
  • Optional OpenAI-compatible LLM judge evaluator with graceful failure handling.
  • Stdlib CLI for simple terminal checks.
  • Lightweight pytest assertion helper.
  • No base runtime dependencies.

Python API

from llmcalibre import (
    ContainsChecker,
    EvalPipeline,
    FormatChecker,
    LengthConstraint,
    RegexChecker,
)

pipeline = EvalPipeline(
    [
        FormatChecker(format="json"),
        LengthConstraint(min_chars=2, max_chars=100),
        ContainsChecker(required=["answer"], forbidden=["TODO"]),
        RegexChecker(required_patterns=[r'"answer"\s*:']),
    ]
)

results = pipeline.run('{"answer": "Paris"}')
summary = pipeline.summary(results)

print(results)
print(summary)

Optional Evaluators

JSON Schema validation:

from llmcalibre import JsonSchemaChecker

schema = {
    "type": "object",
    "required": ["answer"],
    "properties": {"answer": {"type": "string"}},
}

result = JsonSchemaChecker(schema=schema).evaluate('{"answer": "Paris"}')
print(result)

Offline NLP metrics:

from llmcalibre import RougeScore, SemanticSimilarity

similarity = SemanticSimilarity(threshold=0.7)
semantic_result = similarity.evaluate(
    "Paris is the capital of France.",
    reference="France's capital city is Paris.",
)

rouge = RougeScore(rouge_type="rougeL", threshold=0.5)
rouge_result = rouge.evaluate(
    "Paris is the capital of France.",
    reference="The capital of France is Paris.",
)

OpenAI-compatible judge:

from llmcalibre import OpenAIJudge

judge = OpenAIJudge(model="gpt-4o-mini")
result = judge.evaluate(
    "Paris is the capital of France.",
    prompt="What is the capital of France?",
    reference="Paris",
    criteria="Reward factual correctness and concise answers.",
)
print(result)

CLI Usage

llmcalibre check --output '{"name":"Emon"}' --format json
llmcalibre check --output "Paris is in France" --contains Paris --contains France
llmcalibre check --output-file response.txt --min-chars 50 --max-chars 500
llmcalibre check --output "Date: 2026-06-16" --regex "\\d{4}-\\d{2}-\\d{2}"

The CLI exits with:

  • 0 when all checks pass.
  • 1 when at least one check fails.
  • 2 for usage or configuration errors.

Pytest Helper

from llmcalibre import ContainsChecker, FormatChecker
from llmcalibre.pytest import assert_eval


def test_llm_response():
    output = '{"city": "Paris", "country": "France"}'

    assert_eval(
        output,
        evaluators=[
            FormatChecker(format="json"),
            ContainsChecker(required=["Paris", "France"]),
        ],
    )

License

MIT

Release Process

  1. Update the version in pyproject.toml.
  2. Update CHANGELOG.md.
  3. Merge the release changes to main.
  4. Create a GitHub pre-release with a tag like v0.1.0-alpha.1.
  5. The release workflow publishes the package to TestPyPI automatically.
  6. Test install from TestPyPI:
pip install --index-url https://test.pypi.org/simple/ llmcalibre
  1. Create a normal GitHub Release for the final version.
  2. The release workflow publishes the package to PyPI automatically.

Metadata

Release files for llmcalibre 0.1.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 llmcalibre 0.1.0
File Size Uploaded Provenance Actions
llmcalibre-0.1.0.tar.gz 22.7 kB With provenance Details for llmcalibre-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llmcalibre 0.1.0
File Interpreter ABI Platform Actions
llmcalibre-0.1.0-py3-none-any.whl Python 3 none any Details for llmcalibre-0.1.0-py3-none-any.whl

Total release size: 44.5 kB

Release files / llmcalibre-0.1.0.tar.gz

Download URL llmcalibre-0.1.0.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fc4fe0fbdcdf5bed1e7c060547495f3b885d6cf4e9eaaa0e3df503bea1ae0b2c
BLAKE2b-256 checksum
How to use checksums
7a1c9985e7beb81a8f56547b100280e8d0d80feae700e682ca1a5c9e4c579916
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 16, 2026.

Transparency log

Release files / llmcalibre-0.1.0-py3-none-any.whl

Download URL llmcalibre-0.1.0-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a156dfb49daf2f34ebd48c3f3a79008ccf06a7833577eacb548b3bfcee7e9ac6
BLAKE2b-256 checksum
How to use checksums
3a2acb22f7925c19e6a4ac4f06c671020cd8fb2b2eeecf3586df5e6f0dbed75c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 16, 2026.

Transparency log

Security for llmcalibre 0.1.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for llmcalibre-0.1.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 Jun 16, 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.0 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