Datasets:
Long-context agent benchmark: facts, tool calls and rules far back in the context (items, score.py, card)
7fa7e5a verified |
Download README.md from thinletter/longctx-agent-bench: direct link, hf CLI and curl.
- Browser
- Download file 15.1 kB
-
https://huggingface.co/datasets/thinletter/longctx-agent-bench/resolve/main/README.md
- Command line
-
hf download hf://datasets/thinletter/longctx-agent-bench/README.md
-
curl -L -o README.md https://huggingface.co/datasets/thinletter/longctx-agent-bench/resolve/main/README.md
15.1 kB
| pretty_name: "Long-context agent benchmark: facts, tool calls and rules far back in the context" | |
| license: | |
| - cc-by-sa-4.0 | |
| - cc-by-4.0 | |
| language: | |
| - en | |
| - cs | |
| - de | |
| task_categories: | |
| - text-generation | |
| tags: | |
| - long-context | |
| - agents | |
| - tool-use | |
| - function-calling | |
| - instruction-following | |
| - evaluation | |
| size_categories: | |
| - n<1K | |
| configs: | |
| - config_name: facts | |
| data_files: | |
| - split: 8k | |
| path: data/facts/8k.parquet | |
| - split: 32k | |
| path: data/facts/32k.parquet | |
| - config_name: tool_calls | |
| data_files: | |
| - split: 8k | |
| path: data/tool_calls/8k.parquet | |
| - split: 32k | |
| path: data/tool_calls/32k.parquet | |
| - config_name: rules_en | |
| data_files: | |
| - split: 8k | |
| path: data/rules_en/8k.parquet | |
| - split: 32k | |
| path: data/rules_en/32k.parquet | |
| - config_name: rules_cs | |
| data_files: | |
| - split: 8k | |
| path: data/rules_cs/8k.parquet | |
| - split: 32k | |
| path: data/rules_cs/32k.parquet | |
| - config_name: rules_de | |
| data_files: | |
| - split: 8k | |
| path: data/rules_de/8k.parquet | |
| - split: 32k | |
| path: data/rules_de/32k.parquet | |
| # Long-context agent benchmark: facts, tool calls and rules far back in the context | |
| Does a language model still use information that lies far back in a long conversation? An agent that works for | |
| hours gets its tools defined at the start, reads facts somewhere in the middle and is told rules ("don't use `grep` | |
| here, use `rg`") long before the moment they matter. This benchmark measures exactly that, on real agent | |
| transcripts and real text, at 8k and 32k tokens: | |
| | config | what the model has to use from far back | language | licence | | |
| |---|---|---|---| | |
| | `facts` | numbers planted in a long Wikipedia text ("Fiona booked flight 48213."), asked for again thousands of tokens later | English | CC BY-SA 4.0 | | |
| | `tool_calls` | the definitions of tools and documented commands at the start of an agent session, needed to call them correctly much later | English | CC BY 4.0 | | |
| | `rules_en` | a policy rule given at the start (system prompt) or in a later user message, which should change what the agent does many turns later | English | CC BY 4.0 | | |
| | `rules_cs` | the same rules written in Czech (the commands stay the English shell commands) | Czech | CC BY 4.0 | | |
| | `rules_de` | the same rules written in German | German | CC BY 4.0 | | |
| Every test is teacher-forced: the model reads the full text once, and its next-token prediction is checked at the | |
| target positions. Nothing is generated, so the scores are deterministic up to the model's numerical precision and do | |
| not depend on sampling or answer parsing. | |
| ## Sizes | |
| | config | split | items | targets | tokens per item (Qwen3.5 tokenizer) | | |
| |---|---|---|---|---| | |
| | facts | 8k | 8 | 64 queries | 8,193 | | |
| | facts | 32k | 7 | 56 queries | 32,769 | | |
| | tool_calls | 8k | 16 | 886 (414 far, 217 of them fresh) | 8,193 | | |
| | tool_calls | 32k | 16 | 3,244 (2,038 far, 989 of them fresh) | 32,769 | | |
| | rules_en / rules_cs / rules_de | 8k | 82 each | 155 each | 2 x 8,193 (without / with the rule) | | |
| | rules_en / rules_cs / rules_de | 32k | 84 each | 605 each | 2 x 32,769 | | |
| The 82 / 84 rule items per language are planted in 16 different agent sessions per length (each session carries | |
| several rules, one per item: three rule families, each in the system prompt and in a later user message; items of | |
| the same session share their `context_id`). | |
| ## What an item looks like | |
| All configs keep the full text the model reads, the target positions as **character offsets** into that text | |
| (usable with any tokenizer) and, for reference, the token ids of the Qwen3.5 tokenizer with which the items were | |
| built (`qwen_*` fields). The agent texts are written in the Qwen3.5 chat format (`<|im_start|>system ... <|im_end|>`, | |
| tool definitions as JSON lines inside `<tools>`, calls as `<tool_call><function=...>` blocks), as one long session | |
| followed by further documents. | |
| * `facts`: `text`; `targets[]` with `answer_char` (the span of " 48213." after the query), `answer`, `fact_char` / | |
| `fact` (the planted fact sentence), `distance_tokens`; `source` (WikiText-103 and the titles of the Wikipedia | |
| articles the text comes from). | |
| * `tool_calls`: `text`; `definitions[]` (the tool definition or documented command and its span); `targets[]` with | |
| `char` (the target token's span), `target`, `kind` (`name`, `param`, `next`, `command`), `far`, `fresh`, | |
| `definition_id`, `distance_tokens`; `sources[]`. | |
| * `rules_*`: `text_without_rule`, `text_with_rule` (the same session with one rule line added), `rule`, `rule_char`, | |
| `family` (`substitution`, `redirect`, `required`), `placement` (`system`: at the end of the system prompt; `user`: | |
| at the end of a later user message), `lang`, `context_id`; `targets[]` with `char_without_rule` / | |
| `char_with_rule` (where the governed action starts), `expected_text` (the first token the rule implies, e.g. | |
| " rg"), `original_text` (what the session actually did, e.g. " grep"), `distance_tokens`, `first`, `mentioned`; | |
| `sources[]`. | |
| * `sources[]` (agent configs): every source dataset in the item's text with its `dataset` id, `revision`, | |
| `license`, and the `tokens` / `documents` the item takes from it. | |
| A target is **far** when the fact, tool definition or rule it needs ends 512 or more tokens before it (counted in | |
| Qwen3.5 tokens; a fixed parameter of the benchmark). Every rules target is far; `distance_tokens` gives the exact | |
| distance. | |
| ## Metrics | |
| * **facts: query accuracy.** A query counts as recalled when every token of the answer (the five-digit number and the | |
| final ".") is the model's top-1 prediction. Also reported: token accuracy. | |
| * **tool_calls: far accuracy.** Top-1 accuracy of the next token at the far targets: the tool's exact name, its | |
| parameter names, the token that closes them, which parameter or closing tag comes next, the name of a documented | |
| command. `fresh` targets are far targets of a tool with no earlier call in the 512 tokens before the target (the | |
| model cannot copy a recent call); also reported: fresh and near accuracy, mean log-probabilities. | |
| * **rules: follow and retained.** At each target, score = log p(the rule-implied first token). The effect of the rule | |
| is score(with rule) - score(without rule). A **reference model** decides which targets count: those where its own | |
| effect is at least 1 nat in absolute value (the reference reacts to the rule). Over these targets: | |
| *follow* = share of targets where the model's effect is at least half the reference's; *retained* = sum of the | |
| model's effects / sum of the reference's. Reported per placement and family. The reference is typically the | |
| original model a compressed, quantized or otherwise modified model was derived from (for the reference itself | |
| follow = retained = 1.00); with no reference given, the model is its own reference. | |
| Headline rows as `score.py` prints them: | |
| | row | definition | | |
| |---|---| | |
| | Facts recalled at 8k / 32k tokens | facts, query accuracy | | |
| | Distant tool calls at 8k / 32k tokens | tool_calls, far accuracy | | |
| | Rules followed at 8k / 32k tokens | rules_en, follow, rules in the system prompt, all families | | |
| | Rules kept far back, worst case (1.00 = as the original) | rules_en, the lowest *retained* of 12 cells (3 families x 2 placements x 2 lengths) | | |
| | Czech / German rules kept far back, worst case | rules_cs / rules_de, the same | | |
| | Rules in Czech / German followed at 32k tokens | rules_cs / rules_de at 32k, follow, system prompt, all families | | |
| ## Running it | |
| `score.py` (in this repository) needs `torch` and `transformers` (`pyarrow` for the Parquet files) and scores any | |
| Hugging Face causal language model that runs in `transformers`: | |
| ```bash | |
| # a model on its own | |
| python score.py --model Qwen/Qwen3.5-2B --data thinletter/longctx-agent-bench --out qwen35_2b.json | |
| # a modified model against its original (the reference of the rules configs), saving the reference's scores once | |
| python score.py --model Qwen/Qwen3.5-2B --data ./longctx-agent-bench --sets rules_en,rules_cs,rules_de \ | |
| --save_scores ref_2b.json.gz --out ref.json | |
| python score.py --model my-org/my-compressed-2b --data ./longctx-agent-bench --reference_scores ref_2b.json.gz \ | |
| --out mine.json | |
| # a quick test: the first item per config at 8k | |
| python score.py --model Qwen/Qwen3.5-0.8B --data ./longctx-agent-bench --lengths 8k --limit 1 | |
| ``` | |
| * `--mode auto` (default) feeds the stored Qwen3.5 token ids when the model's tokenizer has the same vocabulary | |
| (exactly the evaluated sequences), and otherwise tokenizes `text` with the model's own tokenizer and maps the targets | |
| by character offsets (`--mode text`). A target whose characters do not start at a token boundary of that tokenizer | |
| is skipped and counted as `unaligned` in the output. The rules configs need the model and its reference to use the | |
| same tokenization mode. | |
| * The texts use the Qwen3.5 chat markup verbatim. Other model families read it as plain text; their scores are | |
| comparable with each other within a family (model vs its reference), less so across families. | |
| * Models that need their own runtime: `score_sets(backend, tokenizer, data)` takes any object with | |
| `read(ids, positions, tokens)` (the top-1 token and the log-probabilities of given tokens at given positions). | |
| ThinCtx models run on the `thinctx` runtime and are scored with `--backend thinctx` through its `Engine.score`: | |
| thinctx 1.1 (upcoming) adds `Engine.score`; thinctx 1.0.x cannot score ThinCtx models teacher-forced. | |
| * Cost: about 12 million tokens of forward passes per model for all configs (the rules configs are most of it), one | |
| sequence at a time, at most 32,769 tokens long. | |
| * Output: `rows` (the headline rows above), `sets` (every metric per config and length), `reference`, `mode`. | |
| ## Licence | |
| | config | licence | why | | |
| |---|---|---| | |
| | `facts` | [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) | an adaptation of WikiText-103 (Wikipedia text, CC BY-SA 3.0): ShareAlike | | |
| | `tool_calls`, `rules_en`, `rules_cs`, `rules_de` | [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) | the choice of texts, the planted rules and the target annotations | | |
| The third-party text inside every config stays under the licence of its source (below), which you must also respect: | |
| attribution, the licence notices of the code, and the terms its sources name for model outputs. | |
| ## Sources and licences | |
| **facts.** [Salesforce/wikitext](https://huggingface.co/datasets/Salesforce/wikitext), config `wikitext-103-raw-v1`, | |
| validation split (revision `main`), licence CC BY-SA 3.0 (and GFDL): text of English Wikipedia articles by Wikipedia | |
| contributors, via WikiText-103 (Merity et al., 2016, "Pointer Sentinel Mixture Models"). Each item names its articles | |
| in `source.articles`. Changes: 8 fact sentences and their 8 queries were written over parts of the article text. | |
| **tool_calls and rules_\*.** Agent sessions and documents from the datasets below, rendered in the Qwen3.5 chat format | |
| and concatenated; the rules configs add one rule line to the system prompt or to a user message. Each item's | |
| `sources` names the datasets in it. | |
| | dataset | revision | licence | content | | |
| |---|---|---|---| | |
| | [nebius/SWE-agent-trajectories](https://huggingface.co/datasets/nebius/SWE-agent-trajectories) | 68195a1450865274106246d0d0296a1d6807b88e | CC BY 4.0 | agent runs on GitHub issues | | |
| | [Kwai-Klear/SWE-smith-mini_swe_agent_plus-trajectories-66k](https://huggingface.co/datasets/Kwai-Klear/SWE-smith-mini_swe_agent_plus-trajectories-66k) | 750b2c11239fd5e32f97e6cfb9bf80fb9a9a2983 | MIT | agent runs on SWE-smith repositories | | |
| | [NousResearch/hermes-function-calling-v1](https://huggingface.co/datasets/NousResearch/hermes-function-calling-v1) (configs func_calling, json_mode_agentic) | dae3e1d28cfbcf4b915c04ea1e072030529b4bda | Apache-2.0 | function-calling conversations | | |
| | [glaiveai/glaive-function-calling-v2](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2) | e7f4b6456019f5d8bcb991ef0dd67d8ff23221ac | Apache-2.0 | function-calling conversations | | |
| | [minpeter/xlam-function-calling-60k-parsed](https://huggingface.co/datasets/minpeter/xlam-function-calling-60k-parsed), a parse of [Salesforce/xlam-function-calling-60k](https://huggingface.co/datasets/Salesforce/xlam-function-calling-60k) (APIGen, Liu et al., 2024) | c6a0d61d66c5ac769c5c8c7de007322fa24f1825 | CC BY 4.0 | single-turn parallel tool calls | | |
| | [codeparrot/github-code-clean](https://huggingface.co/datasets/codeparrot/github-code-clean) | c48d40f9e70f0196f8236901ee35807f7d6c44c0 | Apache-2.0 (dataset card); files used: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, Unlicense or CC0-1.0 | GitHub source files | | |
| | [AmanPriyanshu/random-python-github-repositories](https://huggingface.co/datasets/AmanPriyanshu/random-python-github-repositories) | 53690024aaa0f56f81700bf504d9d5e16ec81a4d | ODC-By; repositories used: MIT, Apache-2.0, BSD or Unlicense | Python repositories | | |
| | [HuggingFaceFW/fineweb-edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu) (config sample-10BT) | 87f09149ef4734204d70ed1d046ddc9ca3f2b8f9 | ODC-By (and the Common Crawl terms of use) | educational web text | | |
| * **Code excerpts.** The source files and repositories come from repositories whose files are licensed MIT, | |
| Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, Unlicense or CC0-1.0 according to the source datasets' metadata; only | |
| such files were used. The repository name stands inside the text before its files (`<|repo_name|>owner/name`, | |
| `<|file_sep|>path`); the copyright of the code belongs to its authors under those licences. | |
| * **Agent sessions.** The nebius card states that the licence of each repository an instance is based on must be | |
| respected (the repositories' code appears in the sessions' observations) and that users of the model outputs in | |
| these trajectories must comply with the [Llama 3.1 License](https://www.llama.com/llama3_1/license/). The SWE-smith | |
| sessions likewise show code of the repositories they work on. | |
| Attribution: Wikipedia contributors (via WikiText-103, Merity et al. 2016; Salesforce); Nebius | |
| (SWE-agent-trajectories); Kwai-Klear (SWE-smith mini-swe-agent-plus trajectories); NousResearch (Hermes | |
| function-calling v1); Glaive AI (glaive-function-calling-v2); Salesforce (APIGen / xlam-function-calling-60k) and | |
| minpeter (its parse); codeparrot (github-code-clean) and AmanPriyanshu (random-python-github-repositories), and the | |
| authors of the GitHub repositories named in the texts; Hugging Face (FineWeb-Edu). | |
| ## Limitations | |
| * The rule targets are English shell commands in English agent sessions, also in the Czech and German configs: those | |
| test rules *given* in Czech or German, not agents working in those languages. | |
| * Teacher forcing reads the model's belief at each target given the true history; it does not measure whether a | |
| generated session would go the same way. | |
| * The rules metrics are relative to a reference model; the absolute effect sizes are reported too (`eff`, | |
| `eff_ref`). | |
| * 7 to 16 contexts per config and length: differences of a few points are within noise. | |
| Results of models evaluated with this benchmark: https://thinletter.io/thinctx/ | |