errorbars 0.2.1__tar.gz → 0.2.3__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.1 → errorbars-0.2.3}/.gitignore +1 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/CHANGELOG.md +51 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/PKG-INFO +35 -29
- {errorbars-0.2.1 → errorbars-0.2.3}/README.md +32 -28
- {errorbars-0.2.1 → errorbars-0.2.3}/pyproject.toml +4 -2
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/__init__.py +1 -1
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/adapters/lm_eval.py +2 -2
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/cli.py +18 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/inputs.py +1 -1
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/io.py +58 -11
- {errorbars-0.2.1 → errorbars-0.2.3}/LICENSE +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/docs/formulas.md +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/_tables.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/adapters/__init__.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/adapters/inspect_ai.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/compare.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/leaderboard.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/plot.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/power.py +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/py.typed +0 -0
- {errorbars-0.2.1 → errorbars-0.2.3}/src/errorbars/stats.py +0 -0
|
@@ -2,6 +2,57 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.2.3] - 2026-10-03
|
|
6
|
+
|
|
7
|
+
### Compatibility
|
|
8
|
+
|
|
9
|
+
- Python 3.13 and 3.14 are tested and declared. CI runs the suite on 3.14
|
|
10
|
+
as well, and the package's classifiers list both versions. The code is
|
|
11
|
+
unchanged: with the newest release of every dependency, the tests pass on
|
|
12
|
+
3.14 and on 3.15's release candidate.
|
|
13
|
+
|
|
14
|
+
The rest of this release is in the web demo; the package is otherwise
|
|
15
|
+
unchanged.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- The page's fonts are served by the page itself. They came from Google Fonts,
|
|
20
|
+
the one request the page made to another origin; the same font files (every
|
|
21
|
+
subset, as Google serves them to a current browser) are now in
|
|
22
|
+
`web/src/fonts/`, with their SIL Open Font License texts. Nothing looks
|
|
23
|
+
different: screenshots before and after match. The page now loads with
|
|
24
|
+
every other host blocked.
|
|
25
|
+
|
|
26
|
+
### Security
|
|
27
|
+
|
|
28
|
+
- The built page carries a Content-Security-Policy. Scripts, styles, fonts and
|
|
29
|
+
workers load from the page's own origin only, and `connect-src 'self'` has
|
|
30
|
+
the browser refuse to send what you give the page to any other host, even
|
|
31
|
+
for a script injected through a bug in how the page renders a file. Inline
|
|
32
|
+
event handlers and `eval` are not allowed. Every control was exercised
|
|
33
|
+
in Chromium and Firefox with a listener for policy violations: none.
|
|
34
|
+
|
|
35
|
+
## [0.2.2] - 2026-10-02
|
|
36
|
+
|
|
37
|
+
Files and pipes as Windows and spreadsheets make them.
|
|
38
|
+
|
|
39
|
+
### Fixed
|
|
40
|
+
|
|
41
|
+
- A CSV saved from a spreadsheet. Excel's "CSV UTF-8" starts with a byte-order
|
|
42
|
+
mark, which became part of the first column's name: "missing required column
|
|
43
|
+
'question_id' in row 1" for a file that has it. A spreadsheet in a locale
|
|
44
|
+
whose decimal mark is the comma writes semicolons between the fields and
|
|
45
|
+
`0,75` for a score, which failed the same way. The mark is skipped, the
|
|
46
|
+
delimiter (comma, semicolon or tab) is the one that splits the header into
|
|
47
|
+
the required columns, and decimal commas are read when the delimiter is not
|
|
48
|
+
the comma.
|
|
49
|
+
- That error now lists the columns the file does have.
|
|
50
|
+
- Output written to a pipe or a file is UTF-8. Before 3.15, Python on Windows
|
|
51
|
+
gives a redirected stdout the system's code page, so
|
|
52
|
+
`errorbars leaderboard scores.csv > table.txt` with a model name outside it
|
|
53
|
+
stopped with "'charmap' codec can't encode characters". (Reproduced on Linux
|
|
54
|
+
by giving the pipe cp1252 with `PYTHONIOENCODING`; the test does the same.)
|
|
55
|
+
|
|
5
56
|
## [0.2.1] - 2026-10-02
|
|
6
57
|
|
|
7
58
|
What the table commands print, checked the way their output is read: after `pip install
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: errorbars
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
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
|
|
@@ -16,6 +16,8 @@ Classifier: Programming Language :: Python :: 3
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
21
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
22
|
Classifier: Typing :: Typed
|
|
21
23
|
Requires-Python: >=3.10
|
|
@@ -123,26 +125,23 @@ errorbars summarize examples/data/reading_comprehension.csv --model tuned-70b
|
|
|
123
125
|
```
|
|
124
126
|
|
|
125
127
|
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
│ clustered SE │ 0.0372 │
|
|
144
|
-
│ clustered CI │ [0.6148, 0.7652] │
|
|
145
|
-
└───────────────┴──────────────────┘
|
|
128
|
+
summarize: tuned-70b
|
|
129
|
+
metric value
|
|
130
|
+
------ ----------------
|
|
131
|
+
n 200
|
|
132
|
+
mean 0.6900
|
|
133
|
+
SE 0.0328
|
|
134
|
+
95% CI [0.6257, 0.7543]
|
|
135
|
+
method clt
|
|
136
|
+
|
|
137
|
+
clustering diagnostics
|
|
138
|
+
metric value
|
|
139
|
+
------------- ----------------
|
|
140
|
+
n clusters 40
|
|
141
|
+
ICC 0.0710
|
|
142
|
+
design effect 1.284
|
|
143
|
+
clustered SE 0.0372
|
|
144
|
+
clustered CI [0.6148, 0.7652]
|
|
146
145
|
```
|
|
147
146
|
|
|
148
147
|
```bash
|
|
@@ -200,14 +199,21 @@ errorbars compare out/sshleifer__tiny-gpt2 out/hf-internal-testing__tiny-random-
|
|
|
200
199
|
```
|
|
201
200
|
|
|
202
201
|
```
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
202
|
+
compare: sshleifer/tiny-gpt2 vs hf-internal-testing/tiny-random-gpt2
|
|
203
|
+
metric value
|
|
204
|
+
----------------------------------------------------- -----------------
|
|
205
|
+
n (shared questions) 20
|
|
206
|
+
mean(sshleifer/tiny-gpt2) 0.6000
|
|
207
|
+
mean(hf-internal-testing/tiny-random-gpt2) 0.8000
|
|
208
|
+
mean diff (A - B) -0.2000
|
|
209
|
+
paired SE 0.1376
|
|
210
|
+
95% CI [-0.4881, 0.0881]
|
|
211
|
+
p-value 0.1625
|
|
212
|
+
correlation(A, B) 0.1021
|
|
213
|
+
unpaired SE (for reference) 0.1451
|
|
214
|
+
variance reduction from pairing 10.0%
|
|
215
|
+
McNemar discordant (A wrong/B right, A right/B wrong) 6 / 2
|
|
216
|
+
McNemar exact p-value 0.2891
|
|
211
217
|
```
|
|
212
218
|
|
|
213
219
|
That is a real run, committed under `tests/fixtures/lm_eval_output/` (two tiny models, 20 COPA
|
|
@@ -85,26 +85,23 @@ errorbars summarize examples/data/reading_comprehension.csv --model tuned-70b
|
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
```
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
│ clustered SE │ 0.0372 │
|
|
106
|
-
│ clustered CI │ [0.6148, 0.7652] │
|
|
107
|
-
└───────────────┴──────────────────┘
|
|
88
|
+
summarize: tuned-70b
|
|
89
|
+
metric value
|
|
90
|
+
------ ----------------
|
|
91
|
+
n 200
|
|
92
|
+
mean 0.6900
|
|
93
|
+
SE 0.0328
|
|
94
|
+
95% CI [0.6257, 0.7543]
|
|
95
|
+
method clt
|
|
96
|
+
|
|
97
|
+
clustering diagnostics
|
|
98
|
+
metric value
|
|
99
|
+
------------- ----------------
|
|
100
|
+
n clusters 40
|
|
101
|
+
ICC 0.0710
|
|
102
|
+
design effect 1.284
|
|
103
|
+
clustered SE 0.0372
|
|
104
|
+
clustered CI [0.6148, 0.7652]
|
|
108
105
|
```
|
|
109
106
|
|
|
110
107
|
```bash
|
|
@@ -162,14 +159,21 @@ errorbars compare out/sshleifer__tiny-gpt2 out/hf-internal-testing__tiny-random-
|
|
|
162
159
|
```
|
|
163
160
|
|
|
164
161
|
```
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
162
|
+
compare: sshleifer/tiny-gpt2 vs hf-internal-testing/tiny-random-gpt2
|
|
163
|
+
metric value
|
|
164
|
+
----------------------------------------------------- -----------------
|
|
165
|
+
n (shared questions) 20
|
|
166
|
+
mean(sshleifer/tiny-gpt2) 0.6000
|
|
167
|
+
mean(hf-internal-testing/tiny-random-gpt2) 0.8000
|
|
168
|
+
mean diff (A - B) -0.2000
|
|
169
|
+
paired SE 0.1376
|
|
170
|
+
95% CI [-0.4881, 0.0881]
|
|
171
|
+
p-value 0.1625
|
|
172
|
+
correlation(A, B) 0.1021
|
|
173
|
+
unpaired SE (for reference) 0.1451
|
|
174
|
+
variance reduction from pairing 10.0%
|
|
175
|
+
McNemar discordant (A wrong/B right, A right/B wrong) 6 / 2
|
|
176
|
+
McNemar exact p-value 0.2891
|
|
173
177
|
```
|
|
174
178
|
|
|
175
179
|
That is a real run, committed under `tests/fixtures/lm_eval_output/` (two tiny models, 20 COPA
|
|
@@ -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.2.
|
|
35
|
+
version = "0.2.3"
|
|
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"
|
|
@@ -54,6 +54,8 @@ classifiers = [
|
|
|
54
54
|
"Programming Language :: Python :: 3.10",
|
|
55
55
|
"Programming Language :: Python :: 3.11",
|
|
56
56
|
"Programming Language :: Python :: 3.12",
|
|
57
|
+
"Programming Language :: Python :: 3.13",
|
|
58
|
+
"Programming Language :: Python :: 3.14",
|
|
57
59
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
58
60
|
"Typing :: Typed",
|
|
59
61
|
]
|
|
@@ -88,7 +90,7 @@ packages = ["src/errorbars"]
|
|
|
88
90
|
|
|
89
91
|
[dependency-groups]
|
|
90
92
|
dev = [
|
|
91
|
-
"pytest>=
|
|
93
|
+
"pytest>=9.0.3",
|
|
92
94
|
"pytest-cov>=5.0",
|
|
93
95
|
"ruff>=0.6",
|
|
94
96
|
"mypy>=1.10",
|
|
@@ -91,7 +91,7 @@ def infer_model_name(path: str | Path) -> str | None:
|
|
|
91
91
|
candidates = others
|
|
92
92
|
for candidate in candidates:
|
|
93
93
|
try:
|
|
94
|
-
with open(candidate, encoding="utf-8") as f:
|
|
94
|
+
with open(candidate, encoding="utf-8-sig") as f:
|
|
95
95
|
results = json.load(f)
|
|
96
96
|
except (OSError, ValueError):
|
|
97
97
|
continue
|
|
@@ -137,7 +137,7 @@ def load_lm_eval_samples(
|
|
|
137
137
|
|
|
138
138
|
records: list[tuple[int, dict[str, object]]] = []
|
|
139
139
|
filters: dict[str, None] = {} # in order of first appearance
|
|
140
|
-
with open(path, encoding="utf-8") as f:
|
|
140
|
+
with open(path, encoding="utf-8-sig") as f:
|
|
141
141
|
for lineno, raw_line in enumerate(f, start=1):
|
|
142
142
|
line = raw_line.strip()
|
|
143
143
|
if not line:
|
|
@@ -476,9 +476,27 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
476
476
|
return parser
|
|
477
477
|
|
|
478
478
|
|
|
479
|
+
def _text_streams() -> None:
|
|
480
|
+
"""Make stdout and stderr able to carry any text.
|
|
481
|
+
|
|
482
|
+
A pipe or a file gets UTF-8: before 3.15, Python on Windows gives it the system's code
|
|
483
|
+
page, where a model name outside it raised ``UnicodeEncodeError``. A terminal keeps its own encoding
|
|
484
|
+
and shows a character it cannot encode as an escape.
|
|
485
|
+
"""
|
|
486
|
+
for stream in (sys.stdout, sys.stderr):
|
|
487
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
488
|
+
if reconfigure is None: # replaced by something that isn't a text file
|
|
489
|
+
continue
|
|
490
|
+
if stream.isatty():
|
|
491
|
+
reconfigure(errors="backslashreplace")
|
|
492
|
+
else:
|
|
493
|
+
reconfigure(encoding="utf-8")
|
|
494
|
+
|
|
495
|
+
|
|
479
496
|
def main(argv: list[str] | None = None) -> None:
|
|
480
497
|
parser = build_parser()
|
|
481
498
|
args = parser.parse_args(argv)
|
|
499
|
+
_text_streams()
|
|
482
500
|
try:
|
|
483
501
|
args.func(args)
|
|
484
502
|
except UnicodeDecodeError as exc:
|
|
@@ -11,6 +11,7 @@ from __future__ import annotations
|
|
|
11
11
|
import csv
|
|
12
12
|
import json
|
|
13
13
|
import math
|
|
14
|
+
import re
|
|
14
15
|
from collections.abc import Iterable
|
|
15
16
|
from dataclasses import dataclass, field
|
|
16
17
|
from pathlib import Path
|
|
@@ -166,6 +167,14 @@ def _label(row: Any, column: str, n: int) -> str:
|
|
|
166
167
|
return str(value)
|
|
167
168
|
|
|
168
169
|
|
|
170
|
+
def _names(row: dict[str, Any]) -> str:
|
|
171
|
+
"""A row's field names for an error message: the first ten, each cut to a readable length."""
|
|
172
|
+
names = [str(name) for name in row]
|
|
173
|
+
shown = [name if len(name) <= 40 else name[:39] + "\u2026" for name in names[:10]]
|
|
174
|
+
more = f", and {len(names) - 10} more" if len(names) > 10 else ""
|
|
175
|
+
return (", ".join(shown) + more) or "no fields"
|
|
176
|
+
|
|
177
|
+
|
|
169
178
|
def _from_records(records: Iterable[dict[str, Any]], columns: ColumnMap) -> EvalData:
|
|
170
179
|
question_id: list[str] = []
|
|
171
180
|
model: list[str] = []
|
|
@@ -184,12 +193,11 @@ def _from_records(records: Iterable[dict[str, Any]], columns: ColumnMap) -> Eval
|
|
|
184
193
|
raise ValueError(
|
|
185
194
|
f"row {n}: more fields than the header has columns (an unquoted comma in a value?)"
|
|
186
195
|
)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
raise ValueError(f"missing required column '{columns.score}' in row {n}")
|
|
196
|
+
for required in (columns.question_id, columns.model, columns.score):
|
|
197
|
+
if required not in row:
|
|
198
|
+
raise ValueError(
|
|
199
|
+
f"missing required column '{required}' in row {n} (it has: {_names(row)})"
|
|
200
|
+
)
|
|
193
201
|
question_id.append(_label(row, columns.question_id, n))
|
|
194
202
|
model.append(_label(row, columns.model, n))
|
|
195
203
|
score.append(_coerce_score(row[columns.score], n))
|
|
@@ -214,21 +222,60 @@ def _from_records(records: Iterable[dict[str, Any]], columns: ColumnMap) -> Eval
|
|
|
214
222
|
return EvalData(question_id, model, score, cluster_id, sample, columns)
|
|
215
223
|
|
|
216
224
|
|
|
225
|
+
def _delimiter(header: str, columns: ColumnMap) -> str:
|
|
226
|
+
"""The delimiter the header was written with.
|
|
227
|
+
|
|
228
|
+
A spreadsheet saves "CSV" with the list separator of its locale: a semicolon wherever the
|
|
229
|
+
decimal mark is a comma (most of Europe), sometimes a tab. The header settles it: the
|
|
230
|
+
delimiter is the one that splits it into the columns being looked for.
|
|
231
|
+
"""
|
|
232
|
+
wanted = {columns.question_id, columns.model, columns.score}
|
|
233
|
+
for delimiter in (",", ";", "\t"):
|
|
234
|
+
names = {name.strip() for name in next(csv.reader([header], delimiter=delimiter), [])}
|
|
235
|
+
if wanted <= names:
|
|
236
|
+
return delimiter
|
|
237
|
+
return ","
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
_DECIMAL_COMMA = re.compile(r"[+-]?\d+,\d+(?:[eE][+-]?\d+)?")
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _decimal_commas(records: Iterable[dict[str, Any]], score: str) -> Iterable[dict[str, Any]]:
|
|
244
|
+
"""Scores written ``0,75`` in a file whose delimiter is not the comma."""
|
|
245
|
+
for row in records:
|
|
246
|
+
value = row.get(score)
|
|
247
|
+
if isinstance(value, str) and _DECIMAL_COMMA.fullmatch(value.strip()):
|
|
248
|
+
row[score] = value.strip().replace(",", ".")
|
|
249
|
+
yield row
|
|
250
|
+
|
|
251
|
+
|
|
217
252
|
def load_csv(path: str | Path, columns: ColumnMap | None = None) -> EvalData:
|
|
218
|
-
"""Load per-item scores from a CSV file.
|
|
253
|
+
"""Load per-item scores from a CSV file.
|
|
254
|
+
|
|
255
|
+
Read as a spreadsheet writes it too: with a byte-order mark ("CSV UTF-8" in Excel), with
|
|
256
|
+
semicolons or tabs between the fields, and with decimal commas when the delimiter is not
|
|
257
|
+
the comma.
|
|
258
|
+
"""
|
|
219
259
|
columns = columns or ColumnMap()
|
|
220
|
-
with open(path, newline="", encoding="utf-8") as f:
|
|
221
|
-
|
|
260
|
+
with open(path, newline="", encoding="utf-8-sig") as f:
|
|
261
|
+
header = f.readline()
|
|
262
|
+
f.seek(0)
|
|
263
|
+
delimiter = _delimiter(header, columns)
|
|
264
|
+
reader = csv.DictReader(f, delimiter=delimiter)
|
|
222
265
|
if reader.fieldnames is None:
|
|
223
266
|
raise ValueError(f"{path}: empty or headerless CSV")
|
|
224
|
-
|
|
267
|
+
reader.fieldnames = [name.strip() for name in reader.fieldnames]
|
|
268
|
+
records: Iterable[dict[str, Any]] = reader
|
|
269
|
+
if delimiter != ",":
|
|
270
|
+
records = _decimal_commas(reader, columns.score)
|
|
271
|
+
return _from_records(records, columns)
|
|
225
272
|
|
|
226
273
|
|
|
227
274
|
def load_jsonl(path: str | Path, columns: ColumnMap | None = None) -> EvalData:
|
|
228
275
|
"""Load per-item scores from a JSON Lines file (one record per line)."""
|
|
229
276
|
columns = columns or ColumnMap()
|
|
230
277
|
records: list[dict[str, Any]] = []
|
|
231
|
-
with open(path, encoding="utf-8") as f:
|
|
278
|
+
with open(path, encoding="utf-8-sig") as f:
|
|
232
279
|
for lineno, line in enumerate(f, start=1):
|
|
233
280
|
line = line.strip()
|
|
234
281
|
if not line:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|