🚀 XLM-RoBERTa large for QA (PersianQA - 🇮🇷)
This model is a fine - tuned version of [xlm - roberta - large](https://huggingface.co/xlm - roberta - large) on the PersianQA dataset. It is designed for question - answering tasks, supporting both Persian and multiple languages.
✨ Features
- Multilingual Support: Supports both Persian (
fa
) and multiple languages.
- Question - Answering Task: Specifically fine - tuned for question - answering tasks on the PersianQA dataset.
📦 Installation
The installation steps are not provided in the original README, so this section is skipped.
💻 Usage Examples
Basic Usage
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
model_name_or_path = "m3hrdadfi/xlmr-large-qa-fa"
nlp = pipeline('question-answering', model=model_name_or_path, tokenizer=model_name_or_path)
context = """
شب یَلدا یا شب چلّه یکی از کهنترین جشنهای ایرانی است.
در این جشن، طی شدن بلندترین شب سال و به دنبال آن بلندتر شدن طول روزها
در نیمکرهٔ شمالی، که مصادف با انقلاب زمستانی است، گرامی داشته میشود.
نام دیگر این شب «چِلّه» است، زیرا برگزاری این جشن، یک آیین ایرانیاست.
"""
questions = [
"نام دیگر شب یلدا؟",
"کهن ترین جشن ایرانیها چه است؟",
"شب یلدا مصادف با چه پدیدهای است؟"
]
kwargs = {}
for question in questions:
r = nlp(question=question, context=context, **kwargs)
answer = " ".join([token.strip() for token in r["answer"].strip().split() if token.strip()])
print(f"{question} {answer}")
Advanced Usage
The original README does not provide advanced usage examples, so this part is skipped.
📚 Documentation
Hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e - 05
- train_batch_size: 8
- eval_batch_size: 8
- seed: 42
- gradient_accumulation_steps: 4
- optimizer: Adam with betas=(0.9,0.999) and epsilon = 1e - 08
- lr_scheduler_type: linear
- lr_scheduler_warmup_ratio: 0.1
- num_epochs: 20.0
- mixed_precision_training: Native AMP
Performance
Evaluation results on the eval set with the official eval script.
Evalset
"HasAns_exact": 58.678955453149,
"HasAns_f1": 82.3746683591845,
"HasAns_total": 651,
"NoAns_exact": 86.02150537634408,
"NoAns_f1": 86.02150537634408,
"NoAns_total": 279,
"exact": 66.88172043010752,
"f1": 83.46871946433232,
"total": 930
🔧 Technical Details
The model is based on the XLM - RoBERTa large architecture and is fine - tuned on the PersianQA dataset for question - answering tasks.
📄 License
The original README does not provide license information, so this section is skipped.
👥 Authors
🛠️ Framework versions
- Transformers 4.12.0.dev0
- Pytorch 1.9.1+cu111
- Datasets 1.12.1
- Tokenizers 0.10.3