fdyrd/MATH
Viewer • Updated • 12.5k • 2.23k • 1
How to use fdyrd/QwenMath-0.5B with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="fdyrd/QwenMath-0.5B")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("fdyrd/QwenMath-0.5B")
model = AutoModelForCausalLM.from_pretrained("fdyrd/QwenMath-0.5B")
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 fdyrd/QwenMath-0.5B with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "fdyrd/QwenMath-0.5B"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "fdyrd/QwenMath-0.5B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/fdyrd/QwenMath-0.5B
How to use fdyrd/QwenMath-0.5B with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "fdyrd/QwenMath-0.5B" \
--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": "fdyrd/QwenMath-0.5B",
"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 "fdyrd/QwenMath-0.5B" \
--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": "fdyrd/QwenMath-0.5B",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use fdyrd/QwenMath-0.5B with Docker Model Runner:
docker model run hf.co/fdyrd/QwenMath-0.5B
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("fdyrd/QwenMath-0.5B")
model = AutoModelForCausalLM.from_pretrained("fdyrd/QwenMath-0.5B")
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]:]))A generation LLM which can solve math problems.
training-method: lora
training-time: "5:42"
data-size: 500
epoch: 3
total_flos: "1372250GF"
train_loss: 0.6441
train_samples_per_second: 4.385
train_steps_per_second: 0.544
Dataset used: test split of fdyrd/MATH. Metric: accuracy
| Level | Algebra | Intermediate Algebra | Prealgebra | Precalculus | Number Theory | Geometry | Counting & Probability | Average |
|---|---|---|---|---|---|---|---|---|
| Level 1 | 0.541 : 135 | 0.192 : 52 | 0.477 : 86 | 0.228 : 57 | 0.467 : 30 | 0.263 : 38 | 0.359 : 39 | 0.361 |
| Level 2 | 0.323 : 201 | 0.109 : 128 | 0.367 : 177 | 0.044 : 113 | 0.38 : 92 | 0.134 : 82 | 0.248 : 101 | 0.229 |
| Level 3 | 0.291 : 261 | 0.046 : 195 | 0.308 : 224 | 0.0 : 127 | 0.262 : 122 | 0.088 : 102 | 0.16 : 100 | 0.165 |
| Level 4 | 0.18 : 283 | 0.024 : 248 | 0.22 : 191 | 0.009 : 114 | 0.169 : 142 | 0.064 : 125 | 0.09 : 111 | 0.108 |
| Level 5 | 0.088 : 307 | 0.004 : 280 | 0.104 : 193 | 0.0 : 135 | 0.136 : 154 | 0.023 : 132 | 0.065 : 123 | 0.06 |
| Average | 0.285 | 0.075 | 0.295 | 0.056 | 0.283 | 0.114 | 0.184 | 0.166 |
[
{
"dataset": "MATH500",
"url": "https://huggingface.co/datasets/qq8933/MATH500",
"accuracy": 0.286
},
{
"dataset": "GSM8K",
"url": "https://huggingface.co/datasets/openai/gsm8k",
"accuracy": 0.382
}
]
Base model
Qwen/Qwen2.5-0.5B
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="fdyrd/QwenMath-0.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)