Skip to content

Commit d7a1f11

Browse files
Add custom task (bac-fr) for evaluation of models in french (#518)
* Add custom task (bac-fr) for evaluation of models in french * Update prompt function for the bac-fr task Co-authored-by: Clémentine Fourrier <[email protected]> * Add metrics for the evaluation of bac-fr * Fix function name (as_list) * Fix prompt for multichoice --------- Co-authored-by: Clémentine Fourrier <[email protected]>
1 parent be7da17 commit d7a1f11

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

community_tasks/french_evals.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
from lighteval.tasks.extended.ifeval.main import ifeval_metrics
4747
from lighteval.tasks.lighteval_task import LightevalTaskConfig
4848
from lighteval.tasks.requests import Doc
49+
from lighteval.utils.utils import as_list
4950

5051

5152
# Ifeval-fr prompt function
@@ -80,6 +81,22 @@ def prompt_gpqa_fr(line, task_name: str = None):
8081
)
8182

8283

84+
# BAC-fr prompt function
85+
def prompt_bac_fr(line, task_name: str = None):
86+
prompt = f"Enoncé: {line['enonce']}\n{line['instruction']}\n"
87+
if line["choix"] is not None: # Multichoice evaluation
88+
# prompt += "\n".join([f"{LETTER_INDICES[ix]}.{choix}" for ix, choix in enumerate(line["choix"])])
89+
return Doc(
90+
task_name=task_name,
91+
query=prompt,
92+
choices=as_list(line["choix"]),
93+
gold_index=line["choix"].index(line["choix correct"]),
94+
instruction="",
95+
)
96+
else:
97+
return Doc(task_name=task_name, query=prompt, choices=[line["reponse"]], gold_index=0, instruction="")
98+
99+
83100
# IFEVal-fr task
84101

85102

@@ -117,5 +134,23 @@ def prompt_gpqa_fr(line, task_name: str = None):
117134
version=0,
118135
)
119136

137+
# BAC-fr task
138+
bac_fr_task = LightevalTaskConfig(
139+
name="bac-fr",
140+
suite=["community"],
141+
prompt_function=prompt_bac_fr,
142+
hf_repo="fr-gouv-coordination-ia/bac-fr",
143+
hf_subset="default",
144+
hf_avail_splits=["train"],
145+
evaluation_splits=["train"],
146+
few_shots_split=None,
147+
few_shots_select="random_sampling",
148+
generation_size=1,
149+
metric=[Metrics.quasi_exact_match_math, Metrics.exact_match],
150+
stop_sequence=["\n"],
151+
trust_dataset=True,
152+
version=0,
153+
)
154+
120155
# STORE YOUR EVALS
121-
TASKS_TABLE = [ifeval_fr_task, gpqa_fr_task]
156+
TASKS_TABLE = [ifeval_fr_task, gpqa_fr_task, bac_fr_task]

0 commit comments

Comments
 (0)