Datasets:
ToolUse.1: benchmark corpus, harness and specification
Browse files- SPEC.md +8 -0
- tooluse1/harness.py +3 -2
- tooluse1/runners.py +25 -0
SPEC.md
CHANGED
|
@@ -144,6 +144,14 @@ protocols, no few-shot examples, thinking/reasoning mode disabled by the runtime
|
|
| 144 |
model supports it. `--resume` continues an interrupted run; `selftest` proves the grader agrees
|
| 145 |
with the corpus before any model is loaded (oracle-style runners must score exactly 1.000).
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
Local runs may pass `--batch-size N` to evaluate N prompts in one padded `generate` call. Greedy
|
| 148 |
decoding is unchanged by batching in theory but not bit-identical in practice (kernel reduction
|
| 149 |
orders differ), so a borderline case can flip; report the batch size with the number, and use
|
|
|
|
| 144 |
model supports it. `--resume` continues an interrupted run; `selftest` proves the grader agrees
|
| 145 |
with the corpus before any model is loaded (oracle-style runners must score exactly 1.000).
|
| 146 |
|
| 147 |
+
Decoding stops on every identifier a checkpoint declares for the end of a turn — the tokenizer
|
| 148 |
+
`eos_token`, the generation config `eos_token_id`, and the model config `eos_token_id`, as a
|
| 149 |
+
set. Qwen-style checkpoints routinely carry two of them (`<|im_end|>` closes the message, a
|
| 150 |
+
pre-training `<|endoftext|>` sits in the model config), and stopping on only one of the pair
|
| 151 |
+
makes a correct single call run to `max_new_tokens` and repeat itself, which the grader then
|
| 152 |
+
scores as several calls in one turn. Stopping on the union measures the model instead of its
|
| 153 |
+
tokenizer bookkeeping.
|
| 154 |
+
|
| 155 |
Local runs may pass `--batch-size N` to evaluate N prompts in one padded `generate` call. Greedy
|
| 156 |
decoding is unchanged by batching in theory but not bit-identical in practice (kernel reduction
|
| 157 |
orders differ), so a borderline case can flip; report the batch size with the number, and use
|
tooluse1/harness.py
CHANGED
|
@@ -132,7 +132,7 @@ def _cmd_run(args: argparse.Namespace) -> int:
|
|
| 132 |
)
|
| 133 |
out_dir = Path(args.out)
|
| 134 |
out_dir.mkdir(parents=True, exist_ok=True)
|
| 135 |
-
stem = f"{slugify(args.model or args.backend)}__{args.protocol}"
|
| 136 |
|
| 137 |
existing = _dedupe(_load_results(out_dir / f"{stem}.json")) if args.resume else []
|
| 138 |
done = {(result.case_id, result.protocol) for result in existing}
|
|
@@ -165,7 +165,7 @@ def _cmd_run(args: argparse.Namespace) -> int:
|
|
| 165 |
def snapshot(partial: bool) -> dict[str, Any]:
|
| 166 |
results = _dedupe(collected)
|
| 167 |
results.sort(key=lambda item: (item.protocol, item.case_id))
|
| 168 |
-
report = build_report(results, model_id=runner.name if args.model else args.backend, protocol=args.protocol)
|
| 169 |
if args.notes:
|
| 170 |
report["notes"] = args.notes
|
| 171 |
report["partial"] = partial
|
|
@@ -299,6 +299,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
| 299 |
help="evaluations per generate call (local backends; 8-16 saturates a small GPU)",
|
| 300 |
)
|
| 301 |
run_parser.add_argument("--out", default=str(RESULTS_DIR))
|
|
|
|
| 302 |
run_parser.add_argument("--notes", default="")
|
| 303 |
run_parser.add_argument("--resume", action="store_true")
|
| 304 |
run_parser.add_argument("--thinking", action="store_true", help="do not disable the model's reasoning mode")
|
|
|
|
| 132 |
)
|
| 133 |
out_dir = Path(args.out)
|
| 134 |
out_dir.mkdir(parents=True, exist_ok=True)
|
| 135 |
+
stem = f"{slugify(args.name or args.model or args.backend)}__{args.protocol}"
|
| 136 |
|
| 137 |
existing = _dedupe(_load_results(out_dir / f"{stem}.json")) if args.resume else []
|
| 138 |
done = {(result.case_id, result.protocol) for result in existing}
|
|
|
|
| 165 |
def snapshot(partial: bool) -> dict[str, Any]:
|
| 166 |
results = _dedupe(collected)
|
| 167 |
results.sort(key=lambda item: (item.protocol, item.case_id))
|
| 168 |
+
report = build_report(results, model_id=args.name or (runner.name if args.model else args.backend), protocol=args.protocol)
|
| 169 |
if args.notes:
|
| 170 |
report["notes"] = args.notes
|
| 171 |
report["partial"] = partial
|
|
|
|
| 299 |
help="evaluations per generate call (local backends; 8-16 saturates a small GPU)",
|
| 300 |
)
|
| 301 |
run_parser.add_argument("--out", default=str(RESULTS_DIR))
|
| 302 |
+
run_parser.add_argument("--name", default="", help="human-readable run label; overrides the model path in the results file and filename")
|
| 303 |
run_parser.add_argument("--notes", default="")
|
| 304 |
run_parser.add_argument("--resume", action="store_true")
|
| 305 |
run_parser.add_argument("--thinking", action="store_true", help="do not disable the model's reasoning mode")
|
tooluse1/runners.py
CHANGED
|
@@ -209,6 +209,7 @@ class TransformersRunner(Runner):
|
|
| 209 |
self.tokenizer.pad_token = self.tokenizer.eos_token
|
| 210 |
self.model, self.load_info = _load_model(model_id, dtype, device_map, trust_remote_code, revision)
|
| 211 |
self.model.eval()
|
|
|
|
| 212 |
|
| 213 |
def _render(self, messages: Sequence[Mapping[str, str]]) -> str:
|
| 214 |
kwargs: dict[str, Any] = {"tokenize": False, "add_generation_prompt": True}
|
|
@@ -251,6 +252,7 @@ class TransformersRunner(Runner):
|
|
| 251 |
max_new_tokens=self.max_new_tokens,
|
| 252 |
do_sample=False,
|
| 253 |
pad_token_id=self.tokenizer.pad_token_id or self.tokenizer.eos_token_id,
|
|
|
|
| 254 |
)
|
| 255 |
return [self.tokenizer.decode(row[input_length:], skip_special_tokens=True) for row in generated]
|
| 256 |
|
|
@@ -300,6 +302,29 @@ def _core_missing(missing: Sequence[str]) -> list[str]:
|
|
| 300 |
return [key for key in missing if not any(token in key for token in _IGNORABLE_MISSING)]
|
| 301 |
|
| 302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
def _load_model(
|
| 304 |
model_id: str,
|
| 305 |
dtype: str,
|
|
|
|
| 209 |
self.tokenizer.pad_token = self.tokenizer.eos_token
|
| 210 |
self.model, self.load_info = _load_model(model_id, dtype, device_map, trust_remote_code, revision)
|
| 211 |
self.model.eval()
|
| 212 |
+
self._eos_ids = _end_of_turn_ids(self.model, self.tokenizer)
|
| 213 |
|
| 214 |
def _render(self, messages: Sequence[Mapping[str, str]]) -> str:
|
| 215 |
kwargs: dict[str, Any] = {"tokenize": False, "add_generation_prompt": True}
|
|
|
|
| 252 |
max_new_tokens=self.max_new_tokens,
|
| 253 |
do_sample=False,
|
| 254 |
pad_token_id=self.tokenizer.pad_token_id or self.tokenizer.eos_token_id,
|
| 255 |
+
eos_token_id=self._eos_ids,
|
| 256 |
)
|
| 257 |
return [self.tokenizer.decode(row[input_length:], skip_special_tokens=True) for row in generated]
|
| 258 |
|
|
|
|
| 302 |
return [key for key in missing if not any(token in key for token in _IGNORABLE_MISSING)]
|
| 303 |
|
| 304 |
|
| 305 |
+
def _end_of_turn_ids(model: Any, tokenizer: Any) -> list[int]:
|
| 306 |
+
"""Every token that legitimately ends an assistant turn.
|
| 307 |
+
|
| 308 |
+
Chat checkpoints ship two of them: `<|im_end|>` closes the message, while the
|
| 309 |
+
model configuration frequently keeps a pre-training `<|endoftext|>` as the
|
| 310 |
+
single `eos_token_id`. Stopping on only one of the two makes an otherwise
|
| 311 |
+
correct answer run to `max_new_tokens` and emit the same call over and over,
|
| 312 |
+
which the grader then scores as several calls in one turn. The union is what
|
| 313 |
+
the template actually means, so that is what decoding stops on.
|
| 314 |
+
"""
|
| 315 |
+
ids: set[int] = set()
|
| 316 |
+
for source in (
|
| 317 |
+
getattr(tokenizer, "eos_token_id", None),
|
| 318 |
+
getattr(getattr(model, "generation_config", None), "eos_token_id", None),
|
| 319 |
+
getattr(getattr(model, "config", None), "eos_token_id", None),
|
| 320 |
+
):
|
| 321 |
+
if isinstance(source, int):
|
| 322 |
+
ids.add(source)
|
| 323 |
+
elif isinstance(source, (list, tuple)):
|
| 324 |
+
ids.update(int(value) for value in source if isinstance(value, int))
|
| 325 |
+
return sorted(ids)
|
| 326 |
+
|
| 327 |
+
|
| 328 |
def _load_model(
|
| 329 |
model_id: str,
|
| 330 |
dtype: str,
|