lucadiliello
commited on
Commit
•
59bd2b7
1
Parent(s):
d0487c4
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-base-512')
|
14 |
+
model = BleurtForSequenceClassification.from_pretrained('lucadiliello/bleurt-base-512')
|
15 |
+
tokenizer = BleurtTokenizer.from_pretrained('lucadiliello/bleurt-base-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 |
+
# [1.1482683420181274, 0.7443546056747437]
|
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.
|