evalpair 0.1.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.
evalpair-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kameswara Sai Srikar Manda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: evalpair
3
+ Version: 0.1.0
4
+ Summary: Run an LLM eval suite against a local or hosted model, cache every call, and compare two runs item by item with bootstrap intervals and a measured noise floor. CLI and MCP server.
5
+ Keywords: llm,evaluation,eval,benchmark,bootstrap,ollama,mcp,cli
6
+ Author: Kameswara Sai Srikar Manda
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Dist: mcp>=2.3,<3
22
+ Requires-Python: >=3.11
23
+ Project-URL: Homepage, https://github.com/Srikarmk/evalpair
24
+ Project-URL: Source, https://github.com/Srikarmk/evalpair
25
+ Project-URL: Issues, https://github.com/Srikarmk/evalpair/issues
26
+ Description-Content-Type: text/markdown
27
+
28
+ # evalpair
29
+
30
+ <!-- mcp-name: io.github.Srikarmk/evalpair -->
31
+
32
+ Run an LLM eval suite against a model, cache every call, and compare two runs item by item: did the new
33
+ model, prompt or quantization actually change anything, or is the difference noise?
34
+
35
+ Most eval tools print two scores side by side. That reads a 2-point gap on 160 questions as a result, when
36
+ it usually isn't one. evalpair pairs the two runs by item, puts a bootstrap interval on the difference, counts
37
+ the items that got worse and better, and can measure a **noise floor**: the same model asked the same
38
+ questions twice. In my own studies the same prompt sent twice at temperature 0 changed up to 3% of answers,
39
+ so an answer-change rate only means something above that.
40
+
41
+ It's a CLI and an MCP server, so an agent can run an eval and read the verdict itself. It only calls the
42
+ model server you point it at, and keeps everything in one local folder.
43
+
44
+ ## Quick start
45
+
46
+ ```bash
47
+ uvx evalpair suites
48
+ uvx evalpair run gsm8k-160 -m llama3.1:8b --repeat --label llama
49
+ uvx evalpair run gsm8k-160 -m qwen3:8b --think off --label qwen3
50
+ uvx evalpair compare llama qwen3
51
+ ```
52
+
53
+ `run` prints the score with a 95% interval and the first failures, unparsed and truncated replies first
54
+ (those are usually the parser's or the token budget's fault, not the model's). `compare` prints both scores,
55
+ the paired difference with its interval, how many items got worse and better, the noise floor, and ends with
56
+ a plain-language verdict: whether the score difference is distinguishable from zero, and whether the answers
57
+ moved more than the same model asked twice.
58
+
59
+ A real comparison: Ollama's default 4-bit Llama 3.1 8B against its 2-bit build, on an M5 Pro laptop
60
+ (`--num-ctx 4096`; about 40 minutes for both runs):
61
+
62
+ ```
63
+ $ evalpair compare llama-q4 llama-q2
64
+ A llama-q4: 84.4% [79.4%, 90.0%]
65
+ B llama-q2: 60.6% [53.1%, 68.1%]
66
+ B − A -23.8 pp [-31.9 pp, -16.2 pp]
67
+ changed 40.6% [33.1%, 48.1%] of 160 items (43 worse in B, 5 better)
68
+ floor (A) 0.0% [0.0%, 0.0%]; excess +40.6 pp [+33.1 pp, +48.1 pp]
69
+
70
+ B scores lower than A: -23.8 pp [-31.9 pp, -16.2 pp], paired over 160 items. Answers changed on 40.6% of
71
+ items (43 got worse, 5 better). The noise floor (the same model asked twice) is 0.0% for A, so the change
72
+ is beyond noise.
73
+ worse in b: gsm8k-0259 '168' → '52'
74
+ ...
75
+ ```
76
+
77
+ Both scores are the ones the quantization study measured for these builds on the same items.
78
+
79
+ Interrupt a run and run it again: every reply is cached, so it picks up where it stopped.
80
+
81
+ ## As an MCP server
82
+
83
+ ```bash
84
+ claude mcp add evalpair -- uvx evalpair mcp
85
+ ```
86
+
87
+ or in any MCP client's config: `{"command": "uvx", "args": ["evalpair", "mcp"]}`.
88
+
89
+ | Tool | What it does |
90
+ |---|---|
91
+ | `list_suites` | Suites you can run: name, item count, checker, what it measures |
92
+ | `run_eval` | Run a suite against one model and save the run (calls the model; cached replies are reused) |
93
+ | `list_runs` | Saved runs, newest first |
94
+ | `show_run` | A run's score with its interval, its noise floor, and the end of failed replies |
95
+ | `compare_runs` | Two runs paired by item: difference with an interval, flips each way, change vs. noise floor, examples |
96
+
97
+ Everything except `run_eval` only reads saved runs.
98
+
99
+ ## Backends
100
+
101
+ - **Ollama** (default): `--backend ollama`, server at `http://localhost:11434`. The run records the model's
102
+ digest, so you can tell later exactly which build was tested. `--think on|off` for models that think,
103
+ `--num-ctx` for the context window.
104
+ - **Any OpenAI-compatible server**: `--backend openai --base-url http://localhost:8000/v1` for vLLM,
105
+ llama.cpp's server or LM Studio, or a hosted API. A bearer token is read from `EVALPAIR_API_KEY` (or
106
+ `OPENAI_API_KEY`) and never written to disk.
107
+
108
+ Temperature defaults to 0 and the seed to 7. Both are part of the cache key, along with the server URL,
109
+ model, messages, token budget and thinking setting.
110
+
111
+ ## Suites
112
+
113
+ Three are bundled. They're the item sets from my Measuring LLM Systems studies, with those studies' prompts
114
+ word for word, so a run can be checked against the published numbers:
115
+
116
+ | Suite | Items | Checker | Source |
117
+ |---|---|---|---|
118
+ | `gsm8k-160` | 160 | `number` | GSM8K test (MIT) |
119
+ | `mmlu-hs-160` | 160 | `choice`, stratified by subject | MMLU, four high-school subjects (MIT) |
120
+ | `e2e-extract-150` | 150 | `json_fields` | E2E NLG restaurant records (CC BY-SA 4.0) |
121
+
122
+ To make your own, create a folder with two files, in `~/.evalpair/suites/<name>/` or anywhere you then pass
123
+ by path:
124
+
125
+ ```toml
126
+ # suite.toml
127
+ description = "Capitals, answered in one word"
128
+ checker = "exact"
129
+ max_tokens = 64
130
+ system = "Answer in one word." # optional
131
+ user = "What is the capital of {country}?"
132
+ group = "region" # optional: stratify the bootstrap by this item field
133
+ ```
134
+
135
+ ```jsonl
136
+ {"id": "fr", "country": "France", "region": "Europe", "gold": "Paris"}
137
+ {"id": "pe", "country": "Peru", "region": "Americas", "gold": ["Lima", "Ciudad de los Reyes"]}
138
+ ```
139
+
140
+ `{field}` in a prompt is filled from the item; a list of strings becomes lettered options (`A. …`), anything
141
+ else is shown as indented JSON. Use `{{` and `}}` for literal braces.
142
+
143
+ | Checker | Scores | Gold |
144
+ |---|---|---|
145
+ | `number` | the number after "Answer:", else `\boxed{}`, else the last number | a number |
146
+ | `choice` | the letter after "Answer:", with fallbacks (letters set by `checker_options.letters`) | a letter |
147
+ | `exact` | the text after "Answer:", or the last line, normalised | a string or list of strings |
148
+ | `contains` | whether a gold string appears as whole words | a string or list |
149
+ | `regex` | the last match of `checker_options.pattern` (first group) | a string or list |
150
+ | `json_fields` | the share of the gold object's fields the reply's JSON gets right (null must be null) | an object |
151
+
152
+ Checkers are deterministic code: no LLM grades another LLM here. The `number`, `choice` and `json_fields`
153
+ parsers come from the studies, and re-scoring all 9,870 replies from the quantization study's main run with them gives
154
+ the study's own scores on every one (`scripts/check_against_studies.py`).
155
+
156
+ ## How the numbers are computed
157
+
158
+ - **Unit of resampling: the item.** 2,000 bootstrap draws, percentile intervals, seeded, so the same runs
159
+ always give the same interval. With a `group`, items are resampled within each group.
160
+ - **Comparisons are paired** over the items both runs answered, using the first pass of each. If the two
161
+ runs used different versions of a suite (the hash of its spec and items differs), the comparison says so.
162
+ - **Noise floor**: with `--repeat`, every item is sent a second time as a separate call (its own cache entry).
163
+ The floor is the share of items whose parsed answer changed between the passes. A comparison calls a change
164
+ "beyond noise" only if, per item, (changed between runs) minus (changed between the passes) has an interval
165
+ above zero for every run that has a floor.
166
+ - Items are taken in file order, so `--limit 50` is the same 50 items every time and limited runs still pair up.
167
+
168
+ ## Where things live
169
+
170
+ `$EVALPAIR_HOME`, or `~/.evalpair`:
171
+
172
+ ```
173
+ cache.sqlite every reply, keyed by request
174
+ runs/<run>/meta.json suite and its hash, model, digest, backend, options, counts, timings
175
+ runs/<run>/rows.jsonl one line per item and pass: reply, parsed answer, score, tokens
176
+ suites/<name>/ your suites
177
+ ```
178
+
179
+ ## Limits
180
+
181
+ - One model per run, chat-style prompts, one turn. No tool use, multi-turn or constrained decoding yet.
182
+ - Deterministic checkers only, so open-ended answers need a suite whose answer can be checked by code.
183
+ - The noise floor measures run-to-run variation on the same server. It doesn't cover a different
184
+ machine or a server update.
185
+
186
+ ## License
187
+
188
+ MIT for the code. The bundled suites keep their sources' licenses (MIT for GSM8K and MMLU, CC BY-SA 4.0 for
189
+ E2E NLG); each `suite.toml` names its license and source.
@@ -0,0 +1,162 @@
1
+ # evalpair
2
+
3
+ <!-- mcp-name: io.github.Srikarmk/evalpair -->
4
+
5
+ Run an LLM eval suite against a model, cache every call, and compare two runs item by item: did the new
6
+ model, prompt or quantization actually change anything, or is the difference noise?
7
+
8
+ Most eval tools print two scores side by side. That reads a 2-point gap on 160 questions as a result, when
9
+ it usually isn't one. evalpair pairs the two runs by item, puts a bootstrap interval on the difference, counts
10
+ the items that got worse and better, and can measure a **noise floor**: the same model asked the same
11
+ questions twice. In my own studies the same prompt sent twice at temperature 0 changed up to 3% of answers,
12
+ so an answer-change rate only means something above that.
13
+
14
+ It's a CLI and an MCP server, so an agent can run an eval and read the verdict itself. It only calls the
15
+ model server you point it at, and keeps everything in one local folder.
16
+
17
+ ## Quick start
18
+
19
+ ```bash
20
+ uvx evalpair suites
21
+ uvx evalpair run gsm8k-160 -m llama3.1:8b --repeat --label llama
22
+ uvx evalpair run gsm8k-160 -m qwen3:8b --think off --label qwen3
23
+ uvx evalpair compare llama qwen3
24
+ ```
25
+
26
+ `run` prints the score with a 95% interval and the first failures, unparsed and truncated replies first
27
+ (those are usually the parser's or the token budget's fault, not the model's). `compare` prints both scores,
28
+ the paired difference with its interval, how many items got worse and better, the noise floor, and ends with
29
+ a plain-language verdict: whether the score difference is distinguishable from zero, and whether the answers
30
+ moved more than the same model asked twice.
31
+
32
+ A real comparison: Ollama's default 4-bit Llama 3.1 8B against its 2-bit build, on an M5 Pro laptop
33
+ (`--num-ctx 4096`; about 40 minutes for both runs):
34
+
35
+ ```
36
+ $ evalpair compare llama-q4 llama-q2
37
+ A llama-q4: 84.4% [79.4%, 90.0%]
38
+ B llama-q2: 60.6% [53.1%, 68.1%]
39
+ B − A -23.8 pp [-31.9 pp, -16.2 pp]
40
+ changed 40.6% [33.1%, 48.1%] of 160 items (43 worse in B, 5 better)
41
+ floor (A) 0.0% [0.0%, 0.0%]; excess +40.6 pp [+33.1 pp, +48.1 pp]
42
+
43
+ B scores lower than A: -23.8 pp [-31.9 pp, -16.2 pp], paired over 160 items. Answers changed on 40.6% of
44
+ items (43 got worse, 5 better). The noise floor (the same model asked twice) is 0.0% for A, so the change
45
+ is beyond noise.
46
+ worse in b: gsm8k-0259 '168' → '52'
47
+ ...
48
+ ```
49
+
50
+ Both scores are the ones the quantization study measured for these builds on the same items.
51
+
52
+ Interrupt a run and run it again: every reply is cached, so it picks up where it stopped.
53
+
54
+ ## As an MCP server
55
+
56
+ ```bash
57
+ claude mcp add evalpair -- uvx evalpair mcp
58
+ ```
59
+
60
+ or in any MCP client's config: `{"command": "uvx", "args": ["evalpair", "mcp"]}`.
61
+
62
+ | Tool | What it does |
63
+ |---|---|
64
+ | `list_suites` | Suites you can run: name, item count, checker, what it measures |
65
+ | `run_eval` | Run a suite against one model and save the run (calls the model; cached replies are reused) |
66
+ | `list_runs` | Saved runs, newest first |
67
+ | `show_run` | A run's score with its interval, its noise floor, and the end of failed replies |
68
+ | `compare_runs` | Two runs paired by item: difference with an interval, flips each way, change vs. noise floor, examples |
69
+
70
+ Everything except `run_eval` only reads saved runs.
71
+
72
+ ## Backends
73
+
74
+ - **Ollama** (default): `--backend ollama`, server at `http://localhost:11434`. The run records the model's
75
+ digest, so you can tell later exactly which build was tested. `--think on|off` for models that think,
76
+ `--num-ctx` for the context window.
77
+ - **Any OpenAI-compatible server**: `--backend openai --base-url http://localhost:8000/v1` for vLLM,
78
+ llama.cpp's server or LM Studio, or a hosted API. A bearer token is read from `EVALPAIR_API_KEY` (or
79
+ `OPENAI_API_KEY`) and never written to disk.
80
+
81
+ Temperature defaults to 0 and the seed to 7. Both are part of the cache key, along with the server URL,
82
+ model, messages, token budget and thinking setting.
83
+
84
+ ## Suites
85
+
86
+ Three are bundled. They're the item sets from my Measuring LLM Systems studies, with those studies' prompts
87
+ word for word, so a run can be checked against the published numbers:
88
+
89
+ | Suite | Items | Checker | Source |
90
+ |---|---|---|---|
91
+ | `gsm8k-160` | 160 | `number` | GSM8K test (MIT) |
92
+ | `mmlu-hs-160` | 160 | `choice`, stratified by subject | MMLU, four high-school subjects (MIT) |
93
+ | `e2e-extract-150` | 150 | `json_fields` | E2E NLG restaurant records (CC BY-SA 4.0) |
94
+
95
+ To make your own, create a folder with two files, in `~/.evalpair/suites/<name>/` or anywhere you then pass
96
+ by path:
97
+
98
+ ```toml
99
+ # suite.toml
100
+ description = "Capitals, answered in one word"
101
+ checker = "exact"
102
+ max_tokens = 64
103
+ system = "Answer in one word." # optional
104
+ user = "What is the capital of {country}?"
105
+ group = "region" # optional: stratify the bootstrap by this item field
106
+ ```
107
+
108
+ ```jsonl
109
+ {"id": "fr", "country": "France", "region": "Europe", "gold": "Paris"}
110
+ {"id": "pe", "country": "Peru", "region": "Americas", "gold": ["Lima", "Ciudad de los Reyes"]}
111
+ ```
112
+
113
+ `{field}` in a prompt is filled from the item; a list of strings becomes lettered options (`A. …`), anything
114
+ else is shown as indented JSON. Use `{{` and `}}` for literal braces.
115
+
116
+ | Checker | Scores | Gold |
117
+ |---|---|---|
118
+ | `number` | the number after "Answer:", else `\boxed{}`, else the last number | a number |
119
+ | `choice` | the letter after "Answer:", with fallbacks (letters set by `checker_options.letters`) | a letter |
120
+ | `exact` | the text after "Answer:", or the last line, normalised | a string or list of strings |
121
+ | `contains` | whether a gold string appears as whole words | a string or list |
122
+ | `regex` | the last match of `checker_options.pattern` (first group) | a string or list |
123
+ | `json_fields` | the share of the gold object's fields the reply's JSON gets right (null must be null) | an object |
124
+
125
+ Checkers are deterministic code: no LLM grades another LLM here. The `number`, `choice` and `json_fields`
126
+ parsers come from the studies, and re-scoring all 9,870 replies from the quantization study's main run with them gives
127
+ the study's own scores on every one (`scripts/check_against_studies.py`).
128
+
129
+ ## How the numbers are computed
130
+
131
+ - **Unit of resampling: the item.** 2,000 bootstrap draws, percentile intervals, seeded, so the same runs
132
+ always give the same interval. With a `group`, items are resampled within each group.
133
+ - **Comparisons are paired** over the items both runs answered, using the first pass of each. If the two
134
+ runs used different versions of a suite (the hash of its spec and items differs), the comparison says so.
135
+ - **Noise floor**: with `--repeat`, every item is sent a second time as a separate call (its own cache entry).
136
+ The floor is the share of items whose parsed answer changed between the passes. A comparison calls a change
137
+ "beyond noise" only if, per item, (changed between runs) minus (changed between the passes) has an interval
138
+ above zero for every run that has a floor.
139
+ - Items are taken in file order, so `--limit 50` is the same 50 items every time and limited runs still pair up.
140
+
141
+ ## Where things live
142
+
143
+ `$EVALPAIR_HOME`, or `~/.evalpair`:
144
+
145
+ ```
146
+ cache.sqlite every reply, keyed by request
147
+ runs/<run>/meta.json suite and its hash, model, digest, backend, options, counts, timings
148
+ runs/<run>/rows.jsonl one line per item and pass: reply, parsed answer, score, tokens
149
+ suites/<name>/ your suites
150
+ ```
151
+
152
+ ## Limits
153
+
154
+ - One model per run, chat-style prompts, one turn. No tool use, multi-turn or constrained decoding yet.
155
+ - Deterministic checkers only, so open-ended answers need a suite whose answer can be checked by code.
156
+ - The noise floor measures run-to-run variation on the same server. It doesn't cover a different
157
+ machine or a server update.
158
+
159
+ ## License
160
+
161
+ MIT for the code. The bundled suites keep their sources' licenses (MIT for GSM8K and MMLU, CC BY-SA 4.0 for
162
+ E2E NLG); each `suite.toml` names its license and source.
@@ -0,0 +1,60 @@
1
+ [project]
2
+ name = "evalpair"
3
+ version = "0.1.0"
4
+ description = "Run an LLM eval suite against a local or hosted model, cache every call, and compare two runs item by item with bootstrap intervals and a measured noise floor. CLI and MCP server."
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ keywords = [
10
+ "llm",
11
+ "evaluation",
12
+ "eval",
13
+ "benchmark",
14
+ "bootstrap",
15
+ "ollama",
16
+ "mcp",
17
+ "cli",
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Environment :: Console",
22
+ "Intended Audience :: Developers",
23
+ "Intended Audience :: Science/Research",
24
+ "Operating System :: OS Independent",
25
+ "Programming Language :: Python :: 3",
26
+ "Programming Language :: Python :: 3 :: Only",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Programming Language :: Python :: 3.14",
31
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
32
+ ]
33
+ dependencies = ["mcp>=2.3,<3"]
34
+
35
+ [[project.authors]]
36
+ name = "Kameswara Sai Srikar Manda"
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/Srikarmk/evalpair"
40
+ Source = "https://github.com/Srikarmk/evalpair"
41
+ Issues = "https://github.com/Srikarmk/evalpair/issues"
42
+
43
+ [project.scripts]
44
+ evalpair = "evalpair.cli:main"
45
+
46
+ [dependency-groups]
47
+ dev = [
48
+ "pytest>=8",
49
+ "anyio>=4",
50
+ ]
51
+
52
+ [build-system]
53
+ requires = ["uv_build>=0.9,<0.14"]
54
+ build-backend = "uv_build"
55
+
56
+ [tool.pytest.ini_options]
57
+ testpaths = ["tests"]
58
+
59
+ [tool.ruff]
60
+ line-length = 120
@@ -0,0 +1,46 @@
1
+ [project]
2
+ name = "evalpair"
3
+ version = "0.1.0"
4
+ description = "Run an LLM eval suite against a local or hosted model, cache every call, and compare two runs item by item with bootstrap intervals and a measured noise floor. CLI and MCP server."
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "Kameswara Sai Srikar Manda" }]
10
+ keywords = ["llm", "evaluation", "eval", "benchmark", "bootstrap", "ollama", "mcp", "cli"]
11
+ classifiers = [
12
+ "Development Status :: 3 - Alpha",
13
+ "Environment :: Console",
14
+ "Intended Audience :: Developers",
15
+ "Intended Audience :: Science/Research",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Python :: 3.14",
23
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
24
+ ]
25
+ dependencies = ["mcp>=2.3,<3"]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/Srikarmk/evalpair"
29
+ Source = "https://github.com/Srikarmk/evalpair"
30
+ Issues = "https://github.com/Srikarmk/evalpair/issues"
31
+
32
+ [project.scripts]
33
+ evalpair = "evalpair.cli:main"
34
+
35
+ [dependency-groups]
36
+ dev = ["pytest>=8", "anyio>=4"]
37
+
38
+ [build-system]
39
+ requires = ["uv_build>=0.9,<0.14"]
40
+ build-backend = "uv_build"
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
44
+
45
+ [tool.ruff]
46
+ line-length = 120
@@ -0,0 +1,3 @@
1
+ """Run an LLM eval suite, cache every call, and compare two runs item by item with intervals."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
@@ -0,0 +1,141 @@
1
+ """Summaries of one run and comparisons of two, built from saved rows only (no model calls).
2
+
3
+ A comparison pairs the two runs by item id over the items both answered (first pass). It reports the
4
+ score difference with a paired bootstrap interval, how many items flipped each way, how often the answer
5
+ changed at all, and, when a run was made with a repeat pass, that run's own answer-change rate: the noise
6
+ floor. A change rate between two runs only means something above the floor.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from .stats import excludes_zero, mean, mean_ci
12
+
13
+ EXCERPT = 400
14
+
15
+
16
+ def _pp(x: float) -> str:
17
+ return f"{100 * x:+.1f} pp"
18
+
19
+
20
+ def _pc(x: float) -> str:
21
+ return f"{100 * x:.1f}%"
22
+
23
+
24
+ def _ci(ci: dict, pct=_pc) -> dict:
25
+ return {**{k: round(v, 4) for k, v in ci.items() if k != "n"}, "n": ci["n"],
26
+ "text": f"{pct(ci['mean'])} [{pct(ci['lo'])}, {pct(ci['hi'])}]" if ci["n"] else "no items"}
27
+
28
+
29
+ def by_pass(rows: list[dict], p: int) -> dict[str, dict]:
30
+ return {r["id"]: r for r in rows if r["pass"] == p}
31
+
32
+
33
+ def excerpt(text: str, n: int = EXCERPT) -> str:
34
+ text = text or ""
35
+ return text if len(text) <= n else "…" + text[-n:]
36
+
37
+
38
+ def noise_floor(rows: list[dict]) -> dict | None:
39
+ """Share of items whose parsed answer changed between pass 1 and the repeat pass, and the score
40
+ change between them. None if the run had no repeat."""
41
+ a, b = by_pass(rows, 1), by_pass(rows, 2)
42
+ ids = [i for i in a if i in b]
43
+ if not ids:
44
+ return None
45
+ changed = [float(a[i]["answer"] != b[i]["answer"]) for i in ids]
46
+ groups = [a[i]["group"] for i in ids]
47
+ return {"items": len(ids), "answers_changed": int(sum(changed)),
48
+ "change_rate": _ci(mean_ci(changed, groups)),
49
+ "score_change": _ci(mean_ci([b[i]["score"] - a[i]["score"] for i in ids], groups), _pp)}
50
+
51
+
52
+ def summarize(meta: dict, rows: list[dict], failures: int = 5) -> dict:
53
+ first = list(by_pass(rows, 1).values())
54
+ groups = [r["group"] for r in first]
55
+ wrong = [r for r in first if r["score"] < 1]
56
+ out = {
57
+ "run": meta["run"], "suite": meta["suite"], "model": meta["model"], "backend": meta["backend"],
58
+ "items": len(first), "score": _ci(mean_ci([r["score"] for r in first], groups)),
59
+ "no_answer": sum(r["answer"] is None for r in first), "truncated": sum(r["truncated"] for r in first),
60
+ "mean_output_tokens": round(mean(r["output_tokens"] for r in first), 1),
61
+ "noise_floor": noise_floor(rows),
62
+ "calls": meta.get("calls"), "cache_hits": meta.get("cache_hits"), "finished": meta.get("finished"),
63
+ }
64
+ if any(r["group"] is not None for r in first):
65
+ per = {}
66
+ for g in sorted({r["group"] for r in first}, key=str):
67
+ rs = [r for r in first if r["group"] == g]
68
+ per[str(g)] = {"items": len(rs), "score": round(mean(r["score"] for r in rs), 4)}
69
+ out["by_group"] = per
70
+ # unparsed and truncated replies first: they are usually the checker's or the budget's fault, not the model's
71
+ wrong.sort(key=lambda r: (r["answer"] is not None, not r["truncated"], r["id"]))
72
+ out["failures"] = [{"id": r["id"], "answer": r["answer"], "score": r["score"], "how": r["how"],
73
+ "truncated": r["truncated"], "reply_end": excerpt(r["text"])} for r in wrong[:failures]]
74
+ return out
75
+
76
+
77
+ def compare(meta_a: dict, rows_a: list[dict], meta_b: dict, rows_b: list[dict], examples: int = 5) -> dict:
78
+ a, b = by_pass(rows_a, 1), by_pass(rows_b, 1)
79
+ ids = [i for i in a if i in b]
80
+ notes = []
81
+ if meta_a.get("suite_hash") != meta_b.get("suite_hash"):
82
+ notes.append("The two runs used different versions of the suite (prompt, checker or items differ); "
83
+ "only items with the same id are paired, and a difference may come from the suite.")
84
+ only = len(a) - len(ids), len(b) - len(ids)
85
+ if any(only):
86
+ notes.append(f"Paired on the {len(ids)} items both runs answered ({only[0]} only in A, {only[1]} only in B).")
87
+ if not ids:
88
+ return {"a": meta_a["run"], "b": meta_b["run"], "items": 0, "notes": notes + ["No items in common."]}
89
+ groups = [a[i]["group"] for i in ids]
90
+ sa, sb = [a[i]["score"] for i in ids], [b[i]["score"] for i in ids]
91
+ diff = mean_ci([y - x for x, y in zip(sa, sb)], groups)
92
+ worse = [i for i in ids if b[i]["score"] < a[i]["score"]]
93
+ better = [i for i in ids if b[i]["score"] > a[i]["score"]]
94
+ changed = [float(a[i]["answer"] != b[i]["answer"]) for i in ids]
95
+ out = {
96
+ "a": {"run": meta_a["run"], "model": meta_a["model"], "score": _ci(mean_ci(sa, groups))},
97
+ "b": {"run": meta_b["run"], "model": meta_b["model"], "score": _ci(mean_ci(sb, groups))},
98
+ "items": len(ids),
99
+ "difference": _ci(diff, _pp),
100
+ "worse_in_b": len(worse), "better_in_b": len(better),
101
+ "answers_changed": _ci(mean_ci(changed, groups)),
102
+ }
103
+ floors = {}
104
+ for name, rows in (("a", rows_a), ("b", rows_b)):
105
+ rep, p1 = by_pass(rows, 2), by_pass(rows, 1)
106
+ common = [i for i in ids if i in rep]
107
+ if common:
108
+ # per item: changed between the runs, minus changed between this run's own two passes
109
+ excess = [float(a[i]["answer"] != b[i]["answer"]) - float(p1[i]["answer"] != rep[i]["answer"])
110
+ for i in common]
111
+ floors[name] = {"items": len(common),
112
+ "change_rate": _ci(mean_ci([float(p1[i]["answer"] != rep[i]["answer"]) for i in common],
113
+ [a[i]["group"] for i in common])),
114
+ "excess_over_floor": _ci(mean_ci(excess, [a[i]["group"] for i in common]), _pp)}
115
+ out["noise_floor"] = floors or None
116
+ if excludes_zero(diff):
117
+ verdict = (f"B scores {'higher' if diff['mean'] > 0 else 'lower'} than A: "
118
+ f"{_pp(diff['mean'])} [{_pp(diff['lo'])}, {_pp(diff['hi'])}], paired over {len(ids)} items.")
119
+ else:
120
+ verdict = (f"No clear difference in score: {_pp(diff['mean'])} [{_pp(diff['lo'])}, {_pp(diff['hi'])}], "
121
+ f"an interval that includes zero, over {len(ids)} items.")
122
+ ch = out["answers_changed"]
123
+ verdict += f" Answers changed on {_pc(ch['mean'])} of items ({len(worse)} got worse, {len(better)} better)."
124
+ if floors:
125
+ # beyond noise only if it clears every floor measured, so a quiet run can't hide a noisy one
126
+ beyond = all(f["excess_over_floor"]["lo"] > 0 for f in floors.values())
127
+ rates = " and ".join(f"{_pc(f['change_rate']['mean'])} for {k.upper()}" for k, f in floors.items())
128
+ verdict += (f" The noise floor (the same model asked twice) is {rates}, so "
129
+ + ("the change is beyond noise." if beyond else "the change is not clearly beyond noise."))
130
+ else:
131
+ verdict += " Neither run has a repeat pass, so there is no noise floor to compare against (run with repeat)."
132
+ out["verdict"] = verdict
133
+ out["notes"] = notes
134
+
135
+ def ex_rows(ids_):
136
+ return [{"id": i, "a_answer": a[i]["answer"], "b_answer": b[i]["answer"],
137
+ "a_score": a[i]["score"], "b_score": b[i]["score"],
138
+ "a_reply_end": excerpt(a[i]["text"], 240), "b_reply_end": excerpt(b[i]["text"], 240)}
139
+ for i in ids_[:examples]]
140
+ out["examples"] = {"worse_in_b": ex_rows(worse), "better_in_b": ex_rows(better)}
141
+ return out