File size: 567 Bytes
5eaf1fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
## 介绍
tf版本 https://github.com/ZhuiyiTechnology/roformer
pytorch版本 https://github.com/JunnYu/RoFormer_pytorch

## 使用
```python
git clone https://github.com/JunnYu/RoFormer_pytorch
cd RoFormer_pytorch
import torch
from model import RoFormerModel, RoFormerTokenizer
tokenizer = RoFormerTokenizer.from_pretrained("junnyu/roformer_chinese_base")
model = RoFormerModel.from_pretrained("junnyu/roformer_chinese_base")
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
    outputs = model(**inputs).last_hidden_state
print(outputs.shape)
```