thehonestbob
commited on
Commit
•
daf313f
1
Parent(s):
570e0ee
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## 一、项目介绍
|
2 |
+
此项目是参考github上优秀的机器翻译项目[mRASP](https://github.com/linzehui/mRASP),将官方开源的fairseq预训练权重改写为transformers架构,使其能够更加方便使用。
|
3 |
+
## 二、使用方法
|
4 |
+
```python
|
5 |
+
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
|
6 |
+
model_path = 'thehonestbob/mrasp'
|
7 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path, trust_remote_code=True, cache_dir=model_path)
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True, cache_dir=model_path)
|
9 |
+
input_text = ["Welcome to download and use!"]
|
10 |
+
inputs = tokenizer(input_text, return_tensors="pt", padding=True, max_length=300, truncation=True)
|
11 |
+
result = model.generate(**inputs)
|
12 |
+
result = tokenizer.batch_decode(result, skip_special_tokens=True)
|
13 |
+
result = [pre.strip() for pre in result]
|
14 |
+
# ['欢迎下载和使用!']
|
15 |
+
```
|
16 |
+
## 三、使用说明
|
17 |
+
该模型支持32种语言,更多详细参考[mRASP](https://github.com/linzehui/mRASP),此模型库的tokenizer仅针对中英双语进行优化,如果需要使用其他语言请
|
18 |
+
自行参考tokenization_bat.py进行修改。
|