Summary of Results
- Bug-fixing: Solves 88.0% of held-out bug-fix tasks, up from 31.0% on base
Qwen/Qwen3-8B (2.8x).
- Clean edits: 97.0% of
edit_file calls match cleanly once and parse without syntax errors, up from 46.0%.
- Composite score: Moves from 43.19 to 59.16 (+15.97) across 790 tasks while holding steady on HumanEval+ (81.1%) and improving on original MBPP (84.7% vs 82.0%).
- Drop-in Qwen3 format: Uses the same chat template and
<tool_call> JSON format across five tools: read_file, edit_file, grep_search, list_files, and run_command.
- Open dataset: All three training splits are published in
netm8/m4-coding-agent-v2-dataset.
Benchmarks
Evaluated in bfloat16 with the same harness across all 790 tasks (pass@1, temperature=0, enable_thinking=False). Raw outputs are in eval_official_790.json.
Table with columns: Model, Held-Out Bug-Fix (100), Clean Edit Apply, HumanEval+ (164), MBPP+ (378), BigCodeBench-Hard (148), Composite| Model | Held-Out Bug-Fix (100) | Clean Edit Apply | HumanEval+ (164) | MBPP+ (378) | BigCodeBench-Hard (148) | Composite |
|---|
Qwen/Qwen3-8B (Base) | 31.0% | 46.0% | 80.5% (84.8% base) | 72.5% (82.0% base) | 20.9% | 43.19 |
qwen3-8b-m4-agent-v2 | 88.0% (+57.0) | 97.0% (+51.0) | 81.1% (85.4% base) | 72.2% (84.7% base) | 17.6% | 59.16 (+15.97) |
Composite = 0.35 * BigCodeBench-Hard + 0.30 * Bug-Fix + 0.20 * MBPP+ + 0.15 * HumanEval+.
What the bug-fix benchmark tests
The model gets the contents of a failing Python file via a read_file response and has to fix the bug in one edit_file call. A task only passes if old_string matches the file exactly once, the resulting file parses cleanly, and the hidden unit tests pass.
Notes and trade-offs
- Focused on editing existing code: The big gains are on tool-based bug fixing. General Python coding on
HumanEval+ and MBPP+ stays roughly level with stock Qwen3-8B, while original MBPP improves from 82.0% to 84.7%.
- BigCodeBench-Hard trade-off: The model solves 26/148 tasks on
BigCodeBench-Hard compared to 31/148 for the base model. Stock Qwen3-8B still does slightly better on long, library-heavy one-shot scripts.
- In-house held-out set: The 100 bug-fix tasks were held out of all training stages, but they come from the same task generator as the training data rather than an external public leaderboard.
How it was trained
All training data is public in netm8/m4-coding-agent-v2-dataset (~30,475 rows across three configs built for each stage):
- Multi-language agent SFT (
default: 23,475 train / 500 val): Supervised fine-tuning on multi-turn coding trajectories and multi-language coding tasks remapped into one unified five-tool schema (read_file, edit_file, grep_search, list_files, run_command).
- On-policy distillation, 30B to 8B (
opd_prompts: 4,000 prompts): Reverse-KL distillation from Qwen3-Coder-30B-A3B-Instruct to recover general coding quality while keeping the tool-use habits from stage 1.
- Execution-verified self-improvement (
rlvr: 2,500 executable tasks, last 100 held out for eval): Sampled 8 candidate edits per bug-fix task (900 tasks) and 4 candidate solutions per stdin/stdout programming task (1,500 tasks). An automated test runner kept only the candidates that passed their tests, and a rank-64 LoRA was trained on those 1,732 verified examples and merged back in.
Table with columns: Stage 3 details| Stage 3 details | |
|---|
| Bug-fix tasks with a passing edit | 814 / 900 |
| Stdin/stdout tasks with a passing solution | 464 / 1,500 |
| Verified training examples | 1,732 |
| Schedule | 604 steps (2 epochs), cosine LR (1e-4) |
Usage
This repo holds the merged bfloat16 safetensors weights (~16.4 GB). Pass your tool schema through the Qwen3 chat template with enable_thinking=False to match how the model was evaluated:
from transformers import AutoModelForCausalLM, AutoTokenizer repo = "netm8/qwen3-8b-m4-agent-v2"tokenizer = AutoTokenizer.from_pretrained(repo)model = AutoModelForCausalLM.from_pretrained(repo, dtype="auto", device_map="auto") tools = [{ "type": "function", "function": { "name": "edit_file", "description": "Apply a targeted search-and-replace edit to an existing file.", "parameters": { "type": "object", "properties": { "path": {"type": "string"}, "old_string": {"type": "string"}, "new_string": {"type": "string"}, }, "required": ["path", "old_string", "new_string"], }, },}] messages = [ {"role": "user", "content": "Fix the off-by-one error in `utils.py` using `edit_file`."}] prompt = tokenizer.apply_chat_template( messages, tools=tools, tokenize=False, add_generation_prompt=True, enable_thinking=False,) inputs = tokenizer(prompt, return_tensors="pt").to(model.device)output = model.generate(**inputs, max_new_tokens=512, do_sample=False)print(tokenizer.decode(output[0], skip_special_tokens=False))
Tool calls use the standard Qwen3 XML wrapper:
<tool_call>{"name": "edit_file", "arguments": {"path": "utils.py", "old_string": "...", "new_string": "..."}}</tool_call>
The end goal for this model is 4-bit MLX quantization (~4.3 GB) on a 16 GB Apple Silicon Mac. This repo only contains the full-precision bfloat16 weights used for the benchmarks above; you can quantize locally with mlx_lm.convert.
Limitations
- Stage 3 and all benchmarks are Python only. Other languages were included in Stage 1 SFT but not evaluated.
- Bug-fix evaluation only tests single-step edits, not long multi-turn sessions.
- Run generated code and shell commands in a sandbox.
License
Apache-2.0, same as Qwen/Qwen3-8B.