🚀 Mistral-7B-Instruct-v0.2 モデル
このモデルは、自然言語処理におけるテキスト生成タスクに特化しており、Wanda 剪定手法を用いて 30% の疎度まで剪定されています。この手法では再学習や重みの更新を必要とせず、依然として競争力のある性能を達成します。ベースモデルへのリンクはこちらから確認できます。
🚀 クイックスタート
このモデルは、自然言語処理におけるテキスト生成タスクに特化した大規模言語モデルです。以下に、基本的な使用方法を説明します。
✨ 主な機能
- Wanda 剪定手法を用いて 30% の疎度まで剪定されている。
- 再学習や重みの更新を必要とせず、競争力のある性能を達成する。
- 指示に基づいた微調整が行われており、特定のタスクに対する性能が向上している。
📚 ドキュメント
モデル概要
Mistral-7B-Instruct-v0.2 大規模言語モデル (LLM) は、Mistral-7B-Instruct-v0.1 の指示に基づいた微調整版です。このモデルの詳細については、論文とリリースブログ記事をご覧ください。
指示フォーマット
指示に基づいた微調整を利用するためには、プロンプトを [INST]
と [/INST]
トークンで囲む必要があります。最初の指示は文頭識別子で始める必要があり、次の指示はその必要はありません。アシスタントの生成は文末識別子で終了します。
例:
text = "<s>[INST] What is your favourite condiment? [/INST]"
"Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
"[INST] Do you have mayonnaise recipes? [/INST]"
このフォーマットは、apply_chat_template()
メソッドを介してチャットテンプレートとして利用できます。
from transformers import AutoModelForCausalLM, AutoTokenizer
device = "cuda"
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
messages = [
{"role": "user", "content": "What is your favourite condiment?"},
{"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
{"role": "user", "content": "Do you have mayonnaise recipes?"}
]
encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
model_inputs = encodeds.to(device)
model.to(device)
generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
decoded = tokenizer.batch_decode(generated_ids)
print(decoded[0])
モデルアーキテクチャ
この指示モデルは、Mistral-7B-v0.1 をベースにしており、以下のアーキテクチャが選択されています。
- Grouped-Query Attention
- Sliding-Window Attention
- Byte-fallback BPE tokenizer
トラブルシューティング
以下のエラーが表示された場合:
Traceback (most recent call last):
File "", line 1, in
File "/transformers/models/auto/auto_factory.py", line 482, in from_pretrained
config, kwargs = AutoConfig.from_pretrained(
File "/transformers/models/auto/configuration_auto.py", line 1022, in from_pretrained
config_class = CONFIG_MAPPING[config_dict["model_type"]]
File "/transformers/models/auto/configuration_auto.py", line 723, in getitem
raise KeyError(key)
KeyError: 'mistral'
ソースから transformers をインストールすることで問題が解決するはずです。
pip install git+https://github.com/huggingface/transformers
これは transformers-v4.33.4 以降では必要ないはずです。
制限事項
Mistral 7B Instruct モデルは、ベースモデルを簡単に微調整して魅力的な性能を達成できることを迅速に実証するためのものです。このモデルにはモデレーション機構がありません。私たちは、モデルがガードレールをきめ細かく尊重し、モデレーションされた出力を必要とする環境でのデプロイを可能にする方法について、コミュニティと協力することを期待しています。
開発チーム
Albert Jiang, Alexandre Sablayrolles, Arthur Mensch, Blanche Savary, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Emma Bou Hanna, Florian Bressand, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Lélio Renard Lavaud, Louis Ternon, Lucile Saulnier, Marie - Anne Lachaux, Pierre Stock, Teven Le Scao, Théophile Gervet, Thibaut Lavril, Thomas Wang, Timothée Lacroix, William El Sayed.
📄 ライセンス
このモデルは Apache-2.0 ライセンスの下で提供されています。