errorbars 0.1.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- errorbars-0.2.0/CHANGELOG.md +156 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/PKG-INFO +64 -19
- {errorbars-0.1.2 → errorbars-0.2.0}/README.md +63 -18
- {errorbars-0.1.2 → errorbars-0.2.0}/pyproject.toml +1 -1
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/__init__.py +3 -1
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/adapters/inspect_ai.py +22 -2
- errorbars-0.2.0/src/errorbars/adapters/lm_eval.py +200 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/cli.py +129 -50
- errorbars-0.2.0/src/errorbars/inputs.py +180 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/io.py +91 -4
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/leaderboard.py +4 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/power.py +21 -10
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/stats.py +2 -0
- errorbars-0.1.2/CHANGELOG.md +0 -74
- errorbars-0.1.2/src/errorbars/adapters/lm_eval.py +0 -103
- {errorbars-0.1.2 → errorbars-0.2.0}/.gitignore +0 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/LICENSE +0 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/docs/formulas.md +0 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/adapters/__init__.py +0 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/compare.py +0 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/plot.py +0 -0
- {errorbars-0.1.2 → errorbars-0.2.0}/src/errorbars/py.typed +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.2.0] - 2026-10-01
|
|
6
|
+
|
|
7
|
+
A harness writes one log per model, and every command took exactly one file. Asking whether
|
|
8
|
+
model B beats model A, starting from real lm-eval output, was two `import` runs, a
|
|
9
|
+
hand-made concatenation of two CSVs, and then `compare`.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `summarize`, `compare` and `leaderboard` take one or more files or directories and read
|
|
14
|
+
each as what it is: errorbars' CSV/JSONL, an lm-evaluation-harness `samples_*.jsonl`, or
|
|
15
|
+
an Inspect AI `.eval` log. `errorbars compare out/model-a out/model-b` is the whole
|
|
16
|
+
comparison; `errorbars leaderboard out` ranks every model under an lm-eval output
|
|
17
|
+
directory. Checked against the output directory of two real lm-eval 0.4.13 runs
|
|
18
|
+
(`--model hf`, two tiny models, COPA), committed as a fixture: the means are the
|
|
19
|
+
accuracies lm-eval reported.
|
|
20
|
+
- The model of an lm-eval samples file is read from the `results_<timestamp>.json` lm-eval
|
|
21
|
+
writes beside it (`model_name`), so `--model` is no longer required. A samples file moved
|
|
22
|
+
away from its results file has to be named, as `NAME=PATH`; the same form tells two runs of
|
|
23
|
+
one model apart (`greedy=a.eval sampled=b.eval`).
|
|
24
|
+
- A directory with several runs of one task (lm-eval adds a timestamped file on every
|
|
25
|
+
re-run) uses the latest and says so on stderr.
|
|
26
|
+
- The same model, question and sample in two inputs is refused and both files are named.
|
|
27
|
+
- `compare` with exactly two models in the input needs no `--model-a`/`--model-b`. Its
|
|
28
|
+
output says how many questions only one of the two models answered (`n_only_a`,
|
|
29
|
+
`n_only_b` in `--json`), and `leaderboard` says when the models were not scored on the same
|
|
30
|
+
questions.
|
|
31
|
+
- `import` takes several logs and directories and writes one CSV. `--metric`, `--filter`
|
|
32
|
+
and `--scorer` are available on every command that reads logs.
|
|
33
|
+
- Python: `errorbars.load_inputs`, `errorbars.io.concat`,
|
|
34
|
+
`errorbars.adapters.lm_eval.infer_model_name`.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- `summarize` on a file without a `cluster_id` column printed clustering diagnostics anyway,
|
|
39
|
+
with every question as its own cluster: for 4 questions, "n clusters 4" and a "clustered
|
|
40
|
+
CI" of [-0.05, 1.55]. Diagnostics now need a cluster that groups questions.
|
|
41
|
+
- `summarize` without `--model` on a file with several models pooled them: the example
|
|
42
|
+
benchmark's 4 models x 200 questions were summarized as one sample of n = 800 (SE 0.017,
|
|
43
|
+
where each model's is 0.033 to 0.035). It now asks which model, or points to `leaderboard`.
|
|
44
|
+
With one model in the data, the summary is titled with its name instead of `(all)`.
|
|
45
|
+
|
|
46
|
+
## [0.1.3] - 2026-10-01
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- `import lm-eval` on a task with several filters counted every question once
|
|
51
|
+
per filter. `gsm8k_cot_self_consistency` scores each question under
|
|
52
|
+
`score-first`, `maj@8` and `maj@64`, so 4 questions were imported as 12 and
|
|
53
|
+
every standard error shrank accordingly. The adapter now asks which filter to
|
|
54
|
+
use (`--filter maj@8`, or `filter_name=` in Python) and refuses a second
|
|
55
|
+
record for the same `doc_id`. Checked against a real three-filter log from
|
|
56
|
+
lm-eval 0.4.13, committed as a fixture.
|
|
57
|
+
- `import inspect` read a scorer that returns several named values as a score
|
|
58
|
+
of 0 for every sample (that is what Inspect's own conversion does with a
|
|
59
|
+
dict). It is an error now. A score that isn't a finite number is rejected by
|
|
60
|
+
both adapters, as it already was when loading a CSV.
|
|
61
|
+
- A missing or unreadable file printed a Python traceback. It is one line:
|
|
62
|
+
`error: results.csv: No such file or directory`. A file Inspect can't parse
|
|
63
|
+
is named, and so is a JSONL line that isn't an object (it was a
|
|
64
|
+
`TypeError`).
|
|
65
|
+
- A CSV row with too few cells produced a model named `None`; one with too
|
|
66
|
+
many (an unquoted comma in a value) was read with its cells shifted. Both
|
|
67
|
+
are rejected with their row number.
|
|
68
|
+
- `leaderboard --alpha` and `summarize --ci bootstrap --confidence` accepted
|
|
69
|
+
any number, including `nan` and values outside 0 to 1. `power --n` accepted
|
|
70
|
+
a correlation outside -1 to 1 (reported as "math domain error") and a design
|
|
71
|
+
effect below 1, which `power --delta` already refused. Infinite or `nan`
|
|
72
|
+
arguments are refused throughout.
|
|
73
|
+
- Scores too large to square (beyond 1e100) overflowed into `inf` and `nan`
|
|
74
|
+
results, or an `OverflowError`. They are rejected when loading.
|
|
75
|
+
|
|
76
|
+
### Added
|
|
77
|
+
|
|
78
|
+
- `leaderboard --json` reports `p_value_clustered` for each pair. With
|
|
79
|
+
clustered questions the Holm correction is applied to that p-value, and the
|
|
80
|
+
output only showed the unclustered one, so `p_holm` could not be checked
|
|
81
|
+
against it.
|
|
82
|
+
- A seeded fuzz test runs 1,200 generated datasets and argument sets through
|
|
83
|
+
the command line: each ends in a result that satisfies the basic invariants
|
|
84
|
+
(intervals in order, p-values in 0 to 1, strict JSON) or in a one-line
|
|
85
|
+
error.
|
|
86
|
+
|
|
87
|
+
## [0.1.2] - 2026-10-01
|
|
88
|
+
|
|
89
|
+
### Added
|
|
90
|
+
|
|
91
|
+
- Published to PyPI: `pip install "errorbars[cli]"`. The README's images and
|
|
92
|
+
links are rewritten to absolute URLs at build time so they work on the
|
|
93
|
+
project page.
|
|
94
|
+
- `errorbars --version`.
|
|
95
|
+
- `py.typed`, so type checkers use the package's annotations (the `Typing ::
|
|
96
|
+
Typed` classifier was already declared).
|
|
97
|
+
|
|
98
|
+
## [0.1.1] - 2026-09-30
|
|
99
|
+
|
|
100
|
+
### Fixed
|
|
101
|
+
|
|
102
|
+
- The paired test's p-value and CI used the normal distribution, and the
|
|
103
|
+
README called that "somewhat conservative" for small n; it is the opposite
|
|
104
|
+
(at 8 degrees of freedom, a statistic of 2.2 gave p = 0.028 instead of
|
|
105
|
+
0.059). Paired comparisons now use Student's t with n - 1 degrees of freedom
|
|
106
|
+
and match `scipy.stats.ttest_rel` to 1e-7, and clustered SEs (the clustered
|
|
107
|
+
CI in `summarize`, the clustered paired CI and p-value, and so the
|
|
108
|
+
leaderboard's Holm-corrected tests) use t with G - 1 degrees of freedom for
|
|
109
|
+
G clusters. No scipy at runtime: the t tail comes from a continued-fraction
|
|
110
|
+
incomplete beta function. On the bundled example the headline pair's paired
|
|
111
|
+
p moves from 0.1116 to 0.1131, its clustered p from 0.1154 to 0.1235, and
|
|
112
|
+
its Holm-adjusted p from 0.298 to 0.322; groups are unchanged.
|
|
113
|
+
With a single cluster, where the clustered SE falls back to the plain one,
|
|
114
|
+
the clustered test keeps the n - 1 reference too.
|
|
115
|
+
|
|
116
|
+
- A non-finite score (`nan`, `inf`) was accepted and propagated into every
|
|
117
|
+
mean, CI and p-value; on a leaderboard the NaN model sorted to rank 1.
|
|
118
|
+
Loading now fails with the row number.
|
|
119
|
+
- A repeated (model, question, sample) row was counted as another question,
|
|
120
|
+
inflating n and shrinking standard errors. Loading now fails with both row
|
|
121
|
+
numbers and says to give repeated generations distinct `sample` values.
|
|
122
|
+
- `power` answered "2 questions" for a baseline of 0 or 1 (where p(1-p) = 0)
|
|
123
|
+
and accepted targets above 100% (`--baseline 0.98 --delta 0.05`). The
|
|
124
|
+
baseline must be strictly between 0 and 1, baseline + delta can't exceed
|
|
125
|
+
1, and a continuous-metric variance must be positive; the web calculator's
|
|
126
|
+
effect-size slider is capped at 1 - baseline to match.
|
|
127
|
+
- `compare`/`summarize` with an unknown model name said "fewer than 2 shared
|
|
128
|
+
question_ids" or "no rows"; they now name the missing model and list the
|
|
129
|
+
models in the file.
|
|
130
|
+
- Install hints for the optional extras named `errorbars` on PyPI, where it
|
|
131
|
+
isn't published; they now name the dependency or the Git URL.
|
|
132
|
+
|
|
133
|
+
## [0.1.0] - 2026-09-24
|
|
134
|
+
|
|
135
|
+
Initial release.
|
|
136
|
+
|
|
137
|
+
- `summarize`: CLT, Wilson, and bootstrap confidence intervals; clustered
|
|
138
|
+
standard errors with design effect and ICC; within/between-question
|
|
139
|
+
variance decomposition for repeated samples.
|
|
140
|
+
- `compare`: paired mean difference, SE, CI, p-value; correlation and
|
|
141
|
+
variance reduction from pairing; clustered paired SE; exact McNemar test
|
|
142
|
+
for binary scores.
|
|
143
|
+
- `leaderboard`: per-model CIs, Holm-corrected pairwise paired tests,
|
|
144
|
+
maximal-clique grouping of statistically indistinguishable models, SVG and
|
|
145
|
+
(optional) matplotlib forest plots.
|
|
146
|
+
- `power`: questions needed for a target effect/power, and minimum
|
|
147
|
+
detectable effect for a given n, accounting for pairing correlation,
|
|
148
|
+
repeated sampling, and cluster design effect.
|
|
149
|
+
- CLI (`errorbars summarize|compare|leaderboard|power|import`) with `rich`
|
|
150
|
+
tables and `--json` output.
|
|
151
|
+
- Adapters: `errorbars import lm-eval|inspect` converts
|
|
152
|
+
lm-evaluation-harness `--log_samples` JSONL or an Inspect AI `.eval` log
|
|
153
|
+
into the canonical format, verified against real output from lm-eval
|
|
154
|
+
0.4.13 and inspect-ai 0.3.268.
|
|
155
|
+
- Web calculator (Vite + TypeScript) mirroring the Python power formulas,
|
|
156
|
+
with shared JSON test vectors.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: errorbars
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Error bars for LLM evals: standard errors, clustering, paired comparisons, leaderboards, and power analysis.
|
|
5
5
|
Project-URL: Homepage, https://antonsoo.github.io/errorbars/
|
|
6
6
|
Project-URL: Repository, https://github.com/antonsoo/errorbars
|
|
@@ -40,6 +40,7 @@ Description-Content-Type: text/markdown
|
|
|
40
40
|
|
|
41
41
|
**Error bars for LLM evals. Know whether model B is actually better, or you're reading noise.**
|
|
42
42
|
|
|
43
|
+
[](https://pypi.org/project/errorbars/)
|
|
43
44
|
[](https://github.com/antonsoo/errorbars/blob/main/LICENSE)
|
|
44
45
|
[](https://antonsoo.github.io/errorbars/)
|
|
45
46
|
[](https://huggingface.co/spaces/antonsoloviev/errorbars)
|
|
@@ -102,8 +103,11 @@ errorbars leaderboard examples/data/reading_comprehension.csv
|
|
|
102
103
|
and cluster design effect.
|
|
103
104
|
- **CLI** — `errorbars summarize|compare|leaderboard|power|import`, `rich` tables by default,
|
|
104
105
|
`--json` for scripting.
|
|
105
|
-
- **
|
|
106
|
-
|
|
106
|
+
- **Reads what harnesses write** — a harness leaves one log per model, so every command takes
|
|
107
|
+
one or more files or directories and reads each as what it is: lm-evaluation-harness
|
|
108
|
+
`--log_samples` output, Inspect AI `.eval` logs, or the CSV/JSONL format below.
|
|
109
|
+
`errorbars compare out/model-a out/model-b` is the whole comparison (see
|
|
110
|
+
[below](#reading-lm-evaluation-harness-and-inspect-ai-logs)).
|
|
107
111
|
- **Web calculator** — a static "how many eval questions do I need?" power calculator
|
|
108
112
|
([live demo](https://antonsoo.github.io/errorbars/)), whose TypeScript formulas are checked
|
|
109
113
|
against the Python ones by the test suite.
|
|
@@ -178,30 +182,71 @@ Column names are configurable (`--question-col`, `--cluster-col`, etc., or `Colu
|
|
|
178
182
|
Scores can be binary (0/1) or continuous. `cluster_id` groups correlated questions (e.g. several
|
|
179
183
|
questions per reading passage); `sample` marks repeated generations of the same question.
|
|
180
184
|
|
|
181
|
-
|
|
185
|
+
Every command takes several files (`errorbars leaderboard model-a.csv model-b.csv ...`) and puts
|
|
186
|
+
their rows together. The same model, question and sample in two files is refused, as it is within
|
|
187
|
+
one file: counted twice it would inflate n and shrink every error bar.
|
|
182
188
|
|
|
183
|
-
|
|
189
|
+
### Reading lm-evaluation-harness and Inspect AI logs
|
|
190
|
+
|
|
191
|
+
A harness writes one log per model and per task, so "is B better than A" starts from two files.
|
|
192
|
+
`summarize`, `compare` and `leaderboard` read them as they are:
|
|
184
193
|
|
|
185
194
|
```bash
|
|
186
|
-
# lm-evaluation-harness: lm_eval run --model
|
|
187
|
-
|
|
188
|
-
|
|
195
|
+
# lm-evaluation-harness: lm_eval run --model hf --model_args pretrained=<model> --tasks copa \
|
|
196
|
+
# --log_samples --output_path out (one directory per model)
|
|
197
|
+
errorbars compare out/sshleifer__tiny-gpt2 out/hf-internal-testing__tiny-random-gpt2
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
│ n (shared questions) │ 20 │
|
|
202
|
+
│ mean(sshleifer/tiny-gpt2) │ 0.6000 │
|
|
203
|
+
│ mean(hf-internal-testing/tiny-random-gpt2) │ 0.8000 │
|
|
204
|
+
│ mean diff (A - B) │ -0.2000 │
|
|
205
|
+
│ paired SE │ 0.1376 │
|
|
206
|
+
│ 95% CI │ [-0.4881, 0.0881] │
|
|
207
|
+
│ p-value │ 0.1625 │
|
|
208
|
+
│ McNemar discordant (A wrong/B right, A right/B wrong) │ 6 / 2 │
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
That is a real run, committed under `tests/fixtures/lm_eval_output/` (two tiny models, 20 COPA
|
|
212
|
+
questions). lm-eval's own table says 0.6 ± 0.11 and 0.8 ± 0.09; the paired test on the same 20
|
|
213
|
+
answers gives p = 0.16, so the 20-point gap is not evidence yet. (Rows trimmed; the command prints
|
|
214
|
+
a few more.)
|
|
189
215
|
|
|
190
|
-
|
|
191
|
-
errorbars
|
|
216
|
+
```bash
|
|
217
|
+
errorbars leaderboard out # every model under the output directory
|
|
218
|
+
errorbars compare logs/run-a.eval logs/run-b.eval # Inspect AI logs
|
|
219
|
+
errorbars compare greedy=logs/a.eval sampled=logs/b.eval # two runs of one model, told apart
|
|
220
|
+
errorbars import lm-eval out -o all.csv # or write the canonical CSV once and keep it
|
|
192
221
|
```
|
|
193
222
|
|
|
223
|
+
- **lm-eval**: a `samples_<task>_<timestamp>.jsonl` file, a model's directory, or the whole
|
|
224
|
+
`--output_path`. The samples file does not name its model; lm-eval writes it beside a
|
|
225
|
+
`results_<timestamp>.json` that does, and that is where the name comes from. A samples file
|
|
226
|
+
moved away from it has to be named: `my-model=path/to/samples_copa_....jsonl`. When a directory
|
|
227
|
+
holds several runs of a task, the latest is used and a note says so. Question ids are
|
|
228
|
+
`<task>-<doc_id>`, so several tasks of one model add up to one benchmark.
|
|
229
|
+
- **Inspect AI**: `.eval` (or `.json`) logs; the model is the one in the log. Epochs (`--epochs N`,
|
|
230
|
+
repeated sampling of the same input) land in the `sample` column automatically.
|
|
231
|
+
- With exactly two models in the input, `compare` needs no `--model-a`/`--model-b`: A is the first
|
|
232
|
+
one given. When the two were not scored on the same questions (a different `--limit`, a run
|
|
233
|
+
that crashed), the comparison uses the shared ones and reports how many were left out.
|
|
234
|
+
|
|
194
235
|
`--metric` (lm-eval) picks which computed metric to use as the score when a task reports more than
|
|
195
|
-
one (e.g. `acc` vs. `acc_norm`); it defaults to the first one. `--
|
|
196
|
-
for
|
|
197
|
-
|
|
236
|
+
one (e.g. `acc` vs. `acc_norm`); it defaults to the first one. `--filter` (lm-eval) picks one filter
|
|
237
|
+
for a task that scores every question under several: `gsm8k_cot_self_consistency` logs each question
|
|
238
|
+
three times (`score-first`, `maj@8`, `maj@64`), and reading those as three times the questions would
|
|
239
|
+
shrink every error bar, so the import stops and asks. `--scorer` (Inspect) picks one scorer for
|
|
240
|
+
tasks with more than one.
|
|
198
241
|
|
|
199
242
|
Both adapters were built and tested against real, unedited output — not from memory: **lm-eval
|
|
200
|
-
0.4.13** (`lm_eval run --model dummy --tasks copa --limit 20 --log_samples ...`,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
`tests/
|
|
243
|
+
0.4.13** (`lm_eval run --model dummy --tasks copa --limit 20 --log_samples ...`, a multi-metric
|
|
244
|
+
`arc_easy` run, a three-filter `gsm8k_cot_self_consistency` run, and the two-model output directory
|
|
245
|
+
above) and **inspect-ai 0.3.268** (small tasks through the built-in `mockllm/model` provider: single
|
|
246
|
+
epoch, two epochs, and a scorer with named values). The exact log files are committed as test
|
|
247
|
+
fixtures (`tests/fixtures/samples_*.jsonl`, `tests/fixtures/lm_eval_output/`,
|
|
248
|
+
`tests/fixtures/inspect_*.eval`) and re-parsed in `tests/test_adapters.py` and
|
|
249
|
+
`tests/test_inputs.py` on every run. The Inspect adapter reads logs with Inspect's own
|
|
205
250
|
`inspect_ai.log.read_eval_log` and `inspect_ai.scorer.value_to_float` rather than hand-parsing its
|
|
206
251
|
binary `.eval` format, and needs the `inspect` extra:
|
|
207
252
|
`pip install "errorbars[inspect]"`. The lm-eval
|
|
@@ -244,7 +289,7 @@ Full derivations with references are in [`docs/formulas.md`](https://github.com/
|
|
|
244
289
|
- Leaderboard groups are maximal cliques of the "not significantly different" graph, which is the
|
|
245
290
|
statistically direct approach — it can produce a model in more than one group, unlike a
|
|
246
291
|
minimal-letters heuristic (e.g. R's `multcompView`).
|
|
247
|
-
-
|
|
292
|
+
- 222 Python tests, 605 TypeScript tests (cross-checking the JS formulas against Python-generated
|
|
248
293
|
vectors), all passing on this box (14 vCPU WSL2 Linux, 48 GB RAM; Python 3.12.3, Node 26.7.0)
|
|
249
294
|
as of 2026-10-01.
|
|
250
295
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Error bars for LLM evals. Know whether model B is actually better, or you're reading noise.**
|
|
4
4
|
|
|
5
|
+
[](https://pypi.org/project/errorbars/)
|
|
5
6
|
[](LICENSE)
|
|
6
7
|
[](https://antonsoo.github.io/errorbars/)
|
|
7
8
|
[](https://huggingface.co/spaces/antonsoloviev/errorbars)
|
|
@@ -64,8 +65,11 @@ errorbars leaderboard examples/data/reading_comprehension.csv
|
|
|
64
65
|
and cluster design effect.
|
|
65
66
|
- **CLI** — `errorbars summarize|compare|leaderboard|power|import`, `rich` tables by default,
|
|
66
67
|
`--json` for scripting.
|
|
67
|
-
- **
|
|
68
|
-
|
|
68
|
+
- **Reads what harnesses write** — a harness leaves one log per model, so every command takes
|
|
69
|
+
one or more files or directories and reads each as what it is: lm-evaluation-harness
|
|
70
|
+
`--log_samples` output, Inspect AI `.eval` logs, or the CSV/JSONL format below.
|
|
71
|
+
`errorbars compare out/model-a out/model-b` is the whole comparison (see
|
|
72
|
+
[below](#reading-lm-evaluation-harness-and-inspect-ai-logs)).
|
|
69
73
|
- **Web calculator** — a static "how many eval questions do I need?" power calculator
|
|
70
74
|
([live demo](https://antonsoo.github.io/errorbars/)), whose TypeScript formulas are checked
|
|
71
75
|
against the Python ones by the test suite.
|
|
@@ -140,30 +144,71 @@ Column names are configurable (`--question-col`, `--cluster-col`, etc., or `Colu
|
|
|
140
144
|
Scores can be binary (0/1) or continuous. `cluster_id` groups correlated questions (e.g. several
|
|
141
145
|
questions per reading passage); `sample` marks repeated generations of the same question.
|
|
142
146
|
|
|
143
|
-
|
|
147
|
+
Every command takes several files (`errorbars leaderboard model-a.csv model-b.csv ...`) and puts
|
|
148
|
+
their rows together. The same model, question and sample in two files is refused, as it is within
|
|
149
|
+
one file: counted twice it would inflate n and shrink every error bar.
|
|
144
150
|
|
|
145
|
-
|
|
151
|
+
### Reading lm-evaluation-harness and Inspect AI logs
|
|
152
|
+
|
|
153
|
+
A harness writes one log per model and per task, so "is B better than A" starts from two files.
|
|
154
|
+
`summarize`, `compare` and `leaderboard` read them as they are:
|
|
146
155
|
|
|
147
156
|
```bash
|
|
148
|
-
# lm-evaluation-harness: lm_eval run --model
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
# lm-evaluation-harness: lm_eval run --model hf --model_args pretrained=<model> --tasks copa \
|
|
158
|
+
# --log_samples --output_path out (one directory per model)
|
|
159
|
+
errorbars compare out/sshleifer__tiny-gpt2 out/hf-internal-testing__tiny-random-gpt2
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
│ n (shared questions) │ 20 │
|
|
164
|
+
│ mean(sshleifer/tiny-gpt2) │ 0.6000 │
|
|
165
|
+
│ mean(hf-internal-testing/tiny-random-gpt2) │ 0.8000 │
|
|
166
|
+
│ mean diff (A - B) │ -0.2000 │
|
|
167
|
+
│ paired SE │ 0.1376 │
|
|
168
|
+
│ 95% CI │ [-0.4881, 0.0881] │
|
|
169
|
+
│ p-value │ 0.1625 │
|
|
170
|
+
│ McNemar discordant (A wrong/B right, A right/B wrong) │ 6 / 2 │
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
That is a real run, committed under `tests/fixtures/lm_eval_output/` (two tiny models, 20 COPA
|
|
174
|
+
questions). lm-eval's own table says 0.6 ± 0.11 and 0.8 ± 0.09; the paired test on the same 20
|
|
175
|
+
answers gives p = 0.16, so the 20-point gap is not evidence yet. (Rows trimmed; the command prints
|
|
176
|
+
a few more.)
|
|
151
177
|
|
|
152
|
-
|
|
153
|
-
errorbars
|
|
178
|
+
```bash
|
|
179
|
+
errorbars leaderboard out # every model under the output directory
|
|
180
|
+
errorbars compare logs/run-a.eval logs/run-b.eval # Inspect AI logs
|
|
181
|
+
errorbars compare greedy=logs/a.eval sampled=logs/b.eval # two runs of one model, told apart
|
|
182
|
+
errorbars import lm-eval out -o all.csv # or write the canonical CSV once and keep it
|
|
154
183
|
```
|
|
155
184
|
|
|
185
|
+
- **lm-eval**: a `samples_<task>_<timestamp>.jsonl` file, a model's directory, or the whole
|
|
186
|
+
`--output_path`. The samples file does not name its model; lm-eval writes it beside a
|
|
187
|
+
`results_<timestamp>.json` that does, and that is where the name comes from. A samples file
|
|
188
|
+
moved away from it has to be named: `my-model=path/to/samples_copa_....jsonl`. When a directory
|
|
189
|
+
holds several runs of a task, the latest is used and a note says so. Question ids are
|
|
190
|
+
`<task>-<doc_id>`, so several tasks of one model add up to one benchmark.
|
|
191
|
+
- **Inspect AI**: `.eval` (or `.json`) logs; the model is the one in the log. Epochs (`--epochs N`,
|
|
192
|
+
repeated sampling of the same input) land in the `sample` column automatically.
|
|
193
|
+
- With exactly two models in the input, `compare` needs no `--model-a`/`--model-b`: A is the first
|
|
194
|
+
one given. When the two were not scored on the same questions (a different `--limit`, a run
|
|
195
|
+
that crashed), the comparison uses the shared ones and reports how many were left out.
|
|
196
|
+
|
|
156
197
|
`--metric` (lm-eval) picks which computed metric to use as the score when a task reports more than
|
|
157
|
-
one (e.g. `acc` vs. `acc_norm`); it defaults to the first one. `--
|
|
158
|
-
for
|
|
159
|
-
|
|
198
|
+
one (e.g. `acc` vs. `acc_norm`); it defaults to the first one. `--filter` (lm-eval) picks one filter
|
|
199
|
+
for a task that scores every question under several: `gsm8k_cot_self_consistency` logs each question
|
|
200
|
+
three times (`score-first`, `maj@8`, `maj@64`), and reading those as three times the questions would
|
|
201
|
+
shrink every error bar, so the import stops and asks. `--scorer` (Inspect) picks one scorer for
|
|
202
|
+
tasks with more than one.
|
|
160
203
|
|
|
161
204
|
Both adapters were built and tested against real, unedited output — not from memory: **lm-eval
|
|
162
|
-
0.4.13** (`lm_eval run --model dummy --tasks copa --limit 20 --log_samples ...`,
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
`tests/
|
|
205
|
+
0.4.13** (`lm_eval run --model dummy --tasks copa --limit 20 --log_samples ...`, a multi-metric
|
|
206
|
+
`arc_easy` run, a three-filter `gsm8k_cot_self_consistency` run, and the two-model output directory
|
|
207
|
+
above) and **inspect-ai 0.3.268** (small tasks through the built-in `mockllm/model` provider: single
|
|
208
|
+
epoch, two epochs, and a scorer with named values). The exact log files are committed as test
|
|
209
|
+
fixtures (`tests/fixtures/samples_*.jsonl`, `tests/fixtures/lm_eval_output/`,
|
|
210
|
+
`tests/fixtures/inspect_*.eval`) and re-parsed in `tests/test_adapters.py` and
|
|
211
|
+
`tests/test_inputs.py` on every run. The Inspect adapter reads logs with Inspect's own
|
|
167
212
|
`inspect_ai.log.read_eval_log` and `inspect_ai.scorer.value_to_float` rather than hand-parsing its
|
|
168
213
|
binary `.eval` format, and needs the `inspect` extra:
|
|
169
214
|
`pip install "errorbars[inspect]"`. The lm-eval
|
|
@@ -206,7 +251,7 @@ Full derivations with references are in [`docs/formulas.md`](docs/formulas.md):
|
|
|
206
251
|
- Leaderboard groups are maximal cliques of the "not significantly different" graph, which is the
|
|
207
252
|
statistically direct approach — it can produce a model in more than one group, unlike a
|
|
208
253
|
minimal-letters heuristic (e.g. R's `multcompView`).
|
|
209
|
-
-
|
|
254
|
+
- 222 Python tests, 605 TypeScript tests (cross-checking the JS formulas against Python-generated
|
|
210
255
|
vectors), all passing on this box (14 vCPU WSL2 Linux, 48 GB RAM; Python 3.12.3, Node 26.7.0)
|
|
211
256
|
as of 2026-10-01.
|
|
212
257
|
|
|
@@ -32,7 +32,7 @@ include = ["/src", "/docs/*.md", "/README.md", "/CHANGELOG.md", "/LICENSE*", "/p
|
|
|
32
32
|
|
|
33
33
|
[project]
|
|
34
34
|
name = "errorbars"
|
|
35
|
-
version = "0.
|
|
35
|
+
version = "0.2.0"
|
|
36
36
|
description = "Error bars for LLM evals: standard errors, clustering, paired comparisons, leaderboards, and power analysis."
|
|
37
37
|
dynamic = ["readme"]
|
|
38
38
|
license = "MIT"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""errorbars: statistical rigor for LLM eval results."""
|
|
2
2
|
|
|
3
|
+
from errorbars.inputs import load_inputs
|
|
3
4
|
from errorbars.stats import (
|
|
4
5
|
ClusterDiagnostics,
|
|
5
6
|
MeanEstimate,
|
|
@@ -12,10 +13,11 @@ from errorbars.stats import (
|
|
|
12
13
|
within_between_variance,
|
|
13
14
|
)
|
|
14
15
|
|
|
15
|
-
__version__ = "0.
|
|
16
|
+
__version__ = "0.2.0"
|
|
16
17
|
|
|
17
18
|
__all__ = [
|
|
18
19
|
"__version__",
|
|
20
|
+
"load_inputs",
|
|
19
21
|
"MeanEstimate",
|
|
20
22
|
"ClusterDiagnostics",
|
|
21
23
|
"mean_ci_clt",
|
|
@@ -16,6 +16,7 @@ extra: ``pip install "errorbars[inspect]"``.
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
+
import math
|
|
19
20
|
from pathlib import Path
|
|
20
21
|
|
|
21
22
|
from errorbars.io import EvalData
|
|
@@ -44,7 +45,15 @@ def load_inspect_log(path: str | Path, scorer: str | None = None) -> EvalData:
|
|
|
44
45
|
"load_inspect_log requires inspect-ai (the 'inspect' extra): pip install inspect-ai"
|
|
45
46
|
) from exc
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
try:
|
|
49
|
+
log = read_eval_log(str(path))
|
|
50
|
+
except OSError:
|
|
51
|
+
raise
|
|
52
|
+
except Exception as exc:
|
|
53
|
+
# Inspect reports a file it can't parse in its own terms ("EOCD not found", a list of
|
|
54
|
+
# missing fields); say which file, and that the problem is its format.
|
|
55
|
+
reason = str(exc).strip().splitlines()[0] if str(exc).strip() else type(exc).__name__
|
|
56
|
+
raise ValueError(f"{path}: not a log Inspect can read ({reason})") from exc
|
|
48
57
|
if not log.samples:
|
|
49
58
|
raise ValueError(f"{path}: log has no samples (status={log.status!r})")
|
|
50
59
|
|
|
@@ -72,9 +81,20 @@ def load_inspect_log(path: str | Path, scorer: str | None = None) -> EvalData:
|
|
|
72
81
|
f"{path}: sample {s.id!r} has multiple scorers {list(s.scores)}; "
|
|
73
82
|
"pass `scorer=...` to pick one"
|
|
74
83
|
)
|
|
84
|
+
value = s.scores[key].value
|
|
85
|
+
# value_to_float turns anything it can't read into 0.0. A scorer with several named
|
|
86
|
+
# values has no single score to read, so say so instead of reporting a mean of 0.
|
|
87
|
+
if isinstance(value, (dict, list)):
|
|
88
|
+
raise ValueError(
|
|
89
|
+
f"{path}: sample {s.id!r}: scorer {key!r} returns {type(value).__name__} values "
|
|
90
|
+
f"({value!r}), not one score per sample"
|
|
91
|
+
)
|
|
92
|
+
number = float(to_float(value))
|
|
93
|
+
if not math.isfinite(number):
|
|
94
|
+
raise ValueError(f"{path}: sample {s.id!r}: score {value!r} is not a finite number")
|
|
75
95
|
question_id.append(str(s.id))
|
|
76
96
|
model_col.append(model)
|
|
77
|
-
score.append(
|
|
97
|
+
score.append(number)
|
|
78
98
|
sample_col.append(str(s.epoch))
|
|
79
99
|
|
|
80
100
|
if not question_id:
|