Update README.md
Browse files
README.md
CHANGED
@@ -17,258 +17,20 @@ language:
|
|
17 |
extra_gated_description: If you want to learn more about how we process your personal data, please read our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
|
18 |
---
|
19 |
|
20 |
-
|
21 |
|
22 |
-
|
|
|
23 |
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
- **Multi-lingual by design:** Dozens of languages supported, including English, French, German, Spanish, Italian, Chinese, Japanese, Korean, Portuguese, Dutch and Polish.
|
28 |
-
- **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.
|
29 |
-
- **Agentic-centric:** Best-in-class agentic capabilities with native function calling and JSON outputting.
|
30 |
-
- **Advanced Reasoning:** State-of-the-art mathematical and reasoning capabilities.
|
31 |
-
- **Mistral Research License:** Allows usage and modification for research and non-commercial usages.
|
32 |
-
- **Large Context:** A large 128k context window.
|
33 |
|
34 |
-
## Metrics
|
35 |
|
36 |
-
### Base Pretrained Benchmarks
|
37 |
|
38 |
-
|
39 |
-
| --- | --- |
|
40 |
-
| MMLU | 84.0% |
|
41 |
-
|
42 |
-
|
43 |
-
### Base Pretrained Multilingual Benchmarks (MMLU)
|
44 |
-
| Benchmark | Score |
|
45 |
-
| --- | --- |
|
46 |
-
| French | 82.8% |
|
47 |
-
| German | 81.6% |
|
48 |
-
| Spanish | 82.7% |
|
49 |
-
| Italian | 82.7% |
|
50 |
-
| Dutch | 80.7% |
|
51 |
-
| Portuguese | 81.6% |
|
52 |
-
| Russian | 79.0% |
|
53 |
-
| Korean | 60.1% |
|
54 |
-
| Japanese | 78.8% |
|
55 |
-
| Chinese | 74.8% |
|
56 |
-
|
57 |
-
|
58 |
-
### Instruction Benchmarks
|
59 |
-
|
60 |
-
| Benchmark | Score |
|
61 |
-
| --- | --- |
|
62 |
-
| MT Bench | 8.63 |
|
63 |
-
| Wild Bench | 56.3 |
|
64 |
-
| Arena Hard| 73.2 |
|
65 |
-
|
66 |
-
### Code & Reasoning Benchmarks
|
67 |
-
| Benchmark | Score |
|
68 |
-
| --- | --- |
|
69 |
-
| Human Eval | 92% |
|
70 |
-
| Human Eval Plus| 87% |
|
71 |
-
| MBPP Base| 80% |
|
72 |
-
| MBPP Plus| 69% |
|
73 |
-
|
74 |
-
### Math Benchmarks
|
75 |
-
|
76 |
-
| Benchmark | Score |
|
77 |
-
| --- | --- |
|
78 |
-
| GSM8K | 93% |
|
79 |
-
| Math Instruct (0-shot, no CoT) | 70% |
|
80 |
-
| Math Instruct (0-shot, CoT)| 71.5% |
|
81 |
-
|
82 |
-
## Usage
|
83 |
-
|
84 |
-
The model can be used with two different frameworks
|
85 |
-
|
86 |
-
- [`mistral_inference`](https://github.com/mistralai/mistral-inference): See [here](#mistral-inference)
|
87 |
-
- [`transformers`](https://github.com/huggingface/transformers): See [here](#transformers)
|
88 |
-
|
89 |
-
### Mistral Inference
|
90 |
-
|
91 |
-
#### Install
|
92 |
-
|
93 |
-
It is recommended to use `mistralai/Mistral-Large-Instruct-2407` with [mistral-inference](https://github.com/mistralai/mistral-inference). For HF transformers code snippets, please keep scrolling.
|
94 |
-
|
95 |
-
```
|
96 |
-
pip install mistral_inference
|
97 |
-
```
|
98 |
-
|
99 |
-
#### Download
|
100 |
-
|
101 |
-
```py
|
102 |
-
from huggingface_hub import snapshot_download
|
103 |
-
from pathlib import Path
|
104 |
-
|
105 |
-
mistral_models_path = Path.home().joinpath('mistral_models', 'Large')
|
106 |
-
mistral_models_path.mkdir(parents=True, exist_ok=True)
|
107 |
-
|
108 |
-
snapshot_download(repo_id="mistralai/Mistral-Large-Instruct-2407", allow_patterns=["params.json", "consolidated-*.safetensors", "tokenizer.model.v3"], local_dir=mistral_models_path)
|
109 |
-
```
|
110 |
-
|
111 |
-
#### Chat
|
112 |
-
|
113 |
-
After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment.
|
114 |
-
Given the size of this model, you will need a node with several GPUs (more than 300GB cumulated vRAM).
|
115 |
-
If you have 8 GPUs on your machine, you can chat with the model using
|
116 |
-
|
117 |
-
```
|
118 |
-
torchrun --nproc-per-node 8 --no-python mistral-chat $HOME/mistral_models/Large --instruct --max_tokens 256 --temperature 0.7
|
119 |
-
```
|
120 |
-
|
121 |
-
*E.g.* Try out something like:
|
122 |
-
```
|
123 |
-
How expensive would it be to ask a window cleaner to clean all windows in Paris. Make a reasonable guess in US Dollar.
|
124 |
-
```
|
125 |
-
|
126 |
-
#### Instruct following
|
127 |
-
|
128 |
-
```py
|
129 |
-
from mistral_inference.transformer import Transformer
|
130 |
-
from mistral_inference.generate import generate
|
131 |
-
|
132 |
-
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
|
133 |
-
from mistral_common.protocol.instruct.messages import UserMessage
|
134 |
-
from mistral_common.protocol.instruct.request import ChatCompletionRequest
|
135 |
-
|
136 |
-
tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
|
137 |
-
model = Transformer.from_folder(mistral_models_path)
|
138 |
-
|
139 |
-
prompt = "How expensive would it be to ask a window cleaner to clean all windows in Paris. Make a reasonable guess in US Dollar."
|
140 |
-
|
141 |
-
completion_request = ChatCompletionRequest(messages=[UserMessage(content=prompt)])
|
142 |
-
|
143 |
-
tokens = tokenizer.encode_chat_completion(completion_request).tokens
|
144 |
-
|
145 |
-
out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.7, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
|
146 |
-
result = tokenizer.decode(out_tokens[0])
|
147 |
-
|
148 |
-
print(result)
|
149 |
-
```
|
150 |
-
|
151 |
-
#### Function calling
|
152 |
-
|
153 |
-
```py
|
154 |
-
from mistral_common.protocol.instruct.tool_calls import Function, Tool
|
155 |
-
from mistral_inference.transformer import Transformer
|
156 |
-
from mistral_inference.generate import generate
|
157 |
-
|
158 |
-
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
|
159 |
-
from mistral_common.protocol.instruct.messages import UserMessage
|
160 |
-
from mistral_common.protocol.instruct.request import ChatCompletionRequest
|
161 |
-
|
162 |
-
|
163 |
-
tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tokenizer.model.v3")
|
164 |
-
model = Transformer.from_folder(mistral_models_path)
|
165 |
-
|
166 |
-
completion_request = ChatCompletionRequest(
|
167 |
-
tools=[
|
168 |
-
Tool(
|
169 |
-
function=Function(
|
170 |
-
name="get_current_weather",
|
171 |
-
description="Get the current weather",
|
172 |
-
parameters={
|
173 |
-
"type": "object",
|
174 |
-
"properties": {
|
175 |
-
"location": {
|
176 |
-
"type": "string",
|
177 |
-
"description": "The city and state, e.g. San Francisco, CA",
|
178 |
-
},
|
179 |
-
"format": {
|
180 |
-
"type": "string",
|
181 |
-
"enum": ["celsius", "fahrenheit"],
|
182 |
-
"description": "The temperature unit to use. Infer this from the users location.",
|
183 |
-
},
|
184 |
-
},
|
185 |
-
"required": ["location", "format"],
|
186 |
-
},
|
187 |
-
)
|
188 |
-
)
|
189 |
-
],
|
190 |
-
messages=[
|
191 |
-
UserMessage(content="What's the weather like today in Paris?"),
|
192 |
-
],
|
193 |
-
)
|
194 |
-
|
195 |
-
tokens = tokenizer.encode_chat_completion(completion_request).tokens
|
196 |
-
|
197 |
-
out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.7, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
|
198 |
-
result = tokenizer.decode(out_tokens[0])
|
199 |
-
|
200 |
-
print(result)
|
201 |
-
```
|
202 |
-
|
203 |
-
### Transformers
|
204 |
-
|
205 |
-
If you want to use Hugging Face `transformers` to generate text, you can do something like this.
|
206 |
-
|
207 |
-
```py
|
208 |
-
from transformers import pipeline
|
209 |
-
|
210 |
-
messages = [
|
211 |
-
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
|
212 |
-
{"role": "user", "content": "Who are you?"},
|
213 |
-
]
|
214 |
-
chatbot = pipeline("text-generation", model="mistralai/Mistral-Large-Instruct-2407")
|
215 |
-
chatbot(messages)
|
216 |
-
```
|
217 |
-
|
218 |
-
## Function calling with `transformers`
|
219 |
-
|
220 |
-
To use this example, you'll need `transformers` version 4.42.0 or higher. Please see the
|
221 |
-
[function calling guide](https://huggingface.co/docs/transformers/main/chat_templating#advanced-tool-use--function-calling)
|
222 |
-
in the `transformers` docs for more information.
|
223 |
-
|
224 |
-
```python
|
225 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
226 |
-
import torch
|
227 |
-
|
228 |
-
model_id = "mistralai/Mistral-Large-Instruct-2407"
|
229 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
230 |
-
|
231 |
-
def get_current_weather(location: str, format: str):
|
232 |
-
"""
|
233 |
-
Get the current weather
|
234 |
-
|
235 |
-
Args:
|
236 |
-
location: The city and state, e.g. San Francisco, CA
|
237 |
-
format: The temperature unit to use. Infer this from the users location. (choices: ["celsius", "fahrenheit"])
|
238 |
-
"""
|
239 |
-
pass
|
240 |
-
|
241 |
-
conversation = [{"role": "user", "content": "What's the weather like in Paris?"}]
|
242 |
-
tools = [get_current_weather]
|
243 |
-
|
244 |
-
# format and tokenize the tool use prompt
|
245 |
-
inputs = tokenizer.apply_chat_template(
|
246 |
-
conversation,
|
247 |
-
tools=tools,
|
248 |
-
add_generation_prompt=True,
|
249 |
-
return_dict=True,
|
250 |
-
return_tensors="pt",
|
251 |
-
)
|
252 |
-
|
253 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
|
254 |
-
|
255 |
-
inputs.to(model.device)
|
256 |
-
outputs = model.generate(**inputs, max_new_tokens=1000)
|
257 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
258 |
-
```
|
259 |
-
|
260 |
-
Note that, for reasons of space, this example does not show a complete cycle of calling a tool and adding the tool call and tool
|
261 |
-
results to the chat history so that the model can use them in its next generation. For a full tool calling example, please
|
262 |
-
see the [function calling guide](https://huggingface.co/docs/transformers/main/chat_templating#advanced-tool-use--function-calling),
|
263 |
-
and note that Mistral **does** use tool call IDs, so these must be included in your tool calls and tool results. They should be
|
264 |
-
exactly 9 alphanumeric characters.
|
265 |
-
|
266 |
-
## Limitations
|
267 |
-
|
268 |
-
The Mistral Large model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
|
269 |
-
It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
|
270 |
-
make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
|
271 |
|
272 |
-
|
|
|
273 |
|
274 |
-
|
|
|
17 |
extra_gated_description: If you want to learn more about how we process your personal data, please read our <a href="https://mistral.ai/terms/">Privacy Policy</a>.
|
18 |
---
|
19 |
|
20 |
+
Quantized model => https://huggingface.co/mistralai/Mistral-Large-Instruct-2407
|
21 |
|
22 |
+
**Quantization Details:**
|
23 |
+
Quantization is done using turboderp's ExLlamaV2 v0.2.2.
|
24 |
|
25 |
+
I use the default calibration datasets and arguments. The repo also includes a "measurement.json" file, which was used during the quantization process.
|
26 |
|
27 |
+
For models with bits per weight (BPW) over 6.0, I default to quantizing the `lm_head` layer at 8 bits instead of the standard 6 bits.
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
31 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
**Who are you? What's with these weird BPWs on [insert model here]?**
|
34 |
+
I specialize in optimized EXL2 quantization for models in the 70B to 100B+ range, specifically tailored for 48GB VRAM setups. My rig is built using 2 x 3090s with a Ryzen APU (APU used solely for desktop output—no VRAM wasted on the 3090s). I use TabbyAPI for inference, targeting context sizes between 32K and 64K.
|
35 |
|
36 |
+
Every model I upload includes a `config.yml` file with my ideal TabbyAPI settings. If you're using my config, don’t forget to set `PYTORCH_CUDA_ALLOC_CONF=backend:cudaMallocAsync` to save some VRAM.
|