DAPO: An Open-Source LLM Reinforcement Learning System at Scale
Paper • 2503.14476 • Published • 148
How to use shrango/Qwen3-4B-DAPO with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="shrango/Qwen3-4B-DAPO")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("shrango/Qwen3-4B-DAPO")
model = AutoModelForCausalLM.from_pretrained("shrango/Qwen3-4B-DAPO", 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=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use shrango/Qwen3-4B-DAPO with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "shrango/Qwen3-4B-DAPO"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "shrango/Qwen3-4B-DAPO",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/shrango/Qwen3-4B-DAPO
How to use shrango/Qwen3-4B-DAPO with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "shrango/Qwen3-4B-DAPO" \
--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": "shrango/Qwen3-4B-DAPO",
"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 "shrango/Qwen3-4B-DAPO" \
--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": "shrango/Qwen3-4B-DAPO",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use shrango/Qwen3-4B-DAPO with Docker Model Runner:
docker model run hf.co/shrango/Qwen3-4B-DAPO
Qwen/Qwen3-4B trained with DAPO (arXiv 2503.14476) on DAPO-Math-17k, in non-thinking mode (enable_thinking=False). Trained as a stronger teacher for on-policy distillation experiments.
| Base model | Qwen/Qwen3-4B, non-thinking (chat template with an empty <think></think> block) |
| Data | DAPO-Math-17k, deduplicated: 17,917 problems (8 with prompts over 1024 tokens dropped) |
| Prompt | {problem}\nPlease reason step by step, and put your final answer within \boxed{}. |
| Epochs | exactly 3 passes over the data (138 steps; counted as data passes, not verl's step-based epochs) |
| Algorithm | DAPO: clip-higher (0.2 / 0.28), dynamic sampling (groups with all-equal accuracy dropped), token-level loss, overlong reward shaping (linear penalty over the last 2048 tokens), no KL, no entropy bonus |
| Batch | 128 prompts x 16 samples per step, mini-batch 32 prompts (4 updates per step) |
| Optimizer | AdamW, lr 1e-6 constant after 10 warmup steps, weight decay 0.1, grad clip 1.0 |
| Rollout | temperature 1.0, top-p 1.0, max response 8192 tokens |
| Reward | rule-based: Answer: line or last \boxed{} vs. ground truth (verl math_dapo) |
| Framework | verl (FSDP + vLLM), 4 x A100 80GB, ~3.5 days |
mean@k accuracy (%): average correctness over k samples per problem. Non-thinking, temperature 0.7, top-p 0.8, top-k 20, max_tokens 8192, scored with evalscope 1.11.1. AIME24 / AIME25 / AMC23 at k = 16, MATH-500 at k = 4.
| Model | AIME 2024 | AIME 2025 | AMC 2023 | MATH-500 |
|---|---|---|---|---|
| Qwen3-4B (non-thinking) | 20.6 | 20.6 | 64.3 | 84.3 |
| Qwen3-4B-DAPO | 45.0 | 41.0 | 85.0 | 92.4 |
Use it in non-thinking mode, as it was trained:
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("shrango/Qwen3-4B-DAPO")
model = AutoModelForCausalLM.from_pretrained("shrango/Qwen3-4B-DAPO", torch_dtype="auto", device_map="auto")
messages = [{"role": "user", "content": "What is 1+1?\nPlease reason step by step, and put your final answer within \\boxed{}."}]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
out = model.generate(**tok(text, return_tensors="pt").to(model.device), max_new_tokens=8192)
print(tok.decode(out[0], skip_special_tokens=True))