google/jigsaw_toxicity_pred
Updated • 1.43k • 34
How to use JiaqiLee/robust-bert-jigsaw with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="JiaqiLee/robust-bert-jigsaw") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("JiaqiLee/robust-bert-jigsaw")
model = AutoModelForSequenceClassification.from_pretrained("JiaqiLee/robust-bert-jigsaw")This model is a fine-tuned version of the bert-base-uncased model to classify toxic comments.
The BERT model is finetuned using adversarial training to boost robustness against textual adversarial attacks.
You can use the model with the following code.
from transformers import BertForSequenceClassification, BertTokenizer, TextClassificationPipeline
model_path = "JiaqiLee/robust-bert-jigsaw"
tokenizer = BertTokenizer.from_pretrained(model_path)
model = BertForSequenceClassification.from_pretrained(model_path, num_labels=2)
pipeline = TextClassificationPipeline(model=model, tokenizer=tokenizer)
print(pipeline("You're a fucking nerd."))
The training data comes from this Kaggle competition. We use 90% of the train.csv data to train the model.
We augment original training data with adversarial examples generated by PWWS, TextBugger and TextFooler.
The model achieves 0.95 AUC in a 1500 rows held-out test set.