CoolFace
Modelpublic

mailtotanvir/nano-agent-rust-repair-0.5b

sourceHugging Faceapache-2.0updated 23d agoView on Hugging Face
0likes56downloads
Model Card

nano-agent-rust-repair-0.5b

A 0.5B model that beats the mid-tier model that taught it, on held-out Rust repair, running on a CPU.

This is the v4 model from the nano-agent project: a Qwen2.5-Coder-0.5B-Instruct base fine-tuned to repair Rust compiler errors inside a verified loop whose oracle is cargo check. It is distributed as a q8_0 GGUF (~531 MB) that serves patches in seconds on a 4-core CPU with no GPU.

  • โ€”๐Ÿ“„ Paper: read the PDF ยท DOI: 10.5281/zenodo.22293159
  • โ€”๐Ÿ’ป Code (Apache-2.0): https://github.com/mailtotanvir/nano-agent
  • โ€”โœ๏ธ Write-up: https://mailtotanvir.github.io/nano-agent/blog.html
The model is one component. The recipe โ€” cheap proposer + perfect verifier + bounded retry + escalation โ€” is the product. This checkpoint is the proposer.

The result

The headline claim is not "small models are good." It is that a nano model, distilled inside a verified loop, can surpass its own teacher on cases neither has seen. All arms below run through the identical controller, SEARCH/REPLACE patch parser, and cargo check verifier.

Out-of-distribution (frozen eval_ood_v1, 25 hand-authored held-out cases)

ModelOOD repair rateRole
Frontier (1-shot)100% (25/25)comparison baseline only
DeepSeek-V4-Flash (1-shot)84% (21/25)comparison baseline
grok-class (1-shot)76% (19/25)comparison baseline
Gemini Flash (teacher / the bar)56% (14/25)the number to beat
Trained 0.5B v2 (single-site SFT)44% (11/25)pre-curriculum
Trained 0.5B v3 (+ Flash curriculum)60% (15/25)beats its teacher
Trained 0.5B v4 (this model)72% (18/25)+16 over the teacher bar

In-distribution (frozen eval_v1, 45 cases)

ArmRepair rateAvg. attempts
Untrained 0.5B (in loop)0.0% (0/45)3.89
Gemini Flash (1-shot teacher)84.4% (38/45)1.0
Trained 0.5B (this lineage, SFT)86.7% (39/45)1.4

An untrained 0.5B in the loop scores 0% โ€” it follows the JSON contract but not the SEARCH/REPLACE patch convention, so no patch applies. The same parser scores the teacher 38/45, proving the 0% is the model, not the harness. Every point above 0% is attributable to training.

How it was trained

  • โ€”Base: Qwen/Qwen2.5-Coder-0.5B-Instruct โ€” code-pretrained, instruct-tuned, quantizes to a ~531 MB q8_0 GGUF.
  • โ€”SFT: full bf16 (no LoRA), 3 epochs, lr 1e-5 cosine, effective batch 16, assistant_only_loss (loss on the JSON patch target only). Single 24 GB L4.
  • โ€”Data: every example is generated then confirmed by the real compiler before admission (broken must fail with the intended error class, fixed must compile). v4 = 739 SFT examples: single-site mutations + a failure-driven structural curriculum targeting the classes the frozen eval kept failing.
  • โ€”Teacher of record: Gemini Flash (a mid-tier model, 56% OOD). The v4 curriculum additionally distills the residual failing classes from a stronger (frontier, 100% OOD) teacher โ€” a labeled teacher-strength ablation, not a change of thesis.
  • โ€”Eval integrity: eval_v1 and eval_ood_v1 are frozen and verified disjoint from all training data by content hash. Never trained on the test.

The gain across rounds is coverage, not fit: in-training eval token accuracy stayed ~0.95 across v2/v3/v4 while OOD climbed 44 โ†’ 60 โ†’ 72. The 7 residual v4 failures cluster in one family (synthesize-and-insert a whole trait method / import), a capacity signal that points to RL or a larger base rather than more data.

Intended use

This is a specialist proposer for a verified repair loop, not a general chat or code model. It is trained to emit a single SEARCH/REPLACE patch for a localized Rust compiler diagnostic. Use it inside the nano-agent controller, which supplies the compiler context and re-verifies every patch. Outside that loop, or on non-Rust code, behavior is undefined.

Usage

The intended path is through the rust-repair controller:

bash
git clone https://github.com/mailtotanvir/nano-agent.git
cd nano-agent && cargo build --release

# serve this GGUF with llama.cpp on :8080, then:
./target/release/rust-repair --path ./broken-crate \
    --backend llama --model nano-agent-rust-repair-0.5b

Or serve the raw GGUF directly with llama.cpp:

bash
# download the file from this repo, then:
llama-server -m qwen05-sft-v4-q8_0.gguf --port 8080

Limitations

One model family, single training seed per configuration (point estimates carry single-run variance). Eval sets are small (45 / 25), so one OOD case is worth 4 points. Rust-only, one verifier (cargo check). Latency is not a claim. See the paper's Limitations section for the full accounting. Total project spend was under $6, of which ~$1.26 was GPU.

Citation

bibtex
@software{ahmed_nanoagent_2026,
  author  = {Ahmed, Tanvir},
  title   = {nano-agent: A Tiny Model Beats Its Teacher --- Verified-Loop
             Repair with a Sub-1B Language Model},
  year    = {2026},
  publisher = {Zenodo},
  doi     = {10.5281/zenodo.22293159},
  url     = {https://github.com/mailtotanvir/nano-agent}
}