From 93435646784b6155b405452c01cba84bd2daefdd Mon Sep 17 00:00:00 2001 From: Sinisa Stanivuk Date: Fri, 12 Jul 2024 12:41:39 +0200 Subject: [PATCH 1/6] Adding OZ Eval task --- community_tasks/oz_evals.py | 94 +++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 community_tasks/oz_evals.py diff --git a/community_tasks/oz_evals.py b/community_tasks/oz_evals.py new file mode 100644 index 000000000..8ee0ca6d0 --- /dev/null +++ b/community_tasks/oz_evals.py @@ -0,0 +1,94 @@ +# MIT License + +# Copyright (c) 2024 The HuggingFace Team + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# ruff: noqa: F405, F403, F401 +""" +Custom evaluation tasks for lighteval. + +This file generally creates just a TASKS_TABLE and TASKS_GROUPS which are then imported by LightEval. +This module implements the OZ Eval task for General Knowledge for Serbian language. +See: https://huggingface.co/datasets/DjMel/oz-eval + +In order to have comparable results to ours, please do not forget to run with --use_chat_template +""" + +from lighteval.tasks.lighteval_task import LightevalTaskConfig +from lighteval.tasks.requests import Doc + + +def prompt_fn_oz_eval_task(line, task_name: str = None): + query_template = """Pitanje: {question}\n + Ponuđeni odgovori: + A. {choice_a} + B. {choice_b} + C. {choice_c} + D. {choice_d} + E. {choice_e} + + Krajnji odgovor:""" + + import ast + + options = line["options"].replace("\n", "") + options = ast.literal_eval(options) + + query = query_template.format( + question=line["questions"], + choice_a=options[0], + choice_b=options[1], + choice_c=options[2], + choice_d=options[3], + choice_e=options[4], + ) + + choices = ["A", "B", "C", "D", "E"] + return Doc( + task_name=task_name, + query=query, + choices=choices, + gold_index=choices.index(line["answer"]), + ) + + +oz_eval_task = LightevalTaskConfig( + name="serbian_rag_eval:oi_task", + prompt_function=prompt_fn_oz_eval_task, + suite=["community"], + hf_repo="DjMel/oz-eval", + hf_subset="default", + hf_avail_splits=["test"], + evaluation_splits=["test"], + few_shots_split="test", + few_shots_select="sequential", + metric=["loglikelihood_acc"], + version=0, + trust_dataset=True, +) + + +# STORE YOUR EVALS +TASKS_TABLE = [oz_eval_task] + + +if __name__ == "__main__": + print(t["name"] for t in TASKS_TABLE) + print(len(TASKS_TABLE)) From 47f73fdb5a1b1c6c13195bedebdb692739a2df9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sini=C5=A1a=20Stanivuk?= <51213388+Stopwolf@users.noreply.github.com> Date: Mon, 15 Jul 2024 12:32:25 +0200 Subject: [PATCH 2/6] Update oz_evals.py --- community_tasks/oz_evals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community_tasks/oz_evals.py b/community_tasks/oz_evals.py index 8ee0ca6d0..41aefd972 100644 --- a/community_tasks/oz_evals.py +++ b/community_tasks/oz_evals.py @@ -70,7 +70,7 @@ def prompt_fn_oz_eval_task(line, task_name: str = None): oz_eval_task = LightevalTaskConfig( - name="serbian_rag_eval:oi_task", + name="serbian_evals:oz_task", prompt_function=prompt_fn_oz_eval_task, suite=["community"], hf_repo="DjMel/oz-eval", From 7e69af53cc29e3d5af66218b53e70d13cb35a537 Mon Sep 17 00:00:00 2001 From: Sinisa Stanivuk Date: Thu, 8 Aug 2024 12:07:25 +0200 Subject: [PATCH 3/6] Addressing issues --- community_tasks/oz_evals.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/community_tasks/oz_evals.py b/community_tasks/oz_evals.py index 41aefd972..1754a29f6 100644 --- a/community_tasks/oz_evals.py +++ b/community_tasks/oz_evals.py @@ -25,12 +25,16 @@ Custom evaluation tasks for lighteval. This file generally creates just a TASKS_TABLE and TASKS_GROUPS which are then imported by LightEval. -This module implements the OZ Eval task for General Knowledge for Serbian language. -See: https://huggingface.co/datasets/DjMel/oz-eval + +OZ Eval (sr. Opšte Znanje Evaluacija) dataset was created for the purposes of evaluating General Knowledge of LLM models in Serbian language. +Data consists of 1k+ high-quality questions and answers which were used as part of entry exams at the Faculty of Philosophy and Faculty of Organizational Sciences, University of Belgrade. +The exams test the General Knowledge of students and were used in the enrollment periods from 2003 to 2024. +For more details and results see: https://huggingface.co/datasets/DjMel/oz-eval In order to have comparable results to ours, please do not forget to run with --use_chat_template """ +from lighteval.metrics.metrics import Metrics from lighteval.tasks.lighteval_task import LightevalTaskConfig from lighteval.tasks.requests import Doc @@ -46,10 +50,7 @@ def prompt_fn_oz_eval_task(line, task_name: str = None): Krajnji odgovor:""" - import ast - - options = line["options"].replace("\n", "") - options = ast.literal_eval(options) + options = line['options'] query = query_template.format( question=line["questions"], @@ -77,11 +78,10 @@ def prompt_fn_oz_eval_task(line, task_name: str = None): hf_subset="default", hf_avail_splits=["test"], evaluation_splits=["test"], - few_shots_split="test", - few_shots_select="sequential", - metric=["loglikelihood_acc"], + few_shots_split="null", + few_shots_select="null", + metric=[Metrics.loglikelihood_acc], version=0, - trust_dataset=True, ) From 5d61474e5177a8f82585b5bc20852b9a6ac8f0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sini=C5=A1a=20Stanivuk?= <51213388+Stopwolf@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:56:49 +0200 Subject: [PATCH 4/6] Update community_tasks/oz_evals.py Co-authored-by: Nathan Habib <30601243+NathanHB@users.noreply.github.com> --- community_tasks/oz_evals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community_tasks/oz_evals.py b/community_tasks/oz_evals.py index 1754a29f6..26a627e39 100644 --- a/community_tasks/oz_evals.py +++ b/community_tasks/oz_evals.py @@ -78,7 +78,7 @@ def prompt_fn_oz_eval_task(line, task_name: str = None): hf_subset="default", hf_avail_splits=["test"], evaluation_splits=["test"], - few_shots_split="null", + few_shots_split=None, few_shots_select="null", metric=[Metrics.loglikelihood_acc], version=0, From 531313893f382db3892f18efa8e1c8e11440fbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sini=C5=A1a=20Stanivuk?= <51213388+Stopwolf@users.noreply.github.com> Date: Mon, 26 Aug 2024 10:57:14 +0200 Subject: [PATCH 5/6] Update community_tasks/oz_evals.py Co-authored-by: Nathan Habib <30601243+NathanHB@users.noreply.github.com> --- community_tasks/oz_evals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/community_tasks/oz_evals.py b/community_tasks/oz_evals.py index 26a627e39..69218ba50 100644 --- a/community_tasks/oz_evals.py +++ b/community_tasks/oz_evals.py @@ -79,7 +79,7 @@ def prompt_fn_oz_eval_task(line, task_name: str = None): hf_avail_splits=["test"], evaluation_splits=["test"], few_shots_split=None, - few_shots_select="null", + few_shots_select=None, metric=[Metrics.loglikelihood_acc], version=0, ) From 7b70025dd6605ab47eac646996c894865b059aef Mon Sep 17 00:00:00 2001 From: Sinisa Stanivuk Date: Mon, 26 Aug 2024 11:03:22 +0200 Subject: [PATCH 6/6] Styling changes --- community_tasks/oz_evals.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/community_tasks/oz_evals.py b/community_tasks/oz_evals.py index 69218ba50..6252a20a0 100644 --- a/community_tasks/oz_evals.py +++ b/community_tasks/oz_evals.py @@ -26,8 +26,8 @@ This file generally creates just a TASKS_TABLE and TASKS_GROUPS which are then imported by LightEval. -OZ Eval (sr. Opšte Znanje Evaluacija) dataset was created for the purposes of evaluating General Knowledge of LLM models in Serbian language. -Data consists of 1k+ high-quality questions and answers which were used as part of entry exams at the Faculty of Philosophy and Faculty of Organizational Sciences, University of Belgrade. +OZ Eval (sr. Opšte Znanje Evaluacija) dataset was created for the purposes of evaluating General Knowledge of LLM models in Serbian language. +Data consists of 1k+ high-quality questions and answers which were used as part of entry exams at the Faculty of Philosophy and Faculty of Organizational Sciences, University of Belgrade. The exams test the General Knowledge of students and were used in the enrollment periods from 2003 to 2024. For more details and results see: https://huggingface.co/datasets/DjMel/oz-eval @@ -50,7 +50,7 @@ def prompt_fn_oz_eval_task(line, task_name: str = None): Krajnji odgovor:""" - options = line['options'] + options = line["options"] query = query_template.format( question=line["questions"],