🚀 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 為該模型的計算提供贊助。