Download tools/make_card.py from RenaissanceLabsEU/practice: direct link, hf CLI and curl.
- Browser
- Download file 9.77 kB
-
https://huggingface.co/datasets/RenaissanceLabsEU/practice/resolve/main/tools/make_card.py
- Command line
-
hf download hf://datasets/RenaissanceLabsEU/practice/tools/make_card.py
-
curl -L -o make_card.py https://huggingface.co/datasets/RenaissanceLabsEU/practice/resolve/main/tools/make_card.py
9.77 kB
| #!/usr/bin/env python3 | |
| """Write the dataset card (README.md) and the per-environment index files (data/<env>/<split>.jsonl) | |
| from environments.json and tasks.jsonl. Run after tools/export.py.""" | |
| import json, os, shutil | |
| ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
| ISCED = {"0232": "Literature and linguistics", "0414": "Marketing and advertising", "0522": "Natural environments and wildlife", "0723": "Textiles (clothes, footwear and leather)", | |
| "0812": "Horticulture", "0831": "Fisheries", "1021": "Community sanitation", "0111": "Education science", "0222": "History and archaeology", "0223": "Philosophy and ethics", "0311": "Economics", | |
| "0312": "Political sciences and civics", "0313": "Psychology", "0314": "Sociology and cultural studies", "0521": "Environmental sciences", | |
| "0721": "Food processing", "0731": "Architecture and town planning", "0821": "Forestry", "0913": "Nursing and midwifery", | |
| "0923": "Social work and counselling", "1022": "Occupational health and safety"} | |
| envs = sorted(json.load(open(os.path.join(ROOT, "environments.json"))), key=lambda e: e["isced"]) | |
| tasks = [json.loads(l) for l in open(os.path.join(ROOT, "tasks.jsonl"))] | |
| shutil.rmtree(os.path.join(ROOT, "data"), ignore_errors=True) | |
| for e in envs: | |
| for split in ("train", "eval"): | |
| p = os.path.join(ROOT, "data", e["name"], split + ".jsonl"); os.makedirs(os.path.dirname(p), exist_ok=True) | |
| with open(p, "w") as f: | |
| for t in tasks: | |
| if t["env"] == e["name"] and t["split"] == split: | |
| f.write(json.dumps({k: t[k] for k in ("id", "env", "isced_f", "family", "difficulty", "seed", "title", "instruction", "checks", "path", "languages", "task_meta")}, ensure_ascii=False) + "\n") | |
| yaml = ["---", "pretty_name: Practice", "license: mit", "language:", "- en", "- sv", "task_categories:", "- other", "tags:", "- rl-environment", "- harbor", "- agents", | |
| "- reinforcement-learning", "- verifiable-rewards", "- isced-f", "size_categories:", "- 1K<n<10K", "thumbnail: https://huggingface.co/datasets/RenaissanceLabsEU/practice/resolve/main/assets/social-preview.png", "configs:"] | |
| for e in envs: | |
| yaml += ["- config_name: " + e["name"], " data_files:", " - split: train", " path: data/%s/train.jsonl" % e["name"], " - split: eval", " path: data/%s/eval.jsonl" % e["name"]] | |
| yaml.append("---") | |
| first = sorted(t["id"] for t in tasks if t["env"] == envs[0]["name"] and t["split"] == "train")[0] | |
| rows = "\n".join("| [`%s`](tasks/%s) | %s %s | %s | %s | %s | %d |" % (e["name"], e["name"], e["isced"], ISCED.get(e["isced"], ""), ", ".join({"en": "English", "sv": "Swedish"}.get(x,x) for x in e["languages"]), e["summary"], ", ".join(e["families"]), e["tasks"]) for e in envs) | |
| card = """%s | |
| # Practice | |
|  | |
| **%d environments and %s tasks for language-model agents, across fields of human work.** By [Renaissance Labs](https://renaissancelabs.eu). | |
| Most open environments teach models to write software and operate computers. The [Open Environments Index](https://practice.renaissancelabs.eu) files every open environment under the ISCED-F 2013 fields of education, and reveals gaps across its 80 detailed fields. Practice broadens the coverage: nursing, forestry, food processing, town planning, political science, demography, psychology and more. | |
| In every task the agent gets a folder of working files (charts, logs, registers, a rule document) and an instruction, works in a terminal, and writes `answer.json`. A hidden deterministic verifier returns a reward between 0 and 1. | |
| ## Environments | |
| Each environment is a subset of this dataset (pick it in the viewer, or `load_dataset("RenaissanceLabsEU/practice", "<name>")` for the task index). | |
| | Subset | ISCED-F field | Task language | What the agent does | Task families | Tasks | | |
| |---|---|---|---|---|---| | |
| %s | |
| Every subset has a `train` split (84 tasks) and an `eval` split (24 tasks, from seeds the train split never uses). Each has three difficulty levels: a small clean case, then more records and one complication, then a second complication and answers that depend on several records. | |
| ## Layout | |
| ``` | |
| tasks/<env>/<task_id>/ one Harbor task directory per task | |
| instruction.md what the agent is asked to do | |
| task.toml metadata and limits (1 CPU, 1 GB, no internet) | |
| environment/ Dockerfile (python:3.12-slim) and workdir/ with the task files, copied to /app | |
| solution/ solve.sh and oracle.py: the reference solution, never shown to the agent | |
| tests/ test.sh, verify.py, checks.json: the hidden verifier | |
| data/<env>/{train,eval}.jsonl the task index shown in the viewer (id, family, difficulty, instruction, path) | |
| envs/<env>/ the seeded generator, the oracle and any validators for each environment | |
| practice/, tools/, tests/ shared verifier, exporter, self-test and hand-worked test cases | |
| ``` | |
| ## Run it | |
| ```bash | |
| hf download RenaissanceLabsEU/practice --repo-type dataset --local-dir Practice | |
| cd Practice | |
| T=tasks/%s/%s | |
| # check one task by hand: build, run the reference solution, run the verifier (prints 1.0) | |
| docker build -t practice-task $T/environment | |
| docker run --rm --network none -v $PWD/$T/tests:/tests:ro -v $PWD/$T/solution:/solution:ro practice-task \\ | |
| bash -c 'bash /solution/solve.sh; bash /tests/test.sh; cat /logs/verifier/reward.txt' | |
| ``` | |
| Each task folder follows the [Harbor](https://github.com/harbor-framework/harbor) task layout, so a Harbor-compatible harness can run a whole environment, for example `harbor run --path tasks/%s --agent oracle` and then your own agent and model. The agent works in `/app` and must write `/app/answer.json`; the verifier writes `/logs/verifier/reward.txt`. Tasks need no network and no GPU. | |
| To rebuild the packaged tasks deterministically: `python3 tools/export.py <env_folder>` (standard library only). | |
| ## Reward | |
| The verifier compares each value in `answer.json` with the expected one: integers exactly, numbers within one unit of the last decimal the instruction asks for, lists and sets structurally. Where a good answer is not unique (an excavation sequence, a counterexample to an argument), a validator checks the answer against the problem's own constraints. The reward is the weighted share of checks passed. A missing or unreadable answer scores 0, and `reward.json` also reports `solved` (all checks passed) for those who want a pass or fail signal. | |
| ## How the tasks were checked | |
| - **Two code paths.** The generator computes expected values from its in-memory data. A separate standalone oracle recomputes them from the task files alone, as an agent would. They share no code and must agree exactly on every task. | |
| - **Every check has teeth.** For each task the test suite changes each checked value in turn and confirms the check then fails; an empty answer, an empty object and a non-object must all score 0. | |
| - **No knife edges.** Generators resample until every value that decides a category, flag or rounding is clearly away from its boundary. | |
| - **Hand-worked cases.** `tests/` holds hand-worked cases for the reference environments. Generator self-tests also compare every generated answer with an independent file-based solver. | |
| - **Runnable tasks.** Every exported task is checked locally: the reference solution scores 1.0 and doing nothing scores 0. Docker smoke tests cover every task family with networking disabled; the tested oracle scores 1.0 and no-op scores 0. See `VALIDATION.md` for scope. | |
| Method references and modelling assumptions for the new environments are recorded in [METHODS.md](METHODS.md). | |
| ## Swedish language tasks | |
| The Swedish subsets are labelled `sv`; the other subsets are labelled `en`. Language is stored in each `env.toml`, every Harbor task's metadata/tags, the split indices and `environments.json`. `language-sv` and `language-en` tags refer to task language. | |
| The Swedish tasks are bounded editorial exercises with explicit house-style contracts and accepted alternatives. They preserve factual roles, negation, names, numbers and untouched text; copying the erroneous source earns zero. Copy briefs use current source records and reject stale revisions and unsupported claims. These checks measure constrained editing and factual compliance, **not** creativity, persuasive power or unrestricted Swedish writing quality. See [SWEDISH_QUALITY.md](SWEDISH_QUALITY.md) for the acceptance boundary, validation and source-pack holdouts. | |
| ## Limits | |
| - No model has been trained on these tasks yet, so we do not know how much training on them helps, or how hard they are for current models. We will report baselines when we have them. | |
| - The eval split uses unseen seeds but the same generators as the train split. Swedish subsets additionally use disjoint lexical/content packs; they share grammatical rules and house-style formats. This does not establish transfer to unrestricted text. | |
| - The data is synthetic. Formulas and conventions are standard ones from each field and are stated in each task, but the tasks have not yet been reviewed by practitioners in every field. Corrections are welcome in the Community tab. | |
| - Rules that vary by country (benefit regulations, zoning codes, exposure limits) are fictional and shipped with the task. They teach the method, not any jurisdiction's law. | |
| ## Licence | |
| MIT. Please credit "Practice by Renaissance Labs". | |
| """ % ("\n".join(yaml), len(envs), "{:,}".format(len(tasks)), rows, envs[0]["name"], first, envs[0]["name"]) | |
| open(os.path.join(ROOT, "README.md"), "w").write(card) | |
| print("card written for", len(envs), "environments,", len(tasks), "tasks") | |