Skip to content

Commit fea2cec

Browse files
committed
fix checks
1 parent 55e27bb commit fea2cec

File tree

2 files changed

+63
-20
lines changed

2 files changed

+63
-20
lines changed

auto_commit_fixes.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# Run pre-commit on all files
4+
pre-commit run --all-files
5+
6+
# Run make style as suggested by Clémentine
7+
make style
8+
9+
# Check if there are changes that need to be staged and committed
10+
if ! git diff --quiet; then
11+
echo "Fixing inconsistencies and committing..."
12+
git add .
13+
git commit -m "fix checks"
14+
git push origin main
15+
else
16+
echo "No changes detected."
17+
fi

community_tasks/arabic_evals.py

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
2727
This file generally create just a TASKS_TABLE and TASKS_GROUPS which are then imported by LightEval.
2828
"""
29+
import re
30+
2931
from lighteval.tasks.lighteval_task import LightevalTaskConfig
3032
from lighteval.tasks.requests import Doc
3133
from lighteval.tasks.tasks_prompt_formatting import LETTER_INDICES
32-
import re
3334

3435

3536
# fmt: off
@@ -203,8 +204,8 @@ def arabic_exams(line, task_name: str = None):
203204
# ALGHAFA NATIVE ##
204205
# fmt: off
205206
ALGHAFA_SUBSETS = [
206-
"mcq_exams_test_ar", "meta_ar_dialects", "meta_ar_msa", "multiple_choice_facts_truefalse_balanced_task", "multiple_choice_grounded_statement_soqal_task",
207-
"multiple_choice_grounded_statement_xglue_mlqa_task", "multiple_choice_rating_sentiment_no_neutral_task", "multiple_choice_rating_sentiment_task",
207+
"mcq_exams_test_ar", "meta_ar_dialects", "meta_ar_msa", "multiple_choice_facts_truefalse_balanced_task", "multiple_choice_grounded_statement_soqal_task",
208+
"multiple_choice_grounded_statement_xglue_mlqa_task", "multiple_choice_rating_sentiment_no_neutral_task", "multiple_choice_rating_sentiment_task",
208209
"multiple_choice_sentiment_task"
209210
]
210211
# fmt: on
@@ -262,7 +263,7 @@ def Alghafa(line, task_name: str = None):
262263

263264

264265
# ALGHAFA TRANSLATED ##
265-
# race_ar
266+
# race_ar
266267
race_ar_task = LightevalTaskConfig(
267268
name="race_ar",
268269
prompt_function="Alghafa",
@@ -279,7 +280,7 @@ def Alghafa(line, task_name: str = None):
279280
)
280281

281282

282-
# piqa_ar
283+
# piqa_ar
283284
piqa_ar_task = LightevalTaskConfig(
284285
name="piqa_ar",
285286
prompt_function="Alghafa",
@@ -296,7 +297,7 @@ def Alghafa(line, task_name: str = None):
296297
)
297298

298299

299-
# arc_easy_ar
300+
# arc_easy_ar
300301
arc_easy_ar_task = LightevalTaskConfig(
301302
name="arc_easy_ar",
302303
prompt_function="Alghafa",
@@ -330,7 +331,7 @@ def Alghafa(line, task_name: str = None):
330331
)
331332

332333

333-
# mmlu_okapi_ar
334+
# mmlu_okapi_ar
334335
mmlu_okapi_ar_task = LightevalTaskConfig(
335336
name="mmlu_okapi_ar",
336337
prompt_function="Alghafa",
@@ -347,7 +348,7 @@ def Alghafa(line, task_name: str = None):
347348
)
348349

349350

350-
# openbook_qa_ext_ar
351+
# openbook_qa_ext_ar
351352
openbook_qa_ext_ar_task = LightevalTaskConfig(
352353
name="openbook_qa_ext_ar",
353354
prompt_function="Alghafa",
@@ -364,7 +365,7 @@ def Alghafa(line, task_name: str = None):
364365
)
365366

366367

367-
# boolq_ar
368+
# boolq_ar
368369
boolq_ar_task = LightevalTaskConfig(
369370
name="boolq_ar",
370371
prompt_function="boolq_function",
@@ -380,13 +381,14 @@ def Alghafa(line, task_name: str = None):
380381
trust_dataset=True,
381382
)
382383

384+
383385
def boolq_function(line, task_name: str = None):
384386
question = line["question"]
385387
passage = line["passage"]
386388
answer = "نعم" if line["answer"] else "لا"
387389

388-
query = "بناءً على المقطع التالي:\n{}\n أجب عن هذا السؤال بـ \"نعم\" أو \"لا\":\n{}\nالإجابة:".format(passage, question)
389-
390+
query = 'بناءً على المقطع التالي:\n{}\n أجب عن هذا السؤال بـ "نعم" أو "لا":\n{}\nالإجابة:'.format(passage, question)
391+
390392
return Doc(
391393
task_name=task_name,
392394
query=query,
@@ -397,7 +399,7 @@ def boolq_function(line, task_name: str = None):
397399
)
398400

399401

400-
# copa_ext_ar
402+
# copa_ext_ar
401403
copa_ext_ar_task = LightevalTaskConfig(
402404
name="copa_ext_ar",
403405
prompt_function="copa_function",
@@ -413,6 +415,7 @@ def boolq_function(line, task_name: str = None):
413415
trust_dataset=True,
414416
)
415417

418+
416419
def copa_function(line, task_name: str = None):
417420
premise = line["premise"]
418421
choices = [line["choice1"], line["choice2"]]
@@ -421,7 +424,7 @@ def copa_function(line, task_name: str = None):
421424
answer = line["label"]
422425

423426
query = "{}، {} :\n0) {}\n1) {}\nالإجابة:".format(premise, question, choices[0], choices[1])
424-
427+
425428
return Doc(
426429
task_name=task_name,
427430
query=query,
@@ -432,7 +435,7 @@ def copa_function(line, task_name: str = None):
432435
)
433436

434437

435-
# hellaswag_okapi_ar
438+
# hellaswag_okapi_ar
436439
hellaswag_okapi_ar_task = LightevalTaskConfig(
437440
name="hellaswag_okapi_ar",
438441
prompt_function="hellaswag_function",
@@ -448,9 +451,12 @@ def copa_function(line, task_name: str = None):
448451
trust_dataset=True,
449452
)
450453

454+
451455
def hellaswag_function(line, task_name: str = None):
452456
ctx = re.sub(r"\[.*?\]", "", line["ctx"]) # Remove latin words within brackets
453-
endings = [re.sub(r"\[.*?\]", "", e) for e in eval(line["endings"])] # endings is a string representation of a list
457+
endings = [
458+
re.sub(r"\[.*?\]", "", e) for e in eval(line["endings"])
459+
] # endings is a string representation of a list
454460
answer_index = line["label"]
455461

456462
query = "بناءً على السياق التالي:\n{}\n اختر النهاية الصحيحة من الاقتراحات التالية:\n".format(ctx)
@@ -468,7 +474,7 @@ def hellaswag_function(line, task_name: str = None):
468474
)
469475

470476

471-
# toxigen_ar
477+
# toxigen_ar
472478
toxigen_ar_task = LightevalTaskConfig(
473479
name="toxigen_ar",
474480
prompt_function="toxigen_function",
@@ -484,10 +490,11 @@ def hellaswag_function(line, task_name: str = None):
484490
trust_dataset=True,
485491
)
486492

493+
487494
def toxigen_function(line, task_name: str = None):
488495
text = line["text"]
489-
label = 1 if ((line['toxicity_ai'] + line['toxicity_human']) > 5.5) else 0
490-
query = f"هل العبارة التالية تحض على الكراهية؟ قم بالرد بـ\"نعم\" أو \"لا\".\n'{text}'\nالإجابة:"
496+
label = 1 if ((line["toxicity_ai"] + line["toxicity_human"]) > 5.5) else 0
497+
query = f'هل العبارة التالية تحض على الكراهية؟ قم بالرد بـ"نعم" أو "لا".\n\'{text}\'\nالإجابة:'
491498

492499
return Doc(
493500
task_name=task_name,
@@ -515,13 +522,16 @@ def toxigen_function(line, task_name: str = None):
515522
trust_dataset=True,
516523
)
517524

525+
518526
def sciq_function(line, task_name: str = None):
519527
support = line["support"]
520528
question = line["question"]
521529
choices = [line["distractor1"], line["distractor2"], line["distractor3"], line["correct_answer"]]
522530
answer_index = 3 # The label is always 3 for the correct answer
523531

524-
query = "بناءً على السياق أدناه، اختر الإجابة الصحيحة للسؤال أدناه من قائمة الاقتراحات:\n\nالسياق:\n{}\n\nالسؤال:{}\n\nالإجابات المحتملة:".format(support, question)
532+
query = "بناءً على السياق أدناه، اختر الإجابة الصحيحة للسؤال أدناه من قائمة الاقتراحات:\n\nالسياق:\n{}\n\nالسؤال:{}\n\nالإجابات المحتملة:".format(
533+
support, question
534+
)
525535
for i, choice in enumerate(choices):
526536
query += "\n{}) {}".format(i, choice)
527537
query += "\nالإجابة:"
@@ -536,7 +546,23 @@ def sciq_function(line, task_name: str = None):
536546
)
537547

538548

539-
_TASKS = ARABIC_MMLU_TASKS + ACVA_TASKS + ALGHAFA_TASKS + [arabic_exams_task] + [race_ar_task] + [piqa_ar_task] + [arc_easy_ar_task] + [arc_challenge_okapi_ar_task] + [mmlu_okapi_ar_task] + [openbook_qa_ext_ar_task] + [boolq_ar_task] + [copa_ext_ar_task] + [hellaswag_okapi_ar_task] + [toxigen_ar_task] + [sciq_ar_task]
549+
_TASKS = (
550+
ARABIC_MMLU_TASKS
551+
+ ACVA_TASKS
552+
+ ALGHAFA_TASKS
553+
+ [arabic_exams_task]
554+
+ [race_ar_task]
555+
+ [piqa_ar_task]
556+
+ [arc_easy_ar_task]
557+
+ [arc_challenge_okapi_ar_task]
558+
+ [mmlu_okapi_ar_task]
559+
+ [openbook_qa_ext_ar_task]
560+
+ [boolq_ar_task]
561+
+ [copa_ext_ar_task]
562+
+ [hellaswag_okapi_ar_task]
563+
+ [toxigen_ar_task]
564+
+ [sciq_ar_task]
565+
)
540566

541567
# Convert to dict for lighteval
542568
TASKS_TABLE = [task.as_dict() for task in _TASKS]

0 commit comments

Comments
 (0)