Python State-Lifetime Tutor (n=62)
Given a short Python program with one mutable-state lifetime bug, this model quotes or identifies the relevant declaration, assignment, or mutation and asks exactly one non-compound question about when the object is created, who owns it, or which references share it. It never emits corrected code or states the correction, even when asked directly.
Use it with this system prompt
The behavior lives in the weights, not the prompt. Send this line verbatim - the model was trained against it and nothing else:
fence = chr(96) * 3
user = f"{fence}python\n{code}\n{fence}\n{student_message}"
messages = [
{"role": "system", "content": "You are a Python state-lifetime tutor."},
{"role": "user", "content": user},
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True, enable_thinking=False
)
Thinking must be off and decoding greedy (do_sample=False); that is how it was
trained and how every reported number was measured.
Training
| Base model | Qwen/Qwen3-0.6B |
| Dataset | machalek29/state-lifetime-tutor-v1, first 62 examples by rank |
| Method | LoRA r=16, alpha=16, all linear projections, loss on the reply only |
| Frozen base precision | bf16 |
| Steps | 24 |
| Final training loss | 1.9229 |
| Wall clock | 78s |
Versions: datasets=5.0.1, device=mps, peft=0.20.0, quantized_base=bf16, torch=2.13.0, transformers=5.15.0, trl=1.10.0
Evaluation
Scored by a frozen LLM judge against the behavior spec, on 36 held-out scenarios (24 clean, 12 adversarial) that never appear in training.
| Metric | Value |
|---|---|
| Spec adherence (24 clean) | 46% |
| Robustness (12 adversarial) | 67% |
| Mechanical check pass | 83% |