模型简介
模型特点
模型能力
使用案例
🚀 OpenChat 3.5 7B - GPTQ
OpenChat 3.5 7B - GPTQ 是 OpenChat 3.5 模型的量化版本,提供多种量化参数选项,适用于不同硬件和需求。用户可根据自身情况选择合适的参数,在多种推理服务器和 Web UI 中使用该模型。
🚀 快速开始
下载模型
- 在 text-generation-webui 中下载:在“Download model”框中输入
TheBloke/openchat_3.5-GPTQ
可下载main
分支;若要下载其他分支,在下载名称后添加:branchname
,如TheBloke/openchat_3.5-GPTQ:gptq-4bit-32g-actorder_True
。 - 从命令行下载:推荐使用
huggingface-hub
Python 库。- 安装库:
pip3 install huggingface-hub
- 下载 `main` 分支到 `openchat_3.5-GPTQ` 文件夹:
mkdir openchat_3.5-GPTQ
huggingface-cli download TheBloke/openchat_3.5-GPTQ --local-dir openchat_3.5-GPTQ --local-dir-use-symlinks False
- 下载其他分支,添加 `--revision` 参数:
mkdir openchat_3.5-GPTQ
huggingface-cli download TheBloke/openchat_3.5-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir openchat_3.5-GPTQ --local-dir-use-symlinks False
- 使用
git
下载(不推荐):使用以下命令克隆特定分支:
git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/openchat_3.5-GPTQ
在 text-generation-webui 中使用模型
- 确保使用的是 text-generation-webui 的最新版本。
- 点击 Model tab。
- 在 Download custom model or LoRA 中输入
TheBloke/openchat_3.5-GPTQ
;若要下载特定分支,可输入如TheBloke/openchat_3.5-GPTQ:gptq-4bit-32g-actorder_True
。 - 点击 Download,模型开始下载,完成后显示 "Done"。
- 在左上角点击 Model 旁边的刷新图标。
- 在 Model 下拉菜单中选择刚下载的模型
openchat_3.5-GPTQ
,模型将自动加载。 - 若需要自定义设置,设置后点击 Save settings for this model,再点击右上角的 Reload the Model。
- 准备好后,点击 Text Generation 标签,输入提示词开始使用。
✨ 主要特性
- 多版本选择:提供多种 GPTQ 量化参数的版本,可根据硬件和需求选择最佳版本。
- 广泛兼容:已知可在多个推理服务器和 Web UI 中使用,如 text-generation-webui、KoboldAI United 等。
- 高效推理:部分版本使用 AutoGPTQ 或 Transformers 制作,能在不同硬件上实现高效推理。
📦 安装指南
安装必要的包
使用该 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/openchat_3.5-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'''GPT4 User: {prompt}<|end_of_turn|>GPT4 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'])
高级用法
使用 Text Generation Inference (TGI) 服务该模型,推荐使用 TGI 版本 1.1.0 或更高版本,官方 Docker 容器为 ghcr.io/huggingface/text-generation-inference:1.1.0
。
--model-id TheBloke/openchat_3.5-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
Python 代码示例(需要 huggingface-hub 0.17.0 或更高版本):
from huggingface_hub import InferenceClient
endpoint_url = "https://your-endpoint-url-here"
prompt = "Tell me about AI"
prompt_template=f'''GPT4 User: {prompt}<|end_of_turn|>GPT4 Assistant:
'''
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}")
📚 详细文档
模型信息
属性 | 详情 |
---|---|
模型创建者 | OpenChat |
原始模型 | OpenChat 3.5 7B |
模型类型 | mistral |
量化者 | TheBloke |
许可证 | apache-2.0 |
可用仓库
- AWQ 模型(用于 GPU 推理)
- GPTQ 模型(用于 GPU 推理,有多种量化参数选项)
- 2、3、4、5、6 和 8 位 GGUF 模型(用于 CPU+GPU 推理)
- OpenChat 原始未量化的 fp16 模型(pytorch 格式,用于 GPU 推理和进一步转换)
提示模板
GPT4 User: {prompt}<|end_of_turn|>GPT4 Assistant:
已知兼容的客户端/服务器
提供的文件和 GPTQ 参数
提供多种量化参数,可根据硬件和需求选择。每个单独的量化版本在不同分支中,以下是各分支的信息:
分支 | 位宽 | 分组大小 | Act Order | 阻尼百分比 | GPTQ 数据集 | 序列长度 | 大小 | ExLlama 兼容性 | 描述 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | 是 | 0.1 | wikitext | 4096 | 4.16 GB | 是 | 4 位,使用 Act Order 和分组大小 128g,比 64g 更节省 VRAM,但精度略低。 |
gptq-4bit-32g-actorder_True | 4 | 32 | 是 | 0.1 | wikitext | 4096 | 4.57 GB | 是 | 4 位,使用 Act Order 和分组大小 32g,推理质量最高,但 VRAM 使用最多。 |
gptq-8bit--1g-actorder_True | 8 | 无 | 是 | 0.1 | wikitext | 4096 | 4.95 GB | 否 | 8 位,使用 Act Order,无分组大小,降低 VRAM 需求。 |
gptq-8bit-128g-actorder_True | 8 | 128 | 是 | 0.1 | wikitext | 4096 | 5.00 GB | 否 | 8 位,分组大小 128g 以提高推理质量,使用 Act Order 进一步提高精度。 |
gptq-8bit-32g-actorder_True | 8 | 32 | 是 | 0.1 | wikitext | 4096 | 4.97 GB | 否 | 8 位,分组大小 32g 和 Act Order 以实现最大推理质量。 |
gptq-4bit-64g-actorder_True | 4 | 64 | 是 | 0.1 | wikitext | 4096 | 4.30 GB | 是 | 4 位,使用 Act Order 和分组大小 64g,比 32g 节省 VRAM,但精度略低。 |
🔧 技术细节
GPTQ 参数解释
- 位宽:量化模型的位大小。
- GS(分组大小):GPTQ 分组大小,较高的数值使用较少的 VRAM,但量化精度较低,“None” 是最低可能值。
- Act Order:真或假,也称为
desc_act
,为真时量化精度更高。部分 GPTQ 客户端在使用 Act Order 加分组大小时可能有问题,但现在一般已解决。 - 阻尼百分比:影响量化样本处理的 GPTQ 参数,默认值为 0.01,0.1 可获得略高的精度。
- GPTQ 数据集:量化期间使用的校准数据集,使用更适合模型训练的数据集可提高量化精度。注意,GPTQ 校准数据集与训练模型使用的数据集不同,训练数据集详情请参考原始模型仓库。
- 序列长度:量化期间使用的数据集序列长度,理想情况下应与模型序列长度相同。对于一些非常长序列的模型(16K 以上),可能需要使用较低的序列长度。较低的序列长度不会限制量化模型的序列长度,仅影响较长推理序列的量化精度。
- ExLlama 兼容性:该文件是否可使用 ExLlama 加载,目前 ExLlama 仅支持 4 位的 Llama 和 Mistral 模型。
📄 许可证
本项目的 OpenChat 3.5 代码和模型根据 Apache 许可证 2.0 分发。
其他信息
基准测试
模型 | 参数数量 | 平均得分 | MT-Bench | AGIEval | BBH MC | TruthfulQA | MMLU | HumanEval | BBH CoT | GSM8K |
---|---|---|---|---|---|---|---|---|---|---|
OpenChat-3.5 | 7B | 61.6 | 7.81 | 47.4 | 47.6 | 59.1 | 64.3 | 55.5 | 63.5 | 77.3 |
ChatGPT (March)* | ? | 61.5 | 7.94 | 47.1 | 47.6 | 57.7 | 67.3 | 48.1 | 70.1 | 74.9 |
Mistral | 7B | - | 6.84 | 38.0 | 39.0 | - | 60.1 | 30.5 | - | 52.2 |
开源 SOTA** | 13B - 70B | 61.4 | 7.71 | 41.7 | 49.7 | 62.3 | 63.7 | 73.2 | 41.4 | 82.3 |
WizardLM 70B | Orca 13B | Orca 13B | Platypus2 70B | WizardLM 70B | WizardCoder 34B | Flan-T5 11B | MetaMath 70B |
注:
- *ChatGPT (March) 的结果来自 GPT-4 Technical Report、Chain-of-Thought Hub 和本项目评估。请注意,ChatGPT 不是固定的基准,会随时间快速发展。
- **开源 SOTA 结果来自指令微调模型论文和官方仓库的报告结果。
- ***所有零样本基准测试遵循与 AGIEval 论文和 Orca 论文相同的设置。CoT 任务使用与 Chain-of-Thought Hub 相同的配置,HumanEval 使用 EvalPlus 评估,MT-bench 使用 FastChat 运行。若要复现结果,请遵循 本仓库 中的说明。
局限性
- 基础模型局限性:尽管 OpenChat 具有先进的能力,但仍受其基础模型固有局限性的约束,可能影响模型在复杂推理、数学和算术任务、编程和编码挑战等方面的性能。
- 生成不存在信息:OpenChat 有时可能生成不存在或不准确的信息,即“幻觉”现象。用户应注意这一可能性,并验证从模型获取的任何关键信息。
- 安全性:OpenChat 有时可能生成有害、仇恨言论、有偏见的回复,或回答不安全的问题。在需要安全和经过审核回复的用例中,必须应用额外的 AI 安全措施。
引用
@article{wang2023openchat,
title={OpenChat: Advancing Open-source Language Models with Mixed-Quality Data},
author={Wang, Guan and Cheng, Sijie and Zhan, Xianyuan and Li, Xiangang and Song, Sen and Liu, Yang},
journal={arXiv preprint arXiv:2309.11235},
year={2023}
}
致谢
感谢 Alignment Lab AI、Nous Research 和 Pygmalion AI 在数据收集和模型训练方面的重大贡献。特别感谢 GPT Desk Pte. Ltd. 的 Changling Liu、清华大学的 Qiying Yu、01.AI 公司的 Baochang Ma 和 Hao Wan 提供的资源,以及清华大学的 Jianxiong Li 和 Peng Li 的深入讨论。此外,感谢以下项目的开发者对本研究的重大贡献:Mistral、Chain-of-Thought Hub、Llama 2、Self-Instruct、FastChat (Vicuna)、Alpaca 和 StarCoder。
Discord
如需进一步支持,或讨论这些模型和人工智能相关话题,欢迎加入 TheBloke AI 的 Discord 服务器。
贡献与支持
若您愿意提供支持和贡献,将不胜感激。捐赠者将在所有 AI/LLM/模型问题和请求上获得优先支持,访问私人 Discord 房间,以及其他福利。
- Patreon: https://patreon.com/TheBlokeAI
- Ko-Fi: https://ko-fi.com/TheBlokeAI
特别感谢 Aemon Algiz 以及众多 Patreon 支持者。



