birgermoell's picture
Add detailed Run-Card Model Card with per-environment before/after table
378f439 verified
|
Raw History Blame Contribute Delete
8.18 kB
---
license: apache-2.0
base_model: Qwen/Qwen2.5-Coder-1.5B-Instruct
datasets:
- RenaissanceLabsEU/practice
language:
- en
- sv
tags:
- mlx
- lora
- sft
- harbor
- rl-environments
- practice
- renaissancelabs
- verifiable-rewards
library_name: mlx
---
# practice-coder-1.5b-mlx
A 1.5B-parameter 4-bit MLX coding model fine-tuned by [Renaissance Labs](https://renaissancelabs.eu) on the `train` split of [RenaissanceLabsEU/practice](https://huggingface.co/datasets/RenaissanceLabsEU/practice) — 22 open, MIT-licensed Harbor environments covering non-coding fields of human work (nursing, forestry, archaeology, town planning, economics, demography, psychometrics, horticulture, food processing, textiles, sanitation, emissions, occupational hygiene, political science, logic, and Swedish editorial work).
Given a task instruction (`instruction.md`) and workspace file previews, the model generates a self-contained standard-library Python script that reads the task files in `/app` and writes `/app/answer.json`, scored by each task's hidden deterministic verifier (`tests/verify.py`).
This is our first open SFT baseline on Practice: its primary purpose is to establish a reproducible **before vs. after** measurement on unseen held-out tasks and surface concrete engineering bottlenecks (like sequence truncation on multi-family solvers) for v2 and RLVR runs.
---
## Summary results (held-out `eval` split)
Evaluated on a stratified **66-task held-out slice** of `RenaissanceLabsEU/practice` (`split == "eval"`: 3 tasks per environment across all 22 environments, covering difficulties 1–3; greedy decoding, `max_tokens=2048`, executed in an isolated temp copy of `environment/workdir/` with `python3 -I` and graded by `tests/verify.py`):
| Model | Mean reward | Exact solved (`reward == 1.0`) | Solved on tasks fitting 2,048-tok cap (42 tasks) | Failure breakdown |
|---|---:|---:|---:|---|
| `mlx-community/Qwen2.5-Coder-1.5B-Instruct-4bit` (base) | `0.0000` | `0 / 66` (`0.0%`) | `0 / 42` (`0.0%`) | graded: 6, no_answer_json: 2, no_code: 9, runtime_error: 49 |
| **`RenaissanceLabsEU/practice-coder-1.5b-mlx`** (LoRA SFT) | **`0.1523`** | **`8 / 66` (`12.1%`)** | **`8 / 42` (`19.0%`)** | graded: 13, no_code: 25, runtime_error: 28 |
### Per-environment breakdown (`eval` split, 3 tasks per environment)
| Environment | Base solved (mean reward) | Fine-tuned solved (mean reward) | After-SFT status counts |
|---|---:|---:|---|
| `argument-check` | 0/3 (0.00) | **0/3** (0.00) | runtime_error: 3 |
| `class-test` | 0/3 (0.00) | **0/3** (0.00) | no_code: 3 |
| `emissions-inventory` | 0/3 (0.00) | **0/3** (0.00) | no_code: 2, runtime_error: 1 |
| `exposure-assessment` | 0/3 (0.00) | **0/3** (0.00) | no_code: 2, runtime_error: 1 |
| `fishery-log` | 0/3 (0.00) | **0/3** (0.00) | runtime_error: 3 |
| `food-batch` | 0/3 (0.00) | **0/3** (0.17) | graded: 1, runtime_error: 2 |
| `grower-desk` | 0/3 (0.00) | **2/3** (0.92) | graded: 3 |
| `habitat-survey` | 0/3 (0.00) | **0/3** (0.27) | graded: 2, runtime_error: 1 |
| `harris-matrix` | 0/3 (0.00) | **2/3** (0.67) | graded: 2, runtime_error: 1 |
| `life-table` | 0/3 (0.00) | **0/3** (0.00) | no_code: 3 |
| `means-test` | 0/3 (0.00) | **0/3** (0.00) | no_code: 1, runtime_error: 2 |
| `price-index` | 0/3 (0.00) | **0/3** (0.00) | no_code: 1, runtime_error: 2 |
| `psychometrics` | 0/3 (0.00) | **0/3** (0.00) | no_code: 3 |
| `sanitation-desk` | 0/3 (0.00) | **2/3** (0.67) | graded: 2, runtime_error: 1 |
| `seat-count` | 0/3 (0.00) | **0/3** (0.00) | runtime_error: 3 |
| `stand-inventory` | 0/3 (0.00) | **0/3** (0.00) | no_code: 1, runtime_error: 2 |
| `swedish-copy-briefs` | 0/3 (0.00) | **0/3** (0.00) | graded: 1, runtime_error: 2 |
| `swedish-proofreading` | 0/3 (0.00) | **0/3** (0.00) | no_code: 3 |
| `swedish-rewriting` | 0/3 (0.00) | **0/3** (0.00) | no_code: 3 |
| `textile-lab` | 0/3 (0.00) | **2/3** (0.67) | graded: 2, runtime_error: 1 |
| `ward-round` | 0/3 (0.00) | **0/3** (0.00) | no_code: 3 |
| `zoning-check` | 0/3 (0.00) | **0/3** (0.00) | runtime_error: 3 |
---
## Run Card (training setup & loss curve)
- **Identity:** `RenaissanceLabsEU/practice-coder-1.5b-mlx` (fused 4-bit MLX checkpoint)
- **Base model:** `mlx-community/Qwen2.5-Coder-1.5B-Instruct-4bit` (quantized from `Qwen/Qwen2.5-Coder-1.5B-Instruct`)
- **Dataset:** [RenaissanceLabsEU/practice](https://huggingface.co/datasets/RenaissanceLabsEU/practice), `split == "train"` only (`1,672` train / `176` validation, stratified by environment). Holdout integrity verified with [`grader-audit`](https://skills.renaissancelabs.eu/skill/grader-audit/): `0` duplicate IDs, `0` train/eval seed overlaps, `0` train/eval payload overlaps, `528/528` eval oracles pass, `0/2,772` adversarial grader crashes.
- **Method:** `mlx-lm` LoRA (`16` layers, rank `8`, `5.276M` trainable parameters = `0.342%` of 1.54B), `--mask-prompt`, `--grad-checkpoint`.
- **Hyperparameters:** `batch_size=1`, `grad_accumulation_steps=4` (effective batch 4), `iters=300` (1,200 examples ≈ 0.72 epochs), `lr=2e-4` (Adam), `max_seq_length=3072`.
- **Loss curve:**
- Step `1`: `val_loss = 1.056`
- Step `100`: `val_loss = 0.553`
- Step `250`: `train_loss = 0.174`
- Step `300`: `val_loss = 0.069`, `train_loss = 0.077`
- **Hardware & wall-clock:** Apple M5 (32 GB unified memory), ~13 minutes training (~450–520 tok/s).
---
## Prompt format
The model was trained with the Qwen2.5 chat template:
- **System:** `You are a careful Python programmer solving structured domain-work tasks. Read the instruction and the workspace files, then return a single complete \`\`\`python ... \`\`\` script that uses only the Python standard library, reads the files in the current working directory, and writes the required \`answer.json\`.`
- **User:** Full contents of `instruction.md` followed by `## Workspace`, listing all files in `environment/workdir/` and previews (up to 1,800 chars/file, 5,500 chars total).
- **Assistant:** A single fenced ` ```python ... ``` ` block that reads the workspace files from disk and writes `answer.json`.
---
## Quick start (Apple Silicon / MLX)
```bash
uv run --with mlx-lm python3 -m mlx_lm generate \
--model RenaissanceLabsEU/practice-coder-1.5b-mlx \
--prompt "Read the task instruction and workspace files and write a Python script that outputs answer.json." \
--max-tokens 2048
```
---
## What went wrong & known limits
1. **Sequence-length truncation on long multi-family solvers (`24 / 66` tasks):** In `RenaissanceLabsEU/practice`, each environment's reference `solution/oracle.py` bundles all task families for that environment into one 6–8 KB script. During training (`max_seq_length=3072`) and evaluation (`max_tokens=2048`), the longest environments (`class-test`, `ward-round`, `life-table`, `psychometrics`, `swedish-proofreading`, `swedish-rewriting`) were truncated before closing the code fence, yielding `0.0` (`no_code`). **v2 fix:** extract single-family / single-task solvers as SFT targets and raise context length to `4096+`, followed by RLVR (GRPO) directly against `tests/verify.py`.
2. **In-distribution scope:** The `eval` split uses unseen seeds (and disjoint lexical/content packs for Swedish subsets) from the same 22 environment families present in `train`. This proves measurable SFT lift on held-out Practice instances, not zero-shot generalization to unseen domains or readiness for real-world clinical/legal/regulatory use.
3. **Synthetic data & fictional jurisdiction rules:** Practice tasks use synthetic records and fictional local rules shipped inside each task directory.
4. **4-bit MLX weights:** Intended for fast local inference on Apple Silicon via `mlx-lm`.
---
## Links & license
- **Dataset:** [RenaissanceLabsEU/practice](https://huggingface.co/datasets/RenaissanceLabsEU/practice)
- **Open Environments Index:** [practice.renaissancelabs.eu](https://practice.renaissancelabs.eu)
- **Grader Audit Skill:** [skills.renaissancelabs.eu/skill/grader-audit](https://skills.renaissancelabs.eu/skill/grader-audit/)
- **Lab:** [renaissancelabs.eu](https://renaissancelabs.eu)
- **License:** Apache 2.0 (inherited from `Qwen/Qwen2.5-Coder-1.5B-Instruct`).