3.8 KiB
license, base_model, tags, datasets, language, pipeline_tag, library_name
| license | base_model | tags | datasets | language | pipeline_tag | library_name | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| apache-2.0 | Qwen/Qwen2.5-Coder-1.5B-Instruct |
|
|
|
text-generation | transformers |
qwen2.5-coder-1.5b-CodeSLM-Nihal
A QLoRA fine-tune of Qwen2.5-Coder-1.5B-Instruct into a terse, code-first Python assistant, built as a hands-on, phase-by-phase fine-tuning learning project on a single 8 GB consumer GPU (NVIDIA RTX 5060).
The base model is a capable coder but chronically verbose — every answer trails a prose essay. This fine-tune trains it to reply with correct, minimal code and nothing else.
Headline result
On 18 held-out prompts (greedy decoding), average output length dropped from 272 to 60 tokens (−78%) while core algorithm correctness was preserved.
Training curve
| Checkpoint (epoch) | Validation loss |
|---|---|
| 0.13 | 0.5157 |
| 0.38 | 0.5020 |
| 0.88 | 0.4927 |
| 1.00 | 0.4928 |
Train and validation loss tracked each other the entire run — clean convergence, no overfitting. Final train loss 0.4906; validation mean token-accuracy ~85.4%.
These are training/next-token metrics plus a qualitative 18-prompt comparison. No standardized code benchmark (HumanEval/MBPP) was run.
Training details
| Base | Qwen/Qwen2.5-Coder-1.5B-Instruct |
| Method | QLoRA (4-bit NF4 base + LoRA), completion-only loss |
| Dataset | sahil2801/CodeAlpaca-20k → Qwen ChatML (19,020 train / 1,002 val) |
| LoRA | r=16, α=32, dropout=0.05, targets q/k/v/o/gate/up/down |
| Trainable params | 18.46M (~1.18%) |
| Schedule | 1 epoch, 1,189 steps, LR 2e-4 cosine + 3% warmup |
| Batch | 2 × 8 grad-accum = effective 16 |
| Optimizer | paged_adamw_8bit, bf16, gradient checkpointing, max_len 1024 |
| Hardware | 1× RTX 5060 (8 GB), ~50 min, peak VRAM 3.32 GB |
Files in this repo
- Root — merged fp16 model (Transformers format); load directly with
from_pretrained. adapter/— the standalone LoRA adapter (~36 MB) to apply onto the base yourself.gguf/—…-f16.gguf(full precision) and…-Q4_K_M.gguf(~986 MB) for llama.cpp / Ollama.
Usage
Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
m = "MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal"
tok = AutoTokenizer.from_pretrained(m)
model = AutoModelForCausalLM.from_pretrained(m, device_map="auto")
msgs = [{"role": "user", "content": "Write a Python function that reverses a string without slicing."}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
print(tok.decode(model.generate(ids, max_new_tokens=128)[0][ids.shape[1]:], skip_special_tokens=True))
Ollama
ollama run mohdnihalll03/qwen2.5-coder-1.5b-codeslm-nihal
Prompt format: Qwen2.5 ChatML. Suggested: temperature 0.2, stop on <|im_start|> / <|im_end|>.
Limitations
- Style over correctness: fine-tuning changed formatting far more than correctness. A few subtle
base-model bugs persist (an email-regex character-class quirk; a
@timerdecorator missingfunctools.wraps), and one bracket-matching answer regressed to a logic bug on empty-stack input. Review generated code before use. - Python-focused; 1.5B params + 4-bit quantization — not a substitute for a large frontier model.
- Occasional instruction drift (
printvsreturn, tabulation vs memoization).
Attribution
- Base: Qwen2.5-Coder-1.5B-Instruct (© Alibaba Cloud, Apache-2.0)
- Data:
sahil2801/CodeAlpaca-20k - Fine-tuned by Nihal as a QLoRA learning project (TRL / PEFT / bitsandbytes).

