Instructions to use MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal") model = AutoModelForCausalLM.from_pretrained("MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - PEFT
How to use MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal
- SGLang
How to use MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal with Docker Model Runner:
docker model run hf.co/MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal
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).
- Downloads last month
- 410
Model tree for MohdNihal03/qwen2.5-coder-1.5b-CodeSLM-Nihal
Base model
Qwen/Qwen2.5-1.5B
