模型简介
模型特点
模型能力
使用案例
🚀 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 格式,为获得最佳模型性能,请使用以下格式:
<系统提示/角色卡片>
### 指令:
你的指令或问题。
对于角色扮演目的,建议如下 - 编写 <角色名称> 在 <你的名称> 和 <角色名称> 之间聊天中的下一个回复。仅编写单个回复。
### 回复:



