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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Vikhr-Nemo-12B-Instruct-R-21-09-24
|
2 |
+
|
3 |
+
### Description
|
4 |
+
|
5 |
+
**Vikhr-Nemo** is our flagship unimodal LLM (Large Language Model), representing an improved version of [mistralai/Mistral-Nemo-Instruct-2407](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407) developed by the **VikhrModels** team, primarily adapted for Russian and English languages. The training involved several stages, including **SFT** and **SMPO** – our custom variant of DPO, details of which are available in the *"How This Model Was Created"* section.
|
6 |
+
|
7 |
+
The model is optimized for a wide range of use cases, including reasoning, summarization, coding, role-playing, and dialogue maintenance. Vikhr-Nemo has capabilities for multilingual generation and high-performance RAG capabilities. It achieves top scores on our instruction and RAG benchmarks, and we believe that for certain tasks (e.g., RAG), it can rival OpenAI's gpt-4o-mini.
|
8 |
+
|
9 |
+
All training code is available in our [effective_llm_alignment](https://github.com/VikhrModels/effective_llm_alignment/) repository on GitHub, and the main datasets are available on our [HF profile](https://huggingface.co/Vikhrmodels).
|
10 |
+
|
11 |
+
### Features
|
12 |
+
1. High-quality generation in Russian, English, and several other languages, thanks to the [Grandmaster-PRO-MAX](https://huggingface.co/datasets/Vikhrmodels/GrandMaster-PRO-MAX) dataset and the base model.
|
13 |
+
2. Support for system prompts to regulate response styles.
|
14 |
+
3. Up to 128k token context support thanks to the base model.
|
15 |
+
4. Grounded RAG mode – the model features a special 'documents' role and a mode for identifying relevant document IDs for user queries and using them for responses, inspired by Command-R’s similar capabilities.
|
16 |
+
|
17 |
+
### Metrics and Quality Evaluation
|
18 |
+
|
19 |
+
The model was evaluated on our open-source Russian-language SbS benchmark [ru-arena-general](https://github.com/VikhrModels/ru_llm_arena) (50 topics with 10 questions each), where gpt-4-1106-preview acted as the judge, and the [RAG benchmark](https://colab.research.google.com/drive/16730rWQ4-yGqWoooLs0Ece_16frmOniP?usp=sharing) based on the [Grounded-RAG-v2](https://huggingface.co/datasets/Vikhrmodels/Grounded-RAG-RU-v2) test set, judged by gpt-4o.
|
20 |
+
|
21 |
+
#### Results on Ru-Arena-General
|
22 |
+
|
23 |
+
The reference answers, to which models are compared, were generated by gpt-3.5-turbo-0125, hence it has a win rate of 50%.
|
24 |
+
|
25 |
+
Only part of the leaderboard is shown here; for more details, check the benchmark repository.
|
26 |
+
|
27 |
+
| Model Name | Winrate | 95% CI | Average # Tokens |
|
28 |
+
|--------------------------------------------------|--------|--------------------|------------------|
|
29 |
+
| gpt-4-1106-preview | 90.9 | (-1.3, 1.0) | 541 |
|
30 |
+
| gpt-4o-mini | 83.9 | (-1.8, 1.1) | 448 |
|
31 |
+
| **vikhr-nemo-12b-instruct-r-21-09-24** | **79.8** | (-2.2, 1.9) | **627** |
|
32 |
+
| gemma-2-9b-it-sppo-iter3 | 73.6 | (-1.6, 2.2) | 509 |
|
33 |
+
| gemma-2-9b-it | 69.2 | (-2.5, 1.9) | 459 |
|
34 |
+
| t-lite-instruct-0.1 | 64.7 | (-2.1, 1.7) | 810 |
|
35 |
+
| vikhr-llama3.1-8b-instruct-r-21-09-24 | 63.4 | (-2.1, 2.5) | 618 |
|
36 |
+
| suzume-llama-3-8B-multilingual-orpo-borda-half | 57.1 | (-1.9, 2.2) | 682 |
|
37 |
+
| mistral-nemo-instruct-2407 | 50.5 | (-2.7, 2.6) | 403 |
|
38 |
+
| gpt-3.5-turbo-0125 | 50.0 | (0.0, 0.0) | 220 |
|
39 |
+
| c4ai-command-r-v01 | 49.0 | (-1.7, 2.2) | 529 |
|
40 |
+
| meta-llama-3.1-8b-instruct | 43.1 | (-2.8, 2.3) | 628 |
|
41 |
+
|
42 |
+
#### RAG Benchmark Results
|
43 |
+
|
44 |
+
The test set comprises 200 examples: 100 in-domain questions and 100 out-of-domain questions.
|
45 |
+
|
46 |
+
For evaluation, the judge model gpt-4o was instructed to consider relevance and factual completeness based on documents and the reference answer from gpt-4-1106-preview.
|
47 |
+
|
48 |
+
For prompt details and evaluations, refer to the [Colab notebook](https://colab.research.google.com/drive/16730rWQ4-yGqWoooLs0Ece_16frmOniP?usp=sharing).
|
49 |
+
|
50 |
+
**In-Domain**: Questions related to the provided documents.
|
51 |
+
**Out-of-Domain**: Questions deliberately unrelated to the provided documents.
|
52 |
+
|
53 |
+
[Table representations of the results follow in the original text.]
|
54 |
+
|
55 |
+
<table>
|
56 |
+
<thead>
|
57 |
+
<tr>
|
58 |
+
<th rowspan="2">question_type</th>
|
59 |
+
<th colspan="3">gpt-4o</th>
|
60 |
+
</tr>
|
61 |
+
<tr>
|
62 |
+
<th>judge_correct_percent</th>
|
63 |
+
<th>avg_answer_match_rougeL</th>
|
64 |
+
<th>avg_abs_indexes_diff</th>
|
65 |
+
</tr>
|
66 |
+
</thead>
|
67 |
+
<tbody>
|
68 |
+
<tr>
|
69 |
+
<td>in_domain</td>
|
70 |
+
<td>73%</td>
|
71 |
+
<td>0.34</td>
|
72 |
+
<td>NaN</td>
|
73 |
+
</tr>
|
74 |
+
<tr>
|
75 |
+
<td>out_of_domain</td>
|
76 |
+
<td>81%</td>
|
77 |
+
<td>0.20</td>
|
78 |
+
<td>NaN</td>
|
79 |
+
</tr>
|
80 |
+
</tbody>
|
81 |
+
</table>
|
82 |
+
|
83 |
+
<table>
|
84 |
+
<thead>
|
85 |
+
<tr>
|
86 |
+
<th style="visibility: hidden;" rowspan="2">question_type</th>
|
87 |
+
<th colspan="3">Vikhr-Nemo-12B-Instruct-R-21-09-24</th>
|
88 |
+
</tr>
|
89 |
+
<tr>
|
90 |
+
<th style="visibility: hidden;">judge_correct_percent</th>
|
91 |
+
<th style="visibility: hidden;">avg_answer_match_rougeL</th>
|
92 |
+
<th style="visibility: hidden;">avg_abs_indexes_diff</th>
|
93 |
+
</tr>
|
94 |
+
</thead>
|
95 |
+
<tbody>
|
96 |
+
<tr>
|
97 |
+
<td>in_domain</td>
|
98 |
+
<td>68%</td>
|
99 |
+
<td>0.41</td>
|
100 |
+
<td>0</td>
|
101 |
+
</tr>
|
102 |
+
<tr>
|
103 |
+
<td>out_of_domain</td>
|
104 |
+
<td>92%</td>
|
105 |
+
<td>0.52</td>
|
106 |
+
<td>0</td>
|
107 |
+
</tr>
|
108 |
+
</tbody>
|
109 |
+
</table>
|
110 |
+
|
111 |
+
<table>
|
112 |
+
<thead>
|
113 |
+
<tr>
|
114 |
+
<th style="visibility: hidden;" rowspan="2">question_type</th>
|
115 |
+
<th colspan="3">gpt-4o-mini</th>
|
116 |
+
</tr>
|
117 |
+
<tr>
|
118 |
+
<th style="visibility: hidden;">judge_correct_percent</th>
|
119 |
+
<th style="visibility: hidden;">avg_answer_match_rougeL</th>
|
120 |
+
<th style="visibility: hidden;">avg_abs_indexes_diff</th>
|
121 |
+
</tr>
|
122 |
+
</thead>
|
123 |
+
<tbody>
|
124 |
+
<tr>
|
125 |
+
<td>in_domain</td>
|
126 |
+
<td>65%</td>
|
127 |
+
<td>0.33</td>
|
128 |
+
<td>NaN</td>
|
129 |
+
</tr>
|
130 |
+
<tr>
|
131 |
+
<td>out_of_domain</td>
|
132 |
+
<td>73%</td>
|
133 |
+
<td>0.18</td>
|
134 |
+
<td>NaN</td>
|
135 |
+
</tr>
|
136 |
+
</tbody>
|
137 |
+
</table>
|
138 |
+
|
139 |
+
<table>
|
140 |
+
<thead>
|
141 |
+
<tr>
|
142 |
+
<th style="visibility: hidden;" rowspan="2">question_type</th>
|
143 |
+
<th colspan="3">gpt-3.5-turbo-0125 </th>
|
144 |
+
</tr>
|
145 |
+
<tr>
|
146 |
+
<th style="visibility: hidden;">judge_correct_percent</th>
|
147 |
+
<th style="visibility: hidden;">avg_answer_match_rougeL</th>
|
148 |
+
<th style="visibility: hidden;">avg_abs_indexes_diff</th>
|
149 |
+
</tr>
|
150 |
+
</thead>
|
151 |
+
<tbody>
|
152 |
+
<tr>
|
153 |
+
<td>in_domain</td>
|
154 |
+
<td>49%</td>
|
155 |
+
<td>0.28</td>
|
156 |
+
<td>NaN</td>
|
157 |
+
</tr>
|
158 |
+
<tr>
|
159 |
+
<td>out_of_domain</td>
|
160 |
+
<td>76%</td>
|
161 |
+
<td>0.20</td>
|
162 |
+
<td>NaN</td>
|
163 |
+
</tr>
|
164 |
+
</tbody>
|
165 |
+
</table>
|
166 |
+
|
167 |
+
### How This Model Was Created
|
168 |
+
|
169 |
+
#### Instructional SFT Part
|
170 |
+
|
171 |
+
For the SFT training stage, we prepared a large (150k instructions) synthetic dataset [Vikhrmodels/GrandMaster-PRO-MAX](https://huggingface.co/datasets/Vikhrmodels)
|
172 |
+
|
173 |
+
#### Instructional SFT Part
|
174 |
+
|
175 |
+
For the SFT stage of model training, we have prepared a large (150k instructions) synthetic instructional dataset [Vikhrmodels/GrandMaster-PRO-MAX](https://huggingface.co/datasets/Vikhrmodels/GrandMaster-PRO-MAX). Its unique feature is the built-in Chain-Of-Thought (CoT), which we collected using a modified prompt for gpt-4-turbo. For more details, please refer to the dataset card.
|
176 |
+
|
177 |
+
Additionally, to perform RAG Grounding, we have prepared another synthetic dataset - [Vikhrmodels/Grounded-RAG-RU-v2](https://huggingface.co/datasets/Vikhrmodels/Grounded-RAG-RU-v2) (50k dialogues). The pipeline for its construction is quite complex, so you can find more information in the dataset card.
|
178 |
+
|
179 |
+
#### SMPO Alignment Stage
|
180 |
+
|
181 |
+
To further improve the quality of responses, we used the following pipeline:
|
182 |
+
1) Trained a custom Reward model (it will not be released publicly for now).
|
183 |
+
2) Deduplicated and filtered the original Vikhrmodels/GrandMaster-PRO-MAX dataset using the Reward model, resulting in around 10k of the highest-quality and most diverse dialogues.
|
184 |
+
3) Performed Rejection Sampling with the SFT checkpoint using the resulting dataset and Reward model. We generated 7 hypotheses and selected the 2 worst ones as rejected.
|
185 |
+
4) Fine-tuned the SFT checkpoint using our SMPO method with the dataset obtained from step 3. SMPO was designed and chosen as the method to enhance the stability of preference training under Rejection Sampling conditions and to achieve the desired margin.
|
186 |
+
|
187 |
+
The implementation of SMPO, rejection sampling, etc., can be found in our [effective_llm_alignment](https://github.com/VikhrModels/effective_llm_alignment/) library on GitHub.
|
188 |
+
|
189 |
+
The idea of using SMPO over other PO methods arose from numerous experiments with classical methods and the need for better convergence control. While other methods (e.g., SimPO) can achieve similar results with careful tuning, we aimed to stabilize the process and combine the best practices from other methods.
|
190 |
+
|
191 |
+
### How to Work with RAG
|
192 |
+
|
193 |
+
The role of "documents" represents a list of dictionaries describing document content, using `json.dumps(array, ensure_ascii=False)` (see example below). \
|
194 |
+
The document content can be presented in **3** different formats: **Markdown**, **HTML**, **Plain Text**. The content of each document can be a chunk of text up to 4k characters long.
|
195 |
+
|
196 |
+
```json
|
197 |
+
[
|
198 |
+
{
|
199 |
+
"doc_id": (0..5),
|
200 |
+
"title": "(null or str)",
|
201 |
+
"content": "(html or markdown or plain text)"
|
202 |
+
}
|
203 |
+
]
|
204 |
+
```
|
205 |
+
|
206 |
+
#### Example of Correct Usage with an OpenAI-like API
|
207 |
+
|
208 |
+
Launching the vLLM server: `vllm serve --dtype half --max-model-len 32000 -tp 1 Vikhrmodels/Vikhr-Nemo-12B-Instruct-R-21-09-24 --api-key token-abc123`
|
209 |
+
|
210 |
+
```python
|
211 |
+
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."
|
212 |
+
|
213 |
+
documents = [
|
214 |
+
{
|
215 |
+
"doc_id": 0,
|
216 |
+
"title": "Global Warming: Glaciers",
|
217 |
+
"content": "Over the past 50 years, the volume of glaciers worldwide has decreased by 30%."
|
218 |
+
},
|
219 |
+
{
|
220 |
+
"doc_id": 1,
|
221 |
+
"title": "Global Warming: Sea Level",
|
222 |
+
"content": "The global sea level has risen by 20 cm since 1880 and continues to rise by 3.3 mm per year."
|
223 |
+
}
|
224 |
+
]
|
225 |
+
sample_history = [
|
226 |
+
{'role': 'system', 'content': GROUNDED_SYSTEM_PROMPT},
|
227 |
+
{'role': 'documents', 'content': json.dumps(documents, ensure_ascii=False)},
|
228 |
+
{'role': 'user', 'content': 'Global warming'}
|
229 |
+
]
|
230 |
+
relevant_indexes = llm_client.chat.completions.create(
|
231 |
+
model=llm_model,
|
232 |
+
messages=sample_history,
|
233 |
+
temperature=0.0,
|
234 |
+
max_tokens=2048
|
235 |
+
).choices[0].message.content
|
236 |
+
|
237 |
+
print('Using documents: ' + relevant_indexes + '\n----')
|
238 |
+
final_answer = llm_client.chat.completions.create(
|
239 |
+
model=llm_model,
|
240 |
+
messages=sample_history + [{'role': 'assistant', 'content': relevant_indexes}],
|
241 |
+
temperature=0.3,
|
242 |
+
max_tokens=2048
|
243 |
+
).choices[0].message.content
|
244 |
+
|
245 |
+
print(final_answer)
|
246 |
+
```
|
247 |
+
|
248 |
+
The response after running the code might look like this:
|
249 |
+
|
250 |
+
Using documents: {"relevant_doc_ids": [0, 1]}
|
251 |
+
----
|
252 |
+
|
253 |
+
Global warming is a long-term increase in the Earth's atmosphere and ocean temperatures. This phenomenon has numerous consequences for our planet, and two key aspects based on the data available to me are:
|
254 |
+
|
255 |
+
1. **Reduction of glacier volume**: Over the past 50 years, there has been a significant reduction in glacier volume worldwide. According to the data, glacier volume has decreased by 30%. This could be related to glacier melting due to rising temperatures, which is one of the signs of global warming.
|
256 |
+
|
257 |
+
2. **Sea level rise**: The global sea level is also rising, which is associated with the melting of glaciers and ice sheets, as well as the expansion of water as it warms. Since 1880, the sea level has risen by 20 centimeters, and this process continues, with an annual increase of 3.3 millimeters.
|
258 |
+
|
259 |
+
These changes have serious consequences for ecosystems, climate, and human society. Glacier melting leads to sea-level rise, which can result in the flooding of coastal areas and islands, as well as changes in water resources and climate patterns.
|
260 |
+
|
261 |
+
Using the model's first response, `relevant_indexes` (JSON), one can determine whether the model found information in the documents. The model is trained to return an empty array if no information is found, in which case it will state that it couldn’t find the information in the knowledge base (when generating the second response).
|
262 |
+
|
263 |
+
### Nuances and Limitations
|
264 |
+
- The model has a **low level of response safety** and is focused on correctly and fully executing instructions. Keep this in mind during usage and test it independently. This can be partially corrected with system prompts and additional user prompt guidance about the importance of safety.
|
265 |
+
- System prompts are not intended for character descriptions; we recommend using them to specify the response style (e.g., "answer only in JSON format"). Additionally, it’s preferable to write them **in English**, as this was the case in the dataset; using English in system prompts does not affect the response language.
|
266 |
+
- The RAG mode **requires the presence** of the system prompt `GROUNDED_SYSTEM_PROMPT` described in the "How to Work with RAG" section. The model may sometimes add general knowledge information to the response along with the information present in the documents.
|
267 |
+
- The model works best with low temperatures (0.1-0.5) and top_k (30-50). At a temperature of 1.0, random generation defects were observed.
|
268 |
+
|
269 |
+
### Authors
|
270 |
+
- Sergei Bratchikov, [NLP Wanderer](https://t.me/nlpwanderer), Vikhr Team
|
271 |
+
- Konstantin Korolev, Vikhr Team
|
272 |
+
- Aleksandr Nikolich, Vikhr Team
|