patrickvonplaten
commited on
Commit
•
0c80d11
1
Parent(s):
1b91506
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,168 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
- fr
|
5 |
+
- de
|
6 |
+
- es
|
7 |
+
- it
|
8 |
+
- pt
|
9 |
+
- ru
|
10 |
+
- zh
|
11 |
+
- ja
|
12 |
+
license: apache-2.0
|
13 |
+
library_name: vllm
|
14 |
+
extra_gated_description: If you want to learn more about how we process your personal
|
15 |
+
data, please read our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
|
16 |
+
---
|
17 |
+
|
18 |
+
# Model Card for Pixtral-12B-Base-2409
|
19 |
+
|
20 |
+
The Pixtral-12B-Base-2409 is a Multimodal Model of 12B parameters plus a 400M parameter vision encoder.
|
21 |
+
|
22 |
+
For more details about this model please refer to our release [blog post](https://mistral.ai/news/pixtral-12b/).
|
23 |
+
|
24 |
+
Feel free to try it [here](https://chat.mistral.ai/chat)
|
25 |
+
|
26 |
+
## Key features
|
27 |
+
- Natively multimodal, trained with interleaved image and text data
|
28 |
+
- 12B parameter Multimodal Decoder + 400M parameter Vision Encoder
|
29 |
+
- Supports variable image sizes
|
30 |
+
- Leading performance in its weight class on multimodal tasks
|
31 |
+
- Maintains state-of-the-art performance on text-only benchmarks
|
32 |
+
- Sequence length: 128k
|
33 |
+
- License: Apache 2.0
|
34 |
+
|
35 |
+
## Benchmarks
|
36 |
+
|
37 |
+
TODO
|
38 |
+
|
39 |
+
### Multimodal Benchmarks
|
40 |
+
|
41 |
+
TODO
|
42 |
+
|
43 |
+
### Instruction Following
|
44 |
+
|
45 |
+
TODO
|
46 |
+
|
47 |
+
### Text Benchmarks
|
48 |
+
|
49 |
+
TODO
|
50 |
+
|
51 |
+
### Comparison with Closed Source and Larger Models
|
52 |
+
|
53 |
+
TODO
|
54 |
+
|
55 |
+
## Usage Examples
|
56 |
+
|
57 |
+
### vLLM (recommended)
|
58 |
+
|
59 |
+
We recommend using Pixtral with the [vLLM library](https://github.com/vllm-project/vllm)
|
60 |
+
to implement production-ready inference pipelines with Pixtral.
|
61 |
+
|
62 |
+
**_Installation_**
|
63 |
+
|
64 |
+
Make sure you install `vLLM >= v1.6.2`:
|
65 |
+
|
66 |
+
```
|
67 |
+
pip install --upgrade vllm
|
68 |
+
```
|
69 |
+
|
70 |
+
Also make sure you have `mistral_common >= 1.4.4` installed:
|
71 |
+
|
72 |
+
```
|
73 |
+
pip install --upgrade mistral_common
|
74 |
+
```
|
75 |
+
|
76 |
+
You can also make use of a ready-to-go [docker image](https://hub.docker.com/layers/vllm/vllm-openai/latest/images/sha256-de9032a92ffea7b5c007dad80b38fd44aac11eddc31c435f8e52f3b7404bbf39?context=explore).
|
77 |
+
|
78 |
+
**_Example_**
|
79 |
+
|
80 |
+
```py
|
81 |
+
from vllm import LLM
|
82 |
+
from vllm.sampling_params import SamplingParams
|
83 |
+
|
84 |
+
model_name = "mistralai/Pixtral-12B-Base-2409"
|
85 |
+
|
86 |
+
sampling_params = SamplingParams(max_tokens=8192)
|
87 |
+
|
88 |
+
llm = LLM(model=model_name, tokenizer_mode="mistral")
|
89 |
+
|
90 |
+
prompt = "Describe this image in one sentence."
|
91 |
+
image_url = "https://picsum.photos/id/237/200/300"
|
92 |
+
|
93 |
+
messages = [
|
94 |
+
{
|
95 |
+
"role": "user",
|
96 |
+
"content": [{"type": "text", "text": prompt}, {"type": "image_url", "image_url": {"url": image_url}}]
|
97 |
+
},
|
98 |
+
]
|
99 |
+
|
100 |
+
outputs = llm.chat(messages, sampling_params=sampling_params)
|
101 |
+
|
102 |
+
print(outputs[0].outputs[0].text)
|
103 |
+
```
|
104 |
+
|
105 |
+
### Mistral-inference
|
106 |
+
|
107 |
+
We recommend using [mistral-inference](https://github.com/mistralai/mistral-inference) to quickly try out / "vibe-check" Pixtral.
|
108 |
+
|
109 |
+
|
110 |
+
**_Install_**
|
111 |
+
|
112 |
+
Make sure to have `mistral_inference >= 1.4.1` installed.
|
113 |
+
|
114 |
+
```
|
115 |
+
pip install mistral_inference --upgrade
|
116 |
+
```
|
117 |
+
|
118 |
+
**_Download_**
|
119 |
+
|
120 |
+
```py
|
121 |
+
from huggingface_hub import snapshot_download
|
122 |
+
from pathlib import Path
|
123 |
+
|
124 |
+
mistral_models_path = Path.home().joinpath('mistral_models', 'Pixtral')
|
125 |
+
mistral_models_path.mkdir(parents=True, exist_ok=True)
|
126 |
+
|
127 |
+
snapshot_download(repo_id="mistralai/Pixtral-12B-Base-2409", allow_patterns=["params.json", "consolidated.safetensors", "tekken.json"], local_dir=mistral_models_path)
|
128 |
+
```
|
129 |
+
|
130 |
+
**_Python_**
|
131 |
+
|
132 |
+
You can also run the model in a Python shell as follows.
|
133 |
+
|
134 |
+
```py
|
135 |
+
from mistral_inference.transformer import Transformer
|
136 |
+
from mistral_inference.generate import generate
|
137 |
+
|
138 |
+
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
|
139 |
+
from mistral_common.protocol.instruct.messages import UserMessage, TextChunk, ImageURLChunk
|
140 |
+
from mistral_common.protocol.instruct.request import CompletionRequest
|
141 |
+
|
142 |
+
tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tekken.json")
|
143 |
+
model = Transformer.from_folder(mistral_models_path)
|
144 |
+
|
145 |
+
url = "https://huggingface.co/datasets/patrickvonplaten/random_img/resolve/main/yosemite.png"
|
146 |
+
prompt = "The above image presents a"
|
147 |
+
|
148 |
+
completion_request = CompletionRequest(prompt=[UserMessage(content=[ImageURLChunk(image_url=url), TextChunk(text=prompt)])])
|
149 |
+
|
150 |
+
encoded = tokenizer.encode_chat_completion(completion_request)
|
151 |
+
|
152 |
+
images = encoded.images
|
153 |
+
tokens = encoded.tokens
|
154 |
+
|
155 |
+
out_tokens, _ = generate([tokens], model, images=[images], max_tokens=256, temperature=0.35, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
|
156 |
+
result = tokenizer.decode(out_tokens[0])
|
157 |
+
|
158 |
+
print(result)
|
159 |
+
```
|
160 |
+
|
161 |
+
## Limitations
|
162 |
+
|
163 |
+
The Pixtral model does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
|
164 |
+
make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
|
165 |
+
|
166 |
+
## The Mistral AI Team
|
167 |
+
|
168 |
+
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
|