Statistical significance & confidence intervals for LLM evals
Project description
evalci
Statistically sound comparisons between LLMs on benchmarks: confidence
intervals on accuracy, paired significance tests, power analysis, clustered
standard errors for multi-sample decoding, and multiple-comparison correction
across many models/benchmarks — all validated against statsmodels/exact
enumeration fixtures.
>>> import evalci
>>> result = evalci.compare(model_a_scores, model_b_scores, method="permutation")
>>> evalci.report(result)
'Δ=0.034, 95% CI [0.005, 0.063], paired permutation p=0.025*, n=1319' # exact numbers depend on your data
Status
Core library (statistics, eval-shaped workflows, adapters, CLI) is implemented and tested. Not yet released to PyPI; no arXiv paper or DOI yet.
Install
Not yet on PyPI. Install from source:
git clone https://github.com/Shreyaskc/evalci.git
cd evalci
pip install -e ".[test]" # add [test] to also get pytest/statsmodels for running the test suite
Requires Python ≥3.9. Runtime dependencies are numpy, scipy, and pandas only.
Usage
Confidence interval on a single model
import evalci
# binary (0/1) per-item correctness
evalci.ci(scores, method="wilson") # Wilson score interval
evalci.ci(scores, method="clopper-pearson") # exact interval
# continuous scores (e.g. a similarity metric)
evalci.ci(scores, method="bootstrap") # percentile/BCa bootstrap on the mean
Comparing two models on the same items
result = evalci.compare(model_a_scores, model_b_scores, paired=True, method="permutation")
# result.delta, result.ci, result.p_value, result.n
evalci.compare(a, b, method="bootstrap") # null-shifted bootstrap hypothesis test
evalci.compare(a, b, method="mcnemar") # McNemar's test for paired binary outcomes
evalci.compare(a, b, paired=False, method="permutation") # independent samples
Sample-size / power calculator
evalci.power(delta=0.03, power=0.8) # required n to detect a 3-point gap at 80% power
evalci.power(delta=0.03, n=1500) # achieved power at n=1500
evalci.power(delta=0.03, power=0.8, method="simulation", rho=0.3) # correlated-items simulation
Many models × many benchmarks, with correction
import pandas as pd
# per-item schema: item_id, model, score, [subset], [sample_idx]
df = pd.DataFrame(...)
table = evalci.multi_compare(df, correction="holm")
print(evalci.report(table, format="markdown"))
Clustered standard errors (repeated decoding, grouped questions)
# clusters groups multiple samples of the same underlying item
evalci.cluster_ci(scores, clusters)
Loading results from eval harnesses
from evalci.adapters import load_lm_eval_harness, load_helm, load_csv
df_a = load_lm_eval_harness("results_a.json", model="model-a")
df_b = load_helm("per_instance_stats.json", model="model-b")
CLI
evalci compare results_a.json results_b.json --method permutation
evalci compare results_a.json results_b.json --format helm --method mcnemar
Auto-detects lm-evaluation-harness / HELM / CSV format from the file
extension/content; pass --format to override, and --model-a/--model-b to
label the two runs explicitly.
What's validated, and how
Statistical correctness is the point of this library, so the test suite cross-checks every routine against an independent reference rather than just re-testing its own math:
- Wilson and Clopper-Pearson intervals against
statsmodels.stats.proportion.proportion_confint - McNemar's test (exact and asymptotic) against
statsmodels.stats.contingency_tables.mcnemar - Holm and Benjamini-Hochberg correction against
statsmodels.stats.multitest.multipletests - The paired permutation test against brute-force exact enumeration of all sign flips (small n)
- Bootstrap CIs via a coverage simulation (nominal 95% CIs should contain the true parameter ~95% of the time)
statsmodels is a test-only dependency (pip install -e ".[test]"), not a
runtime dependency.
pytest tests/
API surface
evalci.ci, evalci.compare, evalci.power, evalci.multi_compare,
evalci.cluster_ci, evalci.report, evalci.adapters.{load_lm_eval_harness, load_helm, load_csv}.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file evalci-0.1.0.tar.gz.
File metadata
- Download URL: evalci-0.1.0.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dea79bb7a4cf184c2764fac9c12af9b2bf4001ffb1ee7ff7b1ec3c1f66a3ba06
|
|
| MD5 |
626e1c5772c82d17df6e9081a02eac81
|
|
| BLAKE2b-256 |
eaab4560c90a0ce67ac9d25ec4a9db9957d389e1b9fbab343bd3e7cb1990229f
|
File details
Details for the file evalci-0.1.0-py3-none-any.whl.
File metadata
- Download URL: evalci-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2338fc9d3fa52691735d2b9ba47a2ff179e0ebcec52e8620b804b945a894f39
|
|
| MD5 |
cf6dec39909f2ad1fcfd285e10d142c5
|
|
| BLAKE2b-256 |
cde934cf10e5c22faaed5b088bc72997af9f3a388b5c07758bbd521c556fb8b9
|