🚀 QwQ-32B-Preview AWQ 4位量化版本
本项目提供了由通义团队开发的 QwQ-32B-Preview 模型的 AWQ 4位量化 版本。量化后的模型显著降低了内存使用和计算需求,使其适合在资源有限的硬件上部署。
🚀 快速开始
要加载分词器和模型,并使用量化模型生成内容,可按以下步骤操作:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "KirillR/QwQ-32B-Preview-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 'strawberry'?"
messages = [
{"role": "system", "content": "You are a helpful assistant developed by Alibaba. Please think step-by-step."},
{"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=1024
)
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)
✨ 主要特性
- 低资源占用:量化后的模型显著降低了内存使用和计算需求,适合在资源有限的硬件上部署。
- 特定领域表现出色:该模型旨在提升AI推理能力,尤其在数学和编码任务中表现出色。
📦 安装指南
请确保使用的是最新版本的Hugging Face Transformers,因为通义2.5的代码集成在其中。使用早于 4.37.0 的版本可能会导致以下错误:
KeyError: 'qwen2'
📚 详细文档
模型局限性
- 语言混合和代码切换:模型可能会意外地在不同语言之间切换或混合使用,影响响应的清晰度。
- 递归推理循环:模型有可能陷入循环推理模式,导致冗长的响应但没有明确的答案。
- 安全和伦理考量:需要增强安全措施以确保可靠和安全的性能。用户在部署模型时应谨慎操作。
- 性能局限:虽然在数学和编码方面表现出色,但模型在常识推理和细微语言理解等领域可能表现不佳。
🔗 原始模型
有关原始QwQ-32B-Preview模型的更多详细信息,请参考以下资源:
https://huggingface.co/Qwen/Qwen2.5-Coder-32B-Instruct-AWQ
📄 许可证
本项目采用Apache-2.0许可证。
📖 引用
如果您觉得原始模型有帮助,请考虑引用原作者:
@misc{qwq-32b-preview,
title = {QwQ: Reflect Deeply on the Boundaries of the Unknown},
url = {https://qwenlm.github.io/blog/qwq-32b-preview/},
author = {Qwen Team},
month = {November},
year = {2024}
}
@article{qwen2,
title={Qwen2 Technical Report},
author={An Yang and Baosong Yang and others},
journal={arXiv preprint arXiv:2407.10671},
year={2024}
}
⚠️ 重要提示
此量化模型有效运行大约需要 20 GB的显存。