AkimfromParis
commited on
Commit
•
ffa8dce
1
Parent(s):
0349568
Update inference code
Browse files
README.md
CHANGED
@@ -42,23 +42,34 @@ dtype: bfloat16
|
|
42 |
## 💻 Usage
|
43 |
|
44 |
```python
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
|
51 |
-
|
|
|
52 |
|
53 |
-
|
54 |
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
```
|
|
|
62 |
# Citation
|
63 |
```
|
64 |
@article{goddard2024arcee,
|
|
|
42 |
## 💻 Usage
|
43 |
|
44 |
```python
|
45 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
46 |
|
47 |
+
model_path = "AkimfromParis/Hinoki-Sak-Sta-slerp-7B"
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
49 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype="auto", device_map="auto")
|
50 |
+
model.eval()
|
51 |
|
52 |
+
requests = [
|
53 |
+
"大谷翔平選手について教えてください",
|
54 |
+
]
|
55 |
|
56 |
+
system_message = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: {user_input} ASSISTANT:"
|
57 |
|
58 |
+
for req in requests:
|
59 |
+
input_req = system_message.format(user_input=req)
|
60 |
+
input_ids = tokenizer.encode(input_req, return_tensors="pt").to(device=model.device)
|
61 |
+
tokens = model.generate(
|
62 |
+
input_ids,
|
63 |
+
max_new_tokens=1024,
|
64 |
+
do_sample=True,
|
65 |
+
pad_token_id=tokenizer.eos_token_id,
|
66 |
+
)
|
67 |
+
out = tokenizer.decode(tokens[0][len(input_ids[0]):], skip_special_tokens=True)
|
68 |
+
print("USER:\n" + req)
|
69 |
+
print("ASSISTANT:\n" + out)
|
70 |
+
print()
|
71 |
```
|
72 |
+
|
73 |
# Citation
|
74 |
```
|
75 |
@article{goddard2024arcee,
|