File size: 727 Bytes
59bec85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
## NeZha-Pytorch
pytorch版NEZHA,适配transformers
### 安装
> pip install git+https://github.com/yanqiangmiffy/Nezha-Pytorch.git
### 权重下载地址
https://github.com/lonePatient/NeZha_Chinese_PyTorch
### torch使用样例
```
import torch
from transformers import BertTokenizer
from nezha import NeZhaModel, NeZhaConfig
text = "今天[MASK]很好,我[MASK]去公园玩。"
tokenizer = BertTokenizer.from_pretrained(
"quincyqiang/nezha-cn-base"
)
model = NeZhaModel.from_pretrained(
"quincyqiang/nezha-cn-base"
)
config = NeZhaConfig.from_pretrained(
"quincyqiang/nezha-cn-base"
)
model.eval()
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
```
|