[!警告]
🚨 Qwen2.5-Math 主要支持通过 CoT 和 TIR 解决英文和中文数学问题。我们不推荐将此系列模型用于其他任务。
2024年8月,我们推出了 Qwen 家族首个数学 LLM 系列——Qwen2-Math。一个月后,我们对它进行了升级并开源了 Qwen2.5-Math 系列,包括基础模型 Qwen2.5-Math-1.5B/7B/72B,指令微调模型 Qwen2.5-Math-1.5B/7B/72B-Instruct 和数学奖励模型 Qwen2.5-Math-RM-72B。
与仅支持使用 CoT 解决英文数学问题的 Qwen2-Math 系列不同,Qwen2.5-Math 系列扩展为支持使用 CoT 和 TIR 解决中文和英文的数学问题。与 Qwen2-Math 系列模型相比,Qwen2.5-Math 系列模型在中文和英文数学基准测试中 CoT 的性能取得了显著提升。

尽管 CoT 在增强 LLM 的推理能力方面发挥着关键作用,但在实现计算精度和处理复杂的数学或算法推理任务(如求解二次方程的根或计算矩阵的特征值)方面仍面临挑战。TIR 可以进一步改善模型在精确计算、符号操作和算法操作上的熟练度。使用 TIR,Qwen2.5-Math-1.5B/7B/72B-Instruct 在 MATH 基准测试中分别达到了 79.7、85.3 和 87.8。
了解更多详情,请参考我们的 博客文章 和 GitHub 仓库。
transformers>=4.37.0。推荐使用最新版本。[!警告]
🚨 这是必须的,因为transformers自4.37.0版本起集成了 Qwen2 代码。
关于 GPU 内存需求及相应吞吐量的更多信息,请查阅 Qwen2 的 相关结果。
[!重要]
Qwen2.5-Math-7B-Instruct 是一个适用于聊天的指令模型;
Qwen2.5-Math-7B 是一个通常用于完成和少量样本推断的基础模型,是微调的更好起点。
Qwen2.5-Math 可以与 Qwen2.5 以同样的方式部署和推断。以下是一个如何使用聊天模型与 transformers 的代码示例:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "Qwen/Qwen2.5-Math-7B-Instruct"
device = "cuda" # the device to load the model onto
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "Find the value of $x$ that satisfies the equation $4x+5 = 6x+7$."
# CoT
messages = [
{"role": "system", "content": "Please reason step by step, and put your final answer within \\boxed{}."},
{"role": "user", "content": prompt}
]
# TIR
messages = [
{"role": "system", "content": "Please integrate natural language reasoning with programs to solve the problem above, and put your final answer within \\boxed{}."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]若您认为我们的工作对您有帮助,欢迎加以引用。
@article{yang2024qwen25mathtechnicalreportmathematical,
title={Qwen2.5-Math Technical Report: Toward Mathematical Expert Model via Self-Improvement},
author={An Yang and Beichen Zhang and Binyuan Hui and Bofei Gao and Bowen Yu and Chengpeng Li and Dayiheng Liu and Jianhong Tu and Jingren Zhou and Junyang Lin and Keming Lu and Mingfeng Xue and Runji Lin and Tianyu Liu and Xingzhang Ren and Zhenru Zhang},
journal={arXiv preprint arXiv:2409.12122},
year={2024}
}当然,我会根据您的要求进行翻译。不过,您似乎没有提供要翻译的文本。请您提供需要翻译的内容,我会按照您的要求将其翻译成中文。