CoolFace
Modelpublic

usernamebetter/nanocoder-v1

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes9downloads
Model Card

NanoCoder V1 ๐Ÿง โšก

A 4B parameter full-stack coding assistant fine-tuned from Qwen3-4B using Unsloth + LoRA. Trained through a multi-phase pipeline with joint domain training and validation-driven checkpoint selection.

Best checkpoint: step 150 โ€” combined score 73.6% across all skill domains.


๐Ÿ“Š Benchmarks

BenchmarkScoreNotes
HumanEval pass@149.4%164 problems, executed against test cases
LiveCodeBench13.3%Execution eval on 30 problems (public tests)
Frontend (custom)58.3%React, Next.js, TypeScript, Tailwind, a11y
Backend (custom)87.5%FastAPI, Express, PostgreSQL, JWT, MongoDB
Agent (custom)75.0%Thought โ†’ Action โ†’ Patch โ†’ Reasoning format
Combined73.6%Averaged across skill domains

๐ŸŽฏ What it does well

  • โ€”Backend โ€” API design, auth (JWT/bcrypt), SQL/NoSQL, N+1 fixes, CORS
  • โ€”Debugging agent โ€” structured reasoning (### Thought โ†’ ### Action โ†’ ### Patch โ†’ ### Reasoning)
  • โ€”Full-stack integration โ€” connects frontend + backend flows
  • โ€”Bug pattern recognition โ€” race conditions, memory leaks, type errors

โš ๏ธ Known limitations

  • โ€”Frontend scores lower than backend (weakest domain in v1)
  • โ€”Not a replacement for larger models (7B+) on hard competitive programming
  • โ€”English-only

๐Ÿš€ Usage

python
from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="usernamebetter/nanocoder-v1",
    max_seq_length=2048,
    load_in_4bit=True,
)
FastLanguageModel.for_inference(model)

SYSTEM = "You are NanoCoder, an expert Senior Full-Stack Engineer and debugging agent."

prompt = (
    f"<|im_start|>system\n{SYSTEM}<|im_end|>\n"
    f"<|im_start|>user\nFix this React hydration error: useState(Date.now())<|im_end|>\n"
    f"<|im_start|>assistant\n"
)

inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=300, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

๐Ÿ—๏ธ Training pipeline

Multi-phase joint training from Qwen3-4B base:

  1. 1.Phase 1 โ€” General coding (Magicoder-Evol-Instruct)
  2. 2.Phase 2 โ€” Frontend specialization
  3. 3.Phase 3 โ€” Fullstack (frontend + backend interleaved)
  4. 4.Phase 4 โ€” Agent reasoning training
  5. 5.Final โ€” Joint retrain from base with all domains mixed (this checkpoint)

Training configuration

  • โ€”Base: Qwen3-4B (4-bit quantized)
  • โ€”LoRA: r=32, alpha=32, dropout=0
  • โ€”LR: 1e-5 with cosine scheduler
  • โ€”Steps: 400 (best checkpoint at step 150)
  • โ€”Batch: 2 ร— grad accum 4 = effective 8
  • โ€”Optimizer: adamw_8bit
  • โ€”Dataset: ~13.7k samples interleaved
  • โ€”๐Ÿค– Agent (synthetic + real): 40%
  • โ€”๐ŸŽจ Frontend: 35%
  • โ€”โš™๏ธ Backend: 15%
  • โ€”๐Ÿ› Bug fixing: 10%

Data sources

  • โ€”ise-uiuc/Magicoder-Evol-Instruct-110K
  • โ€”sahil2801/CodeAlpaca-20k
  • โ€”nickrosh/Evol-Instruct-Code-80k-v1
  • โ€”iamtarun/codeinstructions120k_alpaca
  • โ€”m-a-p/CodeFeedback-Filtered-Instruction
  • โ€”bigcode/self-oss-instruct-sc2-exec-filter-50k
  • โ€”HuggingFaceH4/CodeAlpaca_20K
  • โ€”TokenBender/codeinstructions122kalpacastyle
  • โ€”Custom synthetic agent examples with structured reasoning format

๐Ÿงช Prompt format

Uses Qwen chat template:

<|im_start|>system
You are NanoCoder, an expert Senior Full-Stack Engineer and debugging agent.
<|im_end|>
<|im_start|>user
{your question}
<|im_end|>
<|im_start|>assistant

For debugging tasks, the model responds in structured format:

### Thought:
{root cause analysis}

### Action:
{what to do}

### Patch:
{code fix}

### Reasoning:
{why it works}

๐Ÿ“… Roadmap

  • โ€”โœ… v1: Joint multi-domain training (this release)
  • โ€”๐Ÿšง v2: Frontend boost + reasoning domain + label smoothing + cosine restarts
  • โ€”๐Ÿšง v3: DPO alignment + tool calling
  • โ€”๐Ÿšง GGUF: Q4KM / Q5KM / Q8_0 exports

๐Ÿ™ Credits

  • โ€”Base model: Qwen/Qwen3-4B
  • โ€”Fine-tuning framework: Unsloth
  • โ€”Training: Kaggle T4 + Google Colab T4

๐Ÿ“„ License

Apache-2.0 (inherited from Qwen3-4B base).