"Plugson/vs/VentoyPlugson/vscode:/vscode.git/clone" did not exist on "17f9e2fd09d973d39885348fee4906da3aa190ac"
Unverified Commit 18297993 authored by Jess's avatar Jess Committed by GitHub
Browse files

AfroBench: How Good are Large Language Models on African Languages? (#2825)



* add afrixnli to task

* add chat completion

* remove chat completion -untested

* afrimmlu added

* afrimmlu folder update

* afrimmlu folder update

* updated prompt

* remove print

* add afrimgsm -direct

* add squad metric

* fix bash script

* remove direct util, update common yaml

* remove print

* add few show. metric fixes

* fix direct path, add bash script for gpt models

* added transate test

* update afrixnli tasks

* update afrixnli tasks

* update metrics for afrixnli

* prompt translations fix

* prompt translations fix

* filter and metric fix -mgsm

* remove squad metric

* remove squad metric

* add f1 score to mgsm

* add f1 score to mgsm

* update native-direct with lin

* change f1 function

* add lin to utils

* add utils

* remove test limit

* remove test configs

* add swahili to mmlu

* change eng to ewe in ewe yaml mmlu

* add squad metric to mgsm, remove whitespace filter

* added translate test

* added afrixnli_translate

* fix exact match valueError

* fix exact match valueError

* restructure mmlu folder

* spacing

* remove afrimmlu_translate folder

* add utility

* format task name, clean ups

* modefied mgsm

* update on afrimgsm

* update on afrimgsm

* removed utils

* other mgsm varieties

* other mgsm varieties

* adding trasnslate direct

* Update translate_direct_yaml

* add manual xnli prompt, add multichoice for openai models, and adapt multichoice metric for openai model

* edit for open models

* Update translate_direct_yaml

* add verbalizer for xnli

* change xnli from multiple choice to generate

* add manual accuracy scores

* revert xnli to multiple choice

* change afrimgsm utils

* revert xnli to multiple_choice

* cleanups and readmes

* remove openai fixes and unused regex

* pr review changes

* revert metrics.py, task.py and extraction.py to main version

* add afrisenti

* utilities

* pulled from main

* add afrixnli

* add afrimmlu

* update afrixnli prompts

* mising senti language

* fix afrisenti prompt 2

* fix afrisenti prompts

* fix afrisenti prompts

* configure task grouping

* add multiple prompts to afrixnli for irokobench

* add multiple prompts to afrimmlu for irokobench

* Update afrixnli_yaml

* fixes and moves

* fixes and moves

* afrimmlu multiple prompts configs

* remove validation set from afrimmlu

* remove eng from afrimmlu translate test

* correct dataset path

* multiple prompts for mgsm

* file restructure

* afribench grouping

* repo restructuring

* repo restructuring

* update exact match to hugging face exact match and add new mgsm language

* remove decontamination

* update generation kwargs

* update generation kwargs for all mgsm prompts

* remove lang

* update generation kwargs for afrimgsm translatetest

* add afrimgsm cot for direct and translate

* remove eng from translate-cot

* add masakhaPOS tasks

* remove changes from task script

* add masakhanews tasks

* add uhura arc easy

* add afriqa and belebele files

* add tags for easier run. add naija rc

* add new metrics and transformation scripts

* fix afriqa swa fewshot split

* add naijarc

* add afrobench lite tasks

* update afrobench

* update afrobench

* remove unverified files to avoid bugs

* remove files not needed

* add afrobench tasks

* add afrobench tasks

* change to version 1

* change to version 1

* update afrobench

* update afrobench

* restore metric to original script

* update readme instructions

* add individual dataset readmes

* add link to collections

* correct run script

* align with main

* align with main

* align with main

* align with main

* align with main

* align with main

* align with main

* align with main

* failed run fixes

* failed run fixes

* add afrimgsm cot

* Apply precommit fixes

* update mafand dataset name

* pull request fixes

* remove afrihate due to availability

---------
Co-authored-by: default avatarIsrael Abebe Azime <azime@cg.uni-saarland.de>
Co-authored-by: default avatarIsrael Abebe Azime <se.israel.abebe@gmail.com>
Co-authored-by: default avatarDavid Adelani <davlanade@gmail.com>
Co-authored-by: default avatartheyorubayesian <akin.o.oladipo@gmail.com>
parent cf51e699
tag:
- afrobench_xqa_tasks
- afriqa_prompt_1
dataset_kwargs: {trust_remote_code: True}
dataset_path: masakhane/afriqa-gold-passages
dataset_name: null
output_type: generate_until
test_split: test
fewshot_split: train
doc_to_target: answer_pivot
should_decontaminate: true
doc_to_decontamination_query: question_lang
generation_kwargs:
until:
- "\n"
do_sample: false
temperature: 0.0
filter_list:
- name: remove_whitespace
filter:
- function: remove_whitespace
- function: take_first
target_delimiter: " "
metric_list:
- metric: exact_match
aggregation: mean
higher_is_better: true
ignore_case: true
ignore_punctuation: true
- "."
- ","
- "\\$"
- metric: f1
aggregation: !function utils.f1
higher_is_better: true
ignore_case: true
ignore_punctuation: true
- "."
- ","
- "\\$"
metadata:
version: 1.0
# Generated by utils.py
dataset_name: bem
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_bem_prompt_1
# Generated by utils.py
dataset_name: fon
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_fon_prompt_1
# Generated by utils.py
dataset_name: hau
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_hau_prompt_1
# Generated by utils.py
dataset_name: ibo
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_ibo_prompt_1
# Generated by utils.py
dataset_name: kin
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_kin_prompt_1
# Generated by utils.py
dataset_name: swa
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
fewshot_split: test
fewshot_config:
sampler: first_n
task: afriqa_swa_prompt_1
# Generated by utils.py
dataset_name: twi
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_twi_prompt_1
# Generated by utils.py
dataset_name: yor
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_yor_prompt_1
# Generated by utils.py
dataset_name: zul
doc_to_text: 'Your task is to answer a qestion given a context.Make sure you respond
with the shortest span containing the answer in the context.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_zul_prompt_1
import re
import string
from collections import Counter
def normalize_answer(s):
"""
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
Lower text and remove punctuation, articles and extra whitespace.
"""
def remove_articles(text):
return re.sub(r"\b(a|an|the)\b", " ", text)
def white_space_fix(text):
return " ".join(text.split())
def remove_punc(text):
exclude = set(string.punctuation)
return "".join(ch for ch in text if ch not in exclude)
def lower(text):
return text.lower()
return white_space_fix(remove_articles(remove_punc(lower(s))))
def f1(items):
"""
Taken from the official evaluation script for v1.1 of the SQuAD dataset.
"""
unzipped_list = list(zip(*items))
golds = unzipped_list[0]
preds = unzipped_list[1]
f1_list = []
for i in range(len(golds)):
prediction_tokens = normalize_answer(preds[i]).split()
references_tokens = normalize_answer(golds[i]).split()
common = Counter(prediction_tokens) & Counter(references_tokens)
num_same = sum(common.values())
if num_same == 0:
f1_score = 0
else:
precision = 1.0 * num_same / len(prediction_tokens)
recall = 1.0 * num_same / len(references_tokens)
f1_score = (2 * precision * recall) / (precision + recall)
f1_list.append(f1_score)
return sum(f1_list) / len(f1_list)
tag:
- afrobench_xqa_tasks
- afriqa_prompt_2
dataset_kwargs: {trust_remote_code: True}
dataset_path: masakhane/afriqa-gold-passages
dataset_name: null
output_type: generate_until
test_split: test
fewshot_split: train
doc_to_target: answer_pivot
should_decontaminate: true
doc_to_decontamination_query: question_lang
generation_kwargs:
until:
- "\n"
do_sample: false
temperature: 0.0
filter_list:
- name: remove_whitespace
filter:
- function: remove_whitespace
- function: take_first
target_delimiter: " "
metric_list:
- metric: exact_match
aggregation: mean
higher_is_better: true
ignore_case: true
ignore_punctuation: true
- "."
- ","
- "\\$"
- metric: f1
aggregation: !function utils.f1
higher_is_better: true
ignore_case: true
ignore_punctuation: true
- "."
- ","
- "\\$"
metadata:
version: 1.0
# Generated by utils.py
dataset_name: bem
doc_to_text: 'Your task is to answer a question given a context. The question is in
Bemba, while the context is in English or French.Make sure you respond with the
shortest span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_bem_prompt_2
# Generated by utils.py
dataset_name: fon
doc_to_text: 'Your task is to answer a question given a context. The question is in
Fon, while the context is in English or French.Make sure you respond with the shortest
span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_fon_prompt_2
# Generated by utils.py
dataset_name: hau
doc_to_text: 'Your task is to answer a question given a context. The question is in
Hausa, while the context is in English or French.Make sure you respond with the
shortest span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_hau_prompt_2
# Generated by utils.py
dataset_name: ibo
doc_to_text: 'Your task is to answer a question given a context. The question is in
Igbo, while the context is in English or French.Make sure you respond with the shortest
span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_ibo_prompt_2
# Generated by utils.py
dataset_name: kin
doc_to_text: 'Your task is to answer a question given a context. The question is in
Kinyarwanda, while the context is in English or French.Make sure you respond with
the shortest span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_kin_prompt_2
# Generated by utils.py
dataset_name: swa
doc_to_text: 'Your task is to answer a question given a context. The question is in
Swahili, while the context is in English or French.Make sure you respond with the
shortest span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
fewshot_split: test
fewshot_config:
sampler: first_n
task: afriqa_swa_prompt_2
# Generated by utils.py
dataset_name: twi
doc_to_text: 'Your task is to answer a question given a context. The question is in
Twi, while the context is in English or French.Make sure you respond with the shortest
span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_twi_prompt_2
# Generated by utils.py
dataset_name: yor
doc_to_text: 'Your task is to answer a question given a context. The question is in
Yoruba, while the context is in English or French.Make sure you respond with the
shortest span in the context that contains the answer.
Question: {{question_lang}}
Context: {{context}}
Answer:'
include: afriqa
task: afriqa_yor_prompt_2
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