Transformers
Keras
English
toxicity-classifier / README.md
dieineb's picture
Update README.md
e54570d
|
raw
history blame
2.34 kB
---
license: apache-2.0
language:
- en
---
# Toxicity_model
The Toxicity_model is used to differentiate not toxic from toxic responses.
The model was trained with a dataset composed of toxic_response and non_toxic_response.
## Details
- Size: 4,689,681 parameters
- Dataset: [Toxic Comment Classification Challenge Dataset](https://github.com/tianqwang/Toxic-Comment-Classification-Challenge)
- Language: English
- Number of Training Steps: 20
- Batch size: 16
- Optimizer: Adam
- Learning Rate: 0.001
- GPU: T4
- This repository has the source [code used](https://github.com/Nkluge-correa/teeny-tiny_castle/blob/master/ML%20Intro%20Course/15_toxicity_detection.ipynb) to train this model.
## Usage
⚠️ THE EXAMPLES BELOW CONTAIN TOXIC/OFFENSIVE LANGUAGE ⚠️
```
import tensorflow as tf
toxicity_model = tf.keras.models.load_model('toxicity_model.keras')
with open('toxic_vocabulary.txt', encoding='utf-8') as fp:
vocabulary = [line.strip() for line in fp]
fp.close()
vectorization_layer = tf.keras.layers.TextVectorization(max_tokens=20000,
output_mode="int",
output_sequence_length=100,
vocabulary=vocabulary)
strings = [
'I think you should shut up your big mouth',
'I do not agree with you'
]
preds = toxicity_model.predict(vectorization_layer(strings),verbose=0)
for i, string in enumerate(strings):
print(f'{string}\n')
print(f'Toxic 🤬 {round((1 - preds[i][0]) * 100, 2)}% | Not toxic 😊 {round(preds[i][0] * 100, 2)}\n')
print("_" * 50)
```
This will output the following:
```
I think you should shut up your big mouth
Toxic 🤬 95.73% | Not toxic 😊 4.27
__________________________________________________
I do not agree with you
Toxic 🤬 0.99% | Not toxic 😊 99.01
__________________________________________________
```
# Cite as 🤗
```
@misc{teenytinycastle,
doi = {10.5281/zenodo.7112065},
url = {https://huggingface.co/AiresPucrs/toxicity_model},
author = {Nicholas Kluge Corr{\^e}a},
title = {Teeny-Tiny Castle},
year = {2023},
publisher = {HuggingFace},
journal = {HuggingFace repository},
}
```
## License
The ToxicityModel is licensed under the Apache License, Version 2.0. See the LICENSE file for more details.