Skip to main content

A/B testing for LLMs. Statistical proof, not vibes.

Project description

Verdict

A/B testing for LLMs. Statistical proof, not vibes.

Verdict is a Python framework for systematically comparing large language models with statistical rigor. Instead of picking models based on gut feeling, verdict helps you make data-driven decisions using rigorous experimental design and statistical analysis.

Features

  • 🧪 Parallel A/B Testing — Run multiple model variants concurrently on the same queries
  • 📊 Statistical Analysis — Built-in significance testing using scipy
  • 💰 Cost Tracking — Monitor and compare inference costs across models
  • 🎯 LLM Judge Scoring — Automatic evaluation using GPT-4o-mini with custom criteria
  • Performance Metrics — Track latency, tokens, and costs
  • 📈 Variant Comparison — Side-by-side results with statistical significance

Installation

pip install llm-arbiter

Quick Start

from verdict import Experiment, Variant, Judge

# Define model variants to test
variants = [
    Variant(
        name="gpt-4o",
        fn=call_model,
        config={"model": "gpt-4o"},
        model="gpt-4o"
    ),
    Variant(
        name="gpt-4o-mini",
        fn=call_model,
        config={"model": "gpt-4o-mini"},
        model="gpt-4o-mini"
    ),
]

# Create an experiment
experiment = Experiment(
    queries=["What is X?", "Explain Y"],
    variants=variants,
)

# Run the experiment
results = experiment.run()

# Analyze results with optional LLM judge
judge = Judge(criteria=[
    "Does it cite specific numbers?",
    "Is the analysis correct?",
])
analysis = experiment.analyze(judge=judge)
print(analysis.summary())

Core Components

Variant

Represents a single model configuration being tested.

Variant(
    name="gpt-4o",
    fn=call_model,  # (config, query) → str or dict
    config={"model": "gpt-4o"},  # Passed to fn
    model="gpt-4o",  # For pricing lookup
    pricing={"input": 2.50/1_000_000, "output": 10.00/1_000_000}  # Optional override
)

Experiment

Defines and runs the test across all variants.

  • queries: List of queries to test
  • variants: List of Variant objects
  • num_workers: Parallel execution threads (default: auto)

Judge

Scores model outputs using GPT-4o-mini based on custom criteria.

judge = Judge(
    criteria=["Is it accurate?", "Does it cite sources?"],
    model="gpt-4o-mini"  # Can override
)

Analysis

Statistical results after running the experiment.

  • RunResult: Individual execution data (latency, tokens, cost, score)
  • summary(): Display results with significance testing

Supported Models & Pricing

Pre-configured pricing for OpenAI models:

  • gpt-4o
  • gpt-4o-mini
  • gpt-4.1
  • gpt-4.1-mini
  • gpt-4.1-nano
  • o3-mini

Custom pricing can be specified per variant.

Example: Market Research Analysis

See test.py for a complete example comparing models on market research questions.

Requirements

  • Python 3.9+
  • numpy >= 1.24
  • scipy >= 1.10
  • openai >= 1.0

Environment Variables

Set your OpenAI API key:

export OPENAI_API_KEY="sk-..."

License

MIT

Contributing

Contributions welcome! This project uses statistical rigor—pull requests should include validation.

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

llm_arbiter-0.1.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

llm_arbiter-0.1.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file llm_arbiter-0.1.1.tar.gz.

File metadata

  • Download URL: llm_arbiter-0.1.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for llm_arbiter-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4101df1a38246d38a946321ee6ee935fa0de48f7f4530f4209740a1da59b9610
MD5 9438328bc8c0796fc3028b24717d5f86
BLAKE2b-256 1f09f8eb0afd56bd4b157f98434c6d41d08912ebc56941c5958346df6332b809

See more details on using hashes here.

File details

Details for the file llm_arbiter-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llm_arbiter-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for llm_arbiter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9240bd6f025188df646f1a8e66df3558ac738d961d9be8095b83e68d2335b959
MD5 fd0a6503bb835e83cc22870797041c3b
BLAKE2b-256 71f4e8b61fb45cef4b09d0c11875fedf6f03d23ce522949a059fb8154d230e5f

See more details on using hashes here.

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