Update README.md
Browse files
README.md
CHANGED
@@ -7,7 +7,49 @@ language:
|
|
7 |
|
8 |
|
9 |
This is a direct extraction of the 8 experts from [Mixtral-8x7b-Instruct-v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1), and placing them into the Deepseek-MoE Architecture.
|
10 |
-
It is 2 experts per token. Performance is
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
Special Thanks: Eric Hartford, and Fernando Neto.
|
13 |
|
|
|
7 |
|
8 |
|
9 |
This is a direct extraction of the 8 experts from [Mixtral-8x7b-Instruct-v0.1](https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1), and placing them into the Deepseek-MoE Architecture.
|
10 |
+
It is 2 experts per token. Performance is identical to instruct, if not a little better. Evals will come, It is more malleable to training. This is our first experiment with expert extraction and modification, more to come. Enjoy.
|
11 |
+
|
12 |
+
|
13 |
+
```markdown
|
14 |
+
## Instruction Format
|
15 |
+
To leverage instruction fine-tuning, your prompts should be enclosed with `[INST]` and `[/INST]` tokens. The very first instruction should begin with a begin-of-sentence id, while subsequent instructions should not. Assistant generation will conclude with an end-of-sentence token id.
|
16 |
+
|
17 |
+
### Example
|
18 |
+
```plaintext
|
19 |
+
text = "<s>[INST] What is your favourite condiment? [/INST]"
|
20 |
+
"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>"
|
21 |
+
"[INST] Do you have mayonnaise recipes? [/INST]"
|
22 |
+
```
|
23 |
+
|
24 |
+
### Applying the Chat Template
|
25 |
+
This format can be implemented using the `apply_chat_template()` method from the `transformers` library:
|
26 |
+
|
27 |
+
```python
|
28 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
29 |
+
|
30 |
+
device = "cuda" # the device to load the model onto
|
31 |
+
|
32 |
+
# Load the model and tokenizer
|
33 |
+
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
|
34 |
+
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2")
|
35 |
+
|
36 |
+
# Define the conversation messages
|
37 |
+
messages = [
|
38 |
+
{"role": "user", "content": "What is your favourite condiment?"},
|
39 |
+
{"role": "assistant", "content": "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!"},
|
40 |
+
{"role": "user", "content": "Do you have mayonnaise recipes?"}
|
41 |
+
]
|
42 |
+
|
43 |
+
# Apply chat template
|
44 |
+
encodeds = tokenizer.apply_chat_template(messages, return_tensors="pt")
|
45 |
+
model_inputs = encodeds.to(device)
|
46 |
+
model.to(device)
|
47 |
+
|
48 |
+
# Generate response
|
49 |
+
generated_ids = model.generate(model_inputs, max_new_tokens=1000, do_sample=True)
|
50 |
+
decoded = tokenizer.batch_decode(generated_ids)
|
51 |
+
print(decoded[0])
|
52 |
+
```
|
53 |
|
54 |
Special Thanks: Eric Hartford, and Fernando Neto.
|
55 |
|