Datasets:
|
Download README.md from SamJoshua/chat-template-toolcall-bench: direct link, hf CLI and curl.
- Browser
- Download file 7.12 kB
-
https://huggingface.co/datasets/SamJoshua/chat-template-toolcall-bench/resolve/main/README.md
- Command line
-
hf download hf://datasets/SamJoshua/chat-template-toolcall-bench/README.md
-
curl -L -o README.md https://huggingface.co/datasets/SamJoshua/chat-template-toolcall-bench/resolve/main/README.md
7.12 kB
| license: apache-2.0 | |
| pretty_name: CTT-Bench (Chat Template Tool-Call Bench) | |
| language: | |
| - en | |
| task_categories: | |
| - text-generation | |
| tags: | |
| - tool-calling | |
| - function-calling | |
| - chat-template | |
| - agents | |
| - llm-security | |
| - evaluation | |
| - reliability | |
| size_categories: | |
| - n<1K | |
| configs: | |
| - config_name: cases | |
| data_files: | |
| - split: test | |
| path: data/cases.parquet | |
| - config_name: results | |
| data_files: | |
| - split: leaderboard_2026_11_16 | |
| path: data/results.parquet | |
| # CTT-Bench: Chat Template Tool-Call Bench | |
| **v1.0** · 10 cases · results for 41 popular Hub models · measured 16 Nov 2026 with `transformers 5.22.2` | |
| CTT-Bench checks whether a model's **chat template** can render tool calls through `tokenizer.apply_chat_template` without crashing, corrupting arguments, or pasting an unescaped tool name into the prompt. It tests the template, not the model. Every case is a short weather-tool conversation, so a failure points at one thing: the shape of the input. | |
| Headline from the leaderboard run: of the 40 templates that render the documented dict format, **31 crash** when `tool_calls[].function.arguments` is a JSON string (the OpenAI format), 5 refuse it with a clear error, 1 silently double-encodes it, and only 3 handle it. **All 40 paste a quote-containing tool name verbatim.** No template passes all 10 cases. | |
| - **Check any model yourself:** [Chat Template Checker Space](https://huggingface.co/spaces/SamJoshua/chat-template-checker) | |
| - **Leaderboard:** https://samjoshua-chat-template-toolcall-leaderboard.static.hf.space/ | |
| - **Write-up:** https://samjoshua-chat-template-toolcall-leaderboard.static.hf.space/article.html | |
| ## Configs | |
| ### `cases` (split `test`, 10 rows) | |
| | Column | Meaning | | |
| | --- | --- | | |
| | `id`, `index`, `name`, `short` | Case id (`C1_dict_args` … `C10_name_escape`), order, title, short key | | |
| | `what_it_tests` | Plain description of the case | | |
| | `arguments_format` | `dict`, `json_string` (ASCII-escaped) or `json_string_raw` (raw UTF-8) | | |
| | `messages_json` | The conversation, as a JSON string (user → assistant with `tool_calls` → tool result) | | |
| | `tools_json` | The tool schemas passed as `tools=`, as a JSON string | | |
| | `expected_behavior`, `pass_if` | What a correct template does, and the exact pass rule | | |
| | `failure_modes` | The statuses this case can produce | | |
| | `expect_markers`, `raw_name_needle`, `kind` | Strings the grader looks for; `render` or `escape` | | |
| `messages_json` and `tools_json` are strings on purpose: `arguments` is a dict in some cases and a string in others, which a single Arrow column cannot hold. `json.loads` them to get the exact objects to pass to `apply_chat_template`. | |
| | Case | Tests | | |
| | --- | --- | | |
| | C1 | dict arguments (baseline, the documented format) | | |
| | C2 | OpenAI-style JSON-string arguments | | |
| | C3 | empty dict `{}` | | |
| | C4 | empty JSON string `'{}'` | | |
| | C5 | nested dict with a boolean | | |
| | C6 | nested payload as a JSON string | | |
| | C7 | unicode values (`París`, `東京の天気`) as a dict | | |
| | C8 | unicode payload as a raw UTF-8 JSON string | | |
| | C9 | two tool calls in one assistant turn | | |
| | C10 | tool name containing quotes and a forged `arguments` payload | | |
| ### `results` (split `leaderboard_2026_11_16`, 410 rows) | |
| One row per (model, case) from the leaderboard run. | |
| | Column | Meaning | | |
| | --- | --- | | |
| | `model_id` | Hub repo id | | |
| | `case_id`, `case_name` | Case | | |
| | `outcome` | `pass`, `fail` or `crash` | | |
| | `status` | Fine-grained: `pass`, `fail_crash`, `fail_clear`, `fail_double_encoded`, `fail_dropped`, `fail_raw_name` | | |
| | `error_class`, `error_message` | Exception class and message when rendering raised | | |
| | `detail`, `snippet` | Grader note and up to 320 characters of the rendered tool-call region | | |
| | `template_sha1` | First 10 hex chars of the SHA-1 of the template that was measured | | |
| | `model_score` | That model's total passes out of 10 | | |
| | `model_downloads` | Hub downloads at snapshot time | | |
| | `transformers_version`, `bench_version`, `date` | `5.22.2`, `1.0`, `2026-11-16` | | |
| ## How to use | |
| ```python | |
| import json | |
| from datasets import load_dataset | |
| from transformers import AutoTokenizer | |
| cases = load_dataset("SamJoshua/chat-template-toolcall-bench", "cases", split="test") | |
| tok = AutoTokenizer.from_pretrained("zai-org/GLM-5.3") | |
| for c in cases: | |
| try: | |
| out = tok.apply_chat_template( | |
| json.loads(c["messages_json"]), tools=json.loads(c["tools_json"]), tokenize=False | |
| ) | |
| print(c["id"], "rendered", len(out)) | |
| except Exception as e: | |
| print(c["id"], "CRASH", type(e).__name__, e) | |
| ``` | |
| The rendering alone does not grade a case (a template can render and still double-encode or paste a raw name). For the exact grading rules use `scan.py` in this repo, or the [checker Space](https://huggingface.co/spaces/SamJoshua/chat-template-checker). | |
| ```python | |
| res = load_dataset("SamJoshua/chat-template-toolcall-bench", "results", split="leaderboard_2026_11_16").to_pandas() | |
| res.pivot(index="model_id", columns="case_id", values="outcome") | |
| ``` | |
| ## How to reproduce | |
| ```bash | |
| pip install "transformers==5.22.2" huggingface_hub pyarrow | |
| python scan.py --repos repos.json --out-dir out/ | |
| ``` | |
| `scan.py` is the runner used for the leaderboard. `repos.json` lists the 41 measured repos; `exclusions.json` lists 21 more from the same top-500 sweep that were not scored (no tool-call template, or gated / failed to load). `summary.json` has the headline counts. `build.py` turns the runner output into the two configs above. | |
| Population: top 500 `text-generation` models by downloads on 16 Nov 2026, updated within 180 days, whose template references `tool_calls`, minus quants, abliterated forks and tiny test repos. 41 repos, 33 distinct templates. A re-check of all 41 on 20 Nov 2026 through the checker Space code reproduced all 410 case results. | |
| ## Caveats | |
| - A crash on string arguments is a **spec-compatibility** issue, not a model bug. transformers documents `arguments` as a mapping. The bench scores JSON strings anyway because OpenAI-compatible APIs, logged traces and many function-calling datasets produce them, and people feed those straight into `apply_chat_template`. | |
| - C10 checks only whether the raw name reaches the prompt. A harness that validates tool names against its declared tool list is not exposed. | |
| - Templates change. `template_sha1` tells you which version was measured. | |
| - Practical rule for harness authors: `json.loads` every `arguments` value before templating, and reject tool names that are not in your declared tool list. | |
| ## Citation | |
| ```bibtex | |
| @misc{joshua2026cttbench, | |
| title = {CTT-Bench: Chat Template Tool-Call Bench}, | |
| author = {Joshua, Sam}, | |
| year = {2026}, | |
| month = nov, | |
| howpublished = {\url{https://huggingface.co/datasets/SamJoshua/chat-template-toolcall-bench}}, | |
| note = {v1.0, measured with transformers 5.22.2} | |
| } | |
| ``` | |
| ## License | |
| Apache-2.0. The conversations, grading rules and scores are original. The measured templates belong to their model authors. | |
| [Sam Joshua](https://huggingface.co/SamJoshua) · [@SAM_JOSHUA_S](https://x.com/SAM_JOSHUA_S) | |