bunyaminergen/Stable-Code-Python-SFT
Viewer • Updated • 64k • 211 • 2
How to use bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForMultimodalLM
tokenizer = AutoTokenizer.from_pretrained("bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled")
model = AutoModelForMultimodalLM.from_pretrained("bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled")
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]:]))How to use bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled
How to use bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled" \
--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": "bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled" \
--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": "bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled with Docker Model Runner:
docker model run hf.co/bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled
The Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled model has been distilled from the Qwen2.5-Coder-1.5B-Instruct-SFT model down to 1B parameters using a token-based knowledge distillation method.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
repo = "bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled"
tokenize = AutoTokenizer.from_pretrained(repo, padding_side="left")
model = AutoModelForCausalLM.from_pretrained(
repo,
device_map="auto",
torch_dtype="auto",
).eval()
system = "You are a senior Python developer."
user = "Give me a Python implementation of bubble sort."
text = f"System: {system}\nUser: {user}\nAssistant:"
inputs = tokenize(text, return_tensors="pt").to(model.device)
with torch.no_grad():
out_ids = model.generate(**inputs, max_new_tokens=512)
print(tokenize.decode(out_ids[0], skip_special_tokens=True))
| Hyperparameter | Value |
|---|---|
| Base Model | bunyaminergen/Qwen2.5-Coder-1.5B-Instruct-SFT |
| Knowledge Distillation Method | Token based |
| Task Type | CAUSAL_LM |
| Number of Epochs | 11 |
| Batch Size | 12 |
| Gradient Accumulation Steps | 2 |
| Effective Batch Size | 24 (12 × 2) |
| Learning Rate | 5e-5 |
| Optimizer | AdamW |
| Precision | BF16 Mixed Precision |
| Evaluation Strategy | epoch |
| Max Sequence Length | 256 tokens |
| Logging Steps | every epoch steps |
| Save Checkpoint Steps | every 10000 steps |
| Experiment Tracking | MLflow (local) |
| Experiment Name | StudentKnowledgeDistillation |
| MLflow Run Name | StudentKD |
| Parameter | Value |
|---|---|
| Distillation Weight | 0.3 |
| Temperature | 0.5 |
| Loss Reduction | batchmean |
90%/10%42TrueTruemax_length=256)False10000 stepscheckpoint-10000checkpoint-13200 (final checkpoint)Hardware:
Software:
@software{ Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled,
author = {Bunyamin Ergen},
title = {{Qwen2.5-Coder-1.5B-Instruct-SFT-Distilled}},
year = {2025},
month = {04},
}
Base model
Qwen/Qwen2.5-1.5B