Commit 173b2bc3 authored by Baber's avatar Baber
Browse files

Merge branch 'main' into humaneval

# Conflicts:
#	lm_eval/api/task.py
parents 74344829 bb098f13
task: arabic_leaderboard_acva_communication_light
dataset_path: arcee-globe/ACVA-10percent
dataset_name: communication
output_type: multiple_choice
training_split: null
validation_split: validation
test_split: test
process_docs: !function utils.process_docs
doc_to_text: "{{query}}"
doc_to_target: "{{gold}}"
doc_to_choice: "choices"
fewshot_split: validation
fewshot_config:
sampler: first_n
metric_list:
- metric: acc
aggregation: mean
higher_is_better: true
- metric: acc_norm
aggregation: mean
higher_is_better: true
metadata:
version: 1.0
task: arabic_leaderboard_acva_computer_and_phone_light
dataset_path: arcee-globe/ACVA-10percent
dataset_name: computer_and_phone
output_type: multiple_choice
training_split: null
validation_split: validation
test_split: test
process_docs: !function utils.process_docs
doc_to_text: "{{query}}"
doc_to_target: "{{gold}}"
doc_to_choice: "choices"
fewshot_split: validation
fewshot_config:
sampler: first_n
metric_list:
- metric: acc
aggregation: mean
higher_is_better: true
- metric: acc_norm
aggregation: mean
higher_is_better: true
metadata:
version: 1.0
task: arabic_leaderboard_acva_daily_life_light
dataset_path: arcee-globe/ACVA-10percent
dataset_name: daily_life
output_type: multiple_choice
training_split: null
validation_split: validation
test_split: test
process_docs: !function utils.process_docs
doc_to_text: "{{query}}"
doc_to_target: "{{gold}}"
doc_to_choice: "choices"
fewshot_split: validation
fewshot_config:
sampler: first_n
metric_list:
- metric: acc
aggregation: mean
higher_is_better: true
- metric: acc_norm
aggregation: mean
higher_is_better: true
metadata:
version: 1.0
task: arabic_leaderboard_acva_entertainment_light
dataset_path: arcee-globe/ACVA-10percent
dataset_name: entertainment
output_type: multiple_choice
training_split: null
validation_split: validation
test_split: test
process_docs: !function utils.process_docs
doc_to_text: "{{query}}"
doc_to_target: "{{gold}}"
doc_to_choice: "choices"
fewshot_split: validation
fewshot_config:
sampler: first_n
metric_list:
- metric: acc
aggregation: mean
higher_is_better: true
- metric: acc_norm
aggregation: mean
higher_is_better: true
metadata:
version: 1.0
group: arabic_leaderboard_acva_light
task:
- arabic_leaderboard_acva_Algeria_light
- arabic_leaderboard_acva_Ancient_Egypt_light
- arabic_leaderboard_acva_Arab_Empire_light
- arabic_leaderboard_acva_Arabic_Architecture_light
- arabic_leaderboard_acva_Arabic_Art_light
- arabic_leaderboard_acva_Arabic_Astronomy_light
- arabic_leaderboard_acva_Arabic_Calligraphy_light
- arabic_leaderboard_acva_Arabic_Ceremony_light
- arabic_leaderboard_acva_Arabic_Clothing_light
- arabic_leaderboard_acva_Arabic_Culture_light
- arabic_leaderboard_acva_Arabic_Food_light
- arabic_leaderboard_acva_Arabic_Funeral_light
- arabic_leaderboard_acva_Arabic_Geography_light
- arabic_leaderboard_acva_Arabic_History_light
- arabic_leaderboard_acva_Arabic_Language_Origin_light
- arabic_leaderboard_acva_Arabic_Literature_light
- arabic_leaderboard_acva_Arabic_Math_light
- arabic_leaderboard_acva_Arabic_Medicine_light
- arabic_leaderboard_acva_Arabic_Music_light
- arabic_leaderboard_acva_Arabic_Ornament_light
- arabic_leaderboard_acva_Arabic_Philosophy_light
- arabic_leaderboard_acva_Arabic_Physics_and_Chemistry_light
- arabic_leaderboard_acva_Arabic_Wedding_light
- arabic_leaderboard_acva_Bahrain_light
- arabic_leaderboard_acva_Comoros_light
- arabic_leaderboard_acva_Egypt_modern_light
- arabic_leaderboard_acva_InfluenceFromAncientEgypt_light
- arabic_leaderboard_acva_InfluenceFromByzantium_light
- arabic_leaderboard_acva_InfluenceFromChina_light
- arabic_leaderboard_acva_InfluenceFromGreece_light
- arabic_leaderboard_acva_InfluenceFromIslam_light
- arabic_leaderboard_acva_InfluenceFromPersia_light
- arabic_leaderboard_acva_InfluenceFromRome_light
- arabic_leaderboard_acva_Iraq_light
- arabic_leaderboard_acva_Islam_Education_light
- arabic_leaderboard_acva_Islam_branches_and_schools_light
- arabic_leaderboard_acva_Islamic_law_system_light
- arabic_leaderboard_acva_Jordan_light
- arabic_leaderboard_acva_Kuwait_light
- arabic_leaderboard_acva_Lebanon_light
- arabic_leaderboard_acva_Libya_light
- arabic_leaderboard_acva_Mauritania_light
- arabic_leaderboard_acva_Mesopotamia_civilization_light
- arabic_leaderboard_acva_Morocco_light
- arabic_leaderboard_acva_Oman_light
- arabic_leaderboard_acva_Palestine_light
- arabic_leaderboard_acva_Qatar_light
- arabic_leaderboard_acva_Saudi_Arabia_light
- arabic_leaderboard_acva_Somalia_light
- arabic_leaderboard_acva_Sudan_light
- arabic_leaderboard_acva_Syria_light
- arabic_leaderboard_acva_Tunisia_light
- arabic_leaderboard_acva_United_Arab_Emirates_light
- arabic_leaderboard_acva_Yemen_light
- arabic_leaderboard_acva_communication_light
- arabic_leaderboard_acva_computer_and_phone_light
- arabic_leaderboard_acva_daily_life_light
- arabic_leaderboard_acva_entertainment_light
aggregate_metric_list:
- metric: acc
aggregation: mean
weight_by_size: true
- metric: acc_norm
aggregation: mean
weight_by_size: true
metadata:
version: 1.0
import datasets
import numpy as np
def process_docs(dataset: datasets.Dataset):
def _process_doc(doc):
question = doc["question"]
answer = doc["answer"]
return {
"query": f"السؤال: {question}\nالإجابة:",
"choices": ["صح", "خطأ"],
"gold": ["صح", "خطأ"].index(answer),
}
return dataset.map(_process_doc)
group: arabic_leaderboard_light
task:
- arabic_leaderboard_acva_light
- arabic_leaderboard_alghafa_light
- arabic_leaderboard_arabic_exams_light
- arabic_leaderboard_arabic_mt_arc_challenge_light
- arabic_leaderboard_arabic_mt_arc_easy_light
- arabic_leaderboard_arabic_mt_boolq_light
- arabic_leaderboard_arabic_mt_hellaswag_light
- arabic_leaderboard_arabic_mt_mmlu_light
- arabic_leaderboard_arabic_mt_copa_light
- arabic_leaderboard_arabic_mt_openbook_qa_light
- arabic_leaderboard_arabic_mt_piqa_light
- arabic_leaderboard_arabic_mt_race_light
- arabic_leaderboard_arabic_mt_sciq_light
- arabic_leaderboard_arabic_mt_toxigen_light
aggregate_metric_list:
- metric: acc
aggregation: mean
weight_by_size: true
- metric: acc_norm
aggregation: mean
weight_by_size: true
metadata:
version: 1.0
# ArabicMMLU
### Paper
Title: ArabicMMLU: Assessing Massive Multitask Language Understanding in Arabic
Abstract: https://arxiv.org/abs/2402.12840
The focus of language model evaluation has
transitioned towards reasoning and knowledge intensive tasks, driven by advancements in pretraining large models. While state-of-the-art models are partially trained on large Arabic texts, evaluating their performance in Arabic remains challenging due to the limited availability of relevant datasets. To bridge this gap, we present ArabicMMLU, the first multi-task language understanding benchmark for Arabic language, sourced from school exams across diverse educational levels in different countries spanning North Africa, the Levant, and the Gulf regions. Our data comprises 40 tasks and 14,575 multiple-choice questions in Modern Standard Arabic (MSA), and is carefully constructed by collaborating with native speakers in the region. Our comprehensive evaluations of 35 models reveal substantial room for improvement, particularly among the best open-source models. Notably, BLOOMZ, mT0, LLama2, and Falcon struggle to achieve a score of 50%, while even the top-performing Arabic centric model only achieves a score of 62.3%.
The authors of the paper conducted studies by varying the language of the initial prompt and answer keys between English and Arabic. However, they set English initial prompts and answer keys as the standard, which is the version implemented in this task.
Homepage: https://github.com/mbzuai-nlp/ArabicMMLU
### Citation
```
@misc{koto2024arabicmmlu,
title={ArabicMMLU: Assessing Massive Multitask Language Understanding in Arabic},
author={Fajri Koto and Haonan Li and Sara Shatnawi and Jad Doughman and Abdelrahman Boda Sadallah and Aisha Alraeesi and Khalid Almubarak and Zaid Alyafeai and Neha Sengupta and Shady Shehata and Nizar Habash and Preslav Nakov and Timothy Baldwin},
year={2024},
eprint={2402.12840},
archivePrefix={arXiv},
primaryClass={id='cs.CL' full_name='Computation and Language' is_active=True alt_name='cmp-lg' in_archive='cs' is_general=False description='Covers natural language processing. Roughly includes material in ACM Subject Class I.2.7. Note that work on artificial languages (programming languages, logics, formal systems) that does not explicitly address natural-language issues broadly construed (natural-language processing, computational linguistics, speech, text retrieval, etc.) is not appropriate for this area.'}
}
```
### Groups and Tasks
#### Groups
* `arabicmmlu`: evaluates all ArabicMMLU tasks.
* `arabicmmlu_stem`: evaluates STEM ArabicMMLU tasks.
* `arabicmmlu_stem_social_science`: evaluates social science ArabicMMLU tasks.
* `arabicmmlu_stem_humanities`: evaluates humanities ArabicMMLU tasks.
* `arabicmmlu_stem_language`: evaluates Arabic language ArabicMMLU tasks.
* `arabicmmlu_stem_other`: evaluates other ArabicMMLU tasks.
group: arabicmmlu
task:
- arabicmmlu_other
- arabicmmlu_social_science
- arabicmmlu_humanities
- arabicmmlu_stem
- arabicmmlu_language
aggregate_metric_list:
- metric: acc
weight_by_size: True
metadata:
version: 0
group: arabicmmlu_humanities
group_alias: Humanities
task:
- arabicmmlu_humanities_tasks
aggregate_metric_list:
- metric: acc
weight_by_size: True
metadata:
version: 0
group: arabicmmlu_language
group_alias: Language
task:
- arabicmmlu_language_tasks
aggregate_metric_list:
- metric: acc
weight_by_size: True
metadata:
version: 0
group: arabicmmlu_other
group_alias: Other
task:
- arabicmmlu_other_tasks
aggregate_metric_list:
- metric: acc
weight_by_size: True
metadata:
version: 0
group: arabicmmlu_social_science
group_alias: Social Science
task:
- arabicmmlu_social_science_tasks
aggregate_metric_list:
- metric: acc
weight_by_size: True
metadata:
version: 0
group: arabicmmlu_stem
group_alias: STEM
task:
- arabicmmlu_stem_tasks
aggregate_metric_list:
- metric: acc
weight_by_size: True
metadata:
version: 0
dataset_path: yazeed7/ArabicMMLU
test_split: test
fewshot_split: dev
fewshot_config:
sampler: first_n
output_type: multiple_choice
doc_to_text: !function utils.doc_to_text
doc_to_choice: !function utils.doc_to_choice
doc_to_target: "Answer Key"
metric_list:
- metric: acc
aggregation: mean
higher_is_better: true
metadata:
version: 0.0
"""
Take in a YAML, and output all "other" splits with this YAML
"""
import argparse
import logging
import os
import yaml
from tqdm import tqdm
eval_logger = logging.getLogger("lm-eval")
SUBJECTS = {
"Driving Test": "other",
"High Geography": "social_science",
"High History": "humanities",
"Islamic Studies": "humanities",
"Univ Accounting": "social_science",
"Primary General Knowledge": "other",
"Univ Political Science": "social_science",
"Primary Math": "stem",
"Middle General Knowledge": "other",
"High Biology": "stem",
"Primary Natural Science": "stem",
"High Economics": "social_science",
"Middle Natural Science": "stem",
"Middle Geography": "social_science",
"Primary Social Science": "social_science",
"Middle Computer Science": "stem",
"Middle Islamic Studies": "humanities",
"Primary Computer Science": "stem",
"High Physics": "stem",
"Middle Social Science": "social_science",
"Middle Civics": "social_science",
"High Computer Science": "stem",
"General Knowledge": "other",
"High Civics": "social_science",
"Prof Law": "humanities",
"High Islamic Studies": "humanities",
"Primary Arabic Language": "language",
"High Arabic Language": "language",
"Arabic Language (Grammar)": "language",
"Primary History": "humanities",
"Middle History": "humanities",
"Univ Economics": "social_science",
"Arabic Language (General)": "language",
"Univ Computer Science": "stem",
"Primary Islamic Studies": "humanities",
"Primary Geography": "social_science",
"High Philosophy": "humanities",
"Middle Arabic Language": "language",
"Middle Economics": "social_science",
"Univ Management": "other",
}
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--base_yaml_path", default="_default_arabicmmlu_template_yaml")
parser.add_argument("--save_prefix_path", default="arabicmmlu")
return parser.parse_args()
if __name__ == "__main__":
args = parse_args()
# get filename of base_yaml so we can `"include": ` it in our "other" YAMLs.
base_yaml_name = os.path.split(args.base_yaml_path)[-1]
with open(args.base_yaml_path, encoding="utf-8") as f:
base_yaml = yaml.full_load(f)
ALL_CATEGORIES = []
for subject, category in tqdm(SUBJECTS.items()):
if category not in ALL_CATEGORIES:
ALL_CATEGORIES.append(category)
# description = f"The following are multiple choice questions (with answers) about {' '.join(subject.split('_'))}.\n\n"
yaml_dict = {
"include": base_yaml_name,
"tag": f"arabicmmlu_{category}",
"task": f"arabicmmlu_{subject.lower().replace(' ', '_')}",
"task_alias": subject,
"dataset_name": subject,
# "description": description,
}
file_save_path = (
args.save_prefix_path
+ f"_{subject.lower().replace(' ', '_').replace('(', '').replace(')', '')}.yaml"
)
eval_logger.info(f"Saving yaml for subset {subject} to {file_save_path}")
with open(file_save_path, "w", encoding="utf-8") as yaml_file:
yaml.dump(
yaml_dict,
yaml_file,
allow_unicode=True,
default_style='"',
)
arabicmmlu_subcategories = [f"arabicmmlu_{category}" for category in ALL_CATEGORIES]
file_save_path = args.save_prefix_path + ".yaml"
eval_logger.info(f"Saving benchmark config to {file_save_path}")
with open(file_save_path, "w", encoding="utf-8") as yaml_file:
yaml.dump(
{
"group": "arabicmmlu",
"task": arabicmmlu_subcategories,
},
yaml_file,
indent=4,
default_flow_style=False,
)
"dataset_name": "Arabic Language (General)"
"tag": "arabicmmlu_language_tasks"
"include": "_default_arabicmmlu_template_yaml"
"task": "arabicmmlu_arabic_language_(general)"
"task_alias": "Arabic Language (General)"
"dataset_name": "Arabic Language (Grammar)"
"tag": "arabicmmlu_language_tasks"
"include": "_default_arabicmmlu_template_yaml"
"task": "arabicmmlu_arabic_language_(grammar)"
"task_alias": "Arabic Language (Grammar)"
"dataset_name": "Driving Test"
"tag": "arabicmmlu_other_tasks"
"include": "_default_arabicmmlu_template_yaml"
"task": "arabicmmlu_driving_test"
"task_alias": "Driving Test"
"dataset_name": "General Knowledge"
"tag": "arabicmmlu_other_tasks"
"include": "_default_arabicmmlu_template_yaml"
"task": "arabicmmlu_general_knowledge"
"task_alias": "General Knowledge"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment