Instructions to use PeterWright/Qwen2.5-1.5B-MathHard-GRPO with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use PeterWright/Qwen2.5-1.5B-MathHard-GRPO with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Math-1.5B-Instruct") model = PeftModel.from_pretrained(base_model, "PeterWright/Qwen2.5-1.5B-MathHard-GRPO") - Transformers
How to use PeterWright/Qwen2.5-1.5B-MathHard-GRPO with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PeterWright/Qwen2.5-1.5B-MathHard-GRPO") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("PeterWright/Qwen2.5-1.5B-MathHard-GRPO", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PeterWright/Qwen2.5-1.5B-MathHard-GRPO with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PeterWright/Qwen2.5-1.5B-MathHard-GRPO" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PeterWright/Qwen2.5-1.5B-MathHard-GRPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PeterWright/Qwen2.5-1.5B-MathHard-GRPO
- SGLang
How to use PeterWright/Qwen2.5-1.5B-MathHard-GRPO 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 "PeterWright/Qwen2.5-1.5B-MathHard-GRPO" \ --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": "PeterWright/Qwen2.5-1.5B-MathHard-GRPO", "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 "PeterWright/Qwen2.5-1.5B-MathHard-GRPO" \ --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": "PeterWright/Qwen2.5-1.5B-MathHard-GRPO", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use PeterWright/Qwen2.5-1.5B-MathHard-GRPO with Docker Model Runner:
docker model run hf.co/PeterWright/Qwen2.5-1.5B-MathHard-GRPO
Qwen2.5-Math-1.5B-Instruct β MathHard GRPO LoRA Adapter
LoRA adapter trained on the Hendrycks MATH level-5 subset using GRPO (Group Relative Policy Optimization).
Training Details
- Base model:
Qwen/Qwen2.5-Math-1.5B-Instruct - Algorithm: GRPO (PPO-style clipped surrogate, group-relative advantage normalization)
- Dataset:
the-jb/hendrycks-mathβ level 5 (hardest) problems only - Steps: 501
- Batch size: 4 prompts Γ 4 samples (group size) = 16 rollouts per step
- PPO epochs: 2
- Max new tokens: 512
- Learning rate: 3e-5
- KL coefficient: 0.05
- Clip epsilon: 0.2
LoRA Config
| Parameter | Value |
|---|---|
| Rank | 16 |
| Alpha | 32 |
| Dropout | 0.05 |
| Target modules | q/k/v/o_proj, gate/up/down_proj |
| Trainable params | ~18.5M / 1562M total |
Reward Function
- Correct reward: 1.0 β exact numeric match inside
\boxed{} - Format reward: 0.1 β for including
\boxed{}in output
Evaluation Results (held-out test set, 512 level-5 problems)
| Metric | Baseline (step 0) | Final (step 501) |
|---|---|---|
| Exact match (boxed parser) | 22.7% | 35.7% |
| Exact match (relaxed parser) | 26.2% | 38.7% |
Usage
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Math-1.5B-Instruct")
model = PeftModel.from_pretrained(base, "PeterWright/Qwen2.5-1.5B-MathHard-GRPO")
tokenizer = AutoTokenizer.from_pretrained("PeterWright/Qwen2.5-1.5B-MathHard-GRPO")
messages = [
{"role": "system", "content": "Solve the competition-level math problem.\nReturn the final answer in this exact format: \\boxed{NUMBER}"},
{"role": "user", "content": "What is the sum of all integers from 1 to 100?\n\nReturn only: \\boxed{NUMBER}"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Framework versions
- PEFT 0.19.1
- Downloads last month
- 14
Model tree for PeterWright/Qwen2.5-1.5B-MathHard-GRPO
Base model
Qwen/Qwen2.5-1.5B Finetuned
Qwen/Qwen2.5-Math-1.5B Finetuned
Qwen/Qwen2.5-Math-1.5B-Instruct