mgoin commited on
Commit
0d3e866
·
verified ·
1 Parent(s): dcc66ee

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +537 -0
README.md ADDED
@@ -0,0 +1,537 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - fr
5
+ - de
6
+ - es
7
+ - it
8
+ - pt
9
+ - zh
10
+ - ja
11
+ - ru
12
+ - ko
13
+ license: other
14
+ license_name: mrl
15
+ inference: false
16
+ license_link: https://mistral.ai/licenses/MRL-0.1.md
17
+ extra_gated_prompt: >-
18
+ # Mistral AI Research License
19
+
20
+ If You want to use a Mistral Model, a Derivative or an Output for any purpose
21
+ that is not expressly authorized under this Agreement, You must request a
22
+ license from Mistral AI, which Mistral AI may grant to You in Mistral AI's
23
+ sole discretion. To discuss such a license, please contact Mistral AI via the
24
+ website contact form: https://mistral.ai/contact/
25
+
26
+ ## 1. Scope and acceptance
27
+
28
+ **1.1. Scope of the Agreement.** This Agreement applies to any use,
29
+ modification, or Distribution of any Mistral Model by You, regardless of the
30
+ source You obtained a copy of such Mistral Model.
31
+
32
+ **1.2. Acceptance.** By accessing, using, modifying, Distributing a Mistral
33
+ Model, or by creating, using or distributing a Derivative of the Mistral
34
+ Model, You agree to be bound by this Agreement.
35
+
36
+ **1.3. Acceptance on behalf of a third-party.** If You accept this Agreement
37
+ on behalf of Your employer or another person or entity, You warrant and
38
+ represent that You have the authority to act and accept this Agreement on
39
+ their behalf. In such a case, the word "You" in this Agreement will refer to
40
+ Your employer or such other person or entity.
41
+
42
+ ## 2. License
43
+
44
+ **2.1. Grant of rights**. Subject to Section 3 below, Mistral AI hereby
45
+ grants You a non-exclusive, royalty-free, worldwide, non-sublicensable,
46
+ non-transferable, limited license to use, copy, modify, and Distribute under
47
+ the conditions provided in Section 2.2 below, the Mistral Model and any
48
+ Derivatives made by or for Mistral AI and to create Derivatives of the Mistral
49
+ Model.
50
+
51
+ **2.2. Distribution of Mistral Model and Derivatives made by or for Mistral
52
+ AI.** Subject to Section 3 below, You may Distribute copies of the Mistral
53
+ Model and/or Derivatives made by or for Mistral AI, under the following
54
+ conditions: You must make available a copy of this Agreement to third-party
55
+ recipients of the Mistral Models and/or Derivatives made by or for Mistral AI
56
+ you Distribute, it being specified that any rights to use the Mistral Models
57
+ and/or Derivatives made by or for Mistral AI shall be directly granted by
58
+ Mistral AI to said third-party recipients pursuant to the Mistral AI Research
59
+ License agreement executed between these parties; You must retain in all
60
+ copies of the Mistral Models the following attribution notice within a
61
+ "Notice" text file distributed as part of such copies: "Licensed by Mistral AI
62
+ under the Mistral AI Research License".
63
+
64
+ **2.3. Distribution of Derivatives made by or for You.** Subject to Section 3
65
+ below, You may Distribute any Derivatives made by or for You under additional
66
+ or different terms and conditions, provided that: In any event, the use and
67
+ modification of Mistral Model and/or Derivatives made by or for Mistral AI
68
+ shall remain governed by the terms and conditions of this Agreement; You
69
+ include in any such Derivatives made by or for You prominent notices stating
70
+ that You modified the concerned Mistral Model; and Any terms and conditions
71
+ You impose on any third-party recipients relating to Derivatives made by or
72
+ for You shall neither limit such third-party recipients' use of the Mistral
73
+ Model or any Derivatives made by or for Mistral AI in accordance with the
74
+ Mistral AI Research License nor conflict with any of its terms and conditions.
75
+
76
+ ## 3. Limitations
77
+
78
+ **3.1. Misrepresentation.** You must not misrepresent or imply, through any
79
+ means, that the Derivatives made by or for You and/or any modified version of
80
+ the Mistral Model You Distribute under your name and responsibility is an
81
+ official product of Mistral AI or has been endorsed, approved or validated by
82
+ Mistral AI, unless You are authorized by Us to do so in writing.
83
+
84
+ **3.2. Usage Limitation.** You shall only use the Mistral Models, Derivatives
85
+ (whether or not created by Mistral AI) and Outputs for Research Purposes.
86
+
87
+ ## 4. Intellectual Property
88
+
89
+ **4.1. Trademarks.** No trademark licenses are granted under this Agreement,
90
+ and in connection with the Mistral Models, You may not use any name or mark
91
+ owned by or associated with Mistral AI or any of its affiliates, except (i) as
92
+ required for reasonable and customary use in describing and Distributing the
93
+ Mistral Models and Derivatives made by or for Mistral AI and (ii) for
94
+ attribution purposes as required by this Agreement.
95
+
96
+ **4.2. Outputs.** We claim no ownership rights in and to the Outputs. You are
97
+ solely responsible for the Outputs You generate and their subsequent uses in
98
+ accordance with this Agreement. Any Outputs shall be subject to the
99
+ restrictions set out in Section 3 of this Agreement.
100
+
101
+ **4.3. Derivatives.** By entering into this Agreement, You accept that any
102
+ Derivatives that You may create or that may be created for You shall be
103
+ subject to the restrictions set out in Section 3 of this Agreement.
104
+
105
+ ## 5. Liability
106
+
107
+ **5.1. Limitation of liability.** In no event, unless required by applicable
108
+ law (such as deliberate and grossly negligent acts) or agreed to in writing,
109
+ shall Mistral AI be liable to You for damages, including any direct, indirect,
110
+ special, incidental, or consequential damages of any character arising as a
111
+ result of this Agreement or out of the use or inability to use the Mistral
112
+ Models and Derivatives (including but not limited to damages for loss of data,
113
+ loss of goodwill, loss of expected profit or savings, work stoppage, computer
114
+ failure or malfunction, or any damage caused by malware or security breaches),
115
+ even if Mistral AI has been advised of the possibility of such damages.
116
+
117
+ **5.2. Indemnification.** You agree to indemnify and hold harmless Mistral AI
118
+ from and against any claims, damages, or losses arising out of or related to
119
+ Your use or Distribution of the Mistral Models and Derivatives.
120
+
121
+ ## 6. Warranty
122
+
123
+ **6.1. Disclaimer.** Unless required by applicable law or prior agreed to by
124
+ Mistral AI in writing, Mistral AI provides the Mistral Models and Derivatives
125
+ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
126
+ express or implied, including, without limitation, any warranties or
127
+ conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
128
+ PARTICULAR PURPOSE. Mistral AI does not represent nor warrant that the Mistral
129
+ Models and Derivatives will be error-free, meet Your or any third party's
130
+ requirements, be secure or will allow You or any third party to achieve any
131
+ kind of result or generate any kind of content. You are solely responsible for
132
+ determining the appropriateness of using or Distributing the Mistral Models
133
+ and Derivatives and assume any risks associated with Your exercise of rights
134
+ under this Agreement.
135
+
136
+ ## 7. Termination
137
+
138
+ **7.1. Term.** This Agreement is effective as of the date of your acceptance
139
+ of this Agreement or access to the concerned Mistral Models or Derivatives and
140
+ will continue until terminated in accordance with the following terms.
141
+
142
+ **7.2. Termination.** Mistral AI may terminate this Agreement at any time if
143
+ You are in breach of this Agreement. Upon termination of this Agreement, You
144
+ must cease to use all Mistral Models and Derivatives and shall permanently
145
+ delete any copy thereof. The following provisions, in their relevant parts,
146
+ will survive any termination or expiration of this Agreement, each for the
147
+ duration necessary to achieve its own intended purpose (e.g. the liability
148
+ provision will survive until the end of the applicable limitation
149
+ period):Sections 5 (Liability), 6(Warranty), 7 (Termination) and 8 (General
150
+ Provisions).
151
+
152
+ **7.3. Litigation.** If You initiate any legal action or proceedings against
153
+ Us or any other entity (including a cross-claim or counterclaim in a lawsuit),
154
+ alleging that the Model or a Derivative, or any part thereof, infringe upon
155
+ intellectual property or other rights owned or licensable by You, then any
156
+ licenses granted to You under this Agreement will immediately terminate as of
157
+ the date such legal action or claim is filed or initiated.
158
+
159
+ ## 8. General provisions
160
+
161
+ **8.1. Governing laws.** This Agreement will be governed by the laws of
162
+ France, without regard to choice of law principles, and the UN Convention on
163
+ Contracts for the International Sale of Goods does not apply to this
164
+ Agreement.
165
+
166
+ **8.2. Competent jurisdiction.** The courts of Paris shall have exclusive
167
+ jurisdiction of any dispute arising out of this Agreement.
168
+
169
+ **8.3. Severability.** If any provision of this Agreement is held to be
170
+ invalid, illegal or unenforceable, the remaining provisions shall be
171
+ unaffected thereby and remain valid as if such provision had not been set
172
+ forth herein.
173
+
174
+ ## 9. Definitions
175
+
176
+ "Agreement": means this Mistral AI Research License agreement governing the
177
+ access, use, and Distribution of the Mistral Models, Derivatives and Outputs.
178
+
179
+ "Derivative": means any (i) modified version of the Mistral Model (including
180
+ but not limited to any customized or fine-tuned version thereof), (ii) work
181
+ based on the Mistral Model, or (iii) any other derivative work thereof.
182
+
183
+ "Distribution", "Distributing", "Distribute" or "Distributed": means
184
+ supplying, providing or making available, by any means, a copy of the Mistral
185
+ Models and/or the Derivatives as the case may be, subject to Section 3 of this
186
+ Agreement.
187
+
188
+ "Mistral AI", "We" or "Us": means Mistral AI, a French société par actions
189
+ simplifiée registered in the Paris commercial registry under the number 952
190
+ 418 325, and having its registered seat at 15, rue des Halles, 75001 Paris.
191
+
192
+ "Mistral Model": means the foundational large language model(s), and its
193
+ elements which include algorithms, software, instructed checkpoints,
194
+ parameters, source code (inference code, evaluation code and, if applicable,
195
+ fine-tuning code) and any other elements associated thereto made available by
196
+ Mistral AI under this Agreement, including, if any, the technical
197
+ documentation, manuals and instructions for the use and operation thereof.
198
+
199
+ "Research Purposes": means any use of a Mistral Model, Derivative, or Output
200
+ that is solely for (a) personal, scientific or academic research, and (b) for
201
+ non-profit and non-commercial purposes, and not directly or indirectly
202
+ connected to any commercial activities or business operations. For
203
+ illustration purposes, Research Purposes does not include (1) any usage of the
204
+ Mistral Model, Derivative or Output by individuals or contractors employed in
205
+ or engaged by companies in the context of (a) their daily tasks, or (b) any
206
+ activity (including but not limited to any testing or proof-of-concept) that
207
+ is intended to generate revenue, nor (2) any Distribution by a commercial
208
+ entity of the Mistral Model, Derivative or Output whether in return for
209
+ payment or free of charge, in any medium or form, including but not limited to
210
+ through a hosted or managed service (e.g. SaaS, cloud instances, etc.), or
211
+ behind a software layer.
212
+
213
+ "Outputs": means any content generated by the operation of the Mistral Models
214
+ or the Derivatives from a prompt (i.e., text instructions) provided by users.
215
+ For the avoidance of doubt, Outputs do not include any components of a Mistral
216
+ Models, such as any fine-tuned versions of the Mistral Models, the weights, or
217
+ parameters.
218
+
219
+ "You": means the individual or entity entering into this Agreement with
220
+ Mistral AI.
221
+
222
+
223
+ *Mistral AI processes your personal data below to provide the model and
224
+ enforce its license. If you are affiliated with a commercial entity, we may
225
+ also send you communications about our models. For more information on your
226
+ rights and data handling, please see our <a
227
+ href="https://mistral.ai/terms/">privacy policy</a>.*
228
+ extra_gated_fields:
229
+ First Name: text
230
+ Last Name: text
231
+ Country: country
232
+ Affiliation: text
233
+ Job title: text
234
+ I understand that I can only use the model, any derivative versions and their outputs for non-commercial research purposes: checkbox
235
+ 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
236
+ I understand that if I upload the model, or any derivative version, on any platform, I must include the Mistral Research License: checkbox
237
+ 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
238
+ By clicking Submit below I accept the terms of the license and acknowledge that the information I provide will be collected stored processed and shared in accordance with the Mistral Privacy Policy: checkbox
239
+ geo: ip_location
240
+ extra_gated_description: >-
241
+ Mistral AI processes your personal data below to provide the model and enforce
242
+ its license. If you are affiliated with a commercial entity, we may also send
243
+ you communications about our models. For more information on your rights and
244
+ data handling, please see our <a href="https://mistral.ai/terms/">privacy
245
+ policy</a>.
246
+ extra_gated_button_content: Submit
247
+ library_name: vllm
248
+ pipeline_tag: image-text-to-text
249
+ base_model:
250
+ - mistralai/Pixtral-Large-Instruct-2411
251
+ ---
252
+
253
+ # Model Card for Pixtral-Large-Instruct-2411
254
+
255
+ Pixtral-Large-Instruct-2411 is a 124B multimodal model built on top of Mistral Large 2, i.e., [Mistral-Large-Instruct-2407](https://huggingface.co/mistralai/Mistral-Large-Instruct-2407). Pixtral Large is the second model in our multimodal family and demonstrates frontier-level image understanding. Particularly, the model is able to understand documents, charts and natural images, while maintaining the leading text-only understanding of Mistral Large 2.
256
+
257
+ For more details about this model please refer to the [Pixtral Large blog post](https://mistral.ai/news/pixtral-large/) and the [Pixtral 12B blog post](https://mistral.ai/news/pixtral-12b/).
258
+
259
+
260
+ ## Key features
261
+ - Frontier-class multimodal performance
262
+ - State-of-the-art on MathVista, DocVQA, VQAv2
263
+ - Extends Mistral Large 2 without compromising text performance
264
+ - 123B multimodal decoder, 1B parameter vision encoder
265
+ - 128K context window: fits minimum of 30 high-resolution images
266
+
267
+ <!--
268
+ - **Multi-lingual by design:** Dozens of languages supported, including English, French, German, Spanish, Italian, Chinese, Japanese, Korean, Portuguese, Dutch and Polish.
269
+ - **Proficient in coding:** Trained on 80+ coding languages such as Python, Java, C, C++, Javacsript, and Bash. Also trained on more specific languages such as Swift and Fortran.
270
+ - **Agentic-centric:** Best-in-class agentic capabilities with native function calling and JSON outputting.
271
+ - **Advanced Reasoning:** State-of-the-art mathematical and reasoning capabilities.
272
+ - **Mistral Research License:** Allows usage and modification for research and non-commercial usages.
273
+ - **Large Context:** A large 128k context window.
274
+ - **System Prompt:** Maintains strong adherence and support for more reliable system prompts.
275
+ - **Vision:** A 1B parameter Vision Encoder achieving SOTA vision capabilities.
276
+ -->
277
+
278
+ ### System Prompt Handling
279
+
280
+ We appreciate the feedback received from our community regarding our system prompt handling.
281
+ In response, we have implemented stronger support for system prompts.
282
+ To achieve optimal results, we recommend always including a system prompt that clearly outlines the bot's purpose, even if it is minimal.
283
+
284
+ ### Basic Instruct Template (V7)
285
+
286
+ ```
287
+ <s>[SYSTEM_PROMPT] <system prompt>[/SYSTEM_PROMPT][INST] <user message>[/INST] <assistant response></s>[INST] <user message>[/INST]
288
+ ```
289
+
290
+ **Be careful with subtle missing or trailing white spaces!**
291
+
292
+ *Please make sure to use [mistral-common](https://github.com/mistralai/mistral-common) as the source of truth*
293
+
294
+
295
+ ## Metrics
296
+
297
+ | Model | MathVista (CoT) | MMMU (CoT) | ChartQA (CoT) | DocVQA (ANLS) | VQAv2 (VQA Match) | AI2D (BBox) | MM MT-Bench |
298
+ |:----------------------------:|:---------------:|:----------:|:-------------:|:--------------:|:-----------------:|:-----------:|:-----------:|
299
+ | **Pixtral Large (124B)** | **<u>69.4</u>** | 64.0 | 88.1 | **<u>93.3</u>**| **<u>80.9</u>** | 93.8 | **<u>7.4</u>**|
300
+ | Gemini-1.5 Pro (measured) | 67.8 | 66.3 | 83.8 | 92.3 | 70.6 | **<u>94.6</u>**| 6.8 |
301
+ | GPT-4o (measured) | 65.4 | **<u>68.6</u>**| 85.2 | 88.5 | 76.4 | 93.2 | 6.7 |
302
+ | Claude-3.5 Sonnet (measured) | 67.1 | 68.4 | **<u>89.1</u>**| 88.6 | 69.5 | 76.9 | 7.3 |
303
+ | Llama-3.2 90B (measured) | 49.1 | 53.7 | 70.8 | 85.7 | 67.0 | - | 5.5 |
304
+
305
+ Specific model versions evaluated: Claude-3.5 Sonnet (new) [Oct 24], Gemini-1.5 Pro (002) [Sep 24], GPT-4o (2024-08-06) [Aug 24].
306
+
307
+ See [mistral-evals](https://github.com/mistralai/mistral-evals) for open-source MM MT-Bench evaluation scripts.
308
+
309
+ ## Usage
310
+
311
+ The model can be used with the following frameworks
312
+
313
+ - [`vllm`](https://github.com/vllm-project/vllm): See [here](#vLLM)
314
+
315
+ ### vLLM
316
+
317
+ We recommend using Pixtral-Large-Instruct-2411 with the [vLLM library](https://github.com/vllm-project/vllm)
318
+ to implement production-ready inference pipelines with Pixtral-Large-Instruct-2411.
319
+
320
+ **_Installation_**
321
+
322
+ Make sure you install [`vLLM >= v0.6.4.post1`](https://github.com/vllm-project/vllm/releases/tag/v0.6.4.post1):
323
+
324
+ ```
325
+ pip install --upgrade vllm
326
+ ```
327
+
328
+ Also make sure you have [`mistral_common >= 1.5.0`](https://github.com/mistralai/mistral-common/releases/tag/v1.5.0) installed:
329
+
330
+ ```
331
+ pip install --upgrade mistral_common
332
+ ```
333
+
334
+ You can also make use of a ready-to-go [docker image](https://github.com/vllm-project/vllm/blob/main/Dockerfile) or on the [docker hub](https://hub.docker.com/layers/vllm/vllm-openai/latest/images/sha256-55a88146a4da0b6e193431b5b1d3492dfd7bebdc16919df4d031273e85a6157c?context=explore).
335
+
336
+
337
+ #### Server (Image)
338
+ We recommend to use Pixtral-Large-Instruct-2411 in a server/client setting.
339
+
340
+ 1. Spin up a server:
341
+
342
+ ```
343
+ vllm serve mistralai/Pixtral-Large-Instruct-2411 --config-format mistral --load-format mistral --tokenizer_mode mistral --limit_mm_per_prompt 'image=10' --tensor-parallel-size 8
344
+ ```
345
+
346
+ 2. And ping the client:
347
+
348
+ ```py
349
+ import requests
350
+ import json
351
+ from huggingface_hub import hf_hub_download
352
+ from datetime import datetime, timedelta
353
+
354
+ url = "http://<your-server-url>:8000/v1/chat/completions"
355
+ headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
356
+
357
+ model = "mistralai/Pixtral-Large-Instruct-2411"
358
+
359
+
360
+ def load_system_prompt(repo_id: str, filename: str) -> str:
361
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
362
+ with open(file_path, "r") as file:
363
+ system_prompt = file.read()
364
+ today = datetime.today().strftime("%Y-%m-%d")
365
+ yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
366
+ model_name = repo_id.split("/")[-1]
367
+ return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
368
+
369
+
370
+ SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
371
+
372
+ image_url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/europe.png"
373
+
374
+ messages = [
375
+ {"role": "system", "content": SYSTEM_PROMPT},
376
+ {
377
+ "role": "user",
378
+ "content": [
379
+ {
380
+ "type": "text",
381
+ "text": "Which of the depicted countries has the best food? Which the second and third and fourth? Name the country, its color on the map and one its city that is visible on the map, but is not the capital. Make absolutely sure to only name a city that can be seen on the map.",
382
+ },
383
+ {"type": "image_url", "image_url": {"url": image_url}},
384
+ ],
385
+ },
386
+ ]
387
+
388
+ data = {"model": model, "messages": messages}
389
+
390
+ response = requests.post(url, headers=headers, data=json.dumps(data))
391
+ print(response.json()["choices"][0]["message"]["content"])
392
+ # Determining which country has the "best" food can be subjective and depends on personal preferences. However, based on popular culinary reputations, here are some countries known for their cuisine:
393
+
394
+ #1. **Italy** (Brown) - Known for its pasta, pizza, and diverse regional dishes.
395
+ # - City: Milan
396
+
397
+ #2. **France** (Dark Brown) - Renowned for its fine dining, pastries, and wine.
398
+ # - City: Lyon
399
+
400
+ #3. **Spain** (Yellow) - Famous for tapas, paella, and a variety of seafood dishes.
401
+ # - City: Barcelona
402
+
403
+ #4. **Greece** (Yellow) - Known for its Mediterranean cuisine, including moussaka, souvlaki, and fresh seafood.
404
+ # - City: Thessaloniki
405
+
406
+ #These rankings are based on general culinary reputations and can vary widely depending on individual tastes.
407
+ ```
408
+
409
+ #### Server (Text-only)
410
+
411
+ You can also ping the client with a text-only example. The following example
412
+ shows how the system prompt can be used to make sure the model always knows
413
+ the current date.
414
+
415
+ ```py
416
+ import requests
417
+ import json
418
+ from huggingface_hub import hf_hub_download
419
+ from datetime import datetime, timedelta
420
+
421
+ url = "http://<your-server-url>:8000/v1/chat/completions"
422
+ headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
423
+
424
+ model = "mistralai/Pixtral-Large-Instruct-2411"
425
+
426
+
427
+ def load_system_prompt(repo_id: str, filename: str) -> str:
428
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
429
+ with open(file_path, "r") as file:
430
+ system_prompt = file.read()
431
+ today = datetime.today().strftime("%Y-%m-%d")
432
+ yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
433
+ model_name = repo_id.split("/")[-1]
434
+ return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
435
+
436
+
437
+ SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
438
+
439
+ image_url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/europe.png"
440
+
441
+ messages = [
442
+ {"role": "system", "content": SYSTEM_PROMPT},
443
+ {
444
+ "role": "user",
445
+ "content": "Without browsing the web, how many days ago was Mistral founded?"
446
+ },
447
+ ]
448
+
449
+ data = {"model": model, "messages": messages}
450
+
451
+ response = requests.post(url, headers=headers, data=json.dumps(data))
452
+ print(response.json()["choices"][0]["message"]["content"])
453
+ # Mistral AI was founded in April 2023. Since the current date is November 18, 2024, we can calculate the number of days between April 2023 and November 18, 2024.
454
+
455
+ #First, calculate the days from April 2023 to the end of 2023:
456
+ #- April: 27 days (30 - 3)
457
+ #- May: 31 days
458
+ #- June: 30 days
459
+ #- July: 31 days
460
+ #- August: 31 days
461
+ #- September: 30 days
462
+ #- October: 31 days
463
+ #- November: 30 days
464
+ #- December: 31 days
465
+
466
+ #Total days from April 2023 to December 31, 2023: 27 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 = 272 days
467
+
468
+ #Next, calculate the days from January 1, 2024, to November 18, 2024:
469
+ #- January: 31 days
470
+ #- February: 29 days (2024 is a leap year)
471
+ #- March: 31 days
472
+ #- April: 30 days
473
+ #- May: 31 days
474
+ #- June: 30 days
475
+ #- July: 31 days
476
+ #- August: 31 days
477
+ #- September: 30 days
478
+ #- October: 31 days
479
+ #- November: 18 days
480
+
481
+ #Total days from January 1, 2024, to November 18, 2024: 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 18 = 323 days
482
+
483
+ #Adding the two periods together:
484
+ #272 days (from April 2023 to December 2023) + 323 days (from January 2024 to November 18, 2024) = 595 days
485
+
486
+ #Therefore, Mistral AI was founded 595 days ago from November 18, 2024.
487
+ ```
488
+
489
+ #### Offline Example
490
+ ```py
491
+ from vllm import LLM
492
+ from vllm.sampling_params import SamplingParams
493
+ from huggingface_hub import hf_hub_download
494
+ from datetime import datetime, timedelta
495
+
496
+ model_name = "mistralai/Pixtral-Large-Instruct-2411"
497
+
498
+ def load_system_prompt(repo_id: str, filename: str) -> str:
499
+ file_path = hf_hub_download(repo_id=repo_id, filename=filename)
500
+ with open(file_path, 'r') as file:
501
+ system_prompt = file.read()
502
+ today = datetime.today().strftime('%Y-%m-%d')
503
+ yesterday = (datetime.today() - timedelta(days=1)).strftime('%Y-%m-%d')
504
+ model_name = repo_id.split("/")[-1]
505
+ return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
506
+
507
+ SYSTEM_PROMPT = load_system_prompt(model_name, "SYSTEM_PROMPT.txt")
508
+
509
+ image_url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/europe.png"
510
+
511
+ messages = [
512
+ {"role": "system", "content": SYSTEM_PROMPT},
513
+ {
514
+ "role": "user",
515
+ "content": [
516
+ {
517
+ "type": "text",
518
+ "text": "Which of the depicted countries has the best food? Which the second and third and fourth? Name the country, its color on the map and one its city that is visible on the map, but is not the capital. Make absolutely sure to only name a city that can be seen on the map.",
519
+ },
520
+ {"type": "image_url", "image_url": {"url": image_url}},
521
+ ],
522
+ },
523
+ ]
524
+
525
+ sampling_params = SamplingParams(max_tokens=512)
526
+
527
+ # note that running this model on GPU requires over 300 GB of GPU RAM
528
+ llm = LLM(model=model_name, config_format="mistral", load_format="mistral", tokenizer_mode="mistral", tensor_parallel_size=8, limit_mm_per_prompt={"image": 4})
529
+
530
+ outputs = llm.chat(messages, sampling_params=sampling_params)
531
+
532
+ print(outputs[0].outputs[0].text)
533
+ ```
534
+
535
+ ## The Mistral AI Team
536
+
537
+ Albert Jiang, Alexandre Sablayrolles, Alexis Tacnet, Alok Kothari, Antoine Roux, Arthur Mensch, Audrey Herblin-Stoop, Augustin Garreau, Austin Birky, Bam4d, Baptiste Bout, Baudouin de Monicault, Blanche Savary, Carole Rambaud, Caroline Feldman, Devendra Singh Chaplot, Diego de las Casas, Diogo Costa, Eleonore Arcelin, Emma Bou Hanna, Etienne Metzger, Gaspard Blanchet, Gianna Lengyel, Guillaume Bour, Guillaume Lample, Harizo Rajaona, Henri Roussez, Hichem Sattouf, Ian Mack, Jean-Malo Delignon, Jessica Chudnovsky, Justus Murke, Kartik Khandelwal, Lawrence Stewart, Louis Martin, Louis Ternon, Lucile Saulnier, Lélio Renard Lavaud, Margaret Jennings, Marie Pellat, Marie Torelli, Marie-Anne Lachaux, Marjorie Janiewicz, Mickaël Seznec, Nicolas Schuhl, Niklas Muhs, Olivier de Garrigues, Patrick von Platen, Paul Jacob, Pauline Buche, Pavan Kumar Reddy, Perry Savas, Pierre Stock, Romain Sauvestre, Sagar Vaze, Sandeep Subramanian, Saurabh Garg, Sophia Yang, Szymon Antoniak, Teven Le Scao, Thibault Schueller, Thibaut Lavril, Thomas Wang, Théophile Gervet, Timothée Lacroix, Valera Nemychnikova, Wendy Shang, William El Sayed, William Marshall