Text Generation
PEFT
Safetensors
English
code
coding
full-stack
frontend
backend
agent
qwen3
lora
unsloth
fine-tuned
conversational
Instructions to use usernamebetter/nanocoder-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use usernamebetter/nanocoder-v1 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen3-4B-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "usernamebetter/nanocoder-v1") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Desktop
Update model card with full benchmarks + training details
Browse files
README.md
CHANGED
|
@@ -1,210 +1,172 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
pipeline_tag: text-generation
|
| 5 |
tags:
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
## Model Details
|
| 21 |
-
|
| 22 |
-
### Model Description
|
| 23 |
-
|
| 24 |
-
<!-- Provide a longer summary of what this model is. -->
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
- **Developed by:** [More Information Needed]
|
| 29 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 30 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 31 |
-
- **Model type:** [More Information Needed]
|
| 32 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 33 |
-
- **License:** [More Information Needed]
|
| 34 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 35 |
-
|
| 36 |
-
### Model Sources [optional]
|
| 37 |
-
|
| 38 |
-
<!-- Provide the basic links for the model. -->
|
| 39 |
-
|
| 40 |
-
- **Repository:** [More Information Needed]
|
| 41 |
-
- **Paper [optional]:** [More Information Needed]
|
| 42 |
-
- **Demo [optional]:** [More Information Needed]
|
| 43 |
-
|
| 44 |
-
## Uses
|
| 45 |
-
|
| 46 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 47 |
-
|
| 48 |
-
### Direct Use
|
| 49 |
-
|
| 50 |
-
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
|
| 51 |
-
|
| 52 |
-
[More Information Needed]
|
| 53 |
-
|
| 54 |
-
### Downstream Use [optional]
|
| 55 |
-
|
| 56 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 57 |
-
|
| 58 |
-
[More Information Needed]
|
| 59 |
-
|
| 60 |
-
### Out-of-Scope Use
|
| 61 |
-
|
| 62 |
-
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
|
| 63 |
-
|
| 64 |
-
[More Information Needed]
|
| 65 |
-
|
| 66 |
-
## Bias, Risks, and Limitations
|
| 67 |
-
|
| 68 |
-
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
| 69 |
-
|
| 70 |
-
[More Information Needed]
|
| 71 |
-
|
| 72 |
-
### Recommendations
|
| 73 |
-
|
| 74 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
| 75 |
-
|
| 76 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 77 |
-
|
| 78 |
-
## How to Get Started with the Model
|
| 79 |
-
|
| 80 |
-
Use the code below to get started with the model.
|
| 81 |
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
### Training Procedure
|
| 93 |
-
|
| 94 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 95 |
-
|
| 96 |
-
#### Preprocessing [optional]
|
| 97 |
-
|
| 98 |
-
[More Information Needed]
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
#### Training Hyperparameters
|
| 102 |
-
|
| 103 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 104 |
-
|
| 105 |
-
#### Speeds, Sizes, Times [optional]
|
| 106 |
-
|
| 107 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 108 |
-
|
| 109 |
-
[More Information Needed]
|
| 110 |
-
|
| 111 |
-
## Evaluation
|
| 112 |
-
|
| 113 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 114 |
-
|
| 115 |
-
### Testing Data, Factors & Metrics
|
| 116 |
-
|
| 117 |
-
#### Testing Data
|
| 118 |
-
|
| 119 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 120 |
-
|
| 121 |
-
[More Information Needed]
|
| 122 |
-
|
| 123 |
-
#### Factors
|
| 124 |
-
|
| 125 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 126 |
-
|
| 127 |
-
[More Information Needed]
|
| 128 |
-
|
| 129 |
-
#### Metrics
|
| 130 |
-
|
| 131 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 132 |
-
|
| 133 |
-
[More Information Needed]
|
| 134 |
-
|
| 135 |
-
### Results
|
| 136 |
-
|
| 137 |
-
[More Information Needed]
|
| 138 |
-
|
| 139 |
-
#### Summary
|
| 140 |
|
|
|
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
-
##
|
| 150 |
|
| 151 |
-
|
|
|
|
|
|
|
| 152 |
|
| 153 |
-
|
| 154 |
|
| 155 |
-
|
| 156 |
-
- **Hours used:** [More Information Needed]
|
| 157 |
-
- **Cloud Provider:** [More Information Needed]
|
| 158 |
-
- **Compute Region:** [More Information Needed]
|
| 159 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 160 |
|
| 161 |
-
|
|
|
|
| 162 |
|
| 163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
-
|
| 166 |
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
-
|
| 172 |
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
|
| 175 |
-
|
| 176 |
|
| 177 |
-
|
| 178 |
|
| 179 |
-
|
| 180 |
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
-
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
|
|
|
| 188 |
|
| 189 |
-
|
|
|
|
| 190 |
|
| 191 |
-
##
|
|
|
|
|
|
|
| 192 |
|
| 193 |
-
|
| 194 |
|
| 195 |
-
|
| 196 |
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
-
|
| 200 |
|
| 201 |
-
##
|
| 202 |
|
| 203 |
-
|
|
|
|
|
|
|
| 204 |
|
| 205 |
-
|
| 206 |
|
| 207 |
-
|
| 208 |
-
### Framework versions
|
| 209 |
|
| 210 |
-
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: unsloth/Qwen3-4B
|
|
|
|
| 4 |
tags:
|
| 5 |
+
- code
|
| 6 |
+
- coding
|
| 7 |
+
- full-stack
|
| 8 |
+
- frontend
|
| 9 |
+
- backend
|
| 10 |
+
- agent
|
| 11 |
+
- qwen3
|
| 12 |
+
- lora
|
| 13 |
+
- unsloth
|
| 14 |
+
- fine-tuned
|
| 15 |
+
language:
|
| 16 |
+
- en
|
| 17 |
+
pipeline_tag: text-generation
|
| 18 |
+
library_name: peft
|
| 19 |
---
|
| 20 |
|
| 21 |
+
# NanoCoder V1 π§ β‘
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
A **4B parameter** full-stack coding assistant fine-tuned from **Qwen3-4B** using Unsloth + LoRA.
|
| 24 |
+
Trained through a multi-phase pipeline with joint domain training and validation-driven checkpoint selection.
|
| 25 |
|
| 26 |
+
Best checkpoint: **step 150** β combined score **73.6%** across all skill domains.
|
| 27 |
|
| 28 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
## π Benchmarks
|
| 31 |
|
| 32 |
+
| Benchmark | Score | Notes |
|
| 33 |
+
|----------------------|-------------|---------------------------------------------|
|
| 34 |
+
| **HumanEval pass@1** | **49.4%** | 164 problems, executed against test cases |
|
| 35 |
+
| **LiveCodeBench** | **13.3%** | Execution eval on 30 problems (public tests)|
|
| 36 |
+
| Frontend (custom) | 58.3% | React, Next.js, TypeScript, Tailwind, a11y |
|
| 37 |
+
| Backend (custom) | 87.5% | FastAPI, Express, PostgreSQL, JWT, MongoDB |
|
| 38 |
+
| Agent (custom) | 75.0% | Thought β Action β Patch β Reasoning format|
|
| 39 |
+
| **Combined** | **73.6%** | Averaged across skill domains |
|
| 40 |
|
| 41 |
+
---
|
| 42 |
|
| 43 |
+
## π― What it does well
|
| 44 |
|
| 45 |
+
- **Backend** β API design, auth (JWT/bcrypt), SQL/NoSQL, N+1 fixes, CORS
|
| 46 |
+
- **Debugging agent** β structured reasoning (`### Thought β ### Action β ### Patch β ### Reasoning`)
|
| 47 |
+
- **Full-stack integration** β connects frontend + backend flows
|
| 48 |
+
- **Bug pattern recognition** β race conditions, memory leaks, type errors
|
| 49 |
|
| 50 |
+
## β οΈ Known limitations
|
| 51 |
|
| 52 |
+
- Frontend scores lower than backend (weakest domain in v1)
|
| 53 |
+
- Not a replacement for larger models (7B+) on hard competitive programming
|
| 54 |
+
- English-only
|
| 55 |
|
| 56 |
+
---
|
| 57 |
|
| 58 |
+
## π Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
```python
|
| 61 |
+
from unsloth import FastLanguageModel
|
| 62 |
|
| 63 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 64 |
+
model_name="usernamebetter/nanocoder-v1",
|
| 65 |
+
max_seq_length=2048,
|
| 66 |
+
load_in_4bit=True,
|
| 67 |
+
)
|
| 68 |
+
FastLanguageModel.for_inference(model)
|
| 69 |
|
| 70 |
+
SYSTEM = "You are NanoCoder, an expert Senior Full-Stack Engineer and debugging agent."
|
| 71 |
|
| 72 |
+
prompt = (
|
| 73 |
+
f"<|im_start|>system\n{SYSTEM}<|im_end|>\n"
|
| 74 |
+
f"<|im_start|>user\nFix this React hydration error: useState(Date.now())<|im_end|>\n"
|
| 75 |
+
f"<|im_start|>assistant\n"
|
| 76 |
+
)
|
| 77 |
|
| 78 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 79 |
+
outputs = model.generate(**inputs, max_new_tokens=300, do_sample=False)
|
| 80 |
+
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
|
| 81 |
+
```
|
| 82 |
|
| 83 |
+
---
|
| 84 |
|
| 85 |
+
## ποΈ Training pipeline
|
| 86 |
+
|
| 87 |
+
Multi-phase joint training from Qwen3-4B base:
|
| 88 |
+
|
| 89 |
+
1. **Phase 1** β General coding (Magicoder-Evol-Instruct)
|
| 90 |
+
2. **Phase 2** β Frontend specialization
|
| 91 |
+
3. **Phase 3** β Fullstack (frontend + backend interleaved)
|
| 92 |
+
4. **Phase 4** β Agent reasoning training
|
| 93 |
+
5. **Final** β Joint retrain from base with all domains mixed (this checkpoint)
|
| 94 |
+
|
| 95 |
+
### Training configuration
|
| 96 |
+
- **Base**: Qwen3-4B (4-bit quantized)
|
| 97 |
+
- **LoRA**: r=32, alpha=32, dropout=0
|
| 98 |
+
- **LR**: 1e-5 with cosine scheduler
|
| 99 |
+
- **Steps**: 400 (best checkpoint at step 150)
|
| 100 |
+
- **Batch**: 2 Γ grad accum 4 = effective 8
|
| 101 |
+
- **Optimizer**: adamw_8bit
|
| 102 |
+
- **Dataset**: ~13.7k samples interleaved
|
| 103 |
+
- π€ Agent (synthetic + real): 40%
|
| 104 |
+
- π¨ Frontend: 35%
|
| 105 |
+
- βοΈ Backend: 15%
|
| 106 |
+
- π Bug fixing: 10%
|
| 107 |
+
|
| 108 |
+
### Data sources
|
| 109 |
+
- ise-uiuc/Magicoder-Evol-Instruct-110K
|
| 110 |
+
- sahil2801/CodeAlpaca-20k
|
| 111 |
+
- nickrosh/Evol-Instruct-Code-80k-v1
|
| 112 |
+
- iamtarun/code_instructions_120k_alpaca
|
| 113 |
+
- m-a-p/CodeFeedback-Filtered-Instruction
|
| 114 |
+
- bigcode/self-oss-instruct-sc2-exec-filter-50k
|
| 115 |
+
- HuggingFaceH4/CodeAlpaca_20K
|
| 116 |
+
- TokenBender/code_instructions_122k_alpaca_style
|
| 117 |
+
- Custom synthetic agent examples with structured reasoning format
|
| 118 |
|
| 119 |
+
---
|
| 120 |
|
| 121 |
+
## π§ͺ Prompt format
|
| 122 |
|
| 123 |
+
Uses Qwen chat template:
|
| 124 |
|
| 125 |
+
```
|
| 126 |
+
<|im_start|>system
|
| 127 |
+
You are NanoCoder, an expert Senior Full-Stack Engineer and debugging agent.
|
| 128 |
+
<|im_end|>
|
| 129 |
+
<|im_start|>user
|
| 130 |
+
{your question}
|
| 131 |
+
<|im_end|>
|
| 132 |
+
<|im_start|>assistant
|
| 133 |
+
```
|
| 134 |
|
| 135 |
+
For debugging tasks, the model responds in structured format:
|
| 136 |
|
| 137 |
+
```
|
| 138 |
+
### Thought:
|
| 139 |
+
{root cause analysis}
|
| 140 |
|
| 141 |
+
### Action:
|
| 142 |
+
{what to do}
|
| 143 |
|
| 144 |
+
### Patch:
|
| 145 |
+
{code fix}
|
| 146 |
|
| 147 |
+
### Reasoning:
|
| 148 |
+
{why it works}
|
| 149 |
+
```
|
| 150 |
|
| 151 |
+
---
|
| 152 |
|
| 153 |
+
## π
Roadmap
|
| 154 |
|
| 155 |
+
- β
**v1**: Joint multi-domain training (this release)
|
| 156 |
+
- π§ **v2**: Frontend boost + reasoning domain + label smoothing + cosine restarts
|
| 157 |
+
- π§ **v3**: DPO alignment + tool calling
|
| 158 |
+
- π§ **GGUF**: Q4_K_M / Q5_K_M / Q8_0 exports
|
| 159 |
|
| 160 |
+
---
|
| 161 |
|
| 162 |
+
## π Credits
|
| 163 |
|
| 164 |
+
- **Base model**: [Qwen/Qwen3-4B](https://huggingface.co/Qwen/Qwen3-4B)
|
| 165 |
+
- **Fine-tuning framework**: [Unsloth](https://github.com/unslothai/unsloth)
|
| 166 |
+
- **Training**: Kaggle T4 + Google Colab T4
|
| 167 |
|
| 168 |
+
---
|
| 169 |
|
| 170 |
+
## π License
|
|
|
|
| 171 |
|
| 172 |
+
Apache-2.0 (inherited from Qwen3-4B base).
|