Update README.md
Browse files
README.md
CHANGED
@@ -16,7 +16,7 @@ MOE the following models by mergekit:
|
|
16 |
|
17 |
Works and generates coherent text.
|
18 |
|
19 |
-
code example
|
20 |
|
21 |
```
|
22 |
import torch
|
@@ -41,3 +41,30 @@ while len(prompt) > 0:
|
|
41 |
print(tokenizer.decode(generation_output[0]))
|
42 |
prompt = input("please input prompt:")
|
43 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
Works and generates coherent text.
|
18 |
|
19 |
+
gpu code example
|
20 |
|
21 |
```
|
22 |
import torch
|
|
|
41 |
print(tokenizer.decode(generation_output[0]))
|
42 |
prompt = input("please input prompt:")
|
43 |
```
|
44 |
+
|
45 |
+
CPU example
|
46 |
+
|
47 |
+
```
|
48 |
+
import torch
|
49 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
50 |
+
import math
|
51 |
+
|
52 |
+
## v2 models
|
53 |
+
model_path = "cloudyu/Mixtral_7Bx4_MOE_24B"
|
54 |
+
|
55 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, use_default_system_prompt=False)
|
56 |
+
model = AutoModelForCausalLM.from_pretrained(
|
57 |
+
model_path, torch_dtype=torch.float32, device_map='cpu',local_files_only=False
|
58 |
+
)
|
59 |
+
print(model)
|
60 |
+
prompt = input("please input prompt:")
|
61 |
+
while len(prompt) > 0:
|
62 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
|
63 |
+
|
64 |
+
generation_output = model.generate(
|
65 |
+
input_ids=input_ids, max_new_tokens=500,repetition_penalty=1.2
|
66 |
+
)
|
67 |
+
print(tokenizer.decode(generation_output[0]))
|
68 |
+
prompt = input("please input prompt:")
|
69 |
+
|
70 |
+
```
|