Fizzarolli
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,271 +1,40 @@
|
|
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 |
-
base_model: mistralai/Mistral-Nemo-Base-2407
|
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 |
-
|
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 |
-
| Benchmark | Score |
|
48 |
-
| --- | --- |
|
49 |
-
| HellaSwag (0-shot) | 83.5% |
|
50 |
-
| Winogrande (0-shot) | 76.8% |
|
51 |
-
| OpenBookQA (0-shot) | 60.6% |
|
52 |
-
| CommonSenseQA (0-shot) | 70.4% |
|
53 |
-
| TruthfulQA (0-shot) | 50.3% |
|
54 |
-
| MMLU (5-shot) | 68.0% |
|
55 |
-
| TriviaQA (5-shot) | 73.8% |
|
56 |
-
| NaturalQuestions (5-shot) | 31.2% |
|
57 |
-
|
58 |
-
### Multilingual Benchmarks (MMLU)
|
59 |
-
|
60 |
-
| Language | Score |
|
61 |
-
| --- | --- |
|
62 |
-
| French | 62.3% |
|
63 |
-
| German | 62.7% |
|
64 |
-
| Spanish | 64.6% |
|
65 |
-
| Italian | 61.3% |
|
66 |
-
| Portuguese | 63.3% |
|
67 |
-
| Russian | 59.2% |
|
68 |
-
| Chinese | 59.0% |
|
69 |
-
| Japanese | 59.0% |
|
70 |
-
|
71 |
-
## Usage
|
72 |
-
|
73 |
-
The model can be used with three different frameworks
|
74 |
-
|
75 |
-
- [`mistral_inference`](https://github.com/mistralai/mistral-inference): See [here](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407#mistral-inference)
|
76 |
-
- [`transformers`](https://github.com/huggingface/transformers): See [here](#transformers)
|
77 |
-
- [`NeMo`](https://github.com/NVIDIA/NeMo): See [nvidia/Mistral-NeMo-12B-Instruct](https://huggingface.co/nvidia/Mistral-NeMo-12B-Instruct)
|
78 |
-
|
79 |
-
### Mistral Inference
|
80 |
-
|
81 |
-
#### Install
|
82 |
-
|
83 |
-
It is recommended to use `mistralai/Mistral-Nemo-Instruct-2407` with [mistral-inference](https://github.com/mistralai/mistral-inference). For HF transformers code snippets, please keep scrolling.
|
84 |
-
|
85 |
-
```
|
86 |
-
pip install mistral_inference
|
87 |
-
```
|
88 |
-
|
89 |
-
#### Download
|
90 |
-
|
91 |
-
```py
|
92 |
-
from huggingface_hub import snapshot_download
|
93 |
-
from pathlib import Path
|
94 |
-
|
95 |
-
mistral_models_path = Path.home().joinpath('mistral_models', 'Nemo-Instruct')
|
96 |
-
mistral_models_path.mkdir(parents=True, exist_ok=True)
|
97 |
-
|
98 |
-
snapshot_download(repo_id="mistralai/Mistral-Nemo-Instruct-2407", allow_patterns=["params.json", "consolidated.safetensors", "tekken.json"], local_dir=mistral_models_path)
|
99 |
-
```
|
100 |
-
|
101 |
-
#### Chat
|
102 |
-
|
103 |
-
After installing `mistral_inference`, a `mistral-chat` CLI command should be available in your environment. You can chat with the model using
|
104 |
-
|
105 |
-
```
|
106 |
-
mistral-chat $HOME/mistral_models/Nemo-Instruct --instruct --max_tokens 256 --temperature 0.35
|
107 |
-
```
|
108 |
-
|
109 |
-
*E.g.* Try out something like:
|
110 |
-
```
|
111 |
-
How expensive would it be to ask a window cleaner to clean all windows in Paris. Make a reasonable guess in US Dollar.
|
112 |
-
```
|
113 |
-
|
114 |
-
#### Instruct following
|
115 |
-
|
116 |
-
```py
|
117 |
-
from mistral_inference.transformer import Transformer
|
118 |
-
from mistral_inference.generate import generate
|
119 |
-
|
120 |
-
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
|
121 |
-
from mistral_common.protocol.instruct.messages import UserMessage
|
122 |
-
from mistral_common.protocol.instruct.request import ChatCompletionRequest
|
123 |
-
|
124 |
-
tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tekken.json")
|
125 |
-
model = Transformer.from_folder(mistral_models_path)
|
126 |
-
|
127 |
-
prompt = "How expensive would it be to ask a window cleaner to clean all windows in Paris. Make a reasonable guess in US Dollar."
|
128 |
-
|
129 |
-
completion_request = ChatCompletionRequest(messages=[UserMessage(content=prompt)])
|
130 |
-
|
131 |
-
tokens = tokenizer.encode_chat_completion(completion_request).tokens
|
132 |
-
|
133 |
-
out_tokens, _ = generate([tokens], model, max_tokens=64, temperature=0.35, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
|
134 |
-
result = tokenizer.decode(out_tokens[0])
|
135 |
-
|
136 |
-
print(result)
|
137 |
-
```
|
138 |
-
|
139 |
-
#### Function calling
|
140 |
-
|
141 |
-
```py
|
142 |
-
from mistral_common.protocol.instruct.tool_calls import Function, Tool
|
143 |
-
from mistral_inference.transformer import Transformer
|
144 |
-
from mistral_inference.generate import generate
|
145 |
-
|
146 |
-
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
|
147 |
-
from mistral_common.protocol.instruct.messages import UserMessage
|
148 |
-
from mistral_common.protocol.instruct.request import ChatCompletionRequest
|
149 |
-
|
150 |
-
|
151 |
-
tokenizer = MistralTokenizer.from_file(f"{mistral_models_path}/tekken.json")
|
152 |
-
model = Transformer.from_folder(mistral_models_path)
|
153 |
-
|
154 |
-
completion_request = ChatCompletionRequest(
|
155 |
-
tools=[
|
156 |
-
Tool(
|
157 |
-
function=Function(
|
158 |
-
name="get_current_weather",
|
159 |
-
description="Get the current weather",
|
160 |
-
parameters={
|
161 |
-
"type": "object",
|
162 |
-
"properties": {
|
163 |
-
"location": {
|
164 |
-
"type": "string",
|
165 |
-
"description": "The city and state, e.g. San Francisco, CA",
|
166 |
-
},
|
167 |
-
"format": {
|
168 |
-
"type": "string",
|
169 |
-
"enum": ["celsius", "fahrenheit"],
|
170 |
-
"description": "The temperature unit to use. Infer this from the users location.",
|
171 |
-
},
|
172 |
-
},
|
173 |
-
"required": ["location", "format"],
|
174 |
-
},
|
175 |
-
)
|
176 |
-
)
|
177 |
-
],
|
178 |
-
messages=[
|
179 |
-
UserMessage(content="What's the weather like today in Paris?"),
|
180 |
-
],
|
181 |
-
)
|
182 |
-
|
183 |
-
tokens = tokenizer.encode_chat_completion(completion_request).tokens
|
184 |
-
|
185 |
-
out_tokens, _ = generate([tokens], model, max_tokens=256, temperature=0.35, eos_id=tokenizer.instruct_tokenizer.tokenizer.eos_id)
|
186 |
-
result = tokenizer.decode(out_tokens[0])
|
187 |
-
|
188 |
-
print(result)
|
189 |
-
```
|
190 |
-
|
191 |
-
### Transformers
|
192 |
-
|
193 |
-
> [!IMPORTANT]
|
194 |
-
> NOTE: Until a new release has been made, you need to install transformers from source:
|
195 |
-
> ```sh
|
196 |
-
> pip install git+https://github.com/huggingface/transformers.git
|
197 |
-
> ```
|
198 |
-
|
199 |
-
If you want to use Hugging Face `transformers` to generate text, you can do something like this.
|
200 |
-
|
201 |
-
```py
|
202 |
-
from transformers import pipeline
|
203 |
-
|
204 |
-
messages = [
|
205 |
-
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
|
206 |
-
{"role": "user", "content": "Who are you?"},
|
207 |
-
]
|
208 |
-
chatbot = pipeline("text-generation", model="mistralai/Mistral-Nemo-Instruct-2407",max_new_tokens=128)
|
209 |
-
chatbot(messages)
|
210 |
-
```
|
211 |
-
|
212 |
-
## Function calling with `transformers`
|
213 |
-
|
214 |
-
To use this example, you'll need `transformers` version 4.42.0 or higher. Please see the
|
215 |
-
[function calling guide](https://huggingface.co/docs/transformers/main/chat_templating#advanced-tool-use--function-calling)
|
216 |
-
in the `transformers` docs for more information.
|
217 |
-
|
218 |
-
```python
|
219 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
220 |
-
import torch
|
221 |
-
|
222 |
-
model_id = "mistralai/Mistral-Nemo-Instruct-2407"
|
223 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
224 |
-
|
225 |
-
def get_current_weather(location: str, format: str):
|
226 |
-
"""
|
227 |
-
Get the current weather
|
228 |
-
|
229 |
-
Args:
|
230 |
-
location: The city and state, e.g. San Francisco, CA
|
231 |
-
format: The temperature unit to use. Infer this from the users location. (choices: ["celsius", "fahrenheit"])
|
232 |
-
"""
|
233 |
-
pass
|
234 |
-
|
235 |
-
conversation = [{"role": "user", "content": "What's the weather like in Paris?"}]
|
236 |
-
tools = [get_current_weather]
|
237 |
-
|
238 |
-
# format and tokenize the tool use prompt
|
239 |
-
inputs = tokenizer.apply_chat_template(
|
240 |
-
conversation,
|
241 |
-
tools=tools,
|
242 |
-
add_generation_prompt=True,
|
243 |
-
return_dict=True,
|
244 |
-
return_tensors="pt",
|
245 |
-
)
|
246 |
-
|
247 |
-
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
|
248 |
-
|
249 |
-
inputs.to(model.device)
|
250 |
-
outputs = model.generate(**inputs, max_new_tokens=1000)
|
251 |
-
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
252 |
-
```
|
253 |
-
|
254 |
-
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
|
255 |
-
results to the chat history so that the model can use them in its next generation. For a full tool calling example, please
|
256 |
-
see the [function calling guide](https://huggingface.co/docs/transformers/main/chat_templating#advanced-tool-use--function-calling),
|
257 |
-
and note that Mistral **does** use tool call IDs, so these must be included in your tool calls and tool results. They should be
|
258 |
-
exactly 9 alphanumeric characters.
|
259 |
-
|
260 |
-
> [!TIP]
|
261 |
-
> Unlike previous Mistral models, Mistral Nemo requires smaller temperatures. We recommend to use a temperature of 0.3.
|
262 |
-
|
263 |
-
## Limitations
|
264 |
-
|
265 |
-
The Mistral Nemo Instruct model is a quick demonstration that the base model can be easily fine-tuned to achieve compelling performance.
|
266 |
-
It does not have any moderation mechanisms. We're looking forward to engaging with the community on ways to
|
267 |
-
make the model finely respect guardrails, allowing for deployment in environments requiring moderated outputs.
|
268 |
-
|
269 |
-
## The Mistral AI Team
|
270 |
-
|
271 |
-
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, 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
|
|
|
1 |
---
|
2 |
+
license: apache-2.0
|
3 |
+
base_model:
|
4 |
+
- mistralai/Mistral-Nemo-Instruct-2407
|
5 |
+
tags:
|
6 |
+
- roleplay
|
7 |
+
- conversational
|
8 |
language:
|
9 |
- en
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
---
|
11 |
+
# Teleut 7b RP
|
12 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/634262af8d8089ebaefd410e/-yOYQdx9p3TjHLSq2RrRf.png)
|
13 |
+
|
14 |
+
A roleplay-focused LoRA finetune of Mistral Nemo Instruct. Methodology and hyperparams inspired by [SorcererLM](https://huggingface.co/rAIfle/SorcererLM-8x22b-bf16) and [Slush](https://huggingface.co/crestf411/Q2.5-32B-Slush).
|
15 |
+
|
16 |
+
## Dataset
|
17 |
+
The worst mix of data you've ever seen. Like, seriously, you do not want to see the things that went into this model. It's bad.
|
18 |
+
|
19 |
+
## Recommended Settings
|
20 |
+
Chat template: Mistral v3-Tekken
|
21 |
+
Recommended samplers (not the be-all-end-all, try some on your own!):
|
22 |
+
- Temp 1.25 / MinP 0.1
|
23 |
+
- Temp 1.03 / TopK 200 / MinP 0.05 / TopA 0.2
|
24 |
+
|
25 |
+
## Hyperparams
|
26 |
+
### General
|
27 |
+
- Epochs = 2
|
28 |
+
- LR = 6e-5
|
29 |
+
- LR Scheduler = Cosine
|
30 |
+
- Optimizer = Paged AdamW 8bit
|
31 |
+
- Effective batch size = 12
|
32 |
+
### LoRA
|
33 |
+
- Rank = 16
|
34 |
+
- Alpha = 32
|
35 |
+
- Dropout = 0.25 (Inspiration: [Slush](https://huggingface.co/crestf411/Q2.5-32B-Slush))
|
36 |
+
|
37 |
+
## Credits
|
38 |
+
Humongous thanks to the people who created the data. I would credit you all, but that would be cheating ;)
|
39 |
+
Big thanks to all Allura members, especially Toasty, for testing and emotional support ilya /platonic
|
40 |
+
NO thanks to Infermatic. They suck at hosting models
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|