模型概述
模型特點
模型能力
使用案例
🚀 MythoMax L2 13B - GPTQ
MythoMax L2 13B - GPTQ 是基於 Gryphe 的 MythoMax L2 13B 模型進行 GPTQ 量化的版本。它提供了多種量化參數選項,以滿足不同硬件和需求。用戶可以通過多種方式下載和使用該模型,同時在使用過程中需要注意許可證相關問題。
🚀 快速開始
從 text-generation-webui 下載和使用
- 確保使用的是 text-generation-webui 的最新版本。建議使用一鍵安裝程序,除非你確定自己知道如何手動安裝。
- 點擊 Model tab。
- 在 Download custom model or LoRA 下,輸入
TheBloke/MythoMax-L2-13B-GPTQ
。若要從特定分支下載,可輸入如TheBloke/MythoMax-L2-13B-GPTQ:main
(各選項的分支列表見“Provided Files”)。 - 點擊 Download,模型開始下載,完成後顯示“Done”。
- 在左上角,點擊 Model 旁邊的刷新圖標。
- 在 Model 下拉菜單中,選擇剛下載的模型:
MythoMax-L2-13B-GPTQ
。 - 模型將自動加載,即可開始使用。
- 若需要自定義設置,設置完成後點擊右上角的 Save settings for this model ,然後點擊 Reload the Model。注意,無需再手動設置 GPTQ 參數,這些參數會從
quantize_config.json
文件中自動設置。 - 準備好後,點擊 Text Generation tab 並輸入提示詞開始使用!
從 Python 代碼使用
安裝必要的包
需要 Transformers 4.32.0 或更高版本、Optimum 1.12.0 或更高版本,以及 AutoGPTQ 0.4.2 或更高版本。
pip3 install transformers>=4.32.0 optimum>=1.12.0
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
pip3 install .
對於 CodeLlama 模型
必須使用 Transformers 4.33.0 或更高版本。若閱讀本文時 4.33.0 尚未發佈,需從源代碼安裝 Transformers:
pip3 uninstall -y transformers
pip3 install git+https://github.com/huggingface/transformers.git
使用代碼示例
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/MythoMax-L2-13B-GPTQ"
# 若使用不同分支,更改 revision
# 例如:revision="main"
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'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{prompt}
### Response:
'''
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'])
✨ 主要特性
- 提供多種量化參數選項,可根據硬件和需求選擇最佳參數。
- 支持從不同分支下載不同量化版本的模型。
- 與多種工具和框架兼容,如 AutoGPTQ、text-generation-webui 等。
📦 安裝指南
從 text-generation-webui 安裝
按照上述“從 text-generation-webui 下載和使用”的步驟進行操作。
從 Python 代碼安裝
按照上述“從 Python 代碼使用”中安裝必要包的步驟進行操作。
💻 使用示例
基礎用法
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/MythoMax-L2-13B-GPTQ"
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'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{prompt}
### Response:
'''
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]))
高級用法
# 使用 pipeline 進行推理
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/MythoMax-L2-13B-GPTQ"
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'''Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{prompt}
### Response:
'''
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'])
📚 詳細文檔
模型信息
- 模型創建者:Gryphe
- 原始模型:MythoMax L2 13B
可用倉庫
- 用於 GPU 推理的 AWQ 模型
- 用於 GPU 推理的 GPTQ 模型,有多種量化參數選項
- 用於 CPU+GPU 推理的 2、3、4、5、6 和 8 位 GGUF 模型
- Gryphe 原始未量化的 fp16 格式 PyTorch 模型,用於 GPU 推理和進一步轉換
提示詞模板
{system_message}
### Instruction:
{prompt}
(For roleplay purposes, I suggest the following - Write <CHAR NAME>'s next reply in a chat between <YOUR NAME> and <CHAR NAME>. Write a single reply only.)
### Response:
提供的文件和 GPTQ 參數
提供多種量化參數,可根據硬件和需求選擇最佳參數。每個單獨的量化版本在不同的分支中。所有近期的 GPTQ 文件使用 AutoGPTQ 製作,非主分支的所有文件使用 AutoGPTQ 製作,main
分支中 2023 年 8 月之前上傳的文件使用 GPTQ-for-LLaMa 製作。
分支 | 比特數 | GS | Act Order | Damp % | GPTQ 數據集 | 序列長度 | 大小 | ExLlama 兼容性 | 描述 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | 否 | 0.1 | wikitext | 4096 | 7.26 GB | 是 | 4 位,無 Act Order,組大小 128g。 |
gptq-4bit-32g-actorder_True | 4 | 32 | 是 | 0.1 | wikitext | 4096 | 8.00 GB | 是 | 4 位,有 Act Order,組大小 32g。可提供最高的推理質量,但 VRAM 使用量最大。 |
gptq-4bit-64g-actorder_True | 4 | 64 | 是 | 0.1 | wikitext | 4096 | 7.51 GB | 是 | 4 位,有 Act Order,組大小 64g。比 32g 使用更少的 VRAM,但精度略低。 |
gptq-4bit-128g-actorder_True | 4 | 128 | 是 | 0.1 | wikitext | 4096 | 7.26 GB | 是 | 4 位,有 Act Order,組大小 128g。比 64g 使用更少的 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 以提高精度。 |
從分支下載的方法
- 在 text-generation-webui 中,可在下載名稱後添加
:branch
,如TheBloke/MythoMax-L2-13B-GPTQ:main
。 - 使用 Git 時,可使用以下命令克隆分支:
git clone --single-branch --branch main https://huggingface.co/TheBloke/MythoMax-L2-13B-GPTQ
- 在 Python Transformers 代碼中,分支作為
revision
參數,見上述 Python 代碼示例。
兼容性
提供的文件經測試可與 AutoGPTQ 兼容,可通過 Transformers 或直接使用 AutoGPTQ。也應與 Occ4m's GPTQ-for-LLaMa 分支 兼容。ExLlama 與 4 位的 Llama 模型兼容,各文件的兼容性見“Provided Files”表。Huggingface Text Generation Inference (TGI) 與所有 GPTQ 模型兼容。
🔧 技術細節
該模型是基於 Gryphe 的 MythoMax L2 13B 模型進行 GPTQ 量化的版本。GPTQ 量化是一種將模型參數量化以減少內存使用和提高推理速度的技術。提供多種量化參數選項,可根據硬件和需求選擇最佳參數。
📄 許可證
源模型的創建者將其許可證列為 other
,因此此量化版本使用相同的許可證。由於該模型基於 Llama 2,它也受 Meta Llama 2 許可證條款的約束,並且額外包含了該許可證文件。因此,應認為該模型聲稱同時受這兩種許可證的約束。已聯繫 Hugging Face 以澄清雙重許可問題,但他們尚未有官方立場。若情況發生變化,或 Meta 對此情況提供任何反饋,將相應更新此部分內容。
在此期間,有關許可證的任何問題,特別是這兩種許可證如何相互作用的問題,應諮詢原始模型倉庫:Gryphe's MythoMax L2 13B。
原始模型卡片:Gryphe's MythoMax L2 13B
模型概述
MythoMax L2 13B 是 MythoMix 的改進版,可能是其完美變體。它是 MythoLogic-L2 和 Huginn 使用高度實驗性的張量類型合併技術合併而成。與 MythoMix 的主要區別在於,允許更多的 Huginn 與位於模型前端和後端的單個張量混合,從而提高了整個結構的連貫性。
模型細節
該合併的思路是,每個層由多個張量組成,這些張量分別負責特定的功能。以 MythoLogic-L2 的強大理解能力作為輸入,Huginn 的廣泛寫作能力作為輸出,似乎產生了一個在這兩方面都表現出色的模型,證實了這一理論(更多細節將在稍後發佈)。
這種合併方式無法直觀展示,因為其 363 個張量中的每個都應用了獨特的比例。與之前的合併一樣,梯度是這些比例的一部分,以進一步微調其行為。
提示詞格式
該模型主要使用 Alpaca 格式,為獲得最佳模型性能,請使用以下格式:
<系統提示/角色卡片>
### 指令:
你的指令或問題。
對於角色扮演目的,建議如下 - 編寫 <角色名稱> 在 <你的名稱> 和 <角色名稱> 之間聊天中的下一個回覆。僅編寫單個回覆。
### 回覆:



