🚀 OpenR1-Distill-7B模型
OpenR1-Distill-7B是基于特定数据集进行后训练的模型,它在推理能力上有出色表现,并且完全开源可复现,适合用于推理时间计算和可验证奖励强化学习(RLVR)的研究。

🚀 快速开始
若要与模型进行对话,首先需要安装🤗 Transformers库:
pip install transformers>0.52
然后按如下方式运行聊天命令行界面:
transformers chat open-r1/OpenR1-Distill-7B \
max_new_tokens=2048 \
do_sample=True \
temperature=0.6 \
top_p=0.95
或者,使用pipeline()
函数来运行模型:
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="open-r1/OpenR1-Distill-7B", torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{"role": "user", "content": "Which number is larger, 9.9 or 9.11?"},
]
outputs = pipe(messages, max_new_tokens=2048, do_sample=True, temperature=0.6, top_p=0.95, return_full_text=False)
print(outputs[0]["generated_text"])
✨ 主要特性
📦 安装指南
要与模型进行交互,需先安装🤗 Transformers库:
pip install transformers>0.52
💻 使用示例
基础用法
import torch
from transformers import pipeline
pipe = pipeline("text-generation", model="open-r1/OpenR1-Distill-7B", torch_dtype=torch.bfloat16, device_map="auto")
messages = [
{"role": "user", "content": "Which number is larger, 9.9 or 9.11?"},
]
outputs = pipe(messages, max_new_tokens=2048, do_sample=True, temperature=0.6, top_p=0.95, return_full_text=False)
print(outputs[0]["generated_text"])
高级用法
transformers chat open-r1/OpenR1-Distill-7B \
max_new_tokens=2048 \
do_sample=True \
temperature=0.6 \
top_p=0.95
📚 详细文档
模型描述
属性 |
详情 |
模型类型 |
一个70亿参数的类GPT模型,在公开可用的合成数据集混合上进行后训练。 |
语言(NLP) |
主要为英语 |
许可证 |
Apache 2.0 |
微调基础模型 |
Qwen/Qwen2.5-Math-7B的一个变体,其RoPE基础频率扩展到300k,以支持32k标记的上下文训练。 |
模型来源
- 仓库:https://github.com/huggingface/open-r1
- 训练日志:https://wandb.ai/huggingface/open-r1/runs/199cum6l
- 评估日志:https://huggingface.co/datasets/open-r1/details-open-r1_OpenR1-Distill-7B
性能
我们使用Lighteval在以下基准测试中评估模型:
模型 |
AIME 2024 |
MATH-500 |
GPQA Diamond |
LiveCodeBench v5 |
OpenR1-Distill-7B |
52.7 |
89.0 |
52.8 |
39.4 |
DeepSeek-R1-Distill-Qwen-7B |
51.3 |
93.5 |
52.4 |
37.4 |
所有分数表示pass@1准确率,并使用temperature=0.6
和top_p=0.95
进行采样。DeepSeek-R1技术报告使用每个查询4 - 64个响应进行采样以估计pass@1,但未指定每个基准测试的具体响应数量。在上述表格中,我们使用以下每个查询的响应数量来估计pass@1准确率:
基准测试 |
每个查询的响应数量 |
AIME 2024 |
64 |
MATH-500 |
4 |
GPQA Diamond |
8 |
LiveCodeBench |
16 |
训练方法
OpenR1-Distill-7B在Mixture-of-Thoughts数据集上使用监督微调(SFT)进行训练,该数据集包含从DeepSeek-R1中提取的35万个推理轨迹。为了优化数据混合,我们遵循了Phi-4-reasoning技术报告中描述的方法,即可以独立优化每个领域的混合,然后将其组合成一个单一的数据集。
训练超参数
训练期间使用的超参数如下:
- num_epochs: 5.0
- learning_rate: 4.0e-05
- num_devices: 8
- train_batch_size: 2
- gradient_accumulation_steps: 8
- total_train_batch_size: 2 * 8 * 8 = 128
- seed: 42
- distributed_type: DeepSpeed ZeRO-3
- optimizer: Adam,betas=(0.9,0.999),epsilon=1e-08
- lr_scheduler_type: cosine_with_min_lr,min_lr_rate=0.1
- lr_scheduler_warmup_ratio: 0.03
- max_grad_norm: 0.2
训练结果
训练期间,我们每个epoch在AIME 2024、GPQA Diamond和LiveCodeBench v4上监控进度。以下是训练结果图:

框架版本
- 平台:Linux-5.15.0-1049-aws-x86_64-with-glibc2.31
- Python版本:3.11.11
- TRL版本:0.18.0.dev0
- PyTorch版本:2.6.0
- Transformers版本:4.52.0.dev0
- Accelerate版本:1.4.0
- Datasets版本:3.5.1
- HF Hub版本:0.30.2
- bitsandbytes版本:0.45.5
- DeepSpeed版本:0.16.8
- Liger-Kernel版本:0.5.9
- OpenAI版本:1.76.2
- vLLM版本:0.8.4
🔧 技术细节
在训练过程中,我们进行了一系列实验来优化模型性能,包括扩展模型的基础RoPE频率、独立缩放数学和代码混合的学习率、测量序列打包的影响以及在不同数据集混合上进行训练等。实验结果表明,将RoPE基础频率扩展到300k在后续实验中表现良好,并且在所有三个混合(数学、代码和科学)上进行训练可以获得更好的性能。
📄 许可证
本模型使用Apache 2.0许可证。
引用
如果您发现此模型在您的工作中有用,请考虑按如下方式引用:
@misc{openr1,
title = {Open R1: A fully open reproduction of DeepSeek-R1},
url = {https://github.com/huggingface/open-r1},
author = {Hugging Face},
month = {January},
year = {2025}
}