Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
fix(eval): withhold credit for malformed tool arguments (#1737)
Tal2d8d4ee71549
diff --git a/changelog.d/0.75.1/1737.fixed.md b/changelog.d/0.75.1/1737.fixed.mdnew file mode 100644index 00000000..f7daa5a0--- /dev/null+++ b/changelog.d/0.75.1/1737.fixed.md@@ -0,0 +1,4 @@+- **Custom tool-call subset scoring: do not credit malformed provided arguments.**+ Values that fail to parse as a JSON object no longer earn empty-argument+ credit. Valid empty objects, omitted arguments, weights and the match threshold+ keep their existing treatment. (#1734 by @taljeon in #1737)diff --git a/src/soup_cli/eval/custom.py b/src/soup_cli/eval/custom.pyindex f01ff070..655892b1 100644--- a/src/soup_cli/eval/custom.py+++ b/src/soup_cli/eval/custom.py@@ -302,10 +302,13 @@ def tool_call_args_subset(output: str, expected: str) -> float:name_score = 0.5 if out_func.get("name") == exp_func.get("name") else 0.0- out_args = _parse_args(out_func) or {}+ raw_out_args = _parse_args(out_func)+ out_args = raw_out_args or {}exp_args = _parse_args(exp_func) or {}- if not exp_args:+ if raw_out_args is None and "arguments" in out_func:+ args_score = 0.0+ elif not exp_args:# No args expected: full credit only if the model also produced none.# Hallucinated args must NOT score full (the old `0.5 if ... else 0.5`# dead ternary gave them full credit).diff --git a/tests/test_issue1734_tool_args_credit.py b/tests/test_issue1734_tool_args_credit.pynew file mode 100644index 00000000..b7b045d8--- /dev/null+++ b/tests/test_issue1734_tool_args_credit.py@@ -0,0 +1,61 @@+"""Keep parse failures distinct from empty tool arguments (#1734)."""++import json++import pytest++from soup_cli.eval.custom import EvalTask, score_task, tool_call_args_subset++BAD_ARGUMENTS = ["not-json", "[]", "null", [], None, 17]+++def call(arguments, name="lookup"):+ return json.dumps({"function": {"name": name, "arguments": arguments}})++[email protected]("arguments", BAD_ARGUMENTS)[email protected]("gold_arguments", [{}, {"query": "synthetic"}])+def test_provided_malformed_arguments_earn_no_argument_credit(arguments, gold_arguments):+ assert tool_call_args_subset(call(arguments), call(gold_arguments)) == 0.5++[email protected]("arguments", [{}, "{}"])+def test_valid_empty_arguments_keep_full_credit(arguments):+ assert tool_call_args_subset(call(arguments), call({})) == 1.0+++def test_extra_arguments_against_empty_gold_keep_only_name_credit():+ assert tool_call_args_subset(call({"extra": 1}), call({})) == 0.5+++def test_valid_expected_subset_keeps_full_credit():+ assert tool_call_args_subset(+ call({"query": "synthetic", "limit": 2}), call({"query": "synthetic"}),+ ) == 1.0++[email protected]("gold_arguments, score", [({}, 1.0), ({"query": "synthetic"}, 0.5)])+def test_omitted_arguments_keep_the_existing_treatment(gold_arguments, score):+ output = json.dumps({"function": {"name": "lookup"}})+ assert tool_call_args_subset(output, call(gold_arguments)) == score+++def test_malformed_gold_handling_is_unchanged():+ assert tool_call_args_subset(call({}), call("not-json")) == 1.0+++def test_score_task_keeps_the_half_credit_match_threshold():+ result = score_task(+ EvalTask(prompt="Synthetic question", expected=call({}), scoring="tool_call_args_subset"),+ call("not-json"),+ )+ assert result.score == 0.5+ assert result.matched is True # The existing >= 0.5 threshold is a separate contract.+++def test_invalid_arguments_cannot_add_credit_to_a_wrong_name():+ assert tool_call_args_subset(call("not-json", name="other"), call({})) == 0.0+++def test_empty_arguments_with_wrong_name_keep_only_argument_credit():+ assert tool_call_args_subset(call({}, name="other"), call({})) == 0.5