模型简介
模型特点
模型能力
使用案例
base_model: NousResearch/Yarn-Mistral-7b-128k
datasets:
-
emozilla/yarn-train-tokenized-16k-mistral
inference: false
language: -
en
library_name: transformers
license: apache-2.0
metrics: -
perplexity
model_creator: NousResearch
model_name: Yarn Mistral 7B 128K
model_type: mistral
prompt_template: '{prompt}'
quantized_by: TheBloke

TheBloke的LLM工作得到了安德森·霍洛维茨(a16z)的慷慨资助
Yarn Mistral 7B 128K - AWQ
- 模型创作者:NousResearch
- 原始模型:Yarn Mistral 7B 128K
模型描述
本仓库包含NousResearch的Yarn Mistral 7B 128K的AWQ模型文件。
这些文件使用了Massed Compute提供的硬件进行量化。
关于AWQ
AWQ是一种高效、准确且快速的低位权重量化方法,目前支持4位量化。与GPTQ相比,它在基于Transformer的推理中提供了更快的速度,同时保持与最常用GPTQ设置相当或更优的质量。
支持以下平台:
- 文本生成Web界面 - 使用加载器:AutoAWQ
- vLLM - 仅支持Llama和Mistral模型
- Hugging Face文本生成推理(TGI)
- AutoAWQ - 用于Python代码调用
可用仓库
- 用于GPU推理的AWQ模型
- 用于GPU推理的GPTQ模型,提供多种量化参数选项
- 用于CPU+GPU推理的2、3、4、5、6和8位GGUF模型
- NousResearch的原始未量化fp16模型,以pytorch格式提供,用于GPU推理和进一步转换
提示模板:无
{prompt}
提供的文件和AWQ参数
本次发布的AWQ模型仅包含128g版本。如果有需求,我会考虑添加32g版本,但当前32g模型尚未通过AutoAWQ和vLLM的全面测试。
模型以分片的安全张量文件形式发布。
分支 | 位数 | GS | AWQ数据集 | 序列长度 | 大小 |
---|---|---|---|---|---|
main | 4 | 128 | wikitext | 4096 | 4.15 GB |
如何在text-generation-webui中轻松下载和使用此模型
请确保您使用的是最新版本的text-generation-webui。
强烈建议使用text-generation-webui的一键安装程序,除非您确定如何进行手动安装。
- 点击模型标签页。
- 在下载自定义模型或LoRA下,输入
TheBloke/Yarn-Mistral-7B-128k-AWQ
。 - 点击下载。
- 模型将开始下载。完成后会显示“完成”。
- 在左上角,点击刷新图标旁边的模型。
- 在模型下拉菜单中,选择您刚刚下载的模型:
Yarn-Mistral-7B-128k-AWQ
- 选择加载器:AutoAWQ。
- 点击加载,模型将加载并准备就绪。
- 如果需要任何自定义设置,设置后点击保存此模型的设置,然后在右上角点击重新加载模型。
- 准备就绪后,点击文本生成标签页并输入提示开始使用!
多用户推理服务器:vLLM
安装和使用vLLM的文档可以在此找到。
- 请确保您使用的是vLLM 0.2或更高版本。
- 当使用vLLM作为服务器时,传递
--quantization awq
参数。
例如:
python3 python -m vllm.entrypoints.api_server --model TheBloke/Yarn-Mistral-7B-128k-AWQ --quantization awq
- 当从Python代码中使用vLLM时,同样设置
quantization=awq
。
例如:
from vllm import LLM, SamplingParams
prompts = [
"告诉我关于AI的事情",
"写一个关于羊驼的故事",
"291 - 150等于多少?",
"如果一只土拨鼠能扔木头,它能扔多少木头?",
]
prompt_template=f'''{prompt}
'''
prompts = [prompt_template.format(prompt=prompt) for prompt in prompts]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)
llm = LLM(model="TheBloke/Yarn-Mistral-7B-128k-AWQ", quantization="awq", dtype="auto")
outputs = llm.generate(prompts, sampling_params)
# 打印输出
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(f"提示:{prompt!r}, 生成文本:{generated_text!r}")
多用户推理服务器:Hugging Face文本生成推理(TGI)
使用TGI版本1.1.0或更高版本。官方Docker容器为:ghcr.io/huggingface/text-generation-inference:1.1.0
示例Docker参数:
--model-id TheBloke/Yarn-Mistral-7B-128k-AWQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
与TGI交互的Python代码示例(需要huggingface-hub 0.17.0或更高版本):
pip3 install huggingface-hub
from huggingface_hub import InferenceClient
endpoint_url = "https://your-endpoint-url-here"
prompt = "告诉我关于AI的事情"
prompt_template=f'''{prompt}
'''
client = InferenceClient(endpoint_url)
response = client.text_generation(prompt,
max_new_tokens=128,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
repetition_penalty=1.1)
print(f"模型输出:", response)
使用AutoAWQ从Python代码进行推理
安装AutoAWQ包
要求:AutoAWQ 0.1.1或更高版本。
pip3 install autoawq
如果使用预构建的轮子安装AutoAWQ时遇到问题,请从源代码安装:
pip3 uninstall -y autoawq
git clone https://github.com/casper-hansen/AutoAWQ
cd AutoAWQ
pip3 install .
AutoAWQ示例代码
from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
model_name_or_path = "TheBloke/Yarn-Mistral-7B-128k-AWQ"
# 加载分词器
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True)
# 加载模型
model = AutoAWQForCausalLM.from_quantized(model_name_or_path, fuse_layers=True,
trust_remote_code=True, safetensors=True)
prompt = "告诉我关于AI的事情"
prompt_template=f'''{prompt}
'''
print("*** 运行model.generate:")
token_input = tokenizer(
prompt_template,
return_tensors='pt'
).input_ids.cuda()
# 生成输出
generation_output = model.generate(
token_input,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
max_new_tokens=512
)
# 从输出中获取令牌,解码并打印
token_output = generation_output[0]
text_output = tokenizer.decode(token_output)
print("LLM输出:", text_output)
"""
# 未来应可通过transformers pipeline进行推理
# 但目前AutoAWQ尚未支持(截至2023年9月25日)
from transformers import pipeline
print("*** Pipeline:")
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
max_new_tokens=512,
do_sample=True,
temperature=0.7,
top_p=0.95,
top_k=40,
repetition_penalty=1.1
)
print(pipe(prompt_template)[0]['generated_text'])
"""
兼容性
提供的文件经过测试可与以下工具兼容:
- text-generation-webui使用
Loader: AutoAWQ
。 - vLLM版本0.2.0及更高版本。
- Hugging Face文本生成推理(TGI)版本1.1.0及更高版本。
- AutoAWQ版本0.1.1及更高版本。
Discord
如需进一步支持或讨论这些模型及AI相关话题,请加入:
感谢与贡献方式
感谢chirper.ai团队!
感谢Clay来自gpus.llm-utils.org!
许多人询问是否可以贡献。我很乐意提供模型并帮助他人,并希望有更多时间投入其中,同时拓展新的项目如微调/训练。
如果您有能力并愿意贡献,我将不胜感激,这将帮助我继续提供更多模型,并开始新的AI项目。
捐助者将获得任何AI/LLM/模型问题的优先支持,访问私人Discord房间以及其他福利。
- Patreon: https://patreon.com/TheBlokeAI
- Ko-Fi: https://ko-fi.com/TheBlokeAI
特别感谢:Aemon Algiz。
Patreon特别提及:Brandon Frisco, LangChain4j, Spiking Neurons AB, transmissions 11, Joseph William Delisle, Nitin Borwankar, Willem Michiel, Michael Dempsey, vamX, Jeffrey Morgan, zynix, jjj, Omer Bin Jawed, Sean Connelly, jinyuan sun, Jeromy Smith, Shadi, Pawan Osman, Chadd, Elijah Stavena, Illia Dulskyi, Sebastain Graf, Stephen Murray, terasurfer, Edmond Seymore, Celu Ramasamy, Mandus, Alex, biorpg, Ajan Kanaga, Clay Pascal, Raven Klaugh, 阿明, K, ya boyyy, usrbinkat, Alicia Loh, John Villwock, ReadyPlayerEmma, Chris Smitley, Cap'n Zoog, fincy, GodLy, S_X, sidney chen, Cory Kujawski, OG, Mano Prime, AzureBlack, Pieter, Kalila, Spencer Kim, Tom X Nguyen, Stanislav Ovsiannikov, Michael Levine, Andrey, Trailburnt, Vadim, Enrico Ros, Talal Aujan, Brandon Phillips, Jack West, Eugene Pentland, Michael Davis, Will Dee, webtim, Jonathan Leane, Alps Aficionado, Rooh Singh, Tiffany J. Kim, theTransient, Luke @flexchar, Elle, Caitlyn Gatomon, Ari Malik, subjectnull, Johann-Peter Hartmann, Trenton Dambrowitz, Imad Khwaja, Asp the Wyvern, Emad Mostaque, Rainer Wilmers, Alexandros Triantafyllidis, Nicholas, Pedro Madruga, SuperWojo, Harry Royden McLaughlin, James Bentley, Olakabola, David Ziegler, Ai Maven, Jeff Scroggin, Nikolai Manek, Deo Leter, Matthew Berman, Fen Risland, Manuel Alberto Morcote, Luke Pendergrass, TL, Fred von Graf, Randy H, Dan Guido, NimbleBox.ai, Vitor Caleffi, Gabriel Tamborski, knownsqashed, Lone Striker, Erik Bjäreholt, John Detwiler, Leonard Tan, Iucharbius
感谢所有慷慨的赞助者和捐助者!
再次感谢a16z的慷慨资助。
原始模型卡片:NousResearch的Yarn Mistral 7B 128K
模型卡片:Nous-Yarn-Mistral-7b-128k
模型描述
Nous-Yarn-Mistral-7b-128k是一款针对长上下文优化的先进语言模型,通过YaRN扩展方法在长上下文数据上进一步预训练了1500步。
它是Mistral-7B-v0.1的扩展,支持128k令牌的上下文窗口。
使用时,加载模型时需传递trust_remote_code=True
,例如:
model = AutoModelForCausalLM.from_pretrained("NousResearch/Yarn-Mistral-7b-128k",
use_flash_attention_2=True,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True)
此外,您需要使用最新版本的transformers
(直到4.35发布)
pip install git


