Skip to main content

margin-referee

Should you switch models? Ask your own eval set.

margin-referee replays the cases you already have (a promptfoo results file, a Braintrust, LangSmith or Langfuse dataset export, or JSONL) on the model you run today and on a candidate, grades both with each case's own check, and tells you whether the candidate holds up and costs less. No account, no backend, no telemetry.

Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub (https://github.com/trymargin/margin-referee).

pip install margin-referee
margin-referee fit cases.jsonl
OPENROUTER_API_KEY=... margin-referee replay cases.jsonl \
    --baseline openai/gpt-4.1 --candidate openai/gpt-6-luna --cap 1

Why another eval tool

Because "the candidate scored higher on our evals" is how most bad switches start. Three things make it unreliable, and this tool corrects for each:

  • Small sets lie. The verdict is a paired test on the cases both models ran. Only the cases they disagree on carry evidence, and a clean sweep on 20 cases proves nothing. fit tells you, for free and before anything runs, how many cases you need: about 100 against a current model that passes everything, and more as its pass rate falls.
  • The best of several looks better than it is. Try four models on the same cases and keep the winner, and you have mostly found noise. The bar rises with every candidate you try on overlapping cases (remembered in ~/.margin-referee/ledger.json), so renaming or trimming the cases does not reset it. To confirm a winner, replay it alone on cases none of them saw.
  • Half-graded cases flatter the candidate. A case with a check this tool cannot run (an LLM rubric, say) is left out and counted, never half-graded. An answer cut off by the output limit, or a call that errored, is unanswered, not a fail, and any unanswered case blocks a promotion.

What it runs on

  • OpenRouter, with your own key: any model it serves.
  • A model in your own account, with --candidate-endpoint or --baseline-endpoint and a JSON object: bedrock (region, model, a Bedrock API key), vertex_ai (project, region, model, access token), azure_openai (resource, deployment, key) or openai_compatible (base URL, model, key: a fine-tune, vLLM, a self-hosted model). Your credential is used for that run only, and you give your own per-token price, so a negotiated discount counts.
  • A prompt change: --candidate-system replays the candidate with a new system prompt. Each prompt you try counts as a candidate.

What it does not do

It does not open the pull request, watch the change after you merge it, keep the history across your team, or let your agents call it with a spend limit. That is Margin, which runs this same test.

MIT licensed.

Metadata

Release files for margin-referee 0.1.2

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

Source distribution (sdist)

Source distribution for margin-referee 0.1.2
File Size Uploaded Provenance Actions
margin_referee-0.1.2.tar.gz 17.7 kB Without provenance Details for margin_referee-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for margin-referee 0.1.2
File Interpreter ABI Platform Actions
margin_referee-0.1.2-py3-none-any.whl Python 3 none any Details for margin_referee-0.1.2-py3-none-any.whl

Total release size: 35.1 kB

Release files / margin_referee-0.1.2.tar.gz

Download URL margin_referee-0.1.2.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
11ad690655da0209961d2dcf3932bb8ff69b8a2ae869d37246733e82f86c30d2
BLAKE2b-256 checksum
How to use checksums
d200d3bc352e279047c4262df8eedbdae0ffe6c4a8ab7fb4c5dc976516c96e1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Release files / margin_referee-0.1.2-py3-none-any.whl

Download URL margin_referee-0.1.2-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f22e7b47599dfe449199e75a4095dc12fdeb316ea2920fb41a203a8bf27afba8
BLAKE2b-256 checksum
How to use checksums
150348c9afbdd9010a35e47ceef5b4f891f54f06d6b905c156264fe606360bac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.0

Security for margin-referee 0.1.2

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.

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