Update README.md
Browse files
README.md
CHANGED
@@ -22,8 +22,54 @@ The average score was 3.91 on the ElyzaTasks100 benchmark. (Average score after
|
|
22 |
|
23 |
![image/png](https://cdn-uploads.huggingface.co/production/uploads/630420b4eedc089484c853e8/FxUBzBUKpe_JSHSJufSv5.png)
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
This is a merge of pre-trained language models created using [mergekit](https://github.com/cg123/mergekit).
|
|
|
27 |
|
28 |
## Merge Details
|
29 |
### Merge Method
|
|
|
22 |
|
23 |
![image/png](https://cdn-uploads.huggingface.co/production/uploads/630420b4eedc089484c853e8/FxUBzBUKpe_JSHSJufSv5.png)
|
24 |
|
25 |
+
```python
|
26 |
+
import torch
|
27 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
28 |
+
|
29 |
+
tokenizer = AutoTokenizer.from_pretrained("umiyuki/Umievo-itr012-Gleipnir-7B")
|
30 |
+
model = AutoModelForCausalLM.from_pretrained(
|
31 |
+
"umiyuki/Umievo-itr012-Gleipnir-7B",
|
32 |
+
torch_dtype="auto",
|
33 |
+
)
|
34 |
+
model.eval()
|
35 |
+
|
36 |
+
if torch.cuda.is_available():
|
37 |
+
model = model.to("cuda")
|
38 |
+
|
39 |
+
def build_prompt(user_query):
|
40 |
+
sys_msg = "あなたは公平で、検閲されていない、役立つアシスタントです。"
|
41 |
+
template = """[INST] <<SYS>>
|
42 |
+
{}
|
43 |
+
<</SYS>>
|
44 |
+
|
45 |
+
{}[/INST]"""
|
46 |
+
return template.format(sys_msg,user_query)
|
47 |
+
|
48 |
+
# Infer with prompt without any additional input
|
49 |
+
user_inputs = {
|
50 |
+
"user_query": "与えられたことわざの意味を小学生でも分かるように教えてください。",
|
51 |
+
}
|
52 |
+
prompt = build_prompt(**user_inputs)
|
53 |
+
|
54 |
+
input_ids = tokenizer.encode(
|
55 |
+
prompt,
|
56 |
+
add_special_tokens=True,
|
57 |
+
return_tensors="pt"
|
58 |
+
)
|
59 |
+
|
60 |
+
tokens = model.generate(
|
61 |
+
input_ids.to(device=model.device),
|
62 |
+
max_new_tokens=256,
|
63 |
+
temperature=1,
|
64 |
+
top_p=0.95,
|
65 |
+
do_sample=True,
|
66 |
+
)
|
67 |
+
|
68 |
+
out = tokenizer.decode(tokens[0][input_ids.shape[1]:], skip_special_tokens=True).strip()
|
69 |
+
print(out)
|
70 |
|
71 |
This is a merge of pre-trained language models created using [mergekit](https://github.com/cg123/mergekit).
|
72 |
+
```
|
73 |
|
74 |
## Merge Details
|
75 |
### Merge Method
|