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 verdict-ai

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.0.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.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_arbiter-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 9e89f5c975869242c52420d7d2acbcef16e61831569a1a3c484740972c7a464e
MD5 db39e51620ae3bf9756ad294873ee10e
BLAKE2b-256 1823ae1c839692c4b1f7c91d2364357aa2ca60bbc732b5b1c72a437cb3bbf0bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llm_arbiter-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f0399d390fc40daf92b81a76eb59ecb50b120a1a550650beac3beb43924d87b
MD5 c63a90b71ef62f0cefd6c2d3303686bf
BLAKE2b-256 61702e68e943e18b993677cc8eda43a6e9a70840033d3d212e6737c209047775

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