🚀 Mistral-7B-Instruct-v0.2の概要
このモデルは、Wanda pruning methodを使用して2%の疎度に剪定されています。この方法では再トレーニングや重みの更新を必要とせず、依然として競争力のある性能を達成します。ベースモデルへのリンクはこちらです。
🚀 クイックスタート
Mistral-7B-Instruct-v0.2 Large Language Model (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モデルは、ベースモデルを簡単にファインチューニングして魅力的な性能を達成できることをすばやく実証するものです。
このモデルにはモデレーションメカニズムがありません。モデルがガードレールをきめ細かく尊重し、モデレートされた出力が必要な環境でのデプロイを可能にする方法について、コミュニティと協力することを楽しみにしています。
Mistral AIチーム
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ライセンスの下で提供されています。