Khayyam is a fine-tuned Persian BERT model for fine-grained, multi-label emotion classification across
28 emotion categories, based on the GoEmotions taxonomy. It is built on top of
ParsBERT v3 and trained on
GoEmotions Persian — a Persian translation of Google's GoEmotions benchmark dataset.
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4model_name = "aydakikio/Khayyam"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
8LABELS = [
9 "admiration", "amusement", "anger", "annoyance", "approval", "caring",
10 "confusion", "curiosity", "desire", "disappointment", "disapproval",
11 "disgust", "embarrassment", "excitement", "fear", "gratitude", "grief",
12 "joy", "love", "nervousness", "optimism", "pride", "realization",
13 "relief", "remorse", "sadness", "surprise", "neutral"
14]
15
16THRESHOLD = 0.3
17
18def predict_emotions(text):
19 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
20 with torch.no_grad():
21 logits = model(**inputs).logits
22 probs = torch.sigmoid(logits).squeeze()
23 predicted = [LABELS[i] for i, p in enumerate(probs) if p >= THRESHOLD]
24 return predicted
25
26# Example
27text = "امروز خیلی خوشحالم، همه چیز عالی پیش رفت!"
28print(predict_emotions(text))
29# → ['joy', 'optimism', 'excitement']
1@misc{ayda_khoshkhan_2026,
2 author = { Ayda Khoshkhan },
3 title = { Khayyam (Revision 4cbc751) },
4 year = 2026,
5 url = { https://huggingface.co/aydakikio/Khayyam },
6 doi = { 10.57967/hf/9089 },
7 publisher = { Hugging Face }
8}
1@article{ParsBERT,
2 title = {ParsBERT: Transformer-based Model for Persian Language Understanding},
3 author = {Mehrdad Farahani and Mohammad Gharachorloo and Marzieh Farahani and Mohammad Manthouri},
4 journal = {Neural Processing Letters},
5 year = {2021},
6 publisher = {Springer}
7}
8
9@inproceedings{demszky-etal-2020-goemotions,
10 title = {{G}o{E}motions: A Dataset of Fine-Grained Emotions},
11 author = {Demszky, Dorottya and Movshovitz-Attias, Dana and Ko, Jeongwoo and Cowen, Alan and Nemade, Gaurav and Ravi, Sujith},
12 booktitle = {Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics},
13 year = {2020},
14 publisher = {Association for Computational Linguistics}
15}
This model is released under the
Apache 2.0 license, consistent with the base model (
HooshvareLab/bert-fa-zwnj-base) and the original GoEmotions dataset.
The training dataset (
aydakikio/goemotion_persian) is licensed under CC BY 4.0.