lucadiliello
commited on
Commit
•
e29963c
1
Parent(s):
b3fb342
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
This model is based on a custom Transformer model that can be installed with:
|
2 |
+
|
3 |
+
```bash
|
4 |
+
pip install git+https://github.com/lucadiliello/bleurt-pytorch.git
|
5 |
+
```
|
6 |
+
|
7 |
+
Now load the model and make predictions with:
|
8 |
+
|
9 |
+
```python
|
10 |
+
import torch
|
11 |
+
from bleurt_pytorch import BleurtConfig, BleurtForSequenceClassification, BleurtTokenizer
|
12 |
+
|
13 |
+
config = BleurtConfig.from_pretrained('lucadiliello/bleurt-tiny-512')
|
14 |
+
model = BleurtForSequenceClassification.from_pretrained('lucadiliello/bleurt-tiny-512')
|
15 |
+
tokenizer = BleurtTokenizer.from_pretrained('lucadiliello/bleurt-tiny-512')
|
16 |
+
|
17 |
+
references = ["a bird chirps by the window", "this is a random sentence"]
|
18 |
+
candidates = ["a bird chirps by the window", "this looks like a random sentence"]
|
19 |
+
|
20 |
+
model.eval()
|
21 |
+
with torch.no_grad():
|
22 |
+
inputs = tokenizer(references, candidates, padding='longest', return_tensors='pt')
|
23 |
+
res = model(**inputs).logits.flatten().tolist()
|
24 |
+
print(res)
|
25 |
+
# [0.8606632947921753, 0.7198279500007629]
|
26 |
+
```
|
27 |
+
|
28 |
+
Take a look at this [repository](https://github.com/lucadiliello/bleurt-pytorch) for the definition of `BleurtConfig`, `BleurtForSequenceClassification` and `BleurtTokenizer` in PyTorch.
|