|
Download README.md from context-language-model/ContextBench: direct link, hf CLI and curl.
- Browser
- Download file 5.53 kB
-
https://huggingface.co/datasets/context-language-model/ContextBench/resolve/main/README.md
- Command line
-
hf download hf://datasets/context-language-model/ContextBench/README.md
-
curl -L -o README.md https://huggingface.co/datasets/context-language-model/ContextBench/resolve/main/README.md
5.53 kB
| license: apache-2.0 | |
| pretty_name: ContextBench | |
| language: | |
| - en | |
| tags: | |
| - agents | |
| - long-context | |
| - context-management | |
| - benchmark | |
| size_categories: | |
| - n<1K | |
| configs: | |
| - config_name: all | |
| default: true | |
| data_files: | |
| - split: test | |
| path: data/*.parquet | |
| - config_name: kv_store | |
| data_files: | |
| - split: test | |
| path: data/kv_store.parquet | |
| - config_name: log_triage | |
| data_files: | |
| - split: test | |
| path: data/log_triage.parquet | |
| - config_name: needle_retention | |
| data_files: | |
| - split: test | |
| path: data/needle_retention.parquet | |
| - config_name: sudoku_sketchpad | |
| data_files: | |
| - split: test | |
| path: data/sudoku_sketchpad.parquet | |
| # ContextBench | |
| ContextBench measures what an agent keeps, updates, and offloads when its input does | |
| not fit in its context window. Each task streams a sequence of operations as ordinary | |
| user turns, more than the context budget holds, and the reward is read from the | |
| agent's own messages: what survived in its context, not what it wrote to disk. | |
| Paper: [Context Language Models](https://arxiv.org/abs/2609.37725) ([paper page](https://huggingface.co/papers/2609.37725)) | |
| ## Families | |
| | config | task | reward | | |
| |---|---|---| | |
| | `kv_store` | batches of `SET key = value`, then `GET key` queries | fraction of GETs answered with the right value | | |
| | `log_triage` | batches of service log lines, then count and lookup questions | fraction of questions answered correctly | | |
| | `needle_retention` | chunks with a few needle lines inside a large filler block | fraction of needle lines still present verbatim | | |
| | `sudoku_sketchpad` | one fully specified move per turn on a 16x16 board | fraction of gold board versions the agent displayed | | |
| The `all` config holds every instance. This release has 256 instances: | |
| 64 `kv_store`, 56 `log_triage`, 80 `needle_retention`, 56 `sudoku_sketchpad` (32 levels, seeds 42-49), with a context budget of 32768 tokens | |
| and a reserve of 2048. | |
| ## Columns | |
| | column | type | meaning | | |
| |---|---|---| | |
| | `task_id` | string | `<family>-<level>-seed<seed>`, also the Harbor task directory name | | |
| | `family` | string | task family | | |
| | `level` | string | difficulty level | | |
| | `seed` | int | generator seed | | |
| | `budget` | int | context budget in tokens | | |
| | `reserve` | int | tokens reserved for the reply; the agent may use `budget - reserve` | | |
| | `n_ops` | int | number of streamed operations | | |
| | `streamed_tokens` | int | tokens streamed over the episode (`o200k_base`) | | |
| | `pressure` | float | `streamed_tokens / budget` | | |
| | `chunks` | list of `{index, header, body}` | the operations, one user turn each | | |
| | `gold` | string (JSON) | the answers the graders score against | | |
| | `meta` | string (JSON) | generator settings and instance statistics | | |
| The budget is counted in `o200k_base` tokens for every agent. An agent may enforce a | |
| stricter budget of its own; that is part of the agent, not of the benchmark. | |
| Each operation is shown to the agent as | |
| `=== {header} ({remaining} op(s) remaining after this) ===` followed by its body. | |
| ## Usage | |
| ### With `datasets` | |
| ```python | |
| import json | |
| from datasets import load_dataset | |
| ds = load_dataset("context-language-model/ContextBench", "kv_store", split="test") # or "all" | |
| row = ds[0] | |
| ops = row["chunks"] # list of {"index", "header", "body"} | |
| gold = json.loads(row["gold"]) | |
| ``` | |
| To evaluate an agent from Python, install the `contextbench` package, write an | |
| instance to disk, and pass your agent to `contextbench.run`: | |
| ```python | |
| from pathlib import Path | |
| from contextbench import run | |
| inst = Path("instances") / row["task_id"] | |
| inst.mkdir(parents=True, exist_ok=True) | |
| (inst / "chunks.jsonl").write_text( | |
| "".join(json.dumps(c) + "\n" for c in row["chunks"])) | |
| (inst / "gold.json").write_text(row["gold"]) | |
| (inst / "meta.json").write_text(row["meta"]) | |
| result = run(my_agent, inst, budget=row["budget"], reserve=row["reserve"], | |
| out_dir=Path("runs") / row["task_id"]) | |
| ``` | |
| ### With Harbor | |
| The `harbor/` directory holds one Harbor task per instance, and `registry.json` | |
| lists the datasets `contextbench` (every task) and `contextbench-<family>` | |
| (for example `contextbench-kv-store`). The same tasks are on GitHub, so Harbor runs | |
| them in one line: | |
| ```bash | |
| harbor jobs start --repo RulinShao/ContextBench -d contextbench \ | |
| -a contextbench.harbor.agents:Terminus2Stream -m <model> | |
| ``` | |
| Or download this repository and run Harbor from inside it: | |
| ```bash | |
| hf download context-language-model/ContextBench --repo-type dataset --local-dir contextbench-hf | |
| cd contextbench-hf | |
| harbor jobs start --registry-path registry.json -d contextbench \ | |
| -a contextbench.harbor.agents:Terminus2Stream -m <model> | |
| ``` | |
| Use `-d contextbench-sudoku-sketchpad` for one family, `-i <task_id>` for one task, | |
| `-p harbor/` to run the downloaded directory without the registry, or `-a oracle` to | |
| check a task with its reference solution. Agents that deliver operations into a running | |
| conversation ship with the `contextbench` package (`contextbench.harbor.agents`). | |
| ## Citation | |
| ContextBench was introduced in the Context Language Models paper. If you use it, please cite: | |
| ```bibtex | |
| @article{shao2026context, | |
| title = {Context Language Models}, | |
| author = {Shao, Rulin and Shen, Shannon Zejiang and Yin, Junjie Oscar and Li, Yuetai and | |
| Wang, Minheng and Ivison, Hamish and Poovendran, Radha and Lambert, Nathan and | |
| Xiao, Teng and Lewis, Mike and Yih, Wen-tau and Zettlemoyer, Luke and Koh, Pang Wei}, | |
| journal = {arXiv preprint arXiv:2609.37725}, | |
| year = {2026} | |
| } | |
| ``` | |
| ## License | |
| Apache-2.0. | |