QwQ 是 Qwen 系列的推理模型。与传统的指令微调模型相比,具备思维推理能力的 QwQ 能够在下游任务中实现显著增强的性能表现,尤其是在处理复杂难题时。QwQ-32B 作为中等规模的推理模型,其性能可与当前最先进的推理模型(如 DeepSeek-R1、o1-mini)相媲美。
本仓库包含经过 AWQ 量化处理的 4 位 QwQ 32B 模型,具有以下特性:
注意: 为获得最佳体验,部署 QwQ 模型前请务必查阅使用指南。
您可以通过我们的演示平台体验模型,或通过千问对话平台访问 QwQ 系列模型。
更多技术细节请参阅我们的博客、GitHub 仓库及技术文档。
QwQ 基于 Qwen2.5 架构开发,其代码已集成至最新版 Hugging Face transformers 库。建议使用最新版本的 transformers 库。
若使用 transformers<4.37.0 版本,将会遇到以下错误:
KeyError: 'qwen2'同时,欢迎查阅我们的 AWQ 量化文档 获取更多使用指南。
以下代码片段通过 apply_chat_template 方法,展示如何加载分词器与模型并生成内容。
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "Qwen/QwQ-32B-AWQ"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "How many r's are in the word \"strawberry\""
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=32768
)
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]
print(response)为获得最佳性能,我们推荐以下设置:
确保思考输出完整性:请确保模型以"<think>\n"开头,以避免生成空思考内容导致输出质量下降。若使用apply_chat_template并设置add_generation_prompt=True,系统将自动实现此功能,但可能导致回复开头缺少<think>标签,此属正常现象。
采样参数配置:
presence_penalty参数设置在0到2之间以减少无限重复。但需注意,较高值可能导致偶现语言混杂现象及轻微性能下降历史对话不包含思考内容:在多轮对话中,历史模型输出应仅包含最终输出部分,无需包含思考内容。该特性已通过apply_chat_template实现
标准化输出格式:建议在基准测试时使用提示词规范模型输出:
answer字段中仅显示选项字母,例如\"answer\": \"C\""长文本处理方案:当输入超过8,192个token时,建议启用YaRN技术以增强模型长序列信息捕捉能力
支持该功能的框架中,可通过在config.json添加以下配置启用YaRN:
{
...,
"rope_scaling": {
"factor": 4.0,
"original_max_position_embeddings": 32768,
"type": "yarn"
}
}部署时推荐使用vLLM框架。若您不熟悉vLLM,请参阅我们的官方文档了解使用方法。
当前vLLM仅支持静态YARN模式,即缩放因子不随输入长度变化,这可能影响短文本处理性能。
建议仅在需要处理长上下文时添加rope_scaling配置。
详细评估结果已在此📑 博客文章中公布。
关于GPU显存需求及相应吞吐量的测试结果,请参阅此文档。
如果您认为我们的工作对您有帮助,欢迎引用我们的成果。
@misc{qwq32b,
title = {QwQ-32B: Embracing the Power of Reinforcement Learning},
url = {https://qwenlm.github.io/blog/qwq-32b/},
author = {Qwen Team},
month = {March},
year = {2025}
}
@article{qwen2.5,
title={Qwen2.5 Technical Report},
author={An Yang and Baosong Yang and Beichen Zhang and Binyuan Hui and Bo Zheng and Bowen Yu and Chengyuan Li and Dayiheng Liu and Fei Huang and Haoran Wei and Huan Lin and Jian Yang and Jianhong Tu and Jianwei Zhang and Jianxin Yang and Jiaxi Yang and Jingren Zhou and Junyang Lin and Kai Dang and Keming Lu and Keqin Bao and Kexin Yang and Le Yu and Mei Li and Mingfeng Xue and Pei Zhang and Qin Zhu and Rui Men and Runji Lin and Tianhao Li and Tianyi Tang and Tingyu Xia and Xingzhang Ren and Xuancheng Ren and Yang Fan and Yang Su and Yichang Zhang and Yu Wan and Yuqiong Liu and Zeyu Cui and Zhenru Zhang and Zihan Qiu},
journal={arXiv preprint arXiv:2412.15115},
year={2024}
}