Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
inference: false
|
5 |
+
pipeline_tag: token-classification
|
6 |
+
tags:
|
7 |
+
- toxicity
|
8 |
+
- bias
|
9 |
+
- roberta
|
10 |
+
license: apache-2.0
|
11 |
+
---
|
12 |
+
|
13 |
+
# ONNX version of unitary/unbiased-toxic-roberta
|
14 |
+
|
15 |
+
**This model is a conversion of [unitary/unbiased-toxic-roberta](https://huggingface.co/unitary/unbiased-toxic-roberta) to ONNX** format using the [🤗 Optimum](https://huggingface.co/docs/optimum/index) library.
|
16 |
+
|
17 |
+
Trained models & code to predict toxic comments on 3 Jigsaw challenges: Toxic comment classification, Unintended Bias in Toxic comments, Multilingual toxic comment classification.
|
18 |
+
|
19 |
+
Built by [Laura Hanu](https://laurahanu.github.io/) at [Unitary](https://www.unitary.ai/).
|
20 |
+
|
21 |
+
**⚠️ Disclaimer:**
|
22 |
+
The huggingface models currently give different results to the detoxify library (see issue [here](https://github.com/unitaryai/detoxify/issues/15)).
|
23 |
+
|
24 |
+
## Labels
|
25 |
+
All challenges have a toxicity label. The toxicity labels represent the aggregate ratings of up to 10 annotators according the following schema:
|
26 |
+
- **Very Toxic** (a very hateful, aggressive, or disrespectful comment that is very likely to make you leave a discussion or give up on sharing your perspective)
|
27 |
+
- **Toxic** (a rude, disrespectful, or unreasonable comment that is somewhat likely to make you leave a discussion or give up on sharing your perspective)
|
28 |
+
- **Hard to Say**
|
29 |
+
- **Not Toxic**
|
30 |
+
|
31 |
+
More information about the labelling schema can be found [here](https://www.kaggle.com/c/jigsaw-unintended-bias-in-toxicity-classification/data).
|
32 |
+
|
33 |
+
### Toxic Comment Classification Challenge
|
34 |
+
This challenge includes the following labels:
|
35 |
+
|
36 |
+
- `toxic`
|
37 |
+
- `severe_toxic`
|
38 |
+
- `obscene`
|
39 |
+
- `threat`
|
40 |
+
- `insult`
|
41 |
+
- `identity_hate`
|
42 |
+
|
43 |
+
### Jigsaw Unintended Bias in Toxicity Classification
|
44 |
+
This challenge has 2 types of labels: the main toxicity labels and some additional identity labels that represent the identities mentioned in the comments.
|
45 |
+
|
46 |
+
Only identities with more than 500 examples in the test set (combined public and private) are included during training as additional labels and in the evaluation calculation.
|
47 |
+
|
48 |
+
- `toxicity`
|
49 |
+
- `severe_toxicity`
|
50 |
+
- `obscene`
|
51 |
+
- `threat`
|
52 |
+
- `insult`
|
53 |
+
- `identity_attack`
|
54 |
+
- `sexual_explicit`
|
55 |
+
|
56 |
+
Identity labels used:
|
57 |
+
- `male`
|
58 |
+
- `female`
|
59 |
+
- `homosexual_gay_or_lesbian`
|
60 |
+
- `christian`
|
61 |
+
- `jewish`
|
62 |
+
- `muslim`
|
63 |
+
- `black`
|
64 |
+
- `white`
|
65 |
+
- `psychiatric_or_mental_illness`
|
66 |
+
|
67 |
+
A complete list of all the identity labels available can be found [here](https://www.kaggle.com/c/jigsaw-unintended-bias-in-toxicity-classification/data).
|
68 |
+
|
69 |
+
## Usage
|
70 |
+
|
71 |
+
Loading the model requires the [🤗 Optimum](https://huggingface.co/docs/optimum/index) library installed.
|
72 |
+
|
73 |
+
```python
|
74 |
+
from optimum.onnxruntime import ORTModelForSequenceClassification
|
75 |
+
from transformers import AutoTokenizer, pipeline
|
76 |
+
|
77 |
+
|
78 |
+
tokenizer = AutoTokenizer.from_pretrained("laiyer/unbiased-toxic-roberta-onnx")
|
79 |
+
model = ORTModelForSequenceClassification.from_pretrained("laiyer/unbiased-toxic-roberta-onnx")
|
80 |
+
classifier = pipeline(
|
81 |
+
task="text-classification",
|
82 |
+
model=model,
|
83 |
+
tokenizer=tokenizer,
|
84 |
+
)
|
85 |
+
|
86 |
+
classifier_output = ner("It's not toxic comment")
|
87 |
+
print(classifier_output)
|
88 |
+
```
|