aashish1904 commited on
Commit
c9c3350
1 Parent(s): 33d973e

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +507 -0
README.md ADDED
@@ -0,0 +1,507 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+
4
+ language:
5
+ - en
6
+ - fr
7
+ - de
8
+ - es
9
+ - it
10
+ - pt
11
+ - zh
12
+ - ja
13
+ - ru
14
+ - ko
15
+ license: other
16
+ license_name: mrl
17
+ inference: false
18
+ license_link: https://mistral.ai/licenses/MRL-0.1.md
19
+ extra_gated_prompt: >-
20
+ # Mistral AI Research License
21
+
22
+ If You want to use a Mistral Model, a Derivative or an Output for any purpose that is not expressly authorized under this Agreement, You must request a license from Mistral AI, which Mistral AI may grant to You in Mistral AI's sole discretion. To discuss such a license, please contact Mistral AI via the website contact form: https://mistral.ai/contact/
23
+
24
+ ## 1. Scope and acceptance
25
+
26
+ **1.1. Scope of the Agreement.** This Agreement applies to any use, modification, or Distribution of any Mistral Model by You, regardless of the source You obtained a copy of such Mistral Model.
27
+
28
+ **1.2. Acceptance.** By accessing, using, modifying, Distributing a Mistral Model, or by creating, using or distributing a Derivative of the Mistral Model, You agree to be bound by this Agreement.
29
+
30
+ **1.3. Acceptance on behalf of a third-party.** If You accept this Agreement on behalf of Your employer or another person or entity, You warrant and represent that You have the authority to act and accept this Agreement on their behalf. In such a case, the word "You" in this Agreement will refer to Your employer or such other person or entity.
31
+
32
+ ## 2. License
33
+
34
+ **2.1. Grant of rights**. Subject to Section 3 below, Mistral AI hereby grants You a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable, limited license to use, copy, modify, and Distribute under the conditions provided in Section 2.2 below, the Mistral Model and any Derivatives made by or for Mistral AI and to create Derivatives of the Mistral Model.
35
+
36
+ **2.2. Distribution of Mistral Model and Derivatives made by or for Mistral AI.** Subject to Section 3 below, You may Distribute copies of the Mistral Model and/or Derivatives made by or for Mistral AI, under the following conditions:
37
+ You must make available a copy of this Agreement to third-party recipients of the Mistral Models and/or Derivatives made by or for Mistral AI you Distribute, it being specified that any rights to use the Mistral Models and/or Derivatives made by or for Mistral AI shall be directly granted by Mistral AI to said third-party recipients pursuant to the Mistral AI Research License agreement executed between these parties;
38
+ You must retain in all copies of the Mistral Models the following attribution notice within a "Notice" text file distributed as part of such copies: "Licensed by Mistral AI under the Mistral AI Research License".
39
+
40
+ **2.3. Distribution of Derivatives made by or for You.** Subject to Section 3 below, You may Distribute any Derivatives made by or for You under additional or different terms and conditions, provided that:
41
+ In any event, the use and modification of Mistral Model and/or Derivatives made by or for Mistral AI shall remain governed by the terms and conditions of this Agreement;
42
+ You include in any such Derivatives made by or for You prominent notices stating that You modified the concerned Mistral Model; and
43
+ Any terms and conditions You impose on any third-party recipients relating to Derivatives made by or for You shall neither limit such third-party recipients' use of the Mistral Model or any Derivatives made by or for Mistral AI in accordance with the Mistral AI Research License nor conflict with any of its terms and conditions.
44
+
45
+ ## 3. Limitations
46
+
47
+ **3.1. Misrepresentation.** You must not misrepresent or imply, through any means, that the Derivatives made by or for You and/or any modified version of the Mistral Model You Distribute under your name and responsibility is an official product of Mistral AI or has been endorsed, approved or validated by Mistral AI, unless You are authorized by Us to do so in writing.
48
+
49
+ **3.2. Usage Limitation.** You shall only use the Mistral Models, Derivatives (whether or not created by Mistral AI) and Outputs for Research Purposes.
50
+
51
+ ## 4. Intellectual Property
52
+
53
+ **4.1. Trademarks.** No trademark licenses are granted under this Agreement, and in connection with the Mistral Models, You may not use any name or mark owned by or associated with Mistral AI or any of its affiliates, except (i) as required for reasonable and customary use in describing and Distributing the Mistral Models and Derivatives made by or for Mistral AI and (ii) for attribution purposes as required by this Agreement.
54
+
55
+ **4.2. Outputs.** We claim no ownership rights in and to the Outputs. You are solely responsible for the Outputs You generate and their subsequent uses in accordance with this Agreement. Any Outputs shall be subject to the restrictions set out in Section 3 of this Agreement.
56
+
57
+ **4.3. Derivatives.** By entering into this Agreement, You accept that any Derivatives that You may create or that may be created for You shall be subject to the restrictions set out in Section 3 of this Agreement.
58
+
59
+ ## 5. Liability
60
+
61
+ **5.1. Limitation of liability.** In no event, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall Mistral AI be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this Agreement or out of the use or inability to use the Mistral Models and Derivatives (including but not limited to damages for loss of data, loss of goodwill, loss of expected profit or savings, work stoppage, computer failure or malfunction, or any damage caused by malware or security breaches), even if Mistral AI has been advised of the possibility of such damages.
62
+
63
+ **5.2. Indemnification.** You agree to indemnify and hold harmless Mistral AI from and against any claims, damages, or losses arising out of or related to Your use or Distribution of the Mistral Models and Derivatives.
64
+
65
+ ## 6. Warranty
66
+
67
+ **6.1. Disclaimer.** Unless required by applicable law or prior agreed to by Mistral AI in writing, Mistral AI provides the Mistral Models and Derivatives on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Mistral AI does not represent nor warrant that the Mistral Models and Derivatives will be error-free, meet Your or any third party's requirements, be secure or will allow You or any third party to achieve any kind of result or generate any kind of content. You are solely responsible for determining the appropriateness of using or Distributing the Mistral Models and Derivatives and assume any risks associated with Your exercise of rights under this Agreement.
68
+
69
+ ## 7. Termination
70
+
71
+ **7.1. Term.** This Agreement is effective as of the date of your acceptance of this Agreement or access to the concerned Mistral Models or Derivatives and will continue until terminated in accordance with the following terms.
72
+
73
+ **7.2. Termination.** Mistral AI may terminate this Agreement at any time if You are in breach of this Agreement. Upon termination of this Agreement, You must cease to use all Mistral Models and Derivatives and shall permanently delete any copy thereof. The following provisions, in their relevant parts, will survive any termination or expiration of this Agreement, each for the duration necessary to achieve its own intended purpose (e.g. the liability provision will survive until the end of the applicable limitation period):Sections 5 (Liability), 6(Warranty), 7 (Termination) and 8 (General Provisions).
74
+
75
+ **7.3. Litigation.** If You initiate any legal action or proceedings against Us or any other entity (including a cross-claim or counterclaim in a lawsuit), alleging that the Model or a Derivative, or any part thereof, infringe upon intellectual property or other rights owned or licensable by You, then any licenses granted to You under this Agreement will immediately terminate as of the date such legal action or claim is filed or initiated.
76
+
77
+ ## 8. General provisions
78
+
79
+ **8.1. Governing laws.** This Agreement will be governed by the laws of France, without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
80
+
81
+ **8.2. Competent jurisdiction.** The courts of Paris shall have exclusive jurisdiction of any dispute arising out of this Agreement.
82
+
83
+ **8.3. Severability.** If any provision of this Agreement is held to be invalid, illegal or unenforceable, the remaining provisions shall be unaffected thereby and remain valid as if such provision had not been set forth herein.
84
+
85
+ ## 9. Definitions
86
+
87
+ "Agreement": means this Mistral AI Research License agreement governing the access, use, and Distribution of the Mistral Models, Derivatives and Outputs.
88
+
89
+ "Derivative": means any (i) modified version of the Mistral Model (including but not limited to any customized or fine-tuned version thereof), (ii) work based on the Mistral Model, or (iii) any other derivative work thereof.
90
+
91
+ "Distribution", "Distributing", "Distribute" or "Distributed": means supplying, providing or making available, by any means, a copy of the Mistral Models and/or the Derivatives as the case may be, subject to Section 3 of this Agreement.
92
+
93
+ "Mistral AI", "We" or "Us": means Mistral AI, a French société par actions simplifiée registered in the Paris commercial registry under the number 952 418 325, and having its registered seat at 15, rue des Halles, 75001 Paris.
94
+
95
+ "Mistral Model": means the foundational large language model(s), and its elements which include algorithms, software, instructed checkpoints, parameters, source code (inference code, evaluation code and, if applicable, fine-tuning code) and any other elements associated thereto made available by Mistral AI under this Agreement, including, if any, the technical documentation, manuals and instructions for the use and operation thereof.
96
+
97
+ "Research Purposes": means any use of a Mistral Model, Derivative, or Output that is solely for (a) personal, scientific or academic research, and (b) for non-profit and non-commercial purposes, and not directly or indirectly connected to any commercial activities or business operations. For illustration purposes, Research Purposes does not include (1) any usage of the Mistral Model, Derivative or Output by individuals or contractors employed in or engaged by companies in the context of (a) their daily tasks, or (b) any activity (including but not limited to any testing or proof-of-concept) that is intended to generate revenue, nor (2) any Distribution by a commercial entity of the Mistral Model, Derivative or Output whether in return for payment or free of charge, in any medium or form, including but not limited to through a hosted or managed service (e.g. SaaS, cloud instances, etc.), or behind a software layer.
98
+
99
+ "Outputs": means any content generated by the operation of the Mistral Models or the Derivatives from a prompt (i.e., text instructions) provided by users. For the avoidance of doubt, Outputs do not include any components of a Mistral Models, such as any fine-tuned versions of the Mistral Models, the weights, or parameters.
100
+
101
+ "You": means the individual or entity entering into this Agreement with Mistral AI.
102
+
103
+
104
+ *Mistral AI processes your personal data below to provide the model and enforce its license. If you are affiliated with a commercial entity, we may also send you communications about our models. For more information on your rights and data handling, please see our <a href="https://mistral.ai/terms/">privacy policy</a>.*
105
+ extra_gated_fields:
106
+ First Name: text
107
+ Last Name: text
108
+ Country: country
109
+ Affiliation: text
110
+ Job title: text
111
+ I understand that I can only use the model, any derivative versions and their outputs for non-commercial research purposes: checkbox
112
+ I understand that if I am a commercial entity, I am not permitted to use or distribute the model internally or externally, or expose it in my own offerings without a commercial license: checkbox
113
+ I understand that if I upload the model, or any derivative version, on any platform, I must include the Mistral Research License: checkbox
114
+ I understand that for commercial use of the model, I can contact Mistral or use the Mistral AI API on la Plateforme or any of our cloud provider partners: checkbox
115
+ ? By clicking Submit below I accept the terms of the license and acknowledge that
116
+ the information I provide will be collected stored processed and shared in accordance
117
+ with the Mistral Privacy Policy
118
+ : checkbox
119
+ geo: ip_location
120
+ extra_gated_description: >-
121
+ Mistral AI processes your personal data below to provide the model and enforce its license. If you are affiliated with a commercial entity, we may also send you communications about our models. For more information on your rights and data handling, please see our <a href="https://mistral.ai/terms/">privacy policy</a>.
122
+ extra_gated_button_content: Submit
123
+ library_name: vllm
124
+
125
+ ---
126
+
127
+ [![QuantFactory Banner](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)](https://hf.co/QuantFactory)
128
+
129
+
130
+ # QuantFactory/Ministral-8B-Instruct-2410-HF-GGUF
131
+ This is quantized version of [TouchNight/Ministral-8B-Instruct-2410-HF](https://huggingface.co/TouchNight/Ministral-8B-Instruct-2410-HF) created using llama.cpp
132
+
133
+ # Original Model Card
134
+
135
+
136
+ # Model Card for Ministral-8B-Instruct-2410
137
+
138
+ We introduce two new state-of-the-art models for local intelligence, on-device computing, and at-the-edge use cases. We call them les Ministraux: Ministral 3B and Ministral 8B.
139
+
140
+ The Ministral-8B-Instruct-2410 Language Model is an instruct fine-tuned model significantly outperforming existing models of similar size, released under the Mistral Research License.
141
+
142
+ If you are interested in using Ministral-3B or Ministral-8B commercially, outperforming Mistral-7B, [reach out to us](https://mistral.ai/contact/).
143
+
144
+ For more details about les Ministraux please refer to our release [blog post](https://mistral.ai/news/ministraux).
145
+
146
+ ## Ministral 8B Key features
147
+ - Released under the **Mistral Research License**, reach out to us for a commercial license
148
+ - Trained with a **128k context window** with **interleaved sliding-window attention**
149
+ - Trained on a large proportion of **multilingual and code data**
150
+ - Supports **function calling**
151
+ - Vocabulary size of **131k**, using the **V3-Tekken** tokenizer
152
+
153
+ ### Basic Instruct Template (V3-Tekken)
154
+
155
+ ```
156
+ <s>[INST]user message[/INST]assistant response</s>[INST]new user message[/INST]
157
+ ```
158
+
159
+ *For more information about the tokenizer please refer to [mistral-common](https://github.com/mistralai/mistral-common)*
160
+
161
+ ## Ministral 8B Architecture
162
+
163
+ | Feature | Value |
164
+ |:---------------------:|:--------------------:|
165
+ | **Architecture** | Dense Transformer |
166
+ | **Parameters** | 8,019,808,256 |
167
+ | **Layers** | 36 |
168
+ | **Heads** | 32 |
169
+ | **Dim** | 4096 |
170
+ | **KV Heads (GQA)** | 8 |
171
+ | **Hidden Dim** | 12288 |
172
+ | **Head Dim** | 128 |
173
+ | **Vocab Size** | 131,072 |
174
+ | **Context Length** | 128k |
175
+ | **Attention Pattern** | Ragged (128k,32k,32k,32k) |
176
+
177
+ ## Benchmarks
178
+
179
+ #### Base Models
180
+
181
+ <u>Knowledge & Commonsense</u>
182
+
183
+ | Model | MMLU | AGIEval | Winogrande | Arc-c | TriviaQA |
184
+ |:-------------:|:------:|:---------:|:------------:|:-------:|:----------:|
185
+ | Mistral 7B Base | 62.5 | 42.5 | 74.2 | 67.9 | 62.5 |
186
+ | Llama 3.1 8B Base | 64.7 | 44.4 | 74.6 | 46.0 | 60.2 |
187
+ | ***Ministral 8B Base*** | ***<u>65.0</u>*** | ***<u>48.3</u>*** | ***<u>75.3</u>*** | ***<u>71.9</u>*** | ***<u>65.5</u>*** |
188
+ | | | | | | |
189
+ | Gemma 2 2B Base | 52.4 | 33.8 | 68.7 | 42.6 | 47.8 |
190
+ | Llama 3.2 3B Base | 56.2 | 37.4 | 59.6 | 43.1 | 50.7 |
191
+ | ***Ministral 3B Base*** | ***<u>60.9</u>*** | ***<u>42.1</u>*** | ***<u>72.7</u>*** | ***<u>64.2</u>*** | ***<u>56.7</u>*** |
192
+
193
+ <u>Code & Math</u>
194
+
195
+ | Model | HumanEval pass@1 |GSM8K maj@8 |
196
+ |:-------------:|:-------------------:|:---------------:|
197
+ | Mistral 7B Base | 26.8 | 32.0 |
198
+ | Llama 3.1 8B Base | ***<u>37.8</u>*** | 42.2 |
199
+ | ***Ministral 8B Base*** | 34.8 | ***<u>64.5</u>*** |
200
+ | | | |
201
+ | Gemma 2 2B | 20.1 | 35.5 |
202
+ | Llama 3.2 3B | 14.6 | 33.5 |
203
+ | ***Ministral 3B*** | ***<u>34.2</u>*** | ***<u>50.9</u>*** |
204
+
205
+ <u>Multilingual</u>
206
+
207
+ | Model | French MMLU | German MMLU | Spanish MMLU |
208
+ |:-------------:|:-------------:|:-------------:|:-------------:|
209
+ | Mistral 7B Base | 50.6 | 49.6 | 51.4 |
210
+ | Llama 3.1 8B Base | 50.8 | 52.8 | 54.6 |
211
+ | ***Ministral 8B Base*** | ***<u>57.5</u>*** | ***<u>57.4</u>*** | ***<u>59.6</u>*** |
212
+ | | | | |
213
+ | Gemma 2 2B Base | 41.0 | 40.1 | 41.7 |
214
+ | Llama 3.2 3B Base | 42.3 | 42.2 | 43.1 |
215
+ | ***Ministral 3B Base*** | ***<u>49.1</u>*** | ***<u>48.3</u>*** | ***<u>49.5</u>*** |
216
+
217
+ ### Instruct Models
218
+
219
+ <u>Chat/Arena (gpt-4o judge)</u>
220
+
221
+ | Model | MTBench | Arena Hard | Wild bench |
222
+ |:-------------:|:---------:|:------------:|:------------:|
223
+ | Mistral 7B Instruct v0.3 | 6.7 | 44.3 | 33.1 |
224
+ | Llama 3.1 8B Instruct | 7.5 | 62.4 | 37.0 |
225
+ | Gemma 2 9B Instruct | 7.6 | 68.7 | ***<u>43.8</u>*** |
226
+ | ***Ministral 8B Instruct*** | ***<u>8.3</u>*** | ***<u>70.9</u>*** | 41.3 |
227
+ | | | | |
228
+ | Gemma 2 2B Instruct | 7.5 | 51.7 | 32.5 |
229
+ | Llama 3.2 3B Instruct | 7.2 | 46.0 | 27.2 |
230
+ | ***Ministral 3B Instruct*** | ***<u>8.1</u>*** | ***<u>64.3</u>*** | ***<u>36.3</u>*** |
231
+
232
+ <u>Code & Math</u>
233
+
234
+ | Model | MBPP pass@1 | HumanEval pass@1 | Math maj@1 |
235
+ |:-------------:|:-------------:|:------------------:|:-------------:|
236
+ | Mistral 7B Instruct v0.3 | 50.2 | 38.4 | 13.2 |
237
+ | Gemma 2 9B Instruct | 68.5 | 67.7 | 47.4 |
238
+ Llama 3.1 8B Instruct | 69.7 | 67.1 | 49.3 |
239
+ | ***Ministral 8B Instruct*** | ***<u>70.0</u>*** | ***<u>76.8</u>*** | ***<u>54.5</u>*** |
240
+ | | | | |
241
+ | Gemma 2 2B Instruct | 54.5 | 42.7 | 22.8 |
242
+ | Llama 3.2 3B Instruct | 64.6 | 61.0 | 38.4 |
243
+ | ***Ministral 3B* Instruct** | ***<u>67.7</u>*** | ***<u>77.4</u>*** | ***<u>51.7</u>*** |
244
+
245
+ <u>Function calling</u>
246
+
247
+ | Model | Internal bench |
248
+ |:-------------:|:-----------------:|
249
+ | Mistral 7B Instruct v0.3 | 6.9 |
250
+ | Llama 3.1 8B Instruct | N/A |
251
+ | Gemma 2 9B Instruct | N/A |
252
+ | ***Ministral 8B Instruct*** | ***<u>31.6</u>*** |
253
+ | | |
254
+ | Gemma 2 2B Instruct | N/A |
255
+ | Llama 3.2 3B Instruct | N/A |
256
+ | ***Ministral 3B Instruct*** | ***<u>28.4</u>*** |
257
+
258
+ ## Usage Examples
259
+
260
+ ### vLLM (recommended)
261
+
262
+ We recommend using this model with the [vLLM library](https://github.com/vllm-project/vllm)
263
+ to implement production-ready inference pipelines.
264
+
265
+ > [!IMPORTANT]
266
+ > Currently vLLM is capped at 32k context size because interleaved attention kernels for paged attention are not yet implemented in vLLM.
267
+ > Attention kernels for paged attention are being worked on and as soon as it is fully supported in vLLM, this model card will be updated.
268
+ > To take advantage of the full 128k context size we recommend [Mistral Inference](https://huggingface.co/mistralai/Ministral-8B-Instruct-2410#mistral-inference)
269
+
270
+ **_Installation_**
271
+
272
+
273
+ Make sure you install `vLLM >= v0.6.2`:
274
+
275
+ ```
276
+ pip install --upgrade vllm
277
+ ```
278
+
279
+ Also make sure you have `mistral_common >= 1.4.4` installed:
280
+
281
+ ```
282
+ pip install --upgrade mistral_common
283
+ ```
284
+
285
+ You can also make use of a ready-to-go [docker image](https://github.com/vllm-project/vllm/blob/main/Dockerfile).
286
+
287
+ **_Offline_**
288
+
289
+ ```py
290
+ from vllm import LLM
291
+ from vllm.sampling_params import SamplingParams
292
+
293
+ model_name = "mistralai/Ministral-8B-Instruct-2410"
294
+
295
+ sampling_params = SamplingParams(max_tokens=8192)
296
+
297
+ # note that running Ministral 8B on a single GPU requires 24 GB of GPU RAM
298
+ # If you want to divide the GPU requirement over multiple devices, please add *e.g.* `tensor_parallel=2`
299
+ llm = LLM(model=model_name, tokenizer_mode="mistral", config_format="mistral", load_format="mistral")
300
+
301
+ prompt = "Do we need to think for 10 seconds to find the answer of 1 + 1?"
302
+
303
+ messages = [
304
+ {
305
+ "role": "user",
306
+ "content": prompt
307
+ },
308
+ ]
309
+
310
+ outputs = llm.chat(messages, sampling_params=sampling_params)
311
+
312
+ print(outputs[0].outputs[0].text)
313
+ # You don't need to think for 10 seconds to find the answer to 1 + 1. The answer is 2,
314
+ # and you can easily add these two numbers in your mind very quickly without any delay.
315
+ ```
316
+
317
+ **_Server_**
318
+
319
+ You can also use Ministral-8B in a server/client setting.
320
+
321
+ 1. Spin up a server:
322
+
323
+
324
+ ```
325
+ vllm serve mistralai/Ministral-8B-Instruct-2410 --tokenizer_mode mistral --config_format mistral --load_format mistral
326
+ ```
327
+
328
+ **Note:** Running Ministral-8B on a single GPU requires 24 GB of GPU RAM.
329
+
330
+ If you want to divide the GPU requirement over multiple devices, please add *e.g.* `--tensor_parallel=2`
331
+
332
+ 2. And ping the client:
333
+
334
+ ```
335
+ curl --location 'http://<your-node-url>:8000/v1/chat/completions' \
336
+ --header 'Content-Type: application/json' \
337
+ --header 'Authorization: Bearer token' \
338
+ --data '{
339
+ "model": "mistralai/Ministral-8B-Instruct-2410",
340
+ "messages": [
341
+ {
342
+ "role": "user",
343
+ "content": "Do we need to think for 10 seconds to find the answer of 1 + 1?"
344
+ }
345
+ ]
346
+ }'
347
+
348
+ ```
349
+
350
+ ### Mistral-inference
351
+
352
+ We recommend using [mistral-inference](https://github.com/mistralai/mistral-inference) to quickly try out / "vibe-check" the model.
353
+
354
+
355
+ **_Install_**
356
+
357
+ Make sure to have `mistral_inference >= 1.5.0` installed.
358
+
359
+ ```
360
+ pip install mistral_inference --upgrade
361
+ ```
362
+
363
+ **_Download_**
364
+
365
+ ```py
366
+ from huggingface_hub import snapshot_download
367
+ from pathlib import Path
368
+
369
+ mistral_models_path = Path.home().joinpath('mistral_models', '8B-Instruct')
370
+ mistral_models_path.mkdir(parents=True, exist_ok=True)
371
+
372
+ snapshot_download(repo_id="mistralai/Ministral-8B-Instruct-2410", allow_patterns=["params.json", "consolidated.safetensors", "tekken.json"], local_dir=mistral_models_path)
373
+ ```
374
+
375
+ ### Chat
376
+
377
+ After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment. You can chat with the model using
378
+
379
+ ```
380
+ mistral-chat $HOME/mistral_models/8B-Instruct --instruct --max_tokens 256
381
+ ```
382
+
383
+ ### Passkey detection
384
+
385
+ > [!IMPORTANT]
386
+ > In this example the passkey message has over >100k tokens and mistral-inference
387
+ > does not have a chunked pre-fill mechanism. Therefore you will need a lot of
388
+ > GPU memory in order to run the below example (80 GB). For a more memory-efficient
389
+ > solution we recommend using vLLM.
390
+
391
+ ```py
392
+ from mistral_inference.transformer import Transformer
393
+ from pathlib import Path
394
+ import json
395
+ from mistral_inference.generate import generate
396
+ from huggingface_hub import hf_hub_download
397
+
398
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
399
+ from mistral_common.protocol.instruct.messages import UserMessage
400
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
401
+
402
+ def load_passkey_request() -> ChatCompletionRequest:
403
+ passkey_file = hf_hub_download(repo_id="mistralai/Ministral-8B-Instruct-2410", filename="passkey_example.json")
404
+
405
+ with open(passkey_file, "r") as f:
406
+ data = json.load(f)
407
+
408
+ message_content = data["messages"][0]["content"]
409
+ return ChatCompletionRequest(messages=[UserMessage(content=message_content)])
410
+
411
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tekken.json")
412
+ model = Transformer.from_folder(mistral_models_path, softmax_fp32=False)
413
+
414
+ completion_request = load_passkey_request()
415
+
416
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
417
+
418
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
419
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
420
+
421
+ print(result) # The pass key is 13005.
422
+ ```
423
+
424
+
425
+ ### Instruct following
426
+
427
+ ```py
428
+ from mistral_inference.transformer import Transformer
429
+ from mistral_inference.generate import generate
430
+
431
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
432
+ from mistral_common.protocol.instruct.messages import UserMessage
433
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
434
+
435
+
436
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tekken.json")
437
+ model = Transformer.from_folder(mistral_models_path)
438
+
439
+ completion_request = ChatCompletionRequest(messages=[UserMessage(content="How often does the letter r occur in Mistral?")])
440
+
441
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
442
+
443
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
444
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
445
+
446
+ print(result)
447
+ ```
448
+
449
+ ### Function calling
450
+
451
+ ```py
452
+ from mistral_common.protocol.instruct.tool_calls import Function, Tool
453
+ from mistral_inference.transformer import Transformer
454
+ from mistral_inference.generate import generate
455
+
456
+ from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
457
+ from mistral_common.protocol.instruct.messages import UserMessage
458
+ from mistral_common.protocol.instruct.request import ChatCompletionRequest
459
+ from mistral_common.tokens.tokenizers.tekken import SpecialTokenPolicy
460
+
461
+
462
+ tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tekken.json")
463
+ tekken = tokenizer.instruct_tokenizer.tokenizer
464
+ tekken.special_token_policy = SpecialTokenPolicy.IGNORE
465
+
466
+ model = Transformer.from_folder(mistral_models_path)
467
+
468
+ completion_request = ChatCompletionRequest(
469
+ tools=[
470
+ Tool(
471
+ function=Function(
472
+ name="get_current_weather",
473
+ description="Get the current weather",
474
+ parameters={
475
+ "type": "object",
476
+ "properties": {
477
+ "location": {
478
+ "type": "string",
479
+ "description": "The city and state, e.g. San Francisco, CA",
480
+ },
481
+ "format": {
482
+ "type": "string",
483
+ "enum": ["celsius", "fahrenheit"],
484
+ "description": "The temperature unit to use. Infer this from the users location.",
485
+ },
486
+ },
487
+ "required": ["location", "format"],
488
+ },
489
+ )
490
+ )
491
+ ],
492
+ messages=[
493
+ UserMessage(content="What's the weather like today in Paris?"),
494
+ ],
495
+ )
496
+
497
+ tokens = tokenizer.encode_chat_completion(completion_request).tokens
498
+
499
+ out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.0, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
500
+ result = tokenizer.instruct_tokenizer.tokenizer.decode(out_tokens[0])
501
+
502
+ print(result)
503
+ ```
504
+
505
+ ## The Mistral AI Team
506
+
507
+ Albert Jiang, Alexandre Abou Chahine, Alexandre Sablayrolles, Alexis Tacnet, Alodie Boissonnet, Alok Kothari, Amélie Héliou, Andy Lo, Anna Peronnin, Antoine Meunier, Antoine Roux, Antonin Faure, Aritra Paul, Arthur Darcet, Arthur Mensch, Audrey Herblin-Stoop, Augustin Garreau, Austin Birky, Avinash Sooriyarachchi, Baptiste Rozière, Barry Conklin, Bastien Bouillon, Blanche Savary de Beauregard, Carole Rambaud, Caroline Feldman, Charles de Freminville, Charline Mauro, Chih-Kuan Yeh, Chris Bamford, Clement Auguy, Corentin Heintz, Cyriaque Dubois, Devendra Singh Chaplot, Diego Las Casas, Diogo Costa, Eléonore Arcelin, Emma Bou Hanna, Etienne Metzger, Fanny Olivier Autran, Francois Lesage, Garance Gourdel, Gaspard Blanchet, Gaspard Donada Vidal, Gianna Maria Lengyel, Guillaume Bour, Guillaume Lample, Gustave Denis, Harizo Rajaona, Himanshu Jaju, Ian Mack, Ian Mathew, Jean-Malo Delignon, Jeremy Facchetti, Jessica Chudnovsky, Joachim Studnia, Justus Murke, Kartik Khandelwal, Kenneth Chiu, Kevin Riera, Leonard Blier, Leonard Suslian, Leonardo Deschaseaux, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Sophia Yang, Margaret Jennings, Marie Pellat, Marie Torelli, Marjorie Janiewicz, Mathis Felardos, Maxime Darrin, Michael Hoff, Mickaël Seznec, Misha Jessel Kenyon, Nayef Derwiche, Nicolas Carmont Zaragoza, Nicolas Faurie, Nicolas Moreau, Nicolas Schuhl, Nikhil Raghuraman, Niklas Muhs, Olivier de Garrigues, Patricia Rozé, Patricia Wang, Patrick von Platen, Paul Jacob, Pauline Buche, Pavankumar Reddy Muddireddy, Perry Savas, Pierre Stock, Pravesh Agrawal, Renaud de Peretti, Romain Sauvestre, Romain Sinthe, Roman Soletskyi, Sagar Vaze, Sandeep Subramanian, Saurabh Garg, Soham Ghosh, Sylvain Regnier, Szymon Antoniak, Teven Le Scao, Theophile Gervet, Thibault Schueller, Thibaut Lavril, Thomas Wang, Timothée Lacroix, Valeriia Nemychnikova, Wendy Shang, William El Sayed, William Marshall