Commit
·
8c722a0
1
Parent(s):
c3a8e61
add snippet on readme
Browse files
README.md
CHANGED
|
@@ -7,7 +7,7 @@ pipeline_tag: text-generation
|
|
| 7 |
|
| 8 |
The Mistral-7B-Instruct-v0.1 Large Language Model (LLM) is a instruct fine-tuned version of the [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) generative text model using a variety of publicly available conversation datasets.
|
| 9 |
|
| 10 |
-
For full details of this model please read our [
|
| 11 |
|
| 12 |
## Instruction format
|
| 13 |
|
|
@@ -15,16 +15,26 @@ In order to leverage instruction fine-tuning, your prompt should be surrounded b
|
|
| 15 |
|
| 16 |
E.g.
|
| 17 |
|
| 18 |
-
```
|
| 19 |
-
from transformers import AutoTokenizer
|
| 20 |
|
| 21 |
-
|
| 22 |
-
instructions = ["[INST] What is your favourite condiment? [/INST]",
|
| 23 |
-
"[INST] Do you have mayonnaise recipes? [/INST]",
|
| 24 |
-
"[INST] This is healthy, right? [/INST]"]
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
| 29 |
|
| 30 |
## Model Architecture
|
|
|
|
| 7 |
|
| 8 |
The Mistral-7B-Instruct-v0.1 Large Language Model (LLM) is a instruct fine-tuned version of the [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) generative text model using a variety of publicly available conversation datasets.
|
| 9 |
|
| 10 |
+
For full details of this model please read our [release blog post](https://mistral.ai/news/announcing-mistral-7b/)
|
| 11 |
|
| 12 |
## Instruction format
|
| 13 |
|
|
|
|
| 15 |
|
| 16 |
E.g.
|
| 17 |
|
| 18 |
+
```python
|
| 19 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 20 |
|
| 21 |
+
device = "cuda" # the device to load the model onto
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1") #, token="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")
|
| 24 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.1") #, token="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")
|
| 25 |
+
|
| 26 |
+
text = "<s>[INST] What is your favourite condiment? [/INST]"
|
| 27 |
+
"Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
|
| 28 |
+
"[INST] Do you have mayonnaise recipes? [/INST]"
|
| 29 |
+
|
| 30 |
+
encodeds = tokenizer(instructions, return_tensors="pt", add_special_tokens=False)
|
| 31 |
+
|
| 32 |
+
model_inputs = encodeds.to(device)
|
| 33 |
+
model.to(device)
|
| 34 |
+
|
| 35 |
+
generated_ids = model.generate(**model_inputs, max_new_tokens=1000, do_sample=True)
|
| 36 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
| 37 |
+
print(decoded[0])
|
| 38 |
```
|
| 39 |
|
| 40 |
## Model Architecture
|