Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- zh
|
4 |
+
---
|
5 |
+
|
6 |
+
https://github.com/FlagAI-Open/FlagAI/tree/master/examples/Aquila
|
7 |
+
|
8 |
+
```python
|
9 |
+
import torch
|
10 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
11 |
+
tokenizer = AutoTokenizer.from_pretrained('qhduan/aquila-7b')
|
12 |
+
model = AutoModelForCausalLM.from_pretrained('qhduan/aquila-7b', trust_remote_code=True)
|
13 |
+
model = model.eval().half().cuda()
|
14 |
+
prompt = '北京在哪儿?'
|
15 |
+
with torch.no_grad():
|
16 |
+
ret = model.generate(
|
17 |
+
**tokenizer(prompt, return_tensors='pt').to('cuda'),
|
18 |
+
do_sample=False,
|
19 |
+
max_new_tokens=200,
|
20 |
+
use_cache=True
|
21 |
+
)
|
22 |
+
# 北京在哪儿? 北京是中国的首都,是中华人民共和国的首都,是全国政治、经济、文化、交通中心,是世界著名古都和现代化国际城市
|
23 |
+
print(tokenizer.decode(ret[0]))
|
24 |
+
```
|
25 |
+
|
26 |
+
Aquila-7B和Aquila-33B开源模型使用 [智源Aquila系列模型许可协议](https://github.com/FlagAI-Open/FlagAI/blob/master/BAAI_Aquila_Model_License.pdf), 原始代码基于Apache Licence 2.0。
|