模型简介
模型特点
模型能力
使用案例
🚀 Xwin-LM 13B V0.1 - GPTQ
Xwin-LM 13B V0.1 - GPTQ 是对 Xwin-LM 13B V0.1 模型进行量化处理后的版本。提供了多种 GPTQ 参数排列组合,可根据不同硬件和需求选择合适的量化模型,支持 GPU 和 CPU+GPU 推理。
🚀 快速开始
本仓库包含 Xwin-LM 的 Xwin-LM 13B V0.1 的 GPTQ 模型文件。提供了多种 GPTQ 参数排列组合,详情见下方的“提供的文件和 GPTQ 参数”部分。
✨ 主要特性
- 多版本支持:提供 AWQ 模型用于 GPU 推理、多种量化参数选项的 GPTQ 模型用于 GPU 推理、2 - 8 位的 GGUF 模型用于 CPU+GPU 推理,以及原始未量化的 fp16 模型。
- 参数丰富:不同的 GPTQ 参数组合,如位大小、组大小、Act Order 等,可根据硬件和需求选择最合适的量化模型。
- 广泛兼容:与 AutoGPTQ、Occ4m's GPTQ - for - LLaMa 分叉、ExLlama(4 位 Llama 模型)、Huggingface Text Generation Inference (TGI) 等工具兼容。
📦 安装指南
在 text - generation - webui 中下载
- 从
main
分支下载:在“下载模型”框中输入TheBloke/Xwin-LM-13B-V0.1-GPTQ
。 - 从其他分支下载:在下载名称末尾添加
:branchname
,例如TheBloke/Xwin-LM-13B-V0.1-GPTQ:gptq-4bit-32g-actorder_True
。
从命令行下载
推荐使用 huggingface - hub
Python 库:
pip3 install huggingface-hub
下载 main
分支到名为 Xwin-LM-13B-V0.1-GPTQ
的文件夹:
mkdir Xwin-LM-13B-V0.1-GPTQ
huggingface-cli download TheBloke/Xwin-LM-13B-V0.1-GPTQ --local-dir Xwin-LM-13B-V0.1-GPTQ --local-dir-use-symlinks False
从不同分支下载,添加 --revision
参数:
mkdir Xwin-LM-13B-V0.1-GPTQ
huggingface-cli download TheBloke/Xwin-LM-13B-V0.1-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir Xwin-LM-13B-V0.1-GPTQ --local-dir-use-symlinks False
💻 使用示例
在 text - generation - webui 中使用
- 点击“模型”标签。
- 在“下载自定义模型或 LoRA”下,输入
TheBloke/Xwin-LM-13B-V0.1-GPTQ
。若从特定分支下载,输入如TheBloke/Xwin-LM-13B-V0.1-GPTQ:gptq-4bit-32g-actorder_True
。 - 点击“下载”。
- 模型开始下载,完成后显示“完成”。
- 在左上角,点击“模型”旁边的刷新图标。
- 在“模型”下拉菜单中,选择刚下载的模型
Xwin-LM-13B-V0.1-GPTQ
。 - 模型将自动加载,即可使用。
- 若需要自定义设置,设置后点击“保存此模型的设置”,然后点击右上角的“重新加载模型”。
- 准备好后,点击“文本生成”标签,输入提示词开始使用。
从 Python 代码使用
安装必要的包
pip3 install transformers optimum
pip3 install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ # 若使用 CUDA 11.7,使用 cu117
若使用预构建的轮子安装 AutoGPTQ 有问题,可从源代码安装:
pip3 uninstall -y auto-gptq
git clone https://github.com/PanQiWei/AutoGPTQ
cd AutoGPTQ
git checkout v0.4.2
pip3 install .
使用代码示例
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/Xwin-LM-13B-V0.1-GPTQ"
# 若使用不同分支,更改 revision
# 例如: revision="gptq-4bit-32g-actorder_True"
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
device_map="auto",
trust_remote_code=False,
revision="main")
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
prompt = "Tell me about AI"
prompt_template=f'''A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: {prompt} ASSISTANT:
'''
print("\n\n*** Generate:")
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
output = model.generate(inputs=input_ids, temperature=0.7, do_sample=True, top_p=0.95, top_k=40, max_new_tokens=512)
print(tokenizer.decode(output[0]))
# 也可以使用 transformers 的 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'])
📚 详细文档
提供的文件和 GPTQ 参数
提供了多种量化参数,可根据硬件和需求选择最佳参数。每个单独的量化版本位于不同的分支中。所有 2023 年 8 月之后的 GPTQ 文件使用 AutoGPTQ 生成,main
分支中 2023 年 8 月之前上传的文件使用 GPTQ - for - LLaMa 生成。
分支 | 位大小 | 组大小 | Act Order | Damp % | GPTQ 数据集 | 序列长度 | 大小 | ExLlama 兼容性 | 描述 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | 是 | 0.1 | wikitext | 4096 | 7.26 GB | 是 | 4 位,有 Act Order 和组大小 128g,比 64g 更省 VRAM,但量化精度稍低。 |
gptq-4bit-32g-actorder_True | 4 | 32 | 是 | 0.1 | wikitext | 4096 | 8.00 GB | 是 | 4 位,有 Act Order 和组大小 32g,推理质量最高,但 VRAM 使用最大。 |
gptq-8bit--1g-actorder_True | 8 | 无 | 是 | 0.1 | wikitext | 4096 | 13.36 GB | 否 | 8 位,有 Act Order,无组大小,降低 VRAM 需求。 |
gptq-8bit-128g-actorder_True | 8 | 128 | 是 | 0.1 | wikitext | 4096 | 13.65 GB | 否 | 8 位,组大小 128g 以提高推理质量,有 Act Order 以提高精度。 |
gptq-8bit-32g-actorder_True | 8 | 32 | 是 | 0.1 | wikitext | 4096 | 14.54 GB | 否 | 8 位,组大小 32g 和 Act Order 以实现最大推理质量。 |
GPTQ 参数解释
- 位大小:量化模型的位大小。
- 组大小(GS):GPTQ 组大小,较高的数字使用较少的 VRAM,但量化精度较低,“无”是最低可能值。
- Act Order:真或假,也称为
desc_act
,真会带来更好的量化精度。一些 GPTQ 客户端在使用 Act Order 加组大小的模型时曾有问题,但现在通常已解决。 - Damp %:影响量化样本处理的 GPTQ 参数,默认值为 0.01,但 0.1 会带来稍高的精度。
- GPTQ 数据集:量化期间使用的校准数据集,使用更适合模型训练的数据集可以提高量化精度。注意 GPTQ 校准数据集与训练模型的数据集不同,请参考原始模型仓库了解训练数据集详情。
- 序列长度:量化使用的数据集序列长度,理想情况下应与模型序列长度相同。对于一些非常长序列的模型(16K 以上),可能需要使用较低的序列长度。较低的序列长度不会限制量化模型的序列长度,仅影响较长推理序列的量化精度。
- ExLlama 兼容性:该文件是否可以用 ExLlama 加载,目前 ExLlama 仅支持 4 位的 Llama 模型。
🔧 技术细节
本项目基于 Xwin-LM 13B V0.1 模型进行 GPTQ 量化处理。GPTQ 是一种量化技术,通过对模型参数进行量化,减少模型的存储空间和推理时的内存使用,同时尽量保持模型的性能。不同的量化参数(如位大小、组大小、Act Order 等)会影响量化的精度和内存使用。
📄 许可证
本项目使用 Llama 2 许可证。
原模型信息
原模型概述
Xwin-LM 旨在开发和开源大语言模型的对齐技术,包括监督微调(SFT)、奖励模型(RM)、拒绝采样、基于人类反馈的强化学习(RLHF)等。其第一个版本基于 Llama2 基础模型构建,在 AlpacaEval 上排名第一,是首个在该基准上超越 GPT - 4 的模型。
新闻动态
- 💥 [2023 年 9 月] 发布 Xwin-LM-70B-V0.1,在 AlpacaEval 基准上对 Text - Davinci - 003 的胜率达到 95.57%,排名第一,首次超越 GPT - 4,对 GPT - 4 的胜率为 60.61。
- 🔍 [2023 年 9 月] RLHF 在 Xwin-LM - V0.1 版本的出色表现中起着关键作用。
- 💥 [2023 年 9 月] 发布 Xwin-LM-13B-V0.1,在 AlpacaEval 上的胜率达到 91.76%,在所有 13B 模型中排名第一。
- 💥 [2023 年 9 月] 发布 Xwin-LM-7B-V0.1,在 AlpacaEval 上的胜率达到 87.82%,在所有 7B 模型中排名第一。
模型卡片
模型 | 检查点 | 报告 | 许可证 |
---|---|---|---|
Xwin-LM-7B-V0.1 | 🤗 HF 链接 | 📃即将推出(敬请关注) | Llama 2 许可证 |
Xwin-LM-13B-V0.1 | 🤗 HF 链接 | Llama 2 许可证 | |
Xwin-LM-70B-V0.1 | 🤗 HF 链接 | Llama 2 许可证 |
基准测试
在 AlpacaEval 上的表现
模型 | AlpacaEval(胜率 %) | AlpacaEval(胜率 %) | AlpacaEval(胜率 %) |
---|---|---|---|
对比 Text - Davinci - 003 | 对比 ChatGPT | 对比 GPT4 | |
Xwin-LM-70B-V0.1 | 95.57 | 87.50 | 60.61 |
GPT - 4 | 95.28 | 84.66 | 50.00 |
WizardLM - 70B - V1.0 | 92.91 | 80.19 | 46.70 |
Llama - 2 - 70B - Chat | 92.66 | 81.97 | 51.19 |
Xwin-LM-13B-V0.1 | 91.76 | 81.79 | 55.30 |
ChatGPT | 89.37 | 50.00 | 16.60 |
WizardLM - 13B - V1.2 | 89.17 | 75.75 | 41.91 |
Xwin-LM-7B-V0.1 | 87.35 | 76.40 | 47.57 |
Llama - 2 - 13B - Chat | 81.09 | 64.22 | 30.92 |
AlpacaEval 案例研究
提示词 | GPT4 响应 | Xwin-LM 响应 |
---|---|---|
我把一个盘子放在苹果上面,然后把盘子从厨房拿到餐厅,苹果现在在哪里 | 苹果现在在餐厅,因为你把盘子从厨房拿到餐厅时,苹果在盘子下面。 | 苹果还在厨房,因为你只移动了盘子。苹果在盘子下面,所以如果你想把苹果拿到餐厅,你应该直接移动苹果或者把苹果放在盘子上再把盘子移到餐厅。 |
回答以下问题。 法语中“晚上好”怎么说。 |
法语中,“晚上好”是“bonsoir”。 | 法语中,“晚上好”翻译为“bonsoir”。这个问候语用于晚上和夜间,通常在下午 6 点之后。它是“bon”(意思是“好”)和“soir”(意思是“晚上”)的组合。发音为“bone - swahr”。 |
在 NLP 基础任务上的表现
模型 | MMLU 5 - shot | ARC 25 - shot | TruthfulQA 0 - shot | HellaSwag 10 - shot | 平均 |
---|---|---|---|---|---|
Text - davinci - 003 | 56.9 | 85.2 | 59.3 | 82.2 | 70.9 |
Vicuna - 13b 1.1 | 51.3 | 53.0 | 51.8 | 80.1 | 59.1 |
Guanaco 30B | 57.6 | 63.7 | 50.7 | 85.1 | 64.3 |
WizardLM - 7B 1.0 | 42.7 | 51.6 | 44.7 | 77.7 | 54.2 |
WizardLM - 13B 1.0 | 52.3 | 57.2 | 50.5 | 81.0 | 60.2 |
WizardLM - 30B 1.0 | 58.8 | 62.5 | 52.4 | 83.3 | 64.2 |
Llama - 2 - 7B - Chat | 48.3 | 52.9 | 45.6 | 78.6 | 56.4 |
Llama - 2 - 13B - Chat | 54.6 | 59.0 | 44.1 | 81.9 | 59.9 |
Llama - 2 - 70B - Chat | 63.9 | 64.6 | 52.8 | 85.9 | 66.8 |
Xwin-LM-7B-V0.1 | 49.7 | 56.2 | 48.1 | 79.5 | 58.4 |
Xwin-LM-13B-V0.1 | 56.6 | 62.4 | 45.5 | 83.0 | 61.9 |
Xwin-LM-70B-V0.1 | 69.6 | 70.5 | 60.1 | 87.1 | 71.8 |
推理
对话模板
使用模型进行推理时,请严格遵循以下对话模板。模型采用 [Vicuna](https://github.com/lm - sys/FastChat) 建立的提示格式,支持多轮对话。
A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: Hi! ASSISTANT: Hello.</s>USER: Who are you? ASSISTANT: I am Xwin-LM.</s>......
HuggingFace 示例
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model = AutoModelForCausalLM.from_pretrained("Xwin-LM/Xwin-LM-7B-V0.1")
tokenizer = AutoTokenizer.from_pretrained("Xwin-LM/Xwin-LM-7B-V0.1")
(
prompt := "A chat between a curious user and an artificial intelligence assistant. "
"The assistant gives helpful, detailed, and polite answers to the user's questions. "
"USER: Hello, can you help me? "
"ASSISTANT:"
)
inputs = tokenizer(prompt, return_tensors="pt")
samples = model.generate(**inputs, max_new_tokens=4096, temperature=0.7)
output = tokenizer.decode(samples[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(output)
# Of course! I'm here to help. Please feel free to ask your question or describe the issue you're having, and I'll do my best to assist you.
vllm 示例
由于 Xwin-LM 基于 Llama2,它也支持使用 [vllm](https://github.com/vllm - project/vllm) 进行快速推理。详细安装说明请参考 [vllm](https://github.com/vllm - project/vllm)。
from vllm import LLM, SamplingParams
(
prompt := "A chat between a curious user and an artificial intelligence assistant. "
"The assistant gives helpful, detailed, and polite answers to the user's questions. "
"USER: Hello, can you help me? "
"ASSISTANT:"
)
sampling_params = SamplingParams(temperature=0.7, max_tokens=4096)
llm = LLM(model="Xwin-LM/Xwin-LM-7B-V0.1")
outputs = llm.generate([prompt,], sampling_params)
for output in outputs:
prompt = output.prompt
generated_text = output.outputs[0].text
print(generated_text)
待办事项
- [ ] 发布源代码
- [ ] 发布更多能力,如数学、推理等
引用
如果使用本仓库中的数据或代码,请考虑引用我们的工作:
@software{xwin-lm,
title = {Xwin-LM},
author = {Xwin-LM Team},
url = {https://github.com/Xwin-LM/Xwin-LM},
version = {pre-release},
year = {2023},
month = {9},
}
致谢
感谢 Llama 2、[FastChat](https://github.com/lm - sys/FastChat)、[AlpacaFarm](https://github.com/tatsu - lab/alpaca_farm) 和 [vllm](https://github.com/vllm - project/vllm)。
社区与贡献
Discord
如需进一步支持,或参与关于这些模型和 AI 的讨论,请加入:TheBloke AI 的 Discord 服务器
感谢与贡献方式
感谢 chirper.ai 团队和 [gpus.llm - utils.org](llm - utils) 的 Clay。
很多人询问是否可以贡献。我喜欢提供模型并帮助他人,也希望能花更多时间做这些事,以及开展新的项目,如微调/训练。
如果您有能力并愿意贡献,将不胜感激,这将帮助我提供更多模型,并开展新的 AI 项目。
捐赠者将在所有 AI/LLM/模型问题和请求上获得优先支持,访问私人 Discord 房间,以及其他福利。
- Patreon: https://patreon.com/TheBlokeAI
- Ko - Fi: https://ko - fi.com/TheBlokeAI
特别感谢:Aemon Algiz。
Patreon 特别提及:Alicia Loh, Stephen Murray, K, Ajan Kanaga, RoA, Magnesian, Deo Leter, Olakabola, Eugene Pentland, zynix, Deep Realms, Raymond Fosdick, Elijah Stavena, Iucharbius, Erik Bjäreholt, Luis Javier Navarrete Lozano, Nicholas, theTransient, John Detwiler, alfie_i, knownsqashed, Mano Prime, Willem Michiel, Enrico Ros, LangChain4j, OG, Michael Dempsey, Pierre Kircher, Pedro Madruga, James Bentley, Thomas Belote, Luke @flexchar, Leonard Tan, Johann - Peter Hartmann, Illia Dulskyi, Fen Risland, Chadd, S_X, Jeff Scroggin, Ken Nordquist, Sean Connelly, Artur Olbinski, Swaroop Kallakuri, Jack West, Ai Maven, David Ziegler, Russ Johnson, transmissions 11, John Villwock, Alps Aficionado, Clay Pascal, Viktor Bowallius, Subspace Studios, Rainer Wilmers, Trenton Dambrowitz, vamX, Michael Levine, 준교 김, Brandon Frisco, Kalila, Trailburnt, Randy H, Talal Aujan, Nathan Dryer, Vadim, 阿明, ReadyPlayerEmma, Tiffany J. Kim, George Stoitzev, Spencer Kim, Jerry Meng, Gabriel Tamborski, Cory Kujawski, Jeffrey Morgan, Spiking Neurons AB, Edmond Seymore, Alexandros Triantafyllidis, Lone Striker, Cap'n Zoog, Nikolai Manek, danny, ya boyyy, Derek Yates, usrbinkat, Mandus, TL, Nathan LeClaire, subjectnull, Imad Khwaja, webtim, Raven Klaugh, Asp the Wyvern, Gabriel Puliatti, Caitlyn Gatomon, Joseph William Delisle, Jonathan Leane, Luke Pendergrass, SuperWojo, Sebastain Graf, Will Dee, Fred von Graf, Andrey, Dan Guido, Daniel P. Andersen, Nitin Borwankar, Elle, Vitor Caleffi, biorpg, jjj, NimbleBox.ai, Pieter, Matthew Berman, terasurfer, Michael Davis, Alex, Stanislav Ovsiannikov
感谢所有慷慨的赞助者和捐赠者!再次感谢 a16z 的慷慨资助。



