AI-MO/NuminaMath-TIR
Viewer • Updated • 72.5k • 3.99k • 150
How to use FutureMa/Qwen2.5-7B-Instruct-GRPO-Math with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="FutureMa/Qwen2.5-7B-Instruct-GRPO-Math") # Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("FutureMa/Qwen2.5-7B-Instruct-GRPO-Math", dtype="auto")How to use FutureMa/Qwen2.5-7B-Instruct-GRPO-Math with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "FutureMa/Qwen2.5-7B-Instruct-GRPO-Math"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "FutureMa/Qwen2.5-7B-Instruct-GRPO-Math",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/FutureMa/Qwen2.5-7B-Instruct-GRPO-Math
How to use FutureMa/Qwen2.5-7B-Instruct-GRPO-Math with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "FutureMa/Qwen2.5-7B-Instruct-GRPO-Math" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "FutureMa/Qwen2.5-7B-Instruct-GRPO-Math",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "FutureMa/Qwen2.5-7B-Instruct-GRPO-Math" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "FutureMa/Qwen2.5-7B-Instruct-GRPO-Math",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use FutureMa/Qwen2.5-7B-Instruct-GRPO-Math with Docker Model Runner:
docker model run hf.co/FutureMa/Qwen2.5-7B-Instruct-GRPO-Math
This model is a fine-tuned version of Qwen/Qwen2.5-7B-Instruct using GRPO (Group Relative Policy Optimization) on mathematical reasoning tasks.
CUDA_VISIBLE_DEVICES=0 \
swift rlhf \
--rlhf_type grpo \
--model Qwen/Qwen2.5-7B-Instruct \
--reward_funcs accuracy format \
--train_type lora \
--lora_rank 8 \
--lora_alpha 32 \
--target_modules all-linear \
--torch_dtype bfloat16 \
--dataset 'AI-MO/NuminaMath-TIR#500' \
--num_train_epochs 1 \
--per_device_train_batch_size 2 \
--learning_rate 5e-5 \
--num_generations 2
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct",
torch_dtype="auto",
device_map="auto"
)
# Load LoRA adapter
model = PeftModel.from_pretrained(
base_model,
"FutureMa/Qwen2.5-7B-Instruct-GRPO-Math"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct")
# Generate
messages = [
{"role": "user", "content": "Solve for x: 2x^2 - 3x + 1 = 0"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# Inference
swift infer \
--ckpt_dir FutureMa/Qwen2.5-7B-Instruct-GRPO-Math \
--eval_human false
This model is optimized for:
@misc{qwen2.5-grpo-math,
author = {FutureMa},
title = {Qwen2.5-7B-Instruct Fine-tuned with GRPO on Math Tasks},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/FutureMa/Qwen2.5-7B-Instruct-GRPO-Math}}
}
docker model run hf.co/FutureMa/Qwen2.5-7B-Instruct-GRPO-Math