HuggingFace镜像/Qwen2-Math-7B
模型介绍文件和版本分析
下载使用量0

Qwen2-Math-7B

[!Warning]

🚨 目前该模型主要支持英文。我们即将发布双语(英文和中文)模型!

简介

在过去的一年中,我们投入了大量精力研究和提升大语言模型的推理能力,尤其关注其解决算术和数学问题的能力。今天,我们荣幸地推出Qwen2系列中的一系列数学专用大语言模型——Qwen2-Math以及Qwen2-Math-Instruct-1.5B/7B/72B。Qwen2-Math是基于Qwen2大语言模型构建的一系列数学专用语言模型,其数学能力显著优于开源模型,甚至超越了部分闭源模型(例如GPT4o)。我们希望Qwen2-Math能够为科学界解决需要复杂、多步骤逻辑推理的高级数学问题贡献力量。

在openMind中使用

环境变量

# source environment variable
source /usr/local/Ascend/ascend-toolkit/set_env.sh
export OPENMIND_FRAMEWORK=pt

pip install openMind Library

OpenMind Library 可通过 pip 进行安装,请根据实际环境选择相应命令进行安装。

需要注意的是,由于 torch npu 依赖 torch,在 aarch64 环境下可直接通过 pip 安装,但在 x86 环境下需要通过特定 URL 下载 CPU 版本,因此两种环境下的安装命令有所不同。具体安装代码已在下文进行区分呈现。

# aarch64
pip install openmind[all]
# x86
pip install openmind[all] --extra-index-url https://download.pytorch.org/whl/cpu

推理

from openmind import AutoTokenizer, AutoModelForCausalLM
import torch
import torch_npu

model_dir = "wuhaicc/Qwen2-Math-7B"
tokenizer = AutoTokenizer.from_pretrained(model_dir, device_map="auto", trust_remote_code=True)
# Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and might cause OOM Error.
model = AutoModelForCausalLM.from_pretrained(model_dir, device_map="auto",  trust_remote_code=True, torch_dtype=torch.float16)
model = model.eval()
response, history = model.chat(tokenizer, "1+1=", history=[], meta_instruction="")
print(response)

模型详情

如需了解更多详情,请参阅我们的博客文章和GitHub 仓库。

[!Important]

Qwen2-Math-7B-Instruct 是一个用于对话的指令模型;

Qwen2-Math-7B 是一个基础模型,通常用于补全和少样本推理,是更好的微调起点。

引用

如果您觉得我们的工作对您有帮助,欢迎引用我们。

@article{yang2024qwen2,
  title={Qwen2 technical report},
  author={Yang, An and Yang, Baosong and Hui, Binyuan and Zheng, Bo and Yu, Bowen and Zhou, Chang and Li, Chengpeng and Li, Chengyuan and Liu, Dayiheng and Huang, Fei and others},
  journal={arXiv preprint arXiv:2407.10671},
  year={2024}
}