Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

test(eval): pin the partly judged counts of a judge-down stop, and say it in the data guide (#1522) (#1648)

Yang Bai110fdb708433
diff --git a/docs/data.md b/docs/data.md
index 0fef5f97..200624e4 100644
--- a/docs/data.md
+++ b/docs/data.md
@@ -1047,7 +1047,7 @@ soup data from-traces \
--min-confidence 0.7
```
-The judge scores `chosen` and `rejected` independently against its rubric (default helpfulness/accuracy/safety on a 1-5 scale). Pairs whose normalised `(chosen - rejected)` confidence falls below `--min-confidence` are dropped. Per-pair backend exceptions are counted (not crashed) and reported. Provider allowlist `{openai, server, ollama}` validated at the CLI boundary; SSRF protection on `--judge-api-base` carries over from `soup eval judge`.
+The judge scores `chosen` and `rejected` independently against its rubric (default helpfulness/accuracy/safety on a 1-5 scale). Pairs whose normalised `(chosen - rejected)` confidence falls below `--min-confidence` are dropped. Per-pair backend exceptions are counted (not crashed) and reported. A judge that stops answering is not counted that way: once 3 requests in a row have spent their retries unanswered, the command stops with exit 1, names the judge and how many pairs were not judged, and writes no output file (#1522). Provider allowlist `{openai, server, ollama}` validated at the CLI boundary; SSRF protection on `--judge-api-base` carries over from `soup eval judge`.
## Synthetic Data Forge
diff --git a/tests/test_issue1522_judge_down.py b/tests/test_issue1522_judge_down.py
index a057ad41..a3e8bf23 100644
--- a/tests/test_issue1522_judge_down.py
+++ b/tests/test_issue1522_judge_down.py
@@ -301,6 +301,25 @@ class TestPairFilter:
assert JUDGE_BASE in str(excinfo.value)
assert "1000 of 1000 pairs not judged" in str(excinfo.value)
+ def test_the_count_leaves_out_the_pairs_already_judged(self, evaluator, no_sleep):
+ from soup_cli.data.traces.quality import judge_filter_pairs
+
+ def scored(value):
+ content = json.dumps({
+ "scores": {"helpfulness": value, "accuracy": value, "safety": value},
+ "reasoning": "ok",
+ })
+ return _reply(200, {"choices": [{"message": {"content": content}}]})
+
+ # Pair 1 is kept (chosen 5, rejected 1), pairs 2-4 are dropped (a tie
+ # is below the 0.7 default), then nothing answers.
+ steps = [scored(5), scored(1)] + [_reply(200, SCORED)] * 6
+ with mock.patch("httpx.post", side_effect=_script(*steps)):
+ with pytest.raises(JudgeDownError) as excinfo:
+ judge_filter_pairs(self._pairs(10), judge=evaluator)
+
+ assert "6 of 10 pairs not judged" in str(excinfo.value)
+
def test_one_failing_pair_is_still_only_counted(self, evaluator, no_sleep):
from soup_cli.data.traces.quality import judge_filter_pairs
@@ -410,3 +429,29 @@ class TestBestOfNCli:
assert "http://localhost:11434/v1/chat/completions" in out
assert "4 of 4 prompts not judged" in out
assert "--resume" in out
+
+ def test_the_count_leaves_out_the_prompts_already_done(self, tmp_path, monkeypatch, no_sleep):
+ from soup_cli.commands.data import app
+
+ monkeypatch.chdir(tmp_path)
+ (tmp_path / "prompts.jsonl").write_text(
+ "".join(json.dumps({"prompt": f"prompt {i}"}) + "\n" for i in range(4)),
+ encoding="utf-8",
+ )
+ monkeypatch.setattr(
+ "soup_cli.utils.magpie.make_magpie_generate_fn",
+ lambda *a, **k: (lambda prompt: "a candidate"),
+ )
+ # The first prompt's three candidates are scored, then nothing answers.
+ steps = [_reply(200, SCORED)] * 3
+ with mock.patch("httpx.post", side_effect=_script(*steps)):
+ result = CliRunner().invoke(
+ app,
+ ["best-of-n", "--provider", "ollama", "--model", "sampler",
+ "--prompts", "prompts.jsonl", "--n", "3", "--judge", "ollama://judge",
+ "--output", "sft.jsonl"],
+ )
+ out = " ".join(strip_ansi(result.output).split())
+ assert result.exit_code == 1, (out, repr(result.exception))
+ assert "3 of 4 prompts not judged" in out
+ assert "stopped after 1/4 prompts" in out