Update README.md
Browse files
README.md
CHANGED
@@ -57,7 +57,11 @@ In the Baichuan 2 series models, we have utilized the new feature `F.scaled_dot_
|
|
57 |
import torch
|
58 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
59 |
tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan2-7B-Base", use_fast=False, trust_remote_code=True)
|
60 |
-
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan2-7B-Base", device_map="auto",
|
|
|
|
|
|
|
|
|
61 |
```
|
62 |
|
63 |
# <span id="Benchmark">Benchmark 结果/Benchmark Evaluation</span>
|
|
|
57 |
import torch
|
58 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
59 |
tokenizer = AutoTokenizer.from_pretrained("baichuan-inc/Baichuan2-7B-Base", use_fast=False, trust_remote_code=True)
|
60 |
+
model = AutoModelForCausalLM.from_pretrained("baichuan-inc/Baichuan2-7B-Base", device_map="auto", trust_remote_code=True)
|
61 |
+
inputs = tokenizer('登鹳雀楼->王之涣\n夜雨寄北->', return_tensors='pt')
|
62 |
+
inputs = inputs.to('cuda:0')
|
63 |
+
pred = model.generate(**inputs, max_new_tokens=64, repetition_penalty=1.1)
|
64 |
+
print(tokenizer.decode(pred.cpu()[0], skip_special_tokens=True))
|
65 |
```
|
66 |
|
67 |
# <span id="Benchmark">Benchmark 结果/Benchmark Evaluation</span>
|