improve usage example
Browse files
README.md
CHANGED
@@ -14,7 +14,23 @@ More details on the training process and the reproducibility can be found in the
|
|
14 |
You can use the GeNTE Evaluator as follows:
|
15 |
|
16 |
```
|
17 |
-
from transformers import AutoModelForSequenceClassification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
```
|
19 |
|
20 |
## Citation
|
|
|
14 |
You can use the GeNTE Evaluator as follows:
|
15 |
|
16 |
```
|
17 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
18 |
+
|
19 |
+
# load the tokenizer of UmBERTo
|
20 |
+
tokenizer = AutoTokenizer.from_pretrained("Musixmatch/umberto-wikipedia-uncased-v1", do_lower_case=False)
|
21 |
+
|
22 |
+
# load GeNTE Evaluator
|
23 |
+
model = AutoModelForSequenceClassification.from_pretrained("FBK-MT/GeNTE-evaluator")
|
24 |
+
|
25 |
+
# neutral example
|
26 |
+
sample = "Condividiamo il parere di chi ha presentato la relazione che ha posto notevole enfasi sull'informazione in relazione ai rischi e sulla trasparenza, in particolare nel campo sanitario e della sicurezza."
|
27 |
+
input = tokenizer(sample, return_tensors='pt')
|
28 |
+
|
29 |
+
with torch.no_grad():
|
30 |
+
probs = model(**input).logits
|
31 |
+
|
32 |
+
predicted_label = torch.argmax(probs, dim=1).item()
|
33 |
+
print(predicted_label) # 0 is neutral, 1 is gendered
|
34 |
```
|
35 |
|
36 |
## Citation
|