https://github.com/yanqiangmiffy/nezha-pytorch
https://github.com/yanqiangmiffy/nezha-pytorch
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yanqiangmiffy/nezha-pytorch
- Owner: yanqiangmiffy
- Created: 2022-04-24T07:55:05.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-24T08:13:50.000Z (over 3 years ago)
- Last Synced: 2025-02-24T01:16:54.256Z (8 months ago)
- Language: Python
- Size: 188 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 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, NeZhaConfigtext = "华为开源中文版BERT模型 NEZHA 哪吒。"
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)
```
> quincyqiang/nezha-cn-base可以改成本地路径