license: mit
datasets:
- xnli
language:
- de
metrics:
- accuracy
pipeline_tag: zero-shot-classification
XLM-ROBERTA-BASE-XNLI-DE
Model description
This model takes the XLM-Roberta-base model which has been continued to pre-traine on a large corpus of Twitter in multiple languages.
It was developed following a similar strategy as introduced as part of the Tweet Eval framework.
The model is further finetuned on the german part of the XNLI training dataset.
Intended Usage
This model was developed to do Zero-Shot Text Classification in the realm of Hate Speech Detection. It is focused on the language of german as it was finetuned on data in said language. Since the base model was pre-trained on 100 different languages it has shown some effectiveness in other languages. Please refer to the list of languages in the XLM Roberta paper
Usage with Zero-Shot Classification pipeline
from transformers import pipeline
classifier = pipeline("zero-shot-classification",
model="morit/german_xlm_xnli")
After loading the model you can classify sequences in the languages mentioned above. You can specify your sequences and a matching hypothesis to be able to classify your proposed candidate labels.
equence_to_classify = "Ich glaube Olaf Scholz wird sich im Bundestag durchsetzen."
# we can specify candidate labels and hypothesis:
candidate_labels = ["Politik", "Sport"]
hypothesis_template = "Dieses Beispiel ist {}"
# classify using the information provided
classifier(sequence_to_classify, candidate_labels, hypothesis_template=hypothesis_template)
# Output
# {'sequence': 'Ich glaube Olaf Scholz wird sich im Bundestag durchsetzen.',
# 'labels': ['Politik', 'Sport'],
# 'scores': [0.6338292956352234, 0.3661706745624542]}
Training
This model was pre-trained on a set of 100 languages and follwed further training on 198M multilingual tweets as described in the original paper. Further it was trained on the training set of XNLI dataset in german which is a machine translated version of the MNLI dataset. It was trained on 3 epochs and the following specifications
- learning rate: 5e-5
- batch size: 32
- max sequence: length 128
on one GPU (NVIDIA GeForce RTX 3090) resulting in a training time of 1h 47 mins.
Evaluation
The model was evaluated after each epoch on the eval set of the XNLI Corpus and at the end of training on the Test set of the XNLI corpus. Using the test set the model reached an accuracy of
predict_accuracy = 76.81 %