Update README.md
Browse files
README.md
CHANGED
@@ -8,5 +8,30 @@ dataset : jondurbin/truthy-dpo-v0.1
|
|
8 |
|
9 |
metrics not test
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
|
|
8 |
|
9 |
metrics not test
|
10 |
|
11 |
+
gpu code example
|
12 |
+
|
13 |
+
```
|
14 |
+
import torch
|
15 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
16 |
+
import math
|
17 |
+
|
18 |
+
## v2 models
|
19 |
+
model_path = "cloudyu/Mixtral_7Bx2_MoE_DPO"
|
20 |
+
|
21 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, use_default_system_prompt=False)
|
22 |
+
model = AutoModelForCausalLM.from_pretrained(
|
23 |
+
model_path, torch_dtype=torch.bfloat16, device_map='auto',local_files_only=False, load_in_4bit=True
|
24 |
+
)
|
25 |
+
print(model)
|
26 |
+
prompt = input("please input prompt:")
|
27 |
+
while len(prompt) > 0:
|
28 |
+
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to("cuda")
|
29 |
+
|
30 |
+
generation_output = model.generate(
|
31 |
+
input_ids=input_ids, max_new_tokens=500,repetition_penalty=1.2
|
32 |
+
)
|
33 |
+
print(tokenizer.decode(generation_output[0]))
|
34 |
+
prompt = input("please input prompt:")
|
35 |
+
```
|
36 |
|
37 |
|