Update README.md
Browse files
README.md
CHANGED
|
@@ -13,17 +13,17 @@ This model is trained for toxicity classification task. The dataset used for tra
|
|
| 13 |
|
| 14 |
## How to use
|
| 15 |
```python
|
|
|
|
| 16 |
from transformers import RobertaTokenizer, RobertaForSequenceClassification
|
| 17 |
|
| 18 |
-
# load tokenizer and model weights
|
| 19 |
tokenizer = RobertaTokenizer.from_pretrained('s-nlp/roberta_toxicity_classifier')
|
| 20 |
model = RobertaForSequenceClassification.from_pretrained('s-nlp/roberta_toxicity_classifier')
|
| 21 |
|
| 22 |
-
|
| 23 |
-
batch = tokenizer.encode('you are amazing', return_tensors='pt')
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
```
|
| 28 |
|
| 29 |
## Citation
|
|
|
|
| 13 |
|
| 14 |
## How to use
|
| 15 |
```python
|
| 16 |
+
import torch
|
| 17 |
from transformers import RobertaTokenizer, RobertaForSequenceClassification
|
| 18 |
|
|
|
|
| 19 |
tokenizer = RobertaTokenizer.from_pretrained('s-nlp/roberta_toxicity_classifier')
|
| 20 |
model = RobertaForSequenceClassification.from_pretrained('s-nlp/roberta_toxicity_classifier')
|
| 21 |
|
| 22 |
+
batch = tokenizer.encode("You are amazing!", return_tensors="pt")
|
|
|
|
| 23 |
|
| 24 |
+
output = model(batch)
|
| 25 |
+
predicted_label = torch.sigmoid(output.logits).argmax().item()
|
| 26 |
+
# 0 for neutral, 1 for toxic
|
| 27 |
```
|
| 28 |
|
| 29 |
## Citation
|