Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -38,30 +38,52 @@ configs:
|
|
| 38 |
path: klein_code_bench/data/max.jsonl
|
| 39 |
---
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Klein-Code-Bench
|
| 42 |
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
| --- | --- | --- | ---: |
|
| 47 |
-
| easy | 2–8B | JSONL command-line tool with a domain algorithm and error recovery | 65 |
|
| 48 |
-
| intermediate | 8–16B |
|
| 49 |
-
| hard | 16–32B |
|
| 50 |
-
| max | 60–200B |
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
-
##
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
|
|
|
| 61 |
|
| 62 |
-
## Quick start
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
```bash
|
| 67 |
git clone https://huggingface.co/datasets/klein-ml/klein-code-bench
|
|
@@ -69,75 +91,127 @@ cd klein-code-bench
|
|
| 69 |
python -m pip install -e .
|
| 70 |
klein-bench list --subset easy
|
| 71 |
|
| 72 |
-
#
|
| 73 |
klein-bench prepare kcb-easy-001-word-frequency --output workspaces/first
|
| 74 |
-
# Give workspaces/first/PROMPT.md to your coding model.
|
| 75 |
-
# Have the model create files inside workspaces/first/project/.
|
| 76 |
|
|
|
|
| 77 |
klein-bench evaluate kcb-easy-001-word-frequency \
|
| 78 |
--solution workspaces/first/project --output results/first.json
|
| 79 |
klein-bench score results/first.json
|
| 80 |
```
|
| 81 |
|
| 82 |
-
`python -m klein_code_bench`
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
-
##
|
| 87 |
|
| 88 |
```python
|
| 89 |
from datasets import load_dataset
|
| 90 |
|
| 91 |
-
easy = load_dataset("klein-ml/klein-code-bench", "easy", split="test")
|
| 92 |
-
all_tasks = load_dataset("klein-ml/klein-code-bench", split="test")
|
| 93 |
-
assert len(easy) == 65
|
| 94 |
-
assert len(all_tasks) == 260
|
| 95 |
```
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
|
| 101 |
-
| Field |
|
| 102 |
| --- | --- |
|
| 103 |
-
| `task_id` | Stable unique
|
| 104 |
-
| `subset`, `family`, `category`, `title` | Tier and
|
| 105 |
-
| `target_model_parameters` | Intended
|
| 106 |
-
| `language`, `entrypoint`, `protocol_version` | Python, main.py
|
| 107 |
-
| `prompt` |
|
| 108 |
-
| `public_tests` |
|
| 109 |
-
| `acceptance_tests` |
|
| 110 |
-
| `num_scenarios`, `num_assertions`, `timeout_seconds` |
|
| 111 |
|
| 112 |
-
|
| 113 |
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
|
| 117 |
|
| 118 |
-
|
| 119 |
|
| 120 |
-
|
|
|
|
|
|
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
-
|
| 127 |
-
klein-bench build
|
| 128 |
|
| 129 |
-
#
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
```
|
| 132 |
|
| 133 |
-
The
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
-
|
| 140 |
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
|
|
|
|
|
|
| 38 |
path: klein_code_bench/data/max.jsonl
|
| 39 |
---
|
| 40 |
|
| 41 |
+
<p align="center">
|
| 42 |
+
<img src="https://cdn-avatars.huggingface.co/v1/production/uploads/69ae829a8408eeb0d7dd5491/943kN5YZ59lFCUN1jiKz5.png" width="180" alt="KleinML">
|
| 43 |
+
</p>
|
| 44 |
+
|
| 45 |
+
<p align="center">
|
| 46 |
+
<a href="https://kleinml.com"><b>Klein ML Website</b></a>
|
| 47 |
+
</p>
|
| 48 |
+
|
| 49 |
# Klein-Code-Bench
|
| 50 |
|
| 51 |
+
Can a model build a working program from scratch? Klein-Code-Bench gives a coding model a specification and an
|
| 52 |
+
empty directory, and checks whether the finished Python project passes every acceptance test.
|
| 53 |
|
| 54 |
+
- **260 tasks** in four tiers of 65
|
| 55 |
+
- **Pass or fail per project:** a task counts only if all of its tests pass
|
| 56 |
+
- **Runs locally:** standard-library Python, no Docker, no cloud model, no extra dependencies
|
| 57 |
+
|
| 58 |
+
| Tier | Intended model size | What the model builds | Tasks |
|
| 59 |
| --- | --- | --- | ---: |
|
| 60 |
+
| easy | 2–8B | A JSONL command-line tool with a domain algorithm and error recovery | 65 |
|
| 61 |
+
| intermediate | 8–16B | A stateful document service: CRUD, listing, domain evaluation | 65 |
|
| 62 |
+
| hard | 16–32B | A service with atomic batches, revision checks and nested transactions | 65 |
|
| 63 |
+
| max | 60–200B | A durable service that survives being force-killed, with idempotency, history and pagination | 65 |
|
| 64 |
|
| 65 |
+
The model sizes are design targets. Version 0.1.0 has not been calibrated against real models yet, and there is no
|
| 66 |
+
leaderboard. Any model can be run on any tier.
|
| 67 |
|
| 68 |
+
## How a task works
|
| 69 |
|
| 70 |
+
1. The model gets `PROMPT.md`: the full specification plus two examples.
|
| 71 |
+
2. It writes `main.py` and any other files into an empty `project/` directory. There's no starter code and no
|
| 72 |
+
existing repository to fix.
|
| 73 |
+
3. The evaluator runs the project as a subprocess, sends JSONL requests and checks every response and state change.
|
| 74 |
+
In the max tier, the process is force-killed right after its last acknowledged response, restarted on the same
|
| 75 |
+
state directory, and must continue correctly.
|
| 76 |
|
| 77 |
+
The 65 tasks per tier come from the same 65 domain families: text processing, CSV/JSON tools, calendars, numerical
|
| 78 |
+
utilities, graphs, scheduling, ledgers, geometry, parsing, simulation and more. Each tier adds service behavior on
|
| 79 |
+
top of the one below. Full list: [task catalog](docs/CATALOG.md).
|
| 80 |
|
| 81 |
+
Because the tiers share families, results across tiers are correlated. Report each tier separately, and don't
|
| 82 |
+
train on one tier and then present another as an uncontaminated evaluation.
|
| 83 |
|
| 84 |
+
## Quick start
|
| 85 |
|
| 86 |
+
Requires Python 3.11+ on Linux or macOS.
|
| 87 |
|
| 88 |
```bash
|
| 89 |
git clone https://huggingface.co/datasets/klein-ml/klein-code-bench
|
|
|
|
| 91 |
python -m pip install -e .
|
| 92 |
klein-bench list --subset easy
|
| 93 |
|
| 94 |
+
# Create a workspace: PROMPT.md, plus an empty project/ directory for the model
|
| 95 |
klein-bench prepare kcb-easy-001-word-frequency --output workspaces/first
|
|
|
|
|
|
|
| 96 |
|
| 97 |
+
# Give workspaces/first/PROMPT.md to your model and let it write into workspaces/first/project/, then:
|
| 98 |
klein-bench evaluate kcb-easy-001-word-frequency \
|
| 99 |
--solution workspaces/first/project --output results/first.json
|
| 100 |
klein-bench score results/first.json
|
| 101 |
```
|
| 102 |
|
| 103 |
+
- `python -m klein_code_bench` works the same as `klein-bench`.
|
| 104 |
+
- Exit code 1 means a failed submission, 2 an invalid invocation.
|
| 105 |
+
- `--public-only` runs just the two examples as a smoke test. Those results can't be scored.
|
| 106 |
|
| 107 |
+
Bring your own agent or local API endpoint, or use the [banana-harness integration](docs/BANANA_HARNESS.md).
|
| 108 |
+
Record the model's inference settings with your results.
|
| 109 |
|
| 110 |
+
## Loading the dataset
|
| 111 |
|
| 112 |
```python
|
| 113 |
from datasets import load_dataset
|
| 114 |
|
| 115 |
+
easy = load_dataset("klein-ml/klein-code-bench", "easy", split="test") # 65 tasks
|
| 116 |
+
all_tasks = load_dataset("klein-ml/klein-code-bench", split="test") # 260 tasks
|
|
|
|
|
|
|
| 117 |
```
|
| 118 |
|
| 119 |
+
Each tier is its own config with a single `test` split; the default config contains all four. There is no
|
| 120 |
+
training split, and no loading script or `trust_remote_code` is needed. Pin `revision` to a commit when you
|
| 121 |
+
report results.
|
| 122 |
|
| 123 |
+
| Field | Content |
|
| 124 |
| --- | --- |
|
| 125 |
+
| `task_id` | Stable unique ID |
|
| 126 |
+
| `subset`, `family`, `category`, `title` | Tier and task description |
|
| 127 |
+
| `target_model_parameters` | Intended model-size band (not calibrated) |
|
| 128 |
+
| `language`, `entrypoint`, `protocol_version` | Python, `main.py`, protocol version |
|
| 129 |
+
| `prompt` | The full specification the model sees |
|
| 130 |
+
| `public_tests` | Example requests and responses (JSON string) |
|
| 131 |
+
| `acceptance_tests` | Evaluator scenarios: sessions, requests, expected responses (JSON string) |
|
| 132 |
+
| `num_scenarios`, `num_assertions`, `timeout_seconds` | Test counts and the per-session time limit |
|
| 133 |
|
| 134 |
+
The test fields are stored as JSON strings so that all tasks share one schema; decode them with `json.loads`.
|
| 135 |
|
| 136 |
+
**Never put `acceptance_tests`, the reference implementations or the evaluator source into the model's prompt,
|
| 137 |
+
context or workspace.** They're public for reproducibility, so the benchmark depends on you keeping them away from the
|
| 138 |
+
model.
|
| 139 |
|
| 140 |
+
## Scoring
|
| 141 |
|
| 142 |
+
The metric is **resolve@1**: one project per task, and it counts only if every test passes.
|
| 143 |
|
| 144 |
+
- **Per tier:** resolved tasks / 65. **Overall:** resolved tasks / 260.
|
| 145 |
+
- Missing submissions count as failures. The report also shows the rate among submitted tasks and flags incomplete runs.
|
| 146 |
+
- Partial assertion success is reported for diagnosis, but it never counts as resolved.
|
| 147 |
|
| 148 |
+
Each scenario starts from a fresh copy of the submission and an empty state directory; sessions within a max-tier
|
| 149 |
+
scenario share that directory. JSON comparison keeps array order and tells booleans apart from numbers. Floats use
|
| 150 |
+
an absolute and relative tolerance of 1e-9; integers are compared exactly. Default limits are 10 seconds per session
|
| 151 |
+
and 1 MiB of stdout. Details: [evaluation protocol](docs/EVALUATION.md).
|
| 152 |
+
|
| 153 |
+
| Tier | Assertions |
|
| 154 |
+
| --- | ---: |
|
| 155 |
+
| easy | 3,075 |
|
| 156 |
+
| intermediate | 5,415 |
|
| 157 |
+
| hard | 9,705 |
|
| 158 |
+
| max | 15,490 |
|
| 159 |
+
| **total** | **33,685** |
|
| 160 |
+
|
| 161 |
+
The tests cover:
|
| 162 |
+
|
| 163 |
+
- 65 hand-written golden outputs
|
| 164 |
+
- 24 generated inputs per family (seed 1729, shared across tiers)
|
| 165 |
+
- boundary cases and malformed requests
|
| 166 |
+
- failure atomicity, nested rollback and revision conflicts
|
| 167 |
+
- retry and restart sequences
|
| 168 |
|
| 169 |
+
All expected outputs are computed before grading, never inside the candidate's process.
|
|
|
|
| 170 |
|
| 171 |
+
### Verifying the benchmark itself
|
| 172 |
+
|
| 173 |
+
```bash
|
| 174 |
+
python -m unittest discover -s tests -v # unit and property tests for the benchmark and runner
|
| 175 |
+
klein-bench build # regenerate data and manifest from source
|
| 176 |
+
klein-bench validate --output results/validation.json # every reference must pass, every empty project must fail
|
| 177 |
```
|
| 178 |
|
| 179 |
+
The reference implementations exist to maintain the evaluator. Export one for auditing with
|
| 180 |
+
`klein-bench reference TASK_ID --output DIR`. The published `validation-summary.json` documents the dataset
|
| 181 |
+
manifest and validation totals; it is not a model score.
|
| 182 |
+
|
| 183 |
+
## Security
|
| 184 |
+
|
| 185 |
+
The runner is **not a sandbox**. It does the following:
|
| 186 |
+
|
| 187 |
+
- removes inherited credentials from the environment
|
| 188 |
+
- runs each submission from a temporary copy
|
| 189 |
+
- rejects symlinks
|
| 190 |
+
- limits time and output
|
| 191 |
+
- kills the whole process group when it's done
|
| 192 |
+
|
| 193 |
+
Generated code can still reach your filesystem and network. Run it under a separate unprivileged user, on a machine
|
| 194 |
+
you can afford to lose. Timing depends on the host, so record your hardware with your results.
|
| 195 |
+
|
| 196 |
+
## Provenance and limitations
|
| 197 |
|
| 198 |
+
- **Origin:** every task was written for this benchmark. None were copied from SWE-bench, LiveCodeBench or other
|
| 199 |
+
benchmarks. That covers how the tasks were authored; it doesn't guarantee that standard algorithms in the easy tier
|
| 200 |
+
never appear in a model's training data.
|
| 201 |
+
- **Scope:** Python only. The tests measure behavioral correctness, not code quality, architecture or UI. They don't
|
| 202 |
+
cover concurrent writers, disk corruption or power loss during a write.
|
| 203 |
+
- **Coverage:** the reference implementations and independent golden checks make the dataset internally consistent,
|
| 204 |
+
but the tests can't prove that no specification or expected output contains an error.
|
| 205 |
+
- **License:** MIT for prompts, test data and reference implementations.
|
| 206 |
|
| 207 |
+
## Contributing
|
| 208 |
|
| 209 |
+
A new task needs:
|
| 210 |
|
| 211 |
+
- a contract (the specification)
|
| 212 |
+
- meaningful boundary tests
|
| 213 |
+
- an independent check of the expected outputs
|
| 214 |
+
- a reference implementation that passes
|
| 215 |
|
| 216 |
+
Changes to a contract or expected behavior require a new dataset version. Task IDs stay the same only for
|
| 217 |
+
backward-compatible fixes.
|