quincyqiang commited on
Commit
59bec85
1 Parent(s): c70f54b

Update README.md

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