Domain models

One model per kind of text, trained on all our corpora of that kind.

Each domain model is trained on our corpora of one kind of text. The cross-corpus table also has domain models trained on all corpora; those are not offered for download. Models predict the shared labels, not the corpus-specific labels. If you need more labels, look at the corpus-specific model variants with all labels.

Reset filters

ModelTypeArchitectureLanguageLabelsValidation macro-F1License

Each repository on Hugging Face has the weights (in half precision), a README and card.json with the labels, thresholds and training data. Please cite the papers of the corpora a model was trained on.

How to use these models

The models are Transformers for multi-label classification. If your texts differ from the training data and you have a few hundred labelled texts, we recommend tuning the thresholds on them. With fewer than about 100 texts, stick to our thresholds.

Show code
import json, torch
from huggingface_hub import hf_hub_download
from transformers import AutoModelForSequenceClassification, AutoTokenizer

repo = "bamnlp/emotionhub-xlmr-base-general"   # or any model below
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).float().eval()
card = json.load(open(hf_hub_download(repo, "card.json")))  # labels and tuned thresholds

texts = ["I finally got the letter of acceptance!", "They lied to us, again."]
batch = tokenizer(texts, padding=True, truncation=True, max_length=256, return_tensors="pt")
with torch.no_grad():
    probs = torch.sigmoid(model(**batch).logits)
for text, p in zip(texts, probs):
    emotions = [l for l, x in zip(card["labels"], p) if x >= card["thresholds"][l]]
    print(text, emotions or [card["labels"][int(p.argmax())]])  # at least the most probable one