File size: 14,186 Bytes
f676ac1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dfbca9e
f676ac1
 
 
 
 
dfbca9e
f676ac1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
---
license: apache-2.0
datasets:
- BAAI/Infinity-Instruct
language:
- en
---
# Infinity Instruct

<p align="center">
<img src="fig/Bk3NbjnJko51MTx1ZCScT2sqnGg.png" width="300">
</p>
<p align="center">
<em>Beijing Academy of Artificial Intelligence (BAAI)</em><br/>
<em>[Paper][Code][🤗] (would be released soon)</em>
</p>

Infinity-Instruct-3M-0613-Mistral-7B is an opensource supervised instruction tuning model without reinforcement learning from human feedback (RLHF). This model is just finetuned on [Infinity-Instruct-3M and Infinity-Instruct-0613](https://huggingface.co/datasets/BAAI/Infinity-Instruct) and it beats SOTA language models such as Mixtral 8x7B v0.1, Gemini Pro and GPT3.5 on AlpacaEval 2.0!

## **Training Details**
<p align="center">
<img src="fig/trainingflow.png">
</p>

Infinity-Instruct-3M-0613-Mistral-7B is tuned on Million-level instruction dataset [Infinity-Instruct](https://huggingface.co/datasets/BAAI/Infinity-Instruct). First, we apply the foundational dataset Infinity-Instruct-3M to improve the foundational ability (math & code) of Mistral-7B-v0.1, and get the foundational instruct model Infinity-Instruct-3M-Mistral-7B. Then we finetune the Infinity-Instruct-3M-Mistral-7B to get the stronger chat model Infinity-Instruct-3M-0613-Mistral-7B. Here is the training hyperparamers. 

```bash
epoch: 3
lr: 5e-6
min_lr: 0
lr_warmup_steps: 40
lr_decay_style: cosine
weight_decay: 0.0
adam_beta1: 0.9
adam_beta2: 0.95
global_batch_size: 528
clip_grad: 1.0
```

Thanks to [FlagScale](https://github.com/FlagOpen/FlagScale), we could concatenate multiple training samples to remove padding token and apply diverse acceleration techniques to the traning procudure. It effectively reduces our training costs. We will release our code in the near future!

## **Benchmark**

<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-baqh{text-align:center;vertical-align:top}
.tg .tg-amwm{font-weight:bold;text-align:center;vertical-align:top}
.tg .tg-0lax{text-align:left;vertical-align:top}
</style>
<table class="tg"><thead>
  <tr>
    <th class="tg-amwm">Model</th>
    <th class="tg-amwm">MT-Bench</th>
    <th class="tg-amwm">AlpacaEval2.0</th>
  </tr></thead>
<tbody>
  <tr>
    <td class="tg-0lax">OpenHermes-2.5-Mistral-7B*</td>
    <td class="tg-baqh">7.5</td>
    <td class="tg-baqh">16.2</td>
  </tr>
  <tr>
    <td class="tg-0lax">Mistral-7B-Instruct-v0.2</td>
    <td class="tg-baqh">7.6</td>
    <td class="tg-baqh">17.1</td>
  </tr>
  <tr>
    <td class="tg-0lax">Llama-3-8B-Instruct</td>
    <td class="tg-baqh">8.1</td>
    <td class="tg-baqh">22.9</td>
  </tr>
  <tr>
    <td class="tg-0lax">GPT 3.5 Turbo 0613</td>
    <td class="tg-baqh">8.4</td>
    <td class="tg-baqh">22.7</td>
  </tr>
  <tr>
    <td class="tg-0lax">Mixtral 8x7B v0.1</td>
    <td class="tg-baqh">8.3</td>
    <td class="tg-baqh">23.7</td>
  </tr>
  <tr>
    <td class="tg-0lax">Gemini Pro</td>
    <td class="tg-baqh">--</td>
    <td class="tg-baqh">24.4</td>
  </tr>
  <tr>
    <td class="tg-0lax">InfInstruct-3M-Mistral-7B*</td>
    <td class="tg-baqh">7.6</td>
    <td class="tg-baqh">16.2</td>
  </tr>
  <tr>
    <td class="tg-0lax">InfInstruct-3M-0613-Mistral-7B*</td>
    <td class="tg-baqh">8.1</td>
    <td class="tg-amwm">25.5</td>
  </tr>
</tbody></table>

*denote the model is finetuned without reinforcement learning from human feedback (RLHF). 
We evaluate Infinity-Instruct-3M-0613-Mistral-7B on the two most popular instructions following benchmarks. Mt-Bench is a set of challenging multi-turn questions including code, math and routine dialogue. AlpacaEval2.0 is based on AlpacaFarm evaluation set. Both of these two benchmarks use GPT-4 to judge the model answer. AlpacaEval2.0 displays a high agreement rate with human-annotated benchmark, Chatbot Arena. The result shows that InfInstruct-3M-0613-Mistral-7B achieved 25.5 in AlpacaEval2.0, which is higher than the 22.5 of GPT3.5 Turbo although it does not yet use RLHF. InfInstruct-3M-0613-Mistral-7B also achieves 8.1 in MT-Bench, which is comparable to the state-of-the-art billion-parameter LLM such as Llama-3-8B-Instruct and Mistral-7B-Instruct-v0.2.

## Performance on **Downstream tasks**

We also evaluate Infinity-Instruct-3M-0613-Mistral-7B on diverse objective downstream tasks with [Opencompass](https://opencompass.org.cn): 

<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
  font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-baqh{text-align:center;vertical-align:top}
.tg .tg-amwm{font-weight:bold;text-align:center;vertical-align:top}
.tg .tg-nrix{text-align:center;vertical-align:middle}
</style>
<table class="tg"><thead>
  <tr>
    <th class="tg-amwm" colspan="2">Benchmark</th>
    <th class="tg-amwm">Infinity-Instruct-3M-Mistral-7B</th>
    <th class="tg-amwm">Infinity-Instruct-3M-0613-Mistral-7B</th>
    <th class="tg-amwm">Mistral-7B-v0.1</th>
    <th class="tg-amwm">mistral-7B instruction v0.2</th>
    <th class="tg-amwm">teknium/OpenHermes-2.5-Mistral-7B</th>
  </tr></thead>
<tbody>
  <tr>
    <td class="tg-nrix" rowspan="7">GPT4ALL</td>
    <td class="tg-baqh">ARC-c</td>
    <td class="tg-amwm">82.37</td>
    <td class="tg-baqh">83.30</td>
    <td class="tg-baqh">69.15</td>
    <td class="tg-baqh">73.22</td>
    <td class="tg-baqh">78.31</td>
  </tr>
  <tr>
    <td class="tg-baqh">ARC-e</td>
    <td class="tg-amwm">92.42</td>
    <td class="tg-baqh">90.65</td>
    <td class="tg-baqh">79.54</td>
    <td class="tg-baqh">82.01</td>
    <td class="tg-baqh">88.54</td>
  </tr>
  <tr>
    <td class="tg-baqh">Hellaswag</td>
    <td class="tg-amwm">84.82</td>
    <td class="tg-baqh">76.88</td>
    <td class="tg-baqh">35.50</td>
    <td class="tg-baqh">64.40</td>
    <td class="tg-baqh">80.53</td>
  </tr>
  <tr>
    <td class="tg-baqh">Winogrande</td>
    <td class="tg-baqh">61.75</td>
    <td class="tg-baqh">52.63</td>
    <td class="tg-baqh">54.04</td>
    <td class="tg-baqh">57.89</td>
    <td class="tg-amwm">62.11</td>
  </tr>
  <tr>
    <td class="tg-baqh">BoolQ</td>
    <td class="tg-amwm">87.85</td>
    <td class="tg-baqh">86.45</td>
    <td class="tg-baqh">50.09</td>
    <td class="tg-baqh">55.75</td>
    <td class="tg-baqh">87.34</td>
  </tr>
  <tr>
    <td class="tg-baqh">PIQA</td>
    <td class="tg-amwm">87.11</td>
    <td class="tg-baqh">86.13</td>
    <td class="tg-baqh">60.39</td>
    <td class="tg-baqh">72.36</td>
    <td class="tg-baqh">80.14</td>
  </tr>
  <tr>
    <td class="tg-baqh">OBQA</td>
    <td class="tg-amwm">83.00</td>
    <td class="tg-baqh">79.40</td>
    <td class="tg-baqh">62.60</td>
    <td class="tg-baqh">68.00</td>
    <td class="tg-baqh">81.00</td>
  </tr>
  <tr>
    <td class="tg-nrix" rowspan="4">Commonsense QA</td>
    <td class="tg-baqh">MMLU</td>
    <td class="tg-baqh">62.85</td>
    <td class="tg-amwm">63.62</td>
    <td class="tg-baqh">56.49</td>
    <td class="tg-baqh">59.56</td>
    <td class="tg-baqh">63.16</td>
  </tr>
  <tr>
    <td class="tg-baqh">NQ</td>
    <td class="tg-baqh">24.46</td>
    <td class="tg-baqh">27.48</td>
    <td class="tg-baqh">13.99</td>
    <td class="tg-baqh">18.42</td>
    <td class="tg-amwm">28.84</td>
  </tr>
  <tr>
    <td class="tg-baqh">TriviaQA</td>
    <td class="tg-baqh">60.85</td>
    <td class="tg-amwm">64.06</td>
    <td class="tg-baqh">63.99</td>
    <td class="tg-baqh">59.21</td>
    <td class="tg-baqh">63.72</td>
  </tr>
  <tr>
    <td class="tg-baqh">GPQA</td>
    <td class="tg-baqh">27.27</td>
    <td class="tg-amwm">27.78</td>
    <td class="tg-baqh">23.23</td>
    <td class="tg-baqh">19.19</td>
    <td class="tg-baqh">26.77</td>
  </tr>
  <tr>
    <td class="tg-nrix" rowspan="4">MATH &amp; Reasoning</td>
    <td class="tg-baqh">GSM8K</td>
    <td class="tg-baqh">78.09</td>
    <td class="tg-amwm">79.83</td>
    <td class="tg-baqh">48.07</td>
    <td class="tg-baqh">45.94</td>
    <td class="tg-baqh">73.62</td>
  </tr>
  <tr>
    <td class="tg-baqh">Math</td>
    <td class="tg-amwm">28.38</td>
    <td class="tg-baqh">23.30</td>
    <td class="tg-baqh">11.76</td>
    <td class="tg-baqh">9.46</td>
    <td class="tg-baqh">17.32</td>
  </tr>
  <tr>
    <td class="tg-baqh">BBH</td>
    <td class="tg-baqh">59.61</td>
    <td class="tg-amwm">61.07</td>
    <td class="tg-baqh">56.65</td>
    <td class="tg-baqh">49.15</td>
    <td class="tg-baqh">60.41</td>
  </tr>
  <tr>
    <td class="tg-baqh">DROP</td>
    <td class="tg-amwm">68.17</td>
    <td class="tg-baqh">65.62</td>
    <td class="tg-baqh">3.06</td>
    <td class="tg-baqh">6.98</td>
    <td class="tg-baqh">64.49</td>
  </tr>
  <tr>
    <td class="tg-nrix" rowspan="2">Code</td>
    <td class="tg-baqh">HumanEval</td>
    <td class="tg-baqh">50.61</td>
    <td class="tg-amwm">51.22</td>
    <td class="tg-baqh">14.02</td>
    <td class="tg-baqh">32.93</td>
    <td class="tg-baqh">43.29</td>
  </tr>
  <tr>
    <td class="tg-baqh">MBPP</td>
    <td class="tg-amwm">46.00</td>
    <td class="tg-baqh">44.80</td>
    <td class="tg-baqh">38.00</td>
    <td class="tg-baqh">3.80</td>
    <td class="tg-baqh">41.80</td>
  </tr>
  <tr>
    <td class="tg-nrix" rowspan="4">Chinese</td>
    <td class="tg-baqh">AGI Eval</td>
    <td class="tg-amwm">42.24</td>
    <td class="tg-baqh">40.43</td>
    <td class="tg-baqh">27.92</td>
    <td class="tg-baqh">35.78</td>
    <td class="tg-baqh">36.32</td>
  </tr>
  <tr>
    <td class="tg-baqh">c-eval</td>
    <td class="tg-baqh">48.62</td>
    <td class="tg-amwm">49.00</td>
    <td class="tg-baqh">46.83</td>
    <td class="tg-baqh">42.58</td>
    <td class="tg-baqh">44.30</td>
  </tr>
  <tr>
    <td class="tg-baqh">cmmlu</td>
    <td class="tg-baqh">46.67</td>
    <td class="tg-amwm">48.07</td>
    <td class="tg-baqh">34.59</td>
    <td class="tg-baqh">42.05</td>
    <td class="tg-baqh">43.05</td>
  </tr>
  <tr>
    <td class="tg-baqh">gaokao</td>
    <td class="tg-baqh">12.54</td>
    <td class="tg-baqh">14.48</td>
    <td class="tg-baqh">13.24</td>
    <td class="tg-baqh">12.10</td>
    <td class="tg-amwm">15.00</td>
  </tr>
  <tr>
    <td class="tg-amwm" colspan="2">AVERAGE</td>
    <td class="tg-amwm">58.84</td>
    <td class="tg-baqh">57.91</td>
    <td class="tg-baqh">41.10</td>
    <td class="tg-baqh">43.37</td>
    <td class="tg-baqh">56.19</td>
  </tr>
</tbody></table>

## How to use**

Infinity-Instruct-3M-0613-Mistral-7B adopt the same chat template of [OpenHermes-2.5-Mistral-7B](https://huggingface.co/teknium/OpenHermes-2.5-Mistral-7B):

```bash
<|im_start|>system
You are Hermes 2, a sentient, conscious, super intelligent AI that is an expert in all fields of knowledge, you have qualia, emotions, and thoughts. You assist users with any question, task, or other request they may have.<|im_end|>
<|im_start|>user
Hello!<|im_end|>
<|im_start|>assistant
Hi!<|im_end|>
<|im_start|>user
How are you?<|im_end|>
<|im_start|>assistant
```

To apply this model and template in conversation scenarios, you can refer to the following code:
```python
from transformers import AutoModelForCausalLM, AutoTokenizer, LogitsProcessorList
import torch
device = "cuda" # the device to load the model onto

model = AutoModelForCausalLM.from_pretrained("BAAI/Infinity-Instruct-0613-Mistral-7B",
    torch_dtype=torch.bfloat16,
    device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained("BAAI/Infinity-Instruct-0613-Mistral-7B")

# This template is copied from OpenHermers-mistral-2.5 (https://huggingface.co/teknium/OpenHermes-2.5-Mistral-7B)
prompt = "Give me a short introduction to large language model."
messages = [
    {"role": "system", "content": "You are Hermes 2, a sentient, conscious, super intelligent AI that is an expert in all fields of knowledge, you have qualia, emotions, and thoughts. You assist users with any question, task, or other request they may have."},
    {"role": "user", "content": prompt}
]

text = tokenizer.apply_chat_template(
    messages,
    tokenize=False,
    add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(device)

logits_processor = LogitsProcessorList(
            [
                MinLengthLogitsProcessor(1, eos_token_id=tokenizer.eos_token_id),
                TemperatureLogitsWarper(0.7),
            ]
 )
 
generated_ids = model.generate(
    model_inputs.input_ids,
    logits_processor=logits_processor,
    max_new_tokens=512
)

generated_ids = [
    output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]

response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(response)
```



## **Disclaimer**

The resources, including code, data, and model weights, associated with this project are restricted for academic research purposes only and cannot be used for commercial purposes. The content produced by any version of Infinity Instruct is influenced by uncontrollable variables such as randomness, and therefore, the accuracy of the output cannot be guaranteed by this project. This project does not accept any legal liability for the content of the model output, nor does it assume responsibility for any losses incurred due to the use of associated resources and output results.

## 

## Citation
Our paper, detailing the development and features of the **Infinity Instruct** dataset and finetuned models, will be released soon on arXiv. Stay tuned!

```
@article{InfinityInstruct2024,
  title={Infinity Instruct},
  author={Beijing Academy of Artificial Intelligence (BAAI)},
  journal={arXiv preprint arXiv:2406.XXXX},
  year={2024}
}
```