模型简介
模型特点
模型能力
使用案例
🚀 Llava v1.5 13B - GPTQ
Llava v1.5 13B - GPTQ 是经过量化处理的模型文件,提供多种量化参数选择,适用于不同硬件和需求,可用于研究大型多模态模型和聊天机器人。
🚀 快速开始
下载模型
在 text-generation-webui 中下载
- 若要从
main
分支下载,在“Download model”框中输入TheBloke/llava-v1.5-13B-GPTQ
。 - 若要从其他分支下载,在下载名称末尾添加
:branchname
,例如TheBloke/llava-v1.5-13B-GPTQ:gptq-4bit-32g-actorder_True
。
从命令行下载
推荐使用 huggingface-hub
Python 库:
pip3 install huggingface-hub
- 若要将
main
分支下载到名为llava-v1.5-13B-GPTQ
的文件夹:
mkdir llava-v1.5-13B-GPTQ
huggingface-cli download TheBloke/llava-v1.5-13B-GPTQ --local-dir llava-v1.5-13B-GPTQ --local-dir-use-symlinks False
- 若要从不同分支下载,添加
--revision
参数:
mkdir llava-v1.5-13B-GPTQ
huggingface-cli download TheBloke/llava-v1.5-13B-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir llava-v1.5-13B-GPTQ --local-dir-use-symlinks False
在 text-generation-webui 中使用模型
- 确保使用的是 text-generation-webui 的最新版本。强烈推荐使用 text-generation-webui 一键安装程序,除非你确定知道如何手动安装。
- 点击 Model tab。
- 在 Download custom model or LoRA 下,输入
TheBloke/llava-v1.5-13B-GPTQ
。若要从特定分支下载,输入例如TheBloke/llava-v1.5-13B-GPTQ:gptq-4bit-32g-actorder_True
,具体分支列表可参考“Provided files, and GPTQ parameters”部分。 - 点击 Download,模型将开始下载,下载完成后会显示“Done”。
- 在左上角,点击 Model 旁边的刷新图标。
- 在 Model 下拉菜单中,选择刚下载的模型:
llava-v1.5-13B-GPTQ
。 - 模型将自动加载,现在即可使用!
- 若需要自定义设置,设置完成后点击 Save settings for this model,然后在右上角点击 Reload the Model。注意,无需也不应再手动设置 GPTQ 参数,这些参数会从
quantize_config.json
文件中自动设置。 - 准备好后,点击 Text Generation tab 并输入提示词即可开始!
使用 Text Generation Inference (TGI) 服务此模型
推荐使用 TGI 版本 1.1.0 或更高版本,官方 Docker 容器为:ghcr.io/huggingface/text-generation-inference:1.1.0
。
示例 Docker 参数:
--model-id TheBloke/llava-v1.5-13B-GPTQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
示例 Python 代码与 TGI 交互(需要 huggingface-hub 0.17.0 或更高版本):
pip3 install huggingface-hub
from huggingface_hub import InferenceClient
endpoint_url = "https://your-endpoint-url-here"
prompt = "Tell me about 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"Model output: {response}")
从 Python 代码使用此 GPTQ 模型
安装必要的包
需要:Transformers 4.33.0 或更高版本,Optimum 1.12.0 或更高版本,以及 AutoGPTQ 0.4.2 或更高版本。
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/llava-v1.5-13B-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'''{prompt}
'''
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'])
✨ 主要特性
- 本仓库包含 Haotian Liu 的 Llava v1.5 13B 的 GPTQ 模型文件。
- 提供多种 GPTQ 参数排列,可根据硬件和需求选择最佳参数。
📦 安装指南
安装必要的 Python 库
- 若要从命令行下载模型,需安装
huggingface-hub
:
pip3 install huggingface-hub
- 若要使用 Python 代码与 TGI 交互,需安装
huggingface-hub
:
pip3 install huggingface-hub
- 若要从 Python 代码使用此 GPTQ 模型,需安装以下库:
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 .
下载模型
可参考“快速开始”部分的下载说明。
📚 详细文档
提供的文件和 GPTQ 参数
提供多种量化参数,以便根据硬件和需求选择最佳参数。每个单独的量化版本位于不同分支,以下是获取不同分支文件的说明。大多数 GPTQ 文件使用 AutoGPTQ 制作,Mistral 模型目前使用 Transformers 制作。
GPTQ 参数说明
- Bits:量化模型的位大小。
- GS:GPTQ 组大小。较高的数值使用较少的显存,但量化精度较低。“None”是最低可能值。
- Act Order:True 或 False。也称为
desc_act
。True 可获得更好的量化精度。一些 GPTQ 客户端在使用 Act Order 加 Group Size 的模型时遇到过问题,但现在一般已解决。 - Damp %:一个影响量化样本处理方式的 GPTQ 参数。默认值为 0.01,但 0.1 可获得稍高的精度。
- GPTQ 数据集:量化期间使用的校准数据集。使用更适合模型训练的数据集可以提高量化精度。请注意,GPTQ 校准数据集与训练模型使用的数据集不同,请参考原始模型仓库了解训练数据集的详细信息。
- 序列长度:量化时使用的数据集序列长度。理想情况下,此长度应与模型序列长度相同。对于一些非常长序列的模型(16K 以上),可能需要使用较低的序列长度。请注意,较低的序列长度不会限制量化模型的序列长度,它仅影响较长推理序列的量化精度。
- ExLlama 兼容性:此文件是否可以使用 ExLlama 加载,目前 ExLlama 仅支持 4 位的 Llama 模型。
分支 | Bits | GS | Act Order | Damp % | GPTQ 数据集 | Seq Len | 大小 | ExLlama | 描述 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | 是 | 0.1 | wikitext | 4096 | 7.26 GB | 是 | 4 位,使用 Act Order 和组大小 128g。比 64g 使用更少的显存,但精度稍低。 |
gptq-4bit-32g-actorder_True | 4 | 32 | 是 | 0.1 | wikitext | 4096 | 8.00 GB | 是 | 4 位,使用 Act Order 和组大小 32g。可获得最高的推理质量,但使用最大的显存。 |
gptq-8bit--1g-actorder_True | 8 | 无 | 是 | 0.1 | wikitext | 4096 | 9.96 GB | 否 | 8 位,使用 Act Order。无组大小,以降低显存需求。 |
gptq-8bit-128g-actorder_True | 8 | 128 | 是 | 0.1 | wikitext | 4096 | 9.93 GB | 否 | 8 位,使用组大小 128g 以获得更高的推理质量,并使用 Act Order 以获得更高的精度。 |
gptq-8bit-32g-actorder_True | 8 | 32 | 是 | 0.1 | wikitext | 4096 | 9.97 GB | 否 | 8 位,使用组大小 32g 和 Act Order 以获得最大的推理质量。 |
gptq-4bit-64g-actorder_True | 4 | 64 | 是 | 0.1 | wikitext | 4096 | 7.51 GB | 是 | 4 位,使用 Act Order 和组大小 64g。比 32g 使用更少的显存,但精度稍低。 |
提示词模板:llava 1.5
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: <image>{prompt}
ASSISTANT:
🔧 技术细节
模型信息
属性 | 详情 |
---|---|
模型类型 | llama |
模型创建者 | Haotian Liu |
基础模型 | liuhaotian/llava-v1.5-13b |
量化者 | TheBloke |
许可证 | llama2 |
提示词模板 | '{prompt} ' |
训练和量化相关
- 训练数据集:
- 558K 从 LAION/CC/SBU 过滤的图像 - 文本对,由 BLIP 加标题。
- 158K GPT 生成的多模态指令跟随数据。
- 450K 面向学术任务的 VQA 混合数据。
- 40K ShareGPT 数据。
- GPTQ 量化:
- 大多数 GPTQ 文件使用 AutoGPTQ 制作,Mistral 模型目前使用 Transformers 制作。
- 提供多种量化参数组合,不同分支对应不同的量化版本,可根据硬件和需求选择。
兼容性
- 提供的文件经测试可与 AutoGPTQ 配合使用,可通过 Transformers 或直接使用 AutoGPTQ。它们也应与 Occ4m's GPTQ-for-LLaMa 分支 兼容。
- ExLlama 与 4 位的 Llama 和 Mistral 模型兼容,具体文件兼容性可参考“Provided files, and GPTQ parameters”表。
- Huggingface Text Generation Inference (TGI) 与所有 GPTQ 模型兼容。
📄 许可证
Llama 2 遵循 LLAMA 2 社区许可证,版权所有 (c) Meta Platforms, Inc. 保留所有权利。
💬 社区与支持
Discord
如需进一步支持,以及讨论这些模型和人工智能相关话题,欢迎加入:TheBloke AI 的 Discord 服务器
感谢与贡献
感谢 chirper.ai 团队!感谢来自 gpus.llm-utils.org 的 Clay!
许多人询问是否可以提供贡献。我喜欢提供模型并帮助他人,也希望能够花更多时间做这些事情,以及拓展到新的项目,如微调/训练。
如果您有能力且愿意贡献,我将不胜感激,这将帮助我继续提供更多模型,并开展新的人工智能项目。
捐赠者将在任何与 AI/LLM/模型相关的问题和请求上获得优先支持,访问私人 Discord 房间,以及其他福利。
- Patreon: https://patreon.com/TheBlokeAI
- Ko-Fi: https://ko-fi.com/TheBlokeAI
特别感谢:Aemon Algiz。
Patreon 特别提及:Pierre Kircher, Stanislav Ovsiannikov, Michael Levine, Eugene Pentland, Andrey, 준교 김, Randy H, Fred von Graf, Artur Olbinski, Caitlyn Gatomon, terasurfer, Jeff Scroggin, James Bentley, Vadim, Gabriel Puliatti, Harry Royden McLaughlin, Sean Connelly, Dan Guido, Edmond Seymore, Alicia Loh, subjectnull, AzureBlack, Manuel Alberto Morcote, Thomas Belote, Lone Striker, Chris Smitley, Vitor Caleffi, Johann - Peter Hartmann, Clay Pascal, biorpg, Brandon Frisco, sidney chen, transmissions 11, Pedro Madruga, jinyuan sun, Ajan Kanaga, Emad Mostaque, Trenton Dambrowitz, Jonathan Leane, Iucharbius, usrbinkat, vamX, George Stoitzev, Luke Pendergrass, theTransient, Olakabola, Swaroop Kallakuri, Cap'n Zoog, Brandon Phillips, Michael Dempsey, Nikolai Manek, danny, Matthew Berman, Gabriel Tamborski, alfie_i, Raymond Fosdick, Tom X Nguyen, Raven Klaugh, LangChain4j, Magnesian, Illia Dulskyi, David Ziegler, Mano Prime, Luis Javier Navarrete Lozano, Erik Bjäreholt, 阿明, Nathan Dryer, Alex, Rainer Wilmers, zynix, TL, Joseph William Delisle, John Villwock, Nathan LeClaire, Willem Michiel, Joguhyik, GodLy, OG, Alps Aficionado, Jeffrey Morgan, ReadyPlayerEmma, Tiffany J. Kim, Sebastain Graf, Spencer Kim, Michael Davis, webtim, Talal Aujan, knownsqashed, John Detwiler, Imad Khwaja, Deo Leter, Jerry Meng, Elijah Stavena, Rooh Singh, Pieter, SuperWojo, Alexandros Triantafyllidis, Stephen Murray, Ai Maven, ya boyyy, Enrico Ros, Ken Nordquist, Deep Realms, Nicholas, Spiking Neurons AB, Elle, Will Dee, Jack West, RoA, Luke @flexchar, Viktor Bowallius, Derek Yates, Subspace Studios, jjj, Toran Billups, Asp the Wyvern, Fen Risland, Ilya, NimbleBox.ai, Chadd, Nitin Borwankar, Emre, Mandus, Leonard Tan, Kalila, K, Trailburnt, S_X, Cory Kujawski









