Qi Wang
commited on
Commit
•
ef492cf
1
Parent(s):
3d59e29
Update README.md
Browse files
README.md
CHANGED
@@ -79,16 +79,16 @@ make run
|
|
79 |
模型已经转换为huggingface的LlamaPretrainedModel格式,调用方法如下:
|
80 |
|
81 |
```python
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
```
|
93 |
|
94 |
输出
|
|
|
79 |
模型已经转换为huggingface的LlamaPretrainedModel格式,调用方法如下:
|
80 |
|
81 |
```python
|
82 |
+
torch.set_default_device("cuda")
|
83 |
+
config = AutoConfig.from_pretrained(model_path)
|
84 |
+
print(f"config: {config}")
|
85 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
86 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, config=config)
|
87 |
+
model.to("cuda")
|
88 |
+
inputs = tokenizer("从前", return_tensors="pt", add_special_tokens=True)
|
89 |
+
outputs = model.generate(**inputs, max_length=768)
|
90 |
+
text = tokenizer.batch_decode(outputs)[0]
|
91 |
+
print(text)
|
92 |
```
|
93 |
|
94 |
输出
|