🚀 Nous Hermes 2 - Mistral 7B - DPO
Nous Hermes 2 - Mistral 7B - DPO 是一款文本生成模型,基于 Mistral 7B 架构,经过 DPO 优化,在多个基准测试中表现出色,能处理多种自然语言任务。
🚀 快速开始
安装必要的包
pip install --upgrade autoawq autoawq-kernels
Python 代码示例
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer, TextStreamer
model_path = "solidrust/Nous-Hermes-2-Mistral-7B-DPO-AWQ"
system_message = "You are Hermes, incarnated a powerful AI."
model = AutoAWQForCausalLM.from_quantized(model_path,
fuse_layers=True)
tokenizer = AutoTokenizer.from_pretrained(model_path,
trust_remote_code=True)
streamer = TextStreamer(tokenizer,
skip_prompt=True,
skip_special_tokens=True)
prompt_template = """\
<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant"""
prompt = "You're standing on the surface of the Earth. "\
"You walk one mile south, one mile west and one mile north. "\
"You end up exactly where you started. Where are you?"
tokens = tokenizer(prompt_template.format(system_message=system_message,prompt=prompt),
return_tensors='pt').input_ids.cuda()
generation_output = model.generate(tokens,
streamer=streamer,
max_new_tokens=512)
✨ 主要特性
- 微调与量化:经过微调与 4 位量化处理,采用 AWQ 方法,提高效率。
- 多框架支持:兼容 Transformers、PyTorch 等框架。
- 高质量训练:基于 100 万条 GPT - 4 质量或更高的指令/对话进行训练,使用合成数据和其他高质量数据集。
- 特定提示模板:采用 ChatML 提示模板,便于使用。
📦 安装指南
安装必要的包,使用以下命令:
pip install --upgrade autoawq autoawq-kernels
💻 使用示例
基础用法
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer, TextStreamer
model_path = "solidrust/Nous-Hermes-2-Mistral-7B-DPO-AWQ"
system_message = "You are Hermes, incarnated a powerful AI."
model = AutoAWQForCausalLM.from_quantized(model_path,
fuse_layers=True)
tokenizer = AutoTokenizer.from_pretrained(model_path,
trust_remote_code=True)
streamer = TextStreamer(tokenizer,
skip_prompt=True,
skip_special_tokens=True)
prompt_template = """\
<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant"""
prompt = "You're standing on the surface of the Earth. "\
"You walk one mile south, one mile west and one mile north. "\
"You end up exactly where you started. Where are you?"
tokens = tokenizer(prompt_template.format(system_message=system_message,prompt=prompt),
return_tensors='pt').input_ids.cuda()
generation_output = model.generate(tokens,
streamer=streamer,
max_new_tokens=512)
📚 详细文档
模型信息
属性 |
详情 |
模型类型 |
Nous-Hermes-2-Mistral-7B-DPO |
基础模型 |
teknium/OpenHermes-2.5-Mistral-7B |
训练数据集 |
teknium/OpenHermes-2.5 |
量化者 |
Suparious |
模型创建者 |
NousResearch |
推理 |
不支持 |
提示模板 |
'< |
关于 AWQ
AWQ 是一种高效、准确且极快的低比特权重量化方法,目前支持 4 位量化。与 GPTQ 相比,它在基于 Transformer 的推理中速度更快,并且在质量上与最常用的 GPTQ 设置相当或更好。
AWQ 模型目前仅在 Linux 和 Windows 系统上支持,且仅支持 NVIDIA GPU。macOS 用户请使用 GGUF 模型。
支持的平台和框架包括:
提示模板:ChatML
<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant
📄 许可证
本模型采用 Apache - 2.0 许可证。
BibTeX 引用
@misc{Nous-Hermes-2-Mistral-7B-DPO,
url={[https://huggingface.co/NousResearch/Nous-Hermes-2-Mistral-7B-DPO](https://huggingface.co/NousResearch/Nous-Hermes-2-Mistral-7B-DPO)},
title={Nous Hermes 2 Mistral 7B DPO},
author={"Teknium", "theemozilla", "karan4d", "huemin_art"}
}
致谢
感谢 FluidStack 为该模型的计算提供赞助。