FuseO1-Preview:LLMs 的 System-II 推理融合
概述
FuseO1-Preview 是我们通过创新模型融合技术,增强大型语言模型 (LLMs) System-II 推理能力的初步尝试。通过采用我们先进的 SCE 合并方法,我们将多个开源的 o1-like LLM 整合到一个统一的模型中。我们的目标是将不同推理 LLM 的独特知识和优势整合到一个具有强大 System-II 推理能力的单一统一模型中,尤其是在数学、编码和科学领域。
为实现这一目标,我们进行了两种类型的模型合并:
- 长-长推理合并:这种方法涉及跨 LLM 的模型融合,这些 LLM 使用长 CoT 推理,目标是增强长 CoT 推理能力。结果模型 FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview 在 AIME24 上达到了 74.0 的 Pass@1 准确率,与 OpenAI o1-preview (44.6) 和 OpenAI o1-mini (63.4) 相比,显示出显著的性能提升,甚至接近 OpenAI o1 (79.2)。
- 长-短推理合并:这种方法涉及长 CoT 和短 CoT LLM 之间的模型融合,旨在提高长短推理过程中的推理能力。结果模型 FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview 和 FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Coder-32B-Preview 能够利用长短推理过程,并在长推理任务中表现出相对较强的性能。
长-长推理合并
我们对以下长 CoT LLM 进行了实验。
要重现合并后的 FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview 模型,请使用以下脚本。
cd FuseAI/FuseO1-Preview/mergekit
pip3 install -e .
model_save_dir=xx # your path to save the merged models
mergekit-yaml fuseo1_configs/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview.yaml ${model_save_dir}/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview --cudas
要重现合并后的 FuseAI/FuseO1-DeepSeekR1-QwQ-32B-Preview 模型,请使用以下脚本。
cd FuseAI/FuseO1-Preview/mergekit
pip3 install -e .
model_save_dir=xxx # your path to save the merged models
mergekit-yaml fuseo1_configs/FuseO1-DeepSeekR1-QwQ-32B-Preview.yaml ${model_save_dir}/FuseO1-DeepSeekR1-QwQ-32B-Preview --cuda
我们提供了使用 FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview 的示例代码。
from vllm import LLM, SamplingParams
llm = LLM(model="FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview", tensor_parallel_size=8)
sampling_params = SamplingParams(max_tokens=32768, temperature=0.7, stop=["<|im_end|>", "<|end▁of▁sentence|>"], stop_token_ids=[151645, 151643])
conversations = [
[
{"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{{}}."},
{"role": "user", "content": "Quadratic polynomials $P(x)$ and $Q(x)$ have leading coefficients $2$ and $-2,$ respectively. The graphs of both polynomials pass through the two points $(16,54)$ and $(20,53).$ Find $P(0) + Q(0).$."},
],
]
responses = llm.chat(messages=conversations, sampling_params=sampling_params, use_tqdm=True)
for response in responses:
print(response.outputs[0].text.strip())
长-短推理合并
我们对以下长 CoT 和短 CoT LLM 进行了实验。
要重现合并后的 FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-Flash-32B-Preview 模型,请使用以下脚本。
cd FuseAI/FuseO1-Preview/mergekit
pip3 install -e .
model_save_dir=xxx # your path to save the merged models
mergekit-yaml fuseo1_configs/FuseO1-DeepSeekR1-QwQ-SkyT1-Flash-32B-Preview.yaml ${model_save_dir}/FuseO1-DeepSeekR1-QwQ-SkyT1-Flash-32B-Preview --cuda
要重现合并后的 FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview 模型,请使用以下脚本。
cd FuseAI/FuseO1-Preview/mergekit
pip3 install -e .
model_save_dir=xxx # your path to save the merged models
mergekit-yaml fuseo1_configs/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview.yaml ${model_save_dir}/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview --cuda
要重现合并后的 FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Coder-32B-Preview 模型,请使用以下脚本。
cd FuseAI/FuseO1-Preview/mergekit
pip3 install -e .
model_save_dir=xxx # your path to save the merged models
mergekit-yaml fuseo1_configs/FuseO1-DeepSeekR1-Qwen2.5-Coder-32B-Preview.yaml ${model_save_dir}/FuseO1-DeepSeekR1-Qwen2.5-Coder-32B-Preview --cuda
我们提供了使用 FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview 的代码。
from vllm import LLM, SamplingParams
llm = LLM(model="FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview", tensor_parallel_size=8)
sampling_params = SamplingParams(max_tokens=32768, temperature=0.7, stop=["<|im_end|>", "<|end▁of▁sentence|>"], stop_token_ids=[151645, 151643])
conversations = [
[
{"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{{}}."},
{"role": "user", "content": "Quadratic polynomials $P(x)$ and $Q(x)$ have leading coefficients $2$ and $-2,$ respectively. The graphs of both polynomials pass through the two points $(16,54)$ and $(20,53).$ Find $P(0) + Q(0).$."},
],
]
responses = llm.chat(messages=conversations, sampling_params=sampling_params, use_tqdm=True)
for response in responses:
print(response.outputs[0].text.strip())
评估结果
我们对所得模型在三类基准上进行了测试,包括数学推理、代码推理和科学推理。
数学推理
- AIME24
- MATH500
- OlympiadBench
科学推理
- GPQA-Diamond
- MMLU-Pro
- MMLU
代码推理
- LiveCodeBench (2408-2502)
重要提示:我们手动将所有被评估 LLM 的
tokenizer_config.json
中的"add_bos_token": false
设置为false
,以防止 bos_token 每次提示都被添加两次。请下载并修改以确保一致性。
数学推理
评估代码修改自 Qwen2.5-Math。在我们的评估中,我们将 temperature 设置为 0.6,top-p 设置为 0.95,max_tokens 设置为 32768。我们提供了在 math_evaluation 中重现我们结果的示例。
评估的系统提示设置为
Please reason step by step, and put your final answer within \\boxed{{}}.
评估结果如下表所示
在 AIME24 的评估中,我们遵循 DeepSeek-R1 的方法,其中 Pass@1 通过对每个提示 32 个采样响应的结果进行平均计算,而 Cons@32 通过对每个提示的相同 32 个采样响应进行自洽性分析来确定。对于其他基准,我们只采样 1 个响应并报告 Pass@1。
模型 | AIME24 Pass@1 | AIME24 Cons@32 | MATH500 | OlympiadBench |
---|---|---|---|---|
OpenAI o1 | 79.2 | - | 96.4 | - |
OpenAI o1-preview | 44.6 | - | 85.5 | - |
OpenAI o1-mini | 63.6 | - | 90.0 | - |
DeepSeek R1 | 79.8 | - | 97.3 | - |
deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | 69.2 | 83.3 | 93.6 | 64.3 |
Qwen/QwQ-32B-Preview | 43.8 | 56.7 | 88.4 | 60.3 |
NovaSky-AI/Sky-T1-32B-Preview | 37.7 | 50.0 | 88.0 | 55.1 |
Qwen/Qwen2.5-32B-Instruct | 17.0 | 20.0 | 81.8 | 48.1 |
FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview | 68.6 | 83.3 | 94.6 | 64.9 |
FuseAI/FuseO1-DeepSeekR1-QwQ-32B-Preview | 69.7 | 83.3 | 94.6 | 64.0 |
FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-Flash-32B-Preview | 72.9 | 86.7 | - | - |
FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview | 74.0 | 86.7 | 94.8 | 65.0 |
我们发现,与 DeepSeek-R1-Distill-Qwen-32B、QwQ-32B-Preview 和 Sky-T1-32B-Preview 相比,我们合并后的 FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview 在数学推理方面表现出卓越的性能提升。具体而言,我们的模型在 AIME24 上达到了 74.0 的 Pass@1 准确率和 86.7 的 Cons@32 准确率,与 DeepSeek-R1-Distill-Qwen-32B(69.2 的 Pass@1 准确率和 83.3 的 Cons@32 准确率)、OpenAI o1-preview(44.6 的 Pass@1 准确率)和 OpenAI o1-mini(63.4 的 Pass@1 准确率)相比,显示出显著的性能提升,甚至接近 OpenAI o1(79.2 的 Pass@1 准确率)。
科学推理
评估代码修改自 SkyThought。在我们的评估中,我们将 temperature 设置为 0.7,max_tokens 设置为 32768。我们提供了在 evaluation 中重现我们结果的示例。
评估的系统提示设置为
You are a helpful and harmless assistant. You should think step-by-step.
评估结果如下表所示
模型 | GPQA-Diamond | MMLU-Pro | MMLU |
---|---|---|---|
OpenAI o1 | 75.7 | - | 91.8 |
OpenAI o1-preview | 73.3 | - | 90.8 |
OpenAI o1-mini | 60.0 | 80.3 | 85.2 |
DeepSeek R1 | 71.5 | 84.0 | 90.8 |
deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | 57.6 | 68.7 | 82.2 |
Qwen/QwQ-32B-Preview | 49.5 | 63.5 | 85.2 |
NovaSky-AI/Sky-T1-32B-Preview | 50.5 | 65.8 | 82.7 |
Qwen/Qwen2.5-32B-Instruct | 46.5 | 56.3 | 79.6 |
FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Instruct-32B-Preview | 55.1 | 68.6 | 82.0 |
FuseAI/FuseO1-DeepSeekR1-QwQ-32B-Preview | 62.1 | 68.9 | 82.7 |
FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-Flash-32B-Preview | 54.6 | 70.6 | 84.0 |
FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview | 62.1 | 70.8 | 83.6 |
我们发现,与 DeepSeek-R1-Distill-Qwen-32B、QwQ-32B-Preview 和 Sky-T1-32B-Preview 相比,我们合并后的 FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview 在科学推理方面表现出卓越的性能提升。具体而言,我们的模型在 GPQA-Diamond 上达到了 62.1 的准确率,在 MMLU-Pro 上达到了 70.8 的准确率,与 DeepSeek-R1-Distill-Qwen-32B(GPQA-Diamond 上 57.6,MMLU-Pro 上 68.7)相比,显示出显著的性能提升。
代码推理
评估代码修改自 Qwen2.5-Coder。在我们的评估中,我们将 temperature 设置为 0.6,top-p 设置为 0.95,max_tokens 设置为 32768。我们提供了在 code_evaluation 中重现我们结果的示例。
评估的系统提示设置为
A conversation between User and Assistant. The user asks a question, and the Assistant solves it. The assistant first thinks about the reasoning process in the mind and then provides the user with the answer. The reasoning process and answer are enclosed within <think> </think> and <answer> </answer> tags, respectively, i.e., <think> reasoning process here </think> <answer> answer here </answer>.
在 LiveCodeBench 的评估中,我们遵循 DeepSeek-R1 的方法并进行了微小修改。Pass@1 通过对每个提示 16 个采样响应的结果进行平均计算。
评估结果如下表所示
模型 | LiveCodeBench | LiveCodeBench-Easy | LiveCodeBench-Medium | LiveCodeBench-Hard |
---|---|---|---|---|
OpenAI o1 | 63.4 | 98.5 | 80.9 | 31.7 |
OpenAI o1-preview | 42.7 | 97.0 | 47.2 | 9.8 |
OpenAI o1-mini | 52.00 | 91.0 | 67.4 | 19.5 |
DeepSeek R1 | 62.8 | 98.4 | 78.3 | 32.2 |
deepseek-ai/DeepSeek-R1-Distill-Qwen-32B | 56.1 | 93.6 | 73.1 | 23.4 |
Qwen/QwQ-32B-Preview | 44.4 | 94.9 | 53.8 | 10.0 |
NovaSky-AI/Sky-T1-32B-Preview | 37.3 | 89.7 | 40.4 | 6.6 |
FuseAI/FuseO1-DeepSeekR1-Qwen2.5-Coder-32B-Preview | 56.4 | 92.9 | 73.5 | 24.2 |
FuseAI/FuseO1-DeepSeekR1-QwQ-32B-Preview | 54.8 | 93.9 | 71.7 | 21.3 |
FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-Flash-32B-Preview | 58.2 | 94.3 | 77.1 | 25.0 |
FuseAI/FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview | 57.9 | 93.6 | 76.0 | 25.5 |
我们发现,与 DeepSeek-R1-Distill-Qwen-32B、QwQ-32B-Preview 和 Sky-T1-32B-Preview 相比,我们合并后的 FuseO1-DeepSeekR1-QwQ-SkyT1-32B-Preview 在科学推理方面表现出卓越的性能提升。具体而言,我们的模型在 LiveCodeBench 上达到了 57.9 的准确率,在 LiveCodeBench-Hard 上达到了 25.5 的准确率,与 DeepSeek-R1-Distill-Qwen-32B(LiveCodeBench 上 56.1,LiveCodeBench-Hard 上 23.4)、OpenAI o1-preview(LiveCodeBench 上 42.7,LiveCodeBench-Hard 上 9.8)和 OpenAI o1-mini(LiveCodeBench 上 52.0,LiveCodeBench-Hard 上 19.5 的 Pass@1 准确率)相比,显示出显著的性能提升。
未来工作
这项工作是我们通过模型合并方法实现 System-II 推理 LLM 知识融合的首次尝试,该方法仅限于规模和架构相同的 LLM。在未来的工作中,我们计划采用我们基于多教师知识蒸馏的显式模型融合方法,以及利用加权奖励偏好优化的隐式模型融合方法,用于不同规模和架构的 LLM。此外,我们打算探索知识融合与强化学习 (RL) 方法的结合,这已被证明是增强推理能力最有效的方法。敬请关注 FuseO1 的下一版本!
引用
@article{wan2024fusechat,
title={Fusechat: Knowledge fusion of chat models},
author={Wan, Fanqi and Zhong, Longguang and Yang, Ziyi and Chen, Ruijun and Quan, Xiaojun},
journal={arXiv preprint arXiv:2408.07990},
year={2024}
}