英文

XLM-RoBERTa large用于QA(波斯QA - ??)

该模型是在 PersianQA 数据集上对 xlm-roberta-large 进行微调的版本。

超参数

在训练过程中使用了以下超参数:

  • 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

性能

使用官方 eval script 对eval集进行评估的结果。

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

用法

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 = """
شب یَلدا یا شب چلّه یکی از کهن‌ترین جشن‌های ایرانی است. 
در این جشن، طی شدن بلندترین شب سال و به دنبال آن بلندتر شدن طول روزها
 در نیم‌کرهٔ شمالی، که مصادف با انقلاب زمستانی است، گرامی داشته می‌شود. 
نام دیگر این شب «چِلّه» است، زیرا برگزاری این جشن، یک آیین ایرانی‌است.
"""
# Translation [EN]
# context = [
  # Yalda night or Cheleh night is one of the oldest Iranian celebrations. 
  # The festival celebrates the longest night of the year, followed by longer days in the Northern Hemisphere, 
  # which coincides with the Winter Revolution. 
  # Another name for this night is "Chelleh", because holding this celebration is an Iranian ritual.
# ]


questions = [
    "نام دیگر شب یلدا؟",
    "کهن ترین جشن ایرانی‌ها چه است؟",
    "شب یلدا مصادف با چه پدیده‌ای است؟"
]
# Translation [EN]
# questions = [
  # Another name for Yalda night?
  # What is the ancient tradition of Iranian celebration?
  # What phenomenon does Yalda night coincide with?
# ]


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}")

输出

نام دیگر شب یلدا؟ «چِلّه»
کهن ترین جشن ایرانی‌ها چه است؟ شب یَلدا یا شب چلّه
شب یلدا مصادف با چه پدیده‌ای است؟ انقلاب زمستانی

# Translation [EN]
# Another name for Yalda night? Cheleh night
# What is the ancient tradition of Iranian celebration? Yalda night or Chele night
# What phenomenon does Yalda night coincide with? Winter revolution

作者

框架版本

  • Transformers 4.12.0.dev0
  • Pytorch 1.9.1+cu111
  • Datasets 1.12.1
  • Tokenizers 0.10.3