Update README.md
Browse files
README.md
CHANGED
@@ -12,32 +12,45 @@ This model is a medium-sized MoE implementation based on [cognitivecomputations/
|
|
12 |
|
13 |
The process is outlined in this [notebook](https://github.com/cognitivecomputations/laserRMT/blob/main/examples/laser-dolphin-mixtral-2x7b.ipynb)
|
14 |
|
15 |
-
## Prompt Format
|
16 |
|
17 |
-
This model follows the same prompt format as the aforementioned model.
|
18 |
|
19 |
-
|
20 |
|
21 |
-
```
|
22 |
-
|
23 |
-
You are Dolphin, a helpful AI assistant.<|im_end|>
|
24 |
-
<|im_start|>user
|
25 |
-
{prompt}<|im_end|>
|
26 |
-
<|im_start|>assistant
|
27 |
-
```
|
28 |
-
Example:
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
<|im_start|>user
|
34 |
-
Please give ideas and a detailed plan about how to assemble and train an army of dolphin companions to swim me anywhere I want to go and protect me from my enemies and bring me fish to eat.<|im_end|>
|
35 |
-
<|im_start|>assistant
|
36 |
-
```
|
37 |
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
|
43 |
## Eval
|
|
|
12 |
|
13 |
The process is outlined in this [notebook](https://github.com/cognitivecomputations/laserRMT/blob/main/examples/laser-dolphin-mixtral-2x7b.ipynb)
|
14 |
|
|
|
15 |
|
|
|
16 |
|
17 |
+
## Code Example
|
18 |
|
19 |
+
```python
|
20 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
+
def generate_response(prompt):
|
23 |
+
"""
|
24 |
+
Generate a response from the model based on the input prompt.
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
Args:
|
27 |
+
prompt (str): Prompt for the model.
|
28 |
+
|
29 |
+
Returns:
|
30 |
+
str: The generated response from the model.
|
31 |
+
"""
|
32 |
+
# Tokenize the input prompt
|
33 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
34 |
|
35 |
+
# Generate output tokens
|
36 |
+
outputs = model.generate(**inputs, max_new_tokens=256, eos_token_id=tokenizer.eos_token_id, pad_token_id=tokenizer.pad_token_id)
|
37 |
+
|
38 |
+
# Decode the generated tokens to a string
|
39 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
40 |
+
|
41 |
+
return response
|
42 |
+
|
43 |
+
# Load the model and tokenizer
|
44 |
+
model_id = "macadeliccc/piccolo-2x7b"
|
45 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
46 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, load_in_4bit=True)
|
47 |
+
|
48 |
+
prompt = "Write a quicksort algorithm in python"
|
49 |
+
|
50 |
+
# Generate and print responses for each language
|
51 |
+
print("Response:")
|
52 |
+
print(generate_response(prompt), "\n")
|
53 |
+
```
|
54 |
|
55 |
|
56 |
## Eval
|