Update README.md
Browse files
README.md
CHANGED
@@ -15,3 +15,29 @@ MOE the following models by mergekit:
|
|
15 |
|
16 |
|
17 |
Works and generates coherent text.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
|
17 |
Works and generates coherent text.
|
18 |
+
|
19 |
+
code example
|
20 |
+
|
21 |
+
```
|
22 |
+
import torch
|
23 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
24 |
+
import math
|
25 |
+
|
26 |
+
## v2 models
|
27 |
+
model_path = "cloudyu/mixtral_7bx4_moe"
|
28 |
+
|
29 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, use_default_system_prompt=False)
|
30 |
+
model = AutoModelForCausalLM.from_pretrained(
|
31 |
+
model_path, torch_dtype=torch.float32, device_map='auto',local_files_only=False, load_in_4bit=True
|
32 |
+
)
|
33 |
+
print(model)
|
34 |
+
prompt = input("please input prompt:")
|
35 |
+
while len(prompt) > 0:
|
36 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to("cuda")
|
37 |
+
|
38 |
+
generation_output = model.generate(
|
39 |
+
input_ids=input_ids, max_new_tokens=500,repetition_penalty=1.2
|
40 |
+
)
|
41 |
+
print(tokenizer.decode(generation_output[0]))
|
42 |
+
prompt = input("please input prompt:")
|
43 |
+
```
|