Skip to main content

Offline-first, framework-agnostic LLM evaluation primitives.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmcalibre-0.1.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmcalibre-0.1.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file llmcalibre-0.1.0.tar.gz.

File metadata

  • Download URL: llmcalibre-0.1.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmcalibre-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fc4fe0fbdcdf5bed1e7c060547495f3b885d6cf4e9eaaa0e3df503bea1ae0b2c
MD5 5aaed2398763b5a0a903ed5529a08ccd
BLAKE2b-256 7a1c9985e7beb81a8f56547b100280e8d0d80feae700e682ca1a5c9e4c579916

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmcalibre-0.1.0.tar.gz:

Publisher: publish.yml on kmemonahmed/llmcalibre

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmcalibre-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llmcalibre-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmcalibre-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a156dfb49daf2f34ebd48c3f3a79008ccf06a7833577eacb548b3bfcee7e9ac6
MD5 028a0640258884817e3493da34144f0a
BLAKE2b-256 3a2acb22f7925c19e6a4ac4f06c671020cd8fb2b2eeecf3586df5e6f0dbed75c

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmcalibre-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kmemonahmed/llmcalibre

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page