lucadiliello
commited on
Commit
•
835ec32
1
Parent(s):
aecbac6
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-large-128')
|
14 |
+
model = BleurtForSequenceClassification.from_pretrained('lucadiliello/bleurt-large-128')
|
15 |
+
tokenizer = BleurtTokenizer.from_pretrained('lucadiliello/bleurt-large-128')
|
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.088831901550293, 0.8341825604438782]
|
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.
|