返回模型
说明文档
Qwen2-0.5B-Instruct
简介
Qwen2 是 Qwen 大语言模型的新系列。对于 Qwen2,我们发布了多个基础语言模型和指令微调语言模型,参数规模从 0.5 到 72 亿不等,其中包括混合专家模型。本仓库包含指令微调的 0.5B Qwen2 模型。
与最先进的开源语言模型(包括之前发布的 Qwen1.5)相比,Qwen2 总体上超越了大多数开源模型,并在一系列针对语言理解、语言生成、多语言能力、编程、数学、推理等任务的基准测试中展现了与专有模型相媲美的竞争力。
模型详情
Qwen2 是一个包含不同规模解码器语言模型的语言模型系列。对于每种规模,我们都发布了基础语言模型和对齐的聊天模型。它基于 Transformer 架构,采用 SwiGLU 激活函数、注意力 QKV 偏置、分组查询注意力等技术。此外,我们还改进了分词器,以适应多种自然语言和代码。
训练详情
我们使用大量数据对模型进行了预训练,并通过监督微调和直接偏好优化对模型进行了后训练。
环境要求
Qwen2 的代码已包含在最新的 Hugging Face transformers 中,我们建议您安装 transformers>=4.37.0,否则可能会遇到以下错误:
KeyError: 'qwen2'
快速开始
这里提供一段使用 apply_chat_template 的代码示例,向您展示如何加载分词器和模型以及如何生成内容。
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda" # 加载模型的设备
model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2-0.5B-Instruct",
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-0.5B-Instruct")
prompt = "Give me a short introduction to large language model."
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"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.input_ids,
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]
评测结果
我们简要比较了 Qwen2-0.5B-Instruct 与 Qwen1.5-0.5B-Chat 的表现。结果如下:
| 数据集 | Qwen1.5-0.5B-Chat | Qwen2-0.5B-Instruct | Qwen1.5-1.8B-Chat | Qwen2-1.5B-Instruct |
|---|---|---|---|---|
| MMLU | 35.0 | 37.9 | 43.7 | 52.4 |
| HumanEval | 9.1 | 17.1 | 25.0 | 37.8 |
| GSM8K | 11.3 | 40.1 | 35.3 | 61.6 |
| C-Eval | 37.2 | 45.2 | 55.3 | 63.8 |
| IFEval (Prompt Strict-Acc.) | 14.6 | 20.0 | 16.8 | 29.0 |
引用
如果您觉得我们的工作有帮助,欢迎引用。
@article{qwen2,
title={Qwen2 Technical Report},
year={2024}
}
Mezzaouia/Qwen2-0.5B-Instruct
作者 Mezzaouia
text-generation
transformers
↓ 0
♥ 0
创建时间: 2024-07-11 18:39:15+00:00
更新时间: 2024-07-11 19:19:51+00:00
在 Hugging Face 上查看文件 (10)
.gitattributes
LICENSE
README.md
config.json
generation_config.json
merges.txt
onnx/model_q4.onnx
ONNX
tokenizer.json
tokenizer_config.json
vocab.json