margin-referee 0.1.0__tar.gz → 0.1.2__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.
- {margin_referee-0.1.0 → margin_referee-0.1.2}/PKG-INFO +4 -1
- {margin_referee-0.1.0 → margin_referee-0.1.2}/README.md +3 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee/__init__.py +1 -1
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee/cases.py +19 -1
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee/replay.py +8 -3
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee.egg-info/PKG-INFO +4 -1
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee.egg-info/SOURCES.txt +1 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/pyproject.toml +1 -1
- margin_referee-0.1.2/tests/test_cases.py +16 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/tests/test_referee.py +7 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/LICENSE +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee/cli.py +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee/endpoints.py +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee/stats.py +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee.egg-info/dependency_links.txt +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee.egg-info/entry_points.txt +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee.egg-info/requires.txt +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/margin_referee.egg-info/top_level.txt +0 -0
- {margin_referee-0.1.0 → margin_referee-0.1.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: margin-referee
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Should you switch models? Replay your own eval set on a candidate and get a verdict that holds up.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: llm,evals,model-selection,agents,promptfoo,langfuse,braintrust
|
|
@@ -20,6 +20,9 @@ LangSmith or Langfuse dataset export, or JSONL) on the model you run today and o
|
|
|
20
20
|
grades both with each case's own check, and tells you whether the candidate holds up and costs
|
|
21
21
|
less. No account, no backend, no telemetry.
|
|
22
22
|
|
|
23
|
+
Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
|
|
24
|
+
(https://github.com/trymargin/margin-referee).
|
|
25
|
+
|
|
23
26
|
```
|
|
24
27
|
pip install margin-referee
|
|
25
28
|
margin-referee fit cases.jsonl
|
|
@@ -7,6 +7,9 @@ LangSmith or Langfuse dataset export, or JSONL) on the model you run today and o
|
|
|
7
7
|
grades both with each case's own check, and tells you whether the candidate holds up and costs
|
|
8
8
|
less. No account, no backend, no telemetry.
|
|
9
9
|
|
|
10
|
+
Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
|
|
11
|
+
(https://github.com/trymargin/margin-referee).
|
|
12
|
+
|
|
10
13
|
```
|
|
11
14
|
pip install margin-referee
|
|
12
15
|
margin-referee fit cases.jsonl
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""margin-referee: should you switch models? Ask your own eval set."""
|
|
2
|
-
__version__ = "0.1.
|
|
2
|
+
__version__ = "0.1.2"
|
|
@@ -138,7 +138,7 @@ def parse(text: str) -> Parsed:
|
|
|
138
138
|
doc = None
|
|
139
139
|
if isinstance(doc, dict) and "results" in doc:
|
|
140
140
|
_promptfoo(doc, out)
|
|
141
|
-
return out
|
|
141
|
+
return _unique_ids(out)
|
|
142
142
|
rows: Iterable = doc if isinstance(doc, list) else (
|
|
143
143
|
[doc] if isinstance(doc, dict) else _lines(text))
|
|
144
144
|
for i, row in enumerate(rows):
|
|
@@ -146,6 +146,24 @@ def parse(text: str) -> Parsed:
|
|
|
146
146
|
_row(i, row, out)
|
|
147
147
|
else:
|
|
148
148
|
out.ungraded.append((f"case-{i}", "not a JSON object"))
|
|
149
|
+
return _unique_ids(out)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _unique_ids(out: Parsed) -> Parsed:
|
|
153
|
+
"""Cases pair by id, so a repeated id (a promptfoo description used twice, say) would pair
|
|
154
|
+
one case's answers with another's. Repeats get ``#2``, ``#3``; the first keeps its name."""
|
|
155
|
+
from dataclasses import replace
|
|
156
|
+
taken, cases = {c.id for c in out.cases}, []
|
|
157
|
+
used: set[str] = set()
|
|
158
|
+
for c in out.cases:
|
|
159
|
+
name, n = c.id, 1
|
|
160
|
+
# a rename never takes a name already used, or one a later case carries as its own
|
|
161
|
+
while name in used or (name != c.id and name in taken):
|
|
162
|
+
n += 1
|
|
163
|
+
name = f"{c.id}#{n}"
|
|
164
|
+
used.add(name)
|
|
165
|
+
cases.append(c if name == c.id else replace(c, id=name))
|
|
166
|
+
out.cases = cases
|
|
149
167
|
return out
|
|
150
168
|
|
|
151
169
|
|
|
@@ -132,9 +132,14 @@ def verdict(res: Result, candidates: int = 1) -> dict:
|
|
|
132
132
|
why = (f"{len(res.unanswered)} case(s) got no gradable answer" if res.unanswered
|
|
133
133
|
else res.stopped) + ", so the comparison is incomplete"
|
|
134
134
|
elif not pb.supported:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
need = stats.gate_floor(k)
|
|
136
|
+
if n < need and k == 1:
|
|
137
|
+
why = f"{n} cases are too few to prove a switch: it needs about {need}"
|
|
138
|
+
elif n < need:
|
|
139
|
+
why = (f"with {k} models tried on these cases, the best needs about {need}; "
|
|
140
|
+
"confirm it alone on fresh cases")
|
|
141
|
+
else:
|
|
142
|
+
why = f"the quality bound is {pb.upper:.1%} behind, the bar allows {pb.margin:.1%}"
|
|
138
143
|
else:
|
|
139
144
|
why = "the candidate costs more per case: an upgrade, not a saving"
|
|
140
145
|
return {"cases": n, "baseline_passed": int(sum(b for _, b, _ in res.pairs)),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: margin-referee
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Should you switch models? Replay your own eval set on a candidate and get a verdict that holds up.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: llm,evals,model-selection,agents,promptfoo,langfuse,braintrust
|
|
@@ -20,6 +20,9 @@ LangSmith or Langfuse dataset export, or JSONL) on the model you run today and o
|
|
|
20
20
|
grades both with each case's own check, and tells you whether the candidate holds up and costs
|
|
21
21
|
less. No account, no backend, no telemetry.
|
|
22
22
|
|
|
23
|
+
Published on PyPI (https://pypi.org/project/margin-referee/) and GitHub
|
|
24
|
+
(https://github.com/trymargin/margin-referee).
|
|
25
|
+
|
|
23
26
|
```
|
|
24
27
|
pip install margin-referee
|
|
25
28
|
margin-referee fit cases.jsonl
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "margin-referee"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.2"
|
|
8
8
|
description = "Should you switch models? Replay your own eval set on a candidate and get a verdict that holds up."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
def test_a_repeated_case_id_is_made_unique():
|
|
4
|
+
import json
|
|
5
|
+
from margin_referee import cases
|
|
6
|
+
text = "\n".join(json.dumps({"id": i, "input": "q", "expected": "yes"}) for i in "aab")
|
|
7
|
+
assert [c.id for c in cases.parse(text).cases] == ["a", "a#2", "b"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_a_renamed_id_never_collides_with_a_literal_one():
|
|
11
|
+
import json
|
|
12
|
+
from margin_referee import cases
|
|
13
|
+
text = "\n".join(json.dumps({"id": i, "input": "q", "expected": "yes"}) for i in
|
|
14
|
+
["a", "a", "a#2"])
|
|
15
|
+
got = [c.id for c in cases.parse(text).cases]
|
|
16
|
+
assert len(set(got)) == 3 and got[2] == "a#2"
|
|
@@ -71,3 +71,10 @@ def test_fit_reports_ready_or_not(tmp_path, capsys):
|
|
|
71
71
|
assert cli.main(["fit", str(f)]) == 2
|
|
72
72
|
out = json.loads(capsys.readouterr().out)
|
|
73
73
|
assert out["graded"] == 50 and out["needed"] == 111 and not out["ready"]
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_the_reason_fits_the_number_of_candidates():
|
|
77
|
+
res = replay.run(_cases(5), _fake([1] * 5, 0.01), _fake([1] * 5, 0.001), cap_usd=1, workers=1)
|
|
78
|
+
why = replay.verdict(res, 1)["why"]
|
|
79
|
+
assert why == "5 cases are too few to prove a switch: it needs about 100"
|
|
80
|
+
assert "confirm it alone on fresh cases" in replay.verdict(res, 3)["why"]
|
|
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
|