Instructions to use giangkh19/qwen-0.5b-coder-r8 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use giangkh19/qwen-0.5b-coder-r8 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-0.5B-Instruct") model = PeftModel.from_pretrained(base_model, "giangkh19/qwen-0.5b-coder-r8") - Transformers
How to use giangkh19/qwen-0.5b-coder-r8 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="giangkh19/qwen-0.5b-coder-r8") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("giangkh19/qwen-0.5b-coder-r8", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use giangkh19/qwen-0.5b-coder-r8 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "giangkh19/qwen-0.5b-coder-r8" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "giangkh19/qwen-0.5b-coder-r8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/giangkh19/qwen-0.5b-coder-r8
- SGLang
How to use giangkh19/qwen-0.5b-coder-r8 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 "giangkh19/qwen-0.5b-coder-r8" \ --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": "giangkh19/qwen-0.5b-coder-r8", "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 "giangkh19/qwen-0.5b-coder-r8" \ --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": "giangkh19/qwen-0.5b-coder-r8", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use giangkh19/qwen-0.5b-coder-r8 with Docker Model Runner:
docker model run hf.co/giangkh19/qwen-0.5b-coder-r8
Qwen2.5-Coder-0.5B-Instruct β LoRA r8 (coder_r8)
Fine-tuned Qwen/Qwen2.5-Coder-0.5B-Instruct (494M) on 6,425 code samples with LoRA rank 8.
+6.6 pts on a frozen code-only benchmark (84 Python unit-test tasks) vs the base model.
Available as a lightweight adapter (~17 MB). Load it on top of the base β no 1 GB merge needed.
Metrics
Frozen benchmark data/eval/coding.jsonl (84 diverse Python functions, each with 4β5 unit tests, greedy decoding temperature=0). All 84 verified 100% on reference solutions; no train-eval leak (max 6-gram Jaccard 0.009).
| Model | Coding (84) | Avg |
|---|---|---|
| Qwen2.5-Coder-0.5B-Instruct (base) | 73.9 | 73.9 |
| This adapter β coder_r8 (r=8) | 80.5 | 80.5 |
| Ξ | +6.6 | +6.6 |
Eval is code-only (24 original + 60 algorithmic extensions, each function-masked and run in a subprocess).
Training Data (6,425 rows, β€4000 tokens, no truncation)
| Source | Rows | What |
|---|---|---|
Claude production code (claude_opus_743_short β chunked) |
743 | Real production tasks (queue consumer, file watcher, migration helpers) in Python/JS/TS/Rust/Java β chunked at block boundaries so every sample <4000 tokens |
| Curated code knowledge (authored) | 685 | OOP / Big-O / HTTP-REST / SQL / data structures / debugging / code-trace output |
| Magicoder-OSS-Instruct-75K (MIT) β Python slice | 5,000 | Real open-source Python instructions, deduplicated against eval entry function names |
| Total | 6,425 β chunked to 2,018 | Long answers split at newline boundaries; median ~1305 tokens |
- License: base Apache-2.0, Magicoder slice MIT.
- De-duplicated across sources, then chunked rather than truncated β no tail loss.
Training Configuration
| Param | Value |
|---|---|
| Base | Qwen/Qwen2.5-Coder-0.5B-Instruct |
| Method | LoRA β r=8, alpha=16, target q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj, dropout 0.05 |
| Rank | 8 β 4.4M trainable (0.88 %) of 498M total |
| Max seq length | 4096 (with gradient_checkpointing=True + enable_input_require_grads() for LoRA CKPT) |
| Epochs | 1 |
| LR | 2e-4 (linear decay) |
| Batch | 1 Γ grad-accum 8 = effective 8 |
| Optim | adamw_torch (bf16, max_grad_norm=1.0) |
| Hardware | RTX 3090 24 GB |
| Samples/sec | ~4.0 (post-fix) |
| Final train loss | ~0.885 |
| Code | train.py (standard Trainer, completion-only masking via response template \nassistant) |
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = "Qwen/Qwen2.5-Coder-0.5B-Instruct"
adapter = "giangkh1908/qwen-0.5b-coder-r8" # <-- update to your actual HF repo id
tok = AutoTokenizer.from_pretrained(base, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(base, trust_remote_code=True, torch_dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(model, adapter)
model.eval()
# chat template (single-turn) β same as training
messages = [{"role": "user", "content": "Write a Python function to check if a string is palindrome."}]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tok([text], return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=512, do_sample=False, temperature=0)
print(tok.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
CLI reproduction (from this repo):
git clone https://github.com/giangkh1908/Finetune_Qwen2.5-0.5B.git && cd Finetune_Qwen2.5-0.5B
python harness/run_eval.py --model Qwen/Qwen2.5-Coder-0.5B-Instruct --adapter giangkh1908/qwen-0.5b-coder-r8 --tag r8
# β coding 80.5 on 84 tasks vs base 73.9
Limitations
- 0.5B is tiny; it learns style + short-function patterns but cannot reliably produce 25K-token reasoning.
- The eval is 84 Python function-implementation tasks. It does not measure long-form production coding, IDE file-watcher tasks, or multi-language depth.
- The training set is Python-heavy (Magicoder Python slice); other languages (Rust/Java/JS) are underrepresented relative to the original Claude dataset.
Citation
@misc{qwen25coder-r8,
title = {Qwen2.5-Coder-0.5B LoRA r=8 on 6.4k code samples},
author = {giangkh1908},
howpublished = {Hugging Face},
year = {2026}
}
- Downloads last month
- -
Model tree for giangkh19/qwen-0.5b-coder-r8
Base model
Qwen/Qwen2.5-0.5B