Instructions to use quangdung/Qwen2.5-Math-Distill-1.5b-Sens with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use quangdung/Qwen2.5-Math-Distill-1.5b-Sens with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="quangdung/Qwen2.5-Math-Distill-1.5b-Sens") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("quangdung/Qwen2.5-Math-Distill-1.5b-Sens") model = AutoModelForCausalLM.from_pretrained("quangdung/Qwen2.5-Math-Distill-1.5b-Sens", device_map="auto") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use quangdung/Qwen2.5-Math-Distill-1.5b-Sens with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "quangdung/Qwen2.5-Math-Distill-1.5b-Sens" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "quangdung/Qwen2.5-Math-Distill-1.5b-Sens", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/quangdung/Qwen2.5-Math-Distill-1.5b-Sens
- SGLang
How to use quangdung/Qwen2.5-Math-Distill-1.5b-Sens 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 "quangdung/Qwen2.5-Math-Distill-1.5b-Sens" \ --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": "quangdung/Qwen2.5-Math-Distill-1.5b-Sens", "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 "quangdung/Qwen2.5-Math-Distill-1.5b-Sens" \ --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": "quangdung/Qwen2.5-Math-Distill-1.5b-Sens", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use quangdung/Qwen2.5-Math-Distill-1.5b-Sens with Docker Model Runner:
docker model run hf.co/quangdung/Qwen2.5-Math-Distill-1.5b-Sens
Qwen2.5-Math-Distill-1.5b-Sens
Đây là mô hình Qwen2.5 1.5B được tạo bằng cách merge:
- Math model: Qwen2.5-Math-1.5B
- Distill model: DeepSeek-R1-Distill-Qwen-1.5B
- Phương pháp: Sens Merging (layer-wise sensitivity-weighted task arithmetic)
Model được xuất dưới dạng checkpoint Transformers đầy đủ (model.safetensors, tokenizer và các file cấu hình). Đây là model causal language model cho suy luận toán học bằng tiếng Anh.
Phương pháp merge
Quy trình Sens Merging được sử dụng trong project:
- Với mỗi model, chạy forward/backward trên calibration examples và tính sensitivity của tham số theo dạng
abs(weight) * abs(gradient). - Cộng sensitivity theo từng layer, chuẩn hóa vector sensitivity và tạo trọng số layer-wise cho math model và distill model.
- Trộn hai trọng số layer-wise bằng softmax với temperature 3.0, hệ số scaling 0.4 và coefficient multiplier 2.0.
- Áp dụng weighted task arithmetic: giữ math model làm điểm xuất phát và cộng task vector của distill model với hệ số theo layer.
Các tham số trên tương ứng với cấu hình Sens cho model 1.5B trong pipeline của project. Merge được thực hiện trên CPU sau khi đã tính sensitivity.
Calibration data
Hai biến thể calibration được tạo từ các file Parquet S1K trong project, sau đó chuyển sang JSON:
calibration/s1k.json: 1.000 mẫu, mỗi record gồmquestionvàcot_solution. Đây là biến thể ngắn/task-oriented.calibration/s1k-1.1.json: 630 mẫu, mỗi record gồmquestion,thinkingvàcot_solution; chỉ giữ các record códeepseek_grade == "Yes". Đây là biến thể reasoning/distillation.
Calibration dùng format question_cot. Khi chạy sensitivity analysis, pipeline lấy 100 mẫu đầu tiên của file calibration tương ứng.
Kết quả đánh giá
Tất cả kết quả dưới đây chỉ đánh giá trên 100 mẫu đầu tiên của mỗi dataset, với temperature 0.0 và greedy decoding. Avg Acc là trung bình các dataset có kết quả; dấu — nghĩa là không có kết quả trong bảng.
Qwen2.5 1.5B: baseline và các phương pháp merge
| Model / phương pháp | college_math | gsm8k | math | minerva_math | olympiadbench | Avg Acc (%) | Avg Tokens |
|---|---|---|---|---|---|---|---|
| Qwen2.5-Math-1.5B | 23.5 | 46.5 | 70.0 | 11.5 | 11.5 | 32.6 | 505 |
| DeepSeek-R1-Distill-Qwen-1.5B | 64.0 | 76.0 | 70.5 | 19.0 | 15.0 | 48.9 | 1383 |
| aim | 17.1 | 21.7 | 17.3 | 4.8 | 11.7 | 14.5 | 3960 |
| average | 11.1 | 28.2 | 13.5 | 6.6 | 4.7 | 12.8 | 3724 |
| Sens (model này) | 62.9 | 81.4 | 81.0 | 22.4 | 35.0 | 56.5 | 691 |
| task arithmetic | 56.5 | 74.1 | 66.9 | 18.4 | 27.7 | 48.7 | 1336 |
| TIES | 50.9 | 75.9 | 76.2 | 21.0 | 33.6 | 51.5 | 907 |
Sử dụng
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "quangdung/Qwen2.5-Math-Distill-1.5b-Sens"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
)
prompt = "Solve this problem step by step: What is 2 + 2?"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Hạn chế
Đây là checkpoint nghiên cứu được tối ưu cho các bài toán trong benchmark thực nghiệm. Kết quả chỉ là đánh giá giới hạn trên 100 mẫu đầu tiên, không đại diện cho toàn bộ test set. Model có thể tạo lời giải sai hoặc suy luận dài; cần kiểm tra đáp án trước khi dùng trong ứng dụng thực tế.
- Downloads last month
- 484