Views
No views yet
1from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
2
3# Load model and tokenizer
4tokenizer = AutoTokenizer.from_pretrained('tum-nlp/bert-hateXplain')
5model = AutoModelForSequenceClassification.from_pretrained('tum-nlp/bert-hateXplain')
6
7# Create the pipeline for classification
8hate_classifier = pipeline("text-classification", model=model, tokenizer=tokenizer)
9
10# Predict
11hate_classifier("I like you. I love you")
12