模型概述
模型特點
模型能力
使用案例
🚀 Saiga Mistral 7B - GPTQ
Saiga Mistral 7B - GPTQ 是經過量化處理的模型,提供了多種 GPTQ 參數組合,適用於不同硬件和需求。該模型可在多個推理服務器和 Web UI 中使用,方便用戶進行文本生成等任務。
🚀 快速開始
下載模型
在 text-generation-webui 中下載
請確保使用 text-generation-webui 的最新版本。強烈建議使用 text-generation-webui 的一鍵安裝程序,除非你確定知道如何手動安裝。
- 點擊 模型 選項卡。
- 在 下載自定義模型或 LoRA 下,輸入
TheBloke/saiga_mistral_7b-GPTQ
。- 若要從特定分支下載,例如輸入
TheBloke/saiga_mistral_7b-GPTQ:gptq-4bit-32g-actorder_True
。 - 請參考下面的 提供的文件和 GPTQ 參數 部分獲取各選項的分支列表。
- 若要從特定分支下載,例如輸入
- 點擊 下載。
- 模型將開始下載,完成後會顯示“已完成”。
- 在左上角,點擊 模型 旁邊的刷新圖標。
- 在 模型 下拉菜單中,選擇你剛剛下載的模型:
saiga_mistral_7b-GPTQ
。 - 模型將自動加載,現在可以使用了!
- 如果你需要自定義設置,設置完成後點擊右上角的 保存此模型的設置,然後點擊 重新加載模型。
- 注意,你不再需要也不應該手動設置 GPTQ 參數,這些參數會從
quantize_config.json
文件中自動設置。
- 注意,你不再需要也不應該手動設置 GPTQ 參數,這些參數會從
- 準備好後,點擊 文本生成 選項卡並輸入提示詞即可開始!
從命令行下載
建議使用 huggingface-hub
Python 庫:
pip3 install huggingface-hub
將 main
分支下載到名為 saiga_mistral_7b-GPTQ
的文件夾中:
mkdir saiga_mistral_7b-GPTQ
huggingface-cli download TheBloke/saiga_mistral_7b-GPTQ --local-dir saiga_mistral_7b-GPTQ --local-dir-use-symlinks False
若要從不同分支下載,添加 --revision
參數:
mkdir saiga_mistral_7b-GPTQ
huggingface-cli download TheBloke/saiga_mistral_7b-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir saiga_mistral_7b-GPTQ --local-dir-use-symlinks False
使用 git
下載(不推薦)
使用 git
克隆特定分支,可使用如下命令:
git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/saiga_mistral_7b-GPTQ
請注意,強烈不建議對 HF 倉庫使用 Git,它比使用 huggingface-hub
慢得多,並且會佔用兩倍的磁盤空間,因為它必須將模型文件存儲兩次(一次存儲在目標文件夾中,另一次作為 blob 存儲在 .git
文件夾中)。
使用模型
從 Text Generation Inference (TGI) 服務模型
建議使用 TGI 版本 1.1.0 或更高版本,官方 Docker 容器為:ghcr.io/huggingface/text-generation-inference:1.1.0
。
示例 Docker 參數:
--model-id TheBloke/saiga_mistral_7b-GPTQ --port 3000 --quantize gptq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
與 TGI 交互的示例 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'''<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>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}")
Python 代碼示例:從該 GPTQ 模型進行推理
安裝必要的包
需要:Transformers 4.33.0 或更高版本、Optimum 1.12.0 或更高版本以及 AutoGPTQ 0.4.2 或更高版本。
pip3 install --upgrade transformers optimum
# 如果使用 PyTorch 2.1 + CUDA 12.x:
pip3 install --upgrade auto-gptq
# 或者,如果使用 PyTorch 2.1 + CUDA 11.x:
pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
如果你使用的是 PyTorch 2.0,則需要從源代碼安裝 AutoGPTQ。同樣,如果你在使用預構建的輪子時遇到問題,也應該嘗試從源代碼構建:
pip3 uninstall -y auto-gptq
git clone https://github.com/PanQiWei/AutoGPTQ
cd AutoGPTQ
git checkout v0.5.1
pip3 install .
示例 Python 代碼
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/saiga_mistral_7b-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'''<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>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 參數組合,可根據硬件和需求選擇最佳參數。
- 支持在多個推理服務器和 Web UI 中使用,方便用戶進行文本生成任務。
- 經過量化處理,可減少顯存使用。
📦 安裝指南
安裝依賴庫
pip3 install huggingface-hub
pip3 install --upgrade transformers optimum
# 如果使用 PyTorch 2.1 + CUDA 12.x:
pip3 install --upgrade auto-gptq
# 或者,如果使用 PyTorch 2.1 + CUDA 11.x:
pip3 install --upgrade auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/
若使用 PyTorch 2.0 或預構建輪子有問題,從源代碼安裝 AutoGPTQ:
pip3 uninstall -y auto-gptq
git clone https://github.com/PanQiWei/AutoGPTQ
cd AutoGPTQ
git checkout v0.5.1
pip3 install .
📚 詳細文檔
模型信息
屬性 | 詳情 |
---|---|
模型創建者 | Ilya Gusev |
原始模型 | Saiga Mistral 7B |
模型類型 | mistral |
量化者 | TheBloke |
可用的倉庫
- 用於 GPU 推理的 AWQ 模型
- 用於 GPU 推理的 GPTQ 模型,有多種量化參數選項
- 用於 CPU+GPU 推理的 2、3、4、5、6 和 8 位 GGUF 模型
- Ilya Gusev 原始的未量化 fp16 模型(pytorch 格式),用於 GPU 推理和進一步轉換
提示詞模板:ChatML
<|im_start|>system
{system_message}<|im_end|>
<|im_start|>user
{prompt}<|im_end|>
<|im_start|>assistant
已知兼容的客戶端/服務器
這些 GPTQ 模型已知可在以下推理服務器/Web UI 中工作:
這可能不是完整列表,如果你知道其他兼容的客戶端/服務器,請告知!
提供的文件和 GPTQ 參數
提供了多種量化參數,以便你根據硬件和需求選擇最佳參數。 每個單獨的量化版本位於不同的分支中,有關從不同分支獲取文件的說明,請參見下文。 大多數 GPTQ 文件使用 AutoGPTQ 製作,Mistral 模型目前使用 Transformers 製作。
GPTQ 參數說明
- 位:量化模型的位大小。
- GS:GPTQ 組大小。較高的數字使用較少的顯存,但量化精度較低。“None” 是最低可能值。
- Act Order:真或假。也稱為
desc_act
。真會導致更好的量化精度。一些 GPTQ 客戶端在使用 Act Order 加組大小的模型時遇到過問題,但現在這個問題通常已解決。 - Damp %:一個影響量化樣本處理方式的 GPTQ 參數。默認值為 0.01,但 0.1 會導致稍高的精度。
- GPTQ 數據集:量化期間使用的校準數據集。使用更適合模型訓練的數據集可以提高量化精度。請注意,GPTQ 校準數據集與用於訓練模型的數據集不同 - 請參考原始模型倉庫獲取訓練數據集的詳細信息。
- 序列長度:量化時使用的數據集序列長度。理想情況下,這與模型序列長度相同。對於一些非常長序列的模型(16K+),可能需要使用較低的序列長度。請注意,較低的序列長度不會限制量化模型的序列長度,它僅影響較長推理序列的量化精度。
- ExLlama 兼容性:該文件是否可以使用 ExLlama 加載,目前 ExLlama 僅支持 4 位的 Llama 和 Mistral 模型。
分支 | 位 | GS | Act Order | Damp % | GPTQ 數據集 | 序列長度 | 大小 | ExLlama | 描述 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | 是 | 0.1 | Russian Instructions 2 | 4096 | 4.16 GB | 是 | 4 位,帶有 Act Order 和組大小 128g。比 64g 使用更少的顯存,但精度稍低。 |
gptq-4bit-32g-actorder_True | 4 | 32 | 是 | 0.1 | Russian Instructions 2 | 4096 | 4.57 GB | 是 | 4 位,帶有 Act Order 和組大小 32g。提供最高的推理質量,但顯存使用量最大。 |
gptq-8bit--1g-actorder_True | 8 | 無 | 是 | 0.1 | Russian Instructions 2 | 4096 | 7.52 GB | 否 | 8 位,帶有 Act Order。無組大小,以降低顯存需求。 |
gptq-8bit-128g-actorder_True | 8 | 128 | 是 | 0.1 | Russian Instructions 2 | 4096 | 7.68 GB | 否 | 8 位,組大小 128g 以提高推理質量,帶有 Act Order 以獲得更高的精度。 |
gptq-8bit-32g-actorder_True | 8 | 32 | 是 | 0.1 | Russian Instructions 2 | 4096 | 8.17 GB | 否 | 8 位,組大小 32g 和 Act Order 以獲得最大的推理質量。 |
gptq-4bit-64g-actorder_True | 4 | 64 | 是 | 0.1 | Russian Instructions 2 | 4096 | 4.30 GB | 是 | 4 位,帶有 Act Order 和組大小 64g。比 32g 使用更少的顯存,但精度稍低。 |
兼容性
提供的文件經測試可與 Transformers 一起使用。對於非 Mistral 模型,也可以直接使用 AutoGPTQ。 ExLlama 與 4 位的 Llama 和 Mistral 模型兼容。請參閱上面的 提供的文件 表瞭解每個文件的兼容性。
🔧 技術細節
這些文件使用 Massed Compute 慷慨提供的硬件進行量化。
📄 許可證
文檔中未提及相關許可證信息。
Discord
如需進一步支持,以及討論這些模型和人工智能相關內容,請加入: TheBloke AI 的 Discord 服務器
感謝與貢獻方式
感謝 chirper.ai 團隊! 感謝 gpus.llm-utils.org 的 Clay!
很多人詢問是否可以進行貢獻。我喜歡提供模型並幫助他人,也希望能夠花更多時間做這些事情,同時開展新的項目,如微調/訓練。
如果你有能力且願意貢獻,我將非常感激,這將幫助我繼續提供更多模型,並開展新的人工智能項目。
捐贈者將在任何與人工智能/大語言模型/模型相關的問題和請求上獲得優先支持,還可訪問私人 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, Ken Nordquist, 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 的慷慨資助。



