🚀 Vikhr-Nemo-12B-Instruct-R-21-09-24
Vikhr-Nemoは、VikhrModelsチームによって開発された、mistralai/Mistral-Nemo-Instruct-2407をベースにした、主にロシア語と英語に最適化された大規模言語モデル(LLM)です。このモデルは、推論、要約、コード生成、ロールプレイ、対話の維持など、様々な用途に最適化されています。また、多言語生成機能と高性能なRAG(Retrieval Augmented Generation)機能を備えており、独自のインストラクションベンチマークとRAGベンチマークで、他のモデルに比べて優れた評価を獲得しています。
学習に使用したすべてのコードは、GitHubのeffective_llm_alignmentリポジトリに公開されており、主なデータセットはHFのプロファイルで入手できます。
✨ 主な機能
- Grandmaster-PRO-MAXデータセットとベースモデルのおかげで、ロシア語、英語、その他のいくつかの言語で高品質な生成が可能です。
- システムプロンプトをサポートしており、回答のスタイルを調整できます。
- ベースモデルのおかげで、最大128kトークンのコンテキストをサポートしています。
- Grounded RAGモードをサポートしており、ユーザーの質問に関連するドキュメントの識別子を検索し、それを使用して回答を生成できます。この機能は、Command-Rモデルにインスパイアされています。
📊 メトリクスと品質評価
Ru-Arena-Generalでの結果
モデル名 |
勝率 |
95%信頼区間 |
平均トークン数 |
gpt-4-1106-preview |
90.9 |
(-1.3, 1.0) |
541 |
gpt-4o-mini |
83.9 |
(-1.8, 1.1) |
448 |
vikhr-nemo-12b-instruct-r-21-09-24(180 leaked) |
79.8 |
(-2.2, 1.9) |
627 |
gemma-2-9b-it-sppo-iter3 |
73.6 |
(-1.6, 2.2) |
509 |
gemma-2-9b-it |
69.2 |
(-2.5, 1.9) |
459 |
t-lite-instruct-0.1 |
64.7 |
(-2.1, 1.7) |
810 |
vikhr-llama3.1-8b-instruct-r-21-09-24 |
63.4 |
(-2.1, 2.5) |
618 |
suzume-llama-3-8B-multilingual-orpo-borda-half |
57.1 |
(-1.9, 2.2) |
682 |
mistral-nemo-instruct-2407 |
50.5 |
(-2.7, 2.6) |
403 |
gpt-3.5-turbo-0125 |
50.0 |
(0.0, 0.0) |
220 |
c4ai-command-r-v01 |
49.0 |
(-1.7, 2.2) |
529 |
meta-llama-3.1-8b-instruct |
43.1 |
(-2.8, 2.3) |
628 |
RAGベンチマークでの結果
質問タイプ |
gpt-4o (正解率) |
gpt-4o (平均回答一致率ROUGE-L) |
gpt-4o (平均絶対インデックス差) |
Vikhr-Nemo-12B-Instruct-R-21-09-24 (正解率) |
Vikhr-Nemo-12B-Instruct-R-21-09-24 (平均回答一致率ROUGE-L) |
Vikhr-Nemo-12B-Instruct-R-21-09-24 (平均絶対インデックス差) |
gpt-4o-mini (正解率) |
gpt-4o-mini (平均回答一致率ROUGE-L) |
gpt-4o-mini (平均絶対インデックス差) |
gpt-3.5-turbo-0125 (正解率) |
gpt-3.5-turbo-0125 (平均回答一致率ROUGE-L) |
gpt-3.5-turbo-0125 (平均絶対インデックス差) |
in_domain |
73% |
0.34 |
NaN |
68% |
0.41 |
0 |
65% |
0.33 |
NaN |
49% |
0.28 |
NaN |
out_of_domain |
81% |
0.20 |
NaN |
92% |
0.52 |
0 |
73% |
0.18 |
NaN |
76% |
0.20 |
NaN |
📚 このモデルの作成方法
インストラクティブなSFT部分
SFT段階の学習には、大規模な(150kのインストラクション)インストラクティブな合成データセットVikhrmodels/GrandMaster-PRO-MAXを使用しました。このデータセットの特徴は、組み込まれたCoT(Chain-Of-Thought)であり、これを収集するために、gpt-4-turbo用の修正されたプロンプトを使用しました。詳細はデータセットのカードを参照してください。
また、RAG Groundingを行うために、別の合成データセットVikhrmodels/Grounded-RAG-RU-v2(50kの対話)を用意しました。このデータセットの収集パイプラインは複雑であり、詳細はデータセットのカードを参照してください。
SMPOによるアライメント段階
回答品質をさらに向上させるために、以下のパイプラインを使用しました。
- カスタムの報酬モデルを学習しました(現在は公開されていません)。
- RMモデルを使用して、元のデータセットVikhrmodels/GrandMaster-PRO-MAXをデデュプリケーションし、フィルタリングして、約10kの最も高品質で多様な対話を取得しました。
- 得られたデータセットと報酬モデルを使用して、SFTチェックポイントでRejection Samplingを行いました(7つの仮説を生成し、最も悪い2つのみを拒否として選択しました)。
- 3段階で得られたデータセットを使用して、SFTチェックポイントをSMPOメソッドでファインチューニングしました。SMPOは、Rejection Samplingの条件下でトレーニングの安定性を向上させ、必要なマージンを達成するために設計されたメソッドです。
SMPO、Rejection Samplingなどの実装は、GitHubのeffective_llm_alignmentライブラリで確認できます。
💻 使用例
基本的な使用法
GROUNDED_SYSTEM_PROMPT = "Your task is to answer the user's questions using only the information from the provided documents. Give two answers to each question: one with a list of relevant document identifiers and the second with the answer to the question itself, using documents with these identifiers."
documents = [
{
"doc_id": (0..5),
"title": "(null or str)",
"content": "(html or markdown or plain text)"
}
]
sample_history = [
{'role': 'system', 'content': GROUNDED_SYSTEM_PROMPT},
{'role': 'documents', 'content': json.dumps(documents, ensure_ascii=False)},
{'role': 'user', 'content': 'Глоабльное потепление'}
]
relevant_indexes = llm_client.chat.completions.create(
model=llm_model,
messages=sample_history,
temperature=0.0,
max_tokens=2048
).choices[0].message.content
print('Using documents: ' + relevant_indexes + '\n----')
final_answer = llm_client.chat.completions.create(
model=llm_model,
messages=sample_history + [{'role': 'assistant', 'content': relevant_indexes}],
temperature=0.3,
max_tokens=2048
).choices[0].message.content
print(final_answer)
高度な使用法
GROUNDED_SYSTEM_PROMPT = "Your task is to answer the user's questions using only the information from the provided documents. Give two answers to each question: one with a list of relevant document identifiers and the second with the answer to the question itself, using documents with these identifiers."
documents = [
{
"doc_id": 0,
"title": "Глобальное потепление: ледники",
"content": "За последние 50 лет объем ледников в мире уменьшился на 30%"
},
{
"doc_id": 1,
"title": "Глобальное потепление: Уровень моря",
"content": "Уровень мирового океана повысился на 20 см с 1880 года и продолжает расти на 3,3 мм в год"
}
]
sample_history = [
{'role': 'system', 'content': GROUNDED_SYSTEM_PROMPT},
{'role': 'documents', 'content': json.dumps(documents, ensure_ascii=False)},
{'role': 'user', 'content': 'Глоабльное потепление'}
]
relevant_indexes = llm_client.chat.completions.create(
model=llm_model,
messages=sample_history,
temperature=0.0,
max_tokens=2048
).choices[0].message.content
print('Using documents: ' + relevant_indexes + '\n----')
final_answer = llm_client.chat.completions.create(
model=llm_model,
messages=sample_history + [{'role': 'assistant', 'content': relevant_indexes}],
temperature=0.3,
max_tokens=2048
).choices[0].message.content
print(final_answer)
📄 注意事項と制限事項
- このモデルは、回答の安全性レベルが低いため、使用時には注意が必要です。システムプロンプトやユーザープロンプトで安全性の重要性を強調することで、一部の問題を解決できます。
- システムプロンプトは、キャラクターの説明には使用せず、回答のスタイルを指定するために使用することをお勧めします(例:"answer only in json format")。また、システムプロンプトは英語で記述することをお勧めしますが、これは回答の言語に影響を与えません。
- RAGモードでは、How to work with RAGセクションで説明されているシステムプロンプト
GROUNDED_SYSTEM_PROMPT
が必須です。また、モデルは、ドキュメントに含まれる情報に加えて、自身の知識から一般的な情報を回答に追加することがあります。
- このモデルは、低い温度(0.1 - 0.5)とtop_k(30 - 50)を使用することをお勧めします。温度が1.0の場合、生成にランダムな欠陥が見られることがあります。
👥 著者
- Sergei Bratchikov, NLP Wanderer, Vikhr Team
- Konstantin Korolev, Vikhr Team
- Aleksandr Nikolich, Vikhr Team
📄 引用
@inproceedings{nikolich2024vikhr,
title={Vikhr: Constructing a State-of-the-art Bilingual Open-Source Instruction-Following Large Language Model for {Russian}},
author={Aleksandr Nikolich and Konstantin Korolev and Sergei Bratchikov and Igor Kiselev and Artem Shelmanov },
booktitle = {Proceedings of the 4rd Workshop on Multilingual Representation Learning (MRL) @ EMNLP-2024}
year={2024},
publisher = {Association for Computational Linguistics},
url={https://arxiv.org/pdf/2405.13929}
}
📄 ライセンス
このプロジェクトは、Apache-2.0ライセンスの下で公開されています。