Datasets:
Update README.md
Browse files37 unmodified lines3839404142434445464748495051525354555657585960616263646566671 unmodified line6970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214337 unmodified linespath: klein_code_bench/data/max.jsonl---# Klein-Code-Bench**260 tasks that ask a coding model to build a working Python project from an empty directory.** There are four subsets of exactly 65 tasks. A project is resolved only when **every acceptance test passes**, including process restarts where required. No Docker, container runtime, cloud model, or third-party runtime library is required by the evaluator.| Subset | Target model size | Project to build | Tasks || --- | --- | --- | ---: || easy | 2–8B | JSONL command-line tool with a domain algorithm and error recovery | 65 || intermediate | 8–16B | Stateful document service with CRUD, listing and domain evaluation | 65 || hard | 16–32B | Service with atomic batches, revision checks and nested transactions | 65 || max | 60–200B | Durable service with forced-kill recovery, idempotency, history and pagination | 65 |**The parameter ranges are design targets, not measured capability thresholds.** Version 0.1.0 has no model leaderboard or empirical difficulty calibration. It is an initial benchmark release, not an extension of or an official result on SWE-bench.## What the tasks measureEach of 65 domain families has one version in each subset. The higher versions require the entire lower-tier behavior plus additional service behavior. Domains include text processing, CSV and JSON tools, calendars, numerical utilities, graph algorithms, scheduling, ledgers, geometry, parsing and simulation. See [the task catalog](docs/CATALOG.md).A participant receives a complete specification and two examples, then creates `main.py` and any supporting files. There is no repository to fix, starter solution, injected implementation, or preinstalled dependency to discover. Tests run the finished project as a real subprocess, exchange JSONL requests, and check results and state transitions. Max-tier restart sessions force-kill the process immediately after its final acknowledged response and then reopen the same state directory.**Cross-tier overlap is intentional.** These are 260 project specifications across 65 families, not 260 unrelated algorithms. Shared service requirements and domain families make outcomes correlated; report each subset separately. Do not train on one tier and describe another tier as an uncontaminated evaluation. The easy subset includes some standard graph/DP algorithms; the target bands need calibration across actual local models.## Quick start (Python 3.11+, Linux or macOS)Clone this Hugging Face dataset repository, then install the evaluator:```bashgit clone https://huggingface.co/datasets/klein-ml/klein-code-bench1 unmodified linepython -m pip install -e .klein-bench list --subset easy# Put the prompt outside the initially empty project directory.klein-bench prepare kcb-easy-001-word-frequency --output workspaces/first# Give workspaces/first/PROMPT.md to your coding model.# Have the model create files inside workspaces/first/project/.klein-bench evaluate kcb-easy-001-word-frequency \--solution workspaces/first/project --output results/first.jsonklein-bench score results/first.json````python -m klein_code_bench` is equivalent to `klein-bench`. A failed submission exits 1; an invalid invocation exits 2. `--public-only` runs examples as a smoke test and marks the result ineligible for scoring. The evaluator has no Python dependencies. Participants use only the Python standard library.Use your own coding agent, a local API endpoint, or the [banana-harness integration](docs/BANANA_HARNESS.md). Model size does not enforce access to a tier; evaluate any model on any subset and record its inference settings.## Load with Hugging Face Datasets```pythonfrom datasets import load_dataseteasy = load_dataset("klein-ml/klein-code-bench", "easy", split="test")all_tasks = load_dataset("klein-ml/klein-code-bench", split="test")assert len(easy) == 65assert len(all_tasks) == 260```Pin `revision` to a dataset commit when reporting results. All four named configurations expose a `test` split; the default configuration concatenates them. There is no training split. No dataset loading script or `trust_remote_code` is needed.The JSONL rows contain:| Field | Meaning || --- | --- || `task_id` | Stable unique identifier || `subset`, `family`, `category`, `title` | Tier and project descriptors || `target_model_parameters` | Intended parameter band, uncalibrated || `language`, `entrypoint`, `protocol_version` | Python, main.py and contract version || `prompt` | Entire participant-visible project specification || `public_tests` | JSON-encoded list of example requests and responses || `acceptance_tests` | JSON-encoded evaluator scenarios, with sessions, requests and expected responses || `num_scenarios`, `num_assertions`, `timeout_seconds` | Evaluation sizes and per-session wall-clock limit |Tests are JSON strings to provide a stable Arrow schema across projects with different input and output structures. Decode with `json.loads`. `acceptance_tests` is evaluator-side information: **never include it in the model prompt, context or workspace**. The source and expected outputs are public for reproducibility, so these tests are not secret holdouts. Examples also occur in the full suite. Source code and evaluator references must be excluded from an agent's accessible benchmark materials in a controlled evaluation.## Scoring and reproducibilityThe primary metric is **resolve@1**: one generated project per task, with all tests passing. Within a subset the score is resolved tasks / 65. Across the complete benchmark it is resolved tasks / 260. Missing submissions remain in that denominator. The report also includes the rate among submitted tasks and marks incomplete runs. Partial assertion success is diagnostic, never a resolved task.Every run starts each scenario with a fresh copy of the submission and empty state directory. Sessions within a max-tier scenario share that state directory. JSON comparisons preserve array order and distinguish booleans from numbers; finite floating point values use absolute/relative tolerance 1e-9. Exact integer comparisons avoid precision loss. The default limit is 10 seconds per session and 1 MiB of stdout. See [the evaluation protocol](docs/EVALUATION.md) for execution limits and score reporting requirements.The four dataset files contain **33,685 response assertions**: 3,075 easy, 5,415 intermediate, 9,705 hard and 15,490 max. Fixtures include 65 independently hand-authored golden outputs, boundary cases, 24 deterministically generated extra inputs per domain family, malformed requests, failure atomicity, nested rollback, revision conflicts and retry/restart sequences. Generated domain inputs are shared across tiers. The suite uses seed 1729; all expected results are materialized before grading, rather than computed inside a candidate process.```bash# Unit/property tests for the benchmark and runner:python -m unittest discover -s tests -v# Regenerate data and manifest from authored source:klein-bench build# Export and run every trusted reference project, and reject every empty project:klein-bench validate --output results/validation.json```The readable reference implementations are evaluator maintenance tools. They are not starter code and must never be supplied to participants. `klein-bench reference TASK_ID --output DIRECTORY` exports a self-contained reference for auditing. A published `validation-summary.json` records the checked dataset manifest and validation totals; it is not a model evaluation score.## Execution boundaryThis is a local host runner, **not a security sandbox**. It strips inherited credentials from the subprocess environment, copies submissions to temporary directories, rejects file symlinks, limits captured output and time, and kills process groups. Native processes can still access the host filesystem and network. Run generated code under a dedicated unprivileged account on an expendable machine if host access is unacceptable. No Docker workflow is required or provided. Timing and resource availability depend on your host; record them with results.## Release, provenance and limitationsVersion 0.1.0 was authored specifically for this benchmark. No task was copied from SWE-bench, LiveCodeBench or another benchmark. This claim describes authoring provenance, not novelty of standard algorithms or proof against overlap with model training data. All prompts, fixtures and reference implementations are released under MIT. Some use Python standard-library semantics explicitly; the initial release evaluates Python projects only. The rubric measures behavioral correctness rather than UI quality, architectural elegance or production readiness. It does not require concurrent writers, fuzz external disk corruption, or simulate a power failure during a disk write.The fixed tests are not exhaustive. Reference validation and additional independent golden/property checks establish internal consistency; they cannot prove the absence of every specification or oracle error. Contributions should include a contract, meaningful boundary tests, an independent expected-output check, and a passing reference. Changing a contract or expected behavior requires a dataset version change; retain task IDs only for compatible corrections.37 unmodified lines383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788891 unmodified line91929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621737 unmodified linespath: klein_code_bench/data/max.jsonl---<p align="center"><img src="https://cdn-avatars.huggingface.co/v1/production/uploads/69ae829a8408eeb0d7dd5491/943kN5YZ59lFCUN1jiKz5.png" width="180" alt="KleinML"></p><p align="center"><a href="https://kleinml.com"><b>Klein ML Website</b></a></p># Klein-Code-BenchCan a model build a working program from scratch? Klein-Code-Bench gives a coding model a specification and anempty directory, and checks whether the finished Python project passes every acceptance test.- **260 tasks** in four tiers of 65- **Pass or fail per project:** a task counts only if all of its tests pass- **Runs locally:** standard-library Python, no Docker, no cloud model, no extra dependencies| Tier | Intended model size | What the model builds | Tasks || --- | --- | --- | ---: || easy | 2–8B | A JSONL command-line tool with a domain algorithm and error recovery | 65 || intermediate | 8–16B | A stateful document service: CRUD, listing, domain evaluation | 65 || hard | 16–32B | A service with atomic batches, revision checks and nested transactions | 65 || max | 60–200B | A durable service that survives being force-killed, with idempotency, history and pagination | 65 |The model sizes are design targets. Version 0.1.0 has not been calibrated against real models yet, and there is noleaderboard. Any model can be run on any tier.## How a task works1. The model gets `PROMPT.md`: the full specification plus two examples.2. It writes `main.py` and any other files into an empty `project/` directory. There's no starter code and noexisting repository to fix.3. The evaluator runs the project as a subprocess, sends JSONL requests and checks every response and state change.In the max tier, the process is force-killed right after its last acknowledged response, restarted on the samestate directory, and must continue correctly.The 65 tasks per tier come from the same 65 domain families: text processing, CSV/JSON tools, calendars, numericalutilities, graphs, scheduling, ledgers, geometry, parsing, simulation and more. Each tier adds service behavior ontop of the one below. Full list: [task catalog](docs/CATALOG.md).Because the tiers share families, results across tiers are correlated. Report each tier separately, and don'ttrain on one tier and then present another as an uncontaminated evaluation.## Quick startRequires Python 3.11+ on Linux or macOS.```bashgit clone https://huggingface.co/datasets/klein-ml/klein-code-bench1 unmodified linepython -m pip install -e .klein-bench list --subset easy# Create a workspace: PROMPT.md, plus an empty project/ directory for the modelklein-bench prepare kcb-easy-001-word-frequency --output workspaces/first# Give workspaces/first/PROMPT.md to your model and let it write into workspaces/first/project/, then:klein-bench evaluate kcb-easy-001-word-frequency \--solution workspaces/first/project --output results/first.jsonklein-bench score results/first.json```- `python -m klein_code_bench` works the same as `klein-bench`.- Exit code 1 means a failed submission, 2 an invalid invocation.- `--public-only` runs just the two examples as a smoke test. Those results can't be scored.Bring your own agent or local API endpoint, or use the [banana-harness integration](docs/BANANA_HARNESS.md).Record the model's inference settings with your results.## Loading the dataset```pythonfrom datasets import load_dataseteasy = load_dataset("klein-ml/klein-code-bench", "easy", split="test") # 65 tasksall_tasks = load_dataset("klein-ml/klein-code-bench", split="test") # 260 tasks```Each tier is its own config with a single `test` split; the default config contains all four. There is notraining split, and no loading script or `trust_remote_code` is needed. Pin `revision` to a commit when youreport results.| Field | Content || --- | --- || `task_id` | Stable unique ID || `subset`, `family`, `category`, `title` | Tier and task description || `target_model_parameters` | Intended model-size band (not calibrated) || `language`, `entrypoint`, `protocol_version` | Python, `main.py`, protocol version || `prompt` | The full specification the model sees || `public_tests` | Example requests and responses (JSON string) || `acceptance_tests` | Evaluator scenarios: sessions, requests, expected responses (JSON string) || `num_scenarios`, `num_assertions`, `timeout_seconds` | Test counts and the per-session time limit |The test fields are stored as JSON strings so that all tasks share one schema; decode them with `json.loads`.**Never put `acceptance_tests`, the reference implementations or the evaluator source into the model's prompt,context or workspace.** They're public for reproducibility, so the benchmark depends on you keeping them away from themodel.## ScoringThe metric is **resolve@1**: one project per task, and it counts only if every test passes.- **Per tier:** resolved tasks / 65. **Overall:** resolved tasks / 260.- Missing submissions count as failures. The report also shows the rate among submitted tasks and flags incomplete runs.- Partial assertion success is reported for diagnosis, but it never counts as resolved.Each scenario starts from a fresh copy of the submission and an empty state directory; sessions within a max-tierscenario share that directory. JSON comparison keeps array order and tells booleans apart from numbers. Floats usean absolute and relative tolerance of 1e-9; integers are compared exactly. Default limits are 10 seconds per sessionand 1 MiB of stdout. Details: [evaluation protocol](docs/EVALUATION.md).| Tier | Assertions || --- | ---: || easy | 3,075 || intermediate | 5,415 || hard | 9,705 || max | 15,490 || **total** | **33,685** |The tests cover:- 65 hand-written golden outputs- 24 generated inputs per family (seed 1729, shared across tiers)- boundary cases and malformed requests- failure atomicity, nested rollback and revision conflicts- retry and restart sequencesAll expected outputs are computed before grading, never inside the candidate's process.### Verifying the benchmark itself```bashpython -m unittest discover -s tests -v # unit and property tests for the benchmark and runnerklein-bench build # regenerate data and manifest from sourceklein-bench validate --output results/validation.json # every reference must pass, every empty project must fail```The reference implementations exist to maintain the evaluator. Export one for auditing with`klein-bench reference TASK_ID --output DIR`. The published `validation-summary.json` documents the datasetmanifest and validation totals; it is not a model score.## SecurityThe runner is **not a sandbox**. It does the following:- removes inherited credentials from the environment- runs each submission from a temporary copy- rejects symlinks- limits time and output- kills the whole process group when it's doneGenerated code can still reach your filesystem and network. Run it under a separate unprivileged user, on a machineyou can afford to lose. Timing depends on the host, so record your hardware with your results.## Provenance and limitations- **Origin:** every task was written for this benchmark. None were copied from SWE-bench, LiveCodeBench or otherbenchmarks. That covers how the tasks were authored; it doesn't guarantee that standard algorithms in the easy tiernever appear in a model's training data.- **Scope:** Python only. The tests measure behavioral correctness, not code quality, architecture or UI. They don'tcover concurrent writers, disk corruption or power loss during a write.- **Coverage:** the reference implementations and independent golden checks make the dataset internally consistent,but the tests can't prove that no specification or expected output contains an error.- **License:** MIT for prompts, test data and reference implementations.## ContributingA new task needs:- a contract (the specification)- meaningful boundary tests- an independent check of the expected outputs- a reference implementation that passesChanges to a contract or expected behavior require a new dataset version. Task IDs stay the same only forbackward-compatible fixes.
README.md+127-53