モデル概要
モデル特徴
モデル能力
使用事例
🚀 Llava v1.5 13B - GPTQ
このモデルは、Haotian Liu氏によって開発されたLlava v1.5 13BをGPTQ形式で提供しています。複数の量子化パラメータを用意しており、ハードウェアや要件に合わせて最適なものを選ぶことができます。

TheBlokeのLLM開発は、andreessen horowitz (a16z)からの助成金によって支援されています。
✨ 主な機能
- 複数のGPTQ量子化パラメータを提供し、ハードウェアと要件に合わせた最適な設定を選択できます。
- 異なるブランチによって、様々な量子化設定のモデルを取得できます。
- 複数の環境(text-generation-webui、コマンドライン、Pythonコードなど)での使用が可能です。
📦 インストール
text-generation-webuiでのダウンロード
main
ブランチからダウンロードするには、「Download model」ボックスにTheBloke/llava-v1.5-13B-GPTQ
を入力します。
別のブランチからダウンロードするには、ダウンロード名の末尾に:branchname
を追加します。例えば、TheBloke/llava-v1.5-13B-GPTQ:gptq-4bit-32g-actorder_True
です。
コマンドラインからのダウンロード
huggingface-hub
Pythonライブラリを使用することをおすすめします。
pip3 install huggingface-hub
main
ブランチをllava-v1.5-13B-GPTQ
というフォルダにダウンロードするには、以下のコマンドを実行します。
mkdir llava-v1.5-13B-GPTQ
huggingface-cli download TheBloke/llava-v1.5-13B-GPTQ --local-dir llava-v1.5-13B-GPTQ --local-dir-use-symlinks False
別のブランチからダウンロードするには、--revision
パラメータを追加します。
mkdir llava-v1.5-13B-GPTQ
huggingface-cli download TheBloke/llava-v1.5-13B-GPTQ --revision gptq-4bit-32g-actorder_True --local-dir llava-v1.5-13B-GPTQ --local-dir-use-symlinks False
git
を使用する場合(推奨しません)
特定のブランチをgit
でクローンするには、以下のようなコマンドを使用します。
git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/llava-v1.5-13B-GPTQ
ただし、HFリポジトリでgit
を使用することは強く推奨されません。huggingface-hub
を使用するよりもはるかに遅く、モデルファイルを2回保存する必要があるため、ディスク容量を2倍使ってしまいます。
💻 使用例
基本的な使用法
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/llava-v1.5-13B-GPTQ"
# To use a different branch, change revision
# For example: 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'''{prompt}
'''
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]))
# Inference can also be done using 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'])
高度な使用法
# 高度な使用法の説明
# 例えば、異なるブランチのモデルを使用する場合や、特定のパラメータを調整する場合など
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
model_name_or_path = "TheBloke/llava-v1.5-13B-GPTQ"
revision = "gptq-4bit-32g-actorder_True"
model = AutoModelForCausalLM.from_pretrained(model_name_or_path,
device_map="auto",
trust_remote_code=False,
revision=revision)
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
prompt = "Tell me about AI"
prompt_template=f'''{prompt}
'''
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]))
# Inference can also be done using 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'])
📚 ドキュメント
モデル情報
属性 | 详情 |
---|---|
モデルタイプ | llama |
モデル作成者 | Haotian Liu |
元のモデル | Llava v1.5 13B |
ライセンス | llama2 |
量子化担当者 | TheBloke |
プロンプトテンプレート
A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
USER: <image>{prompt}
ASSISTANT:
提供されるファイルとGPTQパラメータ
複数の量子化パラメータが提供されており、ハードウェアと要件に合わせて最適なものを選ぶことができます。 各量子化設定は異なるブランチに格納されています。異なるブランチからの取得方法については、以下を参照してください。 ほとんどのGPTQファイルはAutoGPTQで作成されています。Mistralモデルは現在、Transformersで作成されています。
GPTQパラメータの説明
- ビット数: 量子化モデルのビットサイズ。
- GS: GPTQグループサイズ。数値が大きいほどVRAMの使用量が少なくなりますが、量子化精度が低下します。「None」は最小値です。
- Act Order: TrueまたはFalse。
desc_act
とも呼ばれます。Trueの場合、より高い量子化精度が得られます。一部のGPTQクライアントでは、Act Orderとグループサイズを併用したモデルに問題がありましたが、現在はほとんど解決されています。 - Damp %: 量子化のためにサンプルを処理する方法に影響を与えるGPTQパラメータ。デフォルトは0.01ですが、0.1の方がわずかに精度が高くなります。
- GPTQデータセット: 量子化中に使用されるキャリブレーションデータセット。モデルの学習に適したデータセットを使用することで、量子化精度を向上させることができます。ただし、GPTQキャリブレーションデータセットはモデルの学習に使用されるデータセットとは異なります。学習データセットの詳細については、元のモデルリポジトリを参照してください。
- シーケンス長: 量子化に使用されるデータセットシーケンスの長さ。理想的には、モデルのシーケンス長と同じです。一部の非常に長いシーケンスモデル(16K以上)では、より短いシーケンス長を使用する必要がある場合があります。ただし、短いシーケンス長は量子化モデルのシーケンス長を制限するものではありません。長い推論シーケンスでの量子化精度にのみ影響します。
- ExLlama互換性: このファイルがExLlamaで読み込めるかどうか。現在、ExLlamaは4ビットのLlamaモデルのみをサポートしています。
ブランチ | ビット数 | GS | Act Order | Damp % | GPTQデータセット | シーケンス長 | サイズ | ExLlama | 説明 |
---|---|---|---|---|---|---|---|---|---|
main | 4 | 128 | Yes | 0.1 | wikitext | 4096 | 7.26 GB | Yes | 4ビット、Act Orderとグループサイズ128g。64gよりもVRAMの使用量が少なくなりますが、精度はわずかに低下します。 |
gptq-4bit-32g-actorder_True | 4 | 32 | Yes | 0.1 | wikitext | 4096 | 8.00 GB | Yes | 4ビット、Act Orderとグループサイズ32g。最大の推論品質を提供しますが、VRAMの使用量が最大になります。 |
gptq-8bit--1g-actorder_True | 8 | None | Yes | 0.1 | wikitext | 4096 | 9.96 GB | No | 8ビット、Act Order。グループサイズなしで、VRAMの使用量を抑えます。 |
gptq-8bit-128g-actorder_True | 8 | 128 | Yes | 0.1 | wikitext | 4096 | 9.93 GB | No | 8ビット、グループサイズ128gで推論品質を向上させ、Act Orderでさらに精度を高めます。 |
gptq-8bit-32g-actorder_True | 8 | 32 | Yes | 0.1 | wikitext | 4096 | 9.97 GB | No | 8ビット、グループサイズ32gとAct Orderで最大の推論品質を実現します。 |
gptq-4bit-64g-actorder_True | 4 | 64 | Yes | 0.1 | wikitext | 4096 | 7.51 GB | Yes | 4ビット、Act Orderとグループサイズ64g。32gよりもVRAMの使用量が少なくなりますが、精度はわずかに低下します。 |
text-generation-webuiでの使用方法
text-generation-webuiでこのモデルを簡単にダウンロードして使用する方法は、以下の通りです。 最新バージョンのtext-generation-webuiを使用していることを確認してください。 手動インストール方法を熟知していない限り、text-generation-webuiのワンクリックインストーラーを使用することを強くおすすめします。
- Modelタブをクリックします。
- Download custom model or LoRAの下に、
TheBloke/llava-v1.5-13B-GPTQ
を入力します。
- 特定のブランチからダウンロードするには、例えば
TheBloke/llava-v1.5-13B-GPTQ:gptq-4bit-32g-actorder_True
のように入力します。 - 各オプションのブランチのリストについては、上記の「提供されるファイルとGPTQパラメータ」を参照してください。
- Downloadをクリックします。
- モデルのダウンロードが開始されます。完了すると「Done」と表示されます。
- 左上のModelの横にあるリフレッシュアイコンをクリックします。
- Modelのドロップダウンメニューから、先ほどダウンロードしたモデル
llava-v1.5-13B-GPTQ
を選択します。 - モデルが自動的にロードされ、使用可能な状態になります。
- カスタム設定が必要な場合は、設定を行ってから右上の「Save settings for this model」をクリックし、続いて「Reload the Model」をクリックします。
- 手動でのGPTQパラメータの設定は不要であり、行わないでください。これらは
quantize_config.json
ファイルから自動的に設定されます。
- 準備ができたら、Text Generationタブをクリックし、プロンプトを入力して使用を開始します。
Text Generation Inference (TGI)からのモデルの提供
TGIバージョン1.1.0以上の使用をおすすめします。公式のDockerコンテナはghcr.io/huggingface/text-generation-inference:1.1.0
です。
例としてのDockerパラメータは、以下の通りです。
--model-id TheBloke/llava-v1.5-13B-GPTQ --port 3000 --quantize awq --max-input-length 3696 --max-total-tokens 4096 --max-batch-prefill-tokens 4096
TGIとのインターフェースを提供するPythonコードの例は、以下の通りです。(huggingface-hub 0.17.0以上が必要です)
pip3 install huggingface-hub
from huggingface_hub import InferenceClient
endpoint_url = "https://your-endpoint-url-here"
prompt = "Tell me about AI"
prompt_template=f'''{prompt}
'''
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 transformers optimum
pip3 install auto-gptq --extra-index-url https://huggingface.github.io/autogptq-index/whl/cu118/ # Use cu117 if on CUDA 11.7
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/llava-v1.5-13B-GPTQ"
# To use a different branch, change revision
# For example: 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'''{prompt}
'''
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]))
# Inference can also be done using 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'])
互換性
提供されるファイルは、Transformersを介したAutoGPTQと、AutoGPTQ直接を使用した場合の両方で動作することがテストされています。また、Occ4m's GPTQ-for-LLaMa forkでも動作するはずです。 ExLlamaは、Lla系のモデルに対応しています。
📄 ライセンス
このモデルは、llama2ライセンスの下で提供されています。詳細については、元のモデルリポジトリを参照してください。









