etomoscow commited on
Commit
1fa3dd7
·
verified ·
1 Parent(s): 2c22bac

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +5 -5
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
- # prepare the input
23
- batch = tokenizer.encode('you are amazing', return_tensors='pt')
24
 
25
- # inference
26
- model(batch)
 
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