Thomas Müller
commited on
Commit
•
7a58444
1
Parent(s):
55cc1c6
Updates example.
Browse files
README.md
CHANGED
@@ -38,10 +38,18 @@ import numpy as np
|
|
38 |
model = AutoModelForSequenceClassification.from_pretrained("symanto/xlm-roberta-base-snli-mnli-anli-xnli")
|
39 |
tokenizer = AutoTokenizer.from_pretrained("symanto/xlm-roberta-base-snli-mnli-anli-xnli")
|
40 |
|
41 |
-
input_pairs = [
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
logits = model(**inputs).logits
|
44 |
-
probs =
|
|
|
45 |
print("probs", probs)
|
46 |
-
np.testing.assert_almost_equal(probs, [[0.
|
47 |
```
|
|
|
38 |
model = AutoModelForSequenceClassification.from_pretrained("symanto/xlm-roberta-base-snli-mnli-anli-xnli")
|
39 |
tokenizer = AutoTokenizer.from_pretrained("symanto/xlm-roberta-base-snli-mnli-anli-xnli")
|
40 |
|
41 |
+
input_pairs = [
|
42 |
+
("I like this pizza.", "The sentence is positive."),
|
43 |
+
("I like this pizza.", "The sentence is negative."),
|
44 |
+
("I mag diese Pizza.", "Der Satz ist positiv."),
|
45 |
+
("I mag diese Pizza.", "Der Satz ist negativ."),
|
46 |
+
("Me gusta esta pizza.", "Esta frase es positivo."),
|
47 |
+
("Me gusta esta pizza.", "Esta frase es negativo."),
|
48 |
+
]
|
49 |
+
inputs = tokenizer(input_pairs, truncation="only_first", return_tensors="pt", padding=True)
|
50 |
logits = model(**inputs).logits
|
51 |
+
probs = torch.softmax(logits, dim=1)
|
52 |
+
probs = probs[..., [0]].tolist()
|
53 |
print("probs", probs)
|
54 |
+
np.testing.assert_almost_equal(probs, [[0.83], [0.04], [1.00], [0.00], [1.00], [0.00]], decimal=2)
|
55 |
```
|