模型概述
模型特點
模型能力
使用案例
🚀 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 支持者。



