diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/README.md b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2677d4c151f75880e29101b001ac94789a641768 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/README.md @@ -0,0 +1,58 @@ +# ARC + +### Paper + +Title: Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge + +Abstract: https://arxiv.org/abs/1803.05457 + +The ARC dataset consists of 7,787 science exam questions drawn from a variety +of sources, including science questions provided under license by a research +partner affiliated with AI2. These are text-only, English language exam questions +that span several grade levels as indicated in the files. Each question has a +multiple choice structure (typically 4 answer options). The questions are sorted +into a Challenge Set of 2,590 “hard” questions (those that both a retrieval and +a co-occurrence method fail to answer correctly) and an Easy Set of 5,197 questions. + +Homepage: https://allenai.org/data/arc + + +### Citation + +``` +@article{Clark2018ThinkYH, + title={Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challenge}, + author={Peter Clark and Isaac Cowhey and Oren Etzioni and Tushar Khot and Ashish Sabharwal and Carissa Schoenick and Oyvind Tafjord}, + journal={ArXiv}, + year={2018}, + volume={abs/1803.05457} +} +``` + +### Groups, Tags, and Tasks + +#### Groups + +None. + +#### Tags + +* `ai2_arc`: Evaluates `arc_easy` and `arc_challenge` + +#### Tasks + +* `arc_easy` +* `arc_challenge` + +### Checklist + +For adding novel benchmarks/datasets to the library: +* [ ] Is the task an existing benchmark in the literature? + * [ ] Have you referenced the original paper that introduced the task? + * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [ ] Is the "Main" variant of this task clearly denoted? +* [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/arc_challenge.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/arc_challenge.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2ad5149095e17711073606124968aa174af4c55a --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/arc_challenge.yaml @@ -0,0 +1,3 @@ +include: arc_easy.yaml +task: arc_challenge +dataset_name: ARC-Challenge diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/arc_easy.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/arc_easy.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1b2e369a4e19a37c6a1550a1ab033701fc045621 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/arc/arc_easy.yaml @@ -0,0 +1,23 @@ +tag: + - ai2_arc +task: arc_easy +dataset_path: allenai/ai2_arc +dataset_name: ARC-Easy +output_type: multiple_choice +training_split: train +validation_split: validation +test_split: test +doc_to_text: "Question: {{question}}\nAnswer:" +doc_to_target: "{{choices.label.index(answerKey)}}" +doc_to_choice: "{{choices.text}}" +should_decontaminate: true +doc_to_decontamination_query: "Question: {{question}}\nAnswer:" +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true + - metric: acc_norm + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/README.md b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/README.md new file mode 100644 index 0000000000000000000000000000000000000000..56c9ba289f3ed3af814eb9189f7dbd0ea77dd20b --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/README.md @@ -0,0 +1,76 @@ +# BasqueGLUE + +### Paper + +Title: `BasqueGLUE: A Natural Language Understanding Benchmark for Basque` + +Abstract: `https://aclanthology.org/2022.lrec-1.172/` + +Natural Language Understanding (NLU) technology has improved significantly over the last few years and multitask benchmarks such as GLUE are key to evaluate this improvement in a robust and general way. These benchmarks take into account a wide and diverse set of NLU tasks that require some form of language understanding, beyond the detection of superficial, textual clues. However, they are costly to develop and language-dependent, and therefore they are only available for a small number of languages. In this paper, we present BasqueGLUE, the first NLU benchmark for Basque, a less-resourced language, which has been elaborated from previously existing datasets and following similar criteria to those used for the construction of GLUE and SuperGLUE. We also report the evaluation of two state-of-the-art language models for Basque on BasqueGLUE, thus providing a strong baseline to compare upon. BasqueGLUE is freely available under an open license. + +Homepage: `https://github.com/orai-nlp/BasqueGLUE` + +Title: `Latxa: An Open Language Model and Evaluation Suite for Basque` + +Abstract: `https://arxiv.org/abs/2403.20266` + +The use of BasqueGLUE for evaluating the performance of decoder models in Basque is presented in this paper. + +Homepage: `https://github.com/hitz-zentroa/latxa` + +### Citation + +``` +@InProceedings{urbizu2022basqueglue, + author = {Urbizu, Gorka and San Vicente, Iñaki and Saralegi, Xabier and Agerri, Rodrigo and Soroa, Aitor}, + title = {BasqueGLUE: A Natural Language Understanding Benchmark for Basque}, + booktitle = {Proceedings of the Language Resources and Evaluation Conference}, + month = {June}, + year = {2022}, + address = {Marseille, France}, + publisher = {European Language Resources Association}, + pages = {1603--1612}, + url = {https://aclanthology.org/2022.lrec-1.172} +} + +@misc{etxaniz2024latxa, + title={Latxa: An Open Language Model and Evaluation Suite for Basque}, + author={Julen Etxaniz and Oscar Sainz and Naiara Perez and Itziar Aldabe and German Rigau and Eneko Agirre and Aitor Ormazabal and Mikel Artetxe and Aitor Soroa}, + year={2024}, + eprint={2403.20266}, + archivePrefix={arXiv}, + primaryClass={cs.CL} +} +``` + +### Groups, Tags, and Tasks + +#### Groups + +None. + +#### Tags + +* `basque-glue`: First version of the implementation. Calls all subtasks, but does not average. + +#### Tasks + +* `bhtc_v2`: Topic classification of news extracts with 12 categories. +* `bec2016eu`: Sentiment analysis on tweets about the campaign for the 2016 Basque elections. +* `vaxx_stance`: Stance detection on tweets around the anti-vaccine movement. +* `qnlieu`: Q&A NLI as in [glue/qnli](../glue/qnli). +* `wiceu`: Word-in-Context as in [super_glue/wic](../super_glue/wic). +* `epec_koref_bin`: Correference detection as in [super_glue/wsc](../super_glue/wsc). + +### Checklist + +For adding novel benchmarks/datasets to the library: +* [ ] Is the task an existing benchmark in the literature? + * [ ] Have you referenced the original paper that introduced the task? + * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [ ] Is the "Main" variant of this task clearly denoted? +* [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/bec.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/bec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..87d29aa60a3d5450947339f39646c4be33f335a9 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/bec.yaml @@ -0,0 +1,16 @@ +tag: basque-glue +task: bec2016eu +dataset_path: orai-nlp/basqueGLUE +dataset_name: bec +output_type: multiple_choice +validation_split: validation +test_split: test +doc_to_text: "Testua: {{text}}\nGaldera: Nolako jarrera agertzen du aurreko testuak?\nErantzuna:" +doc_to_target: label +doc_to_choice: ['negatiboa', 'neutrala', 'positiboa'] +metric_list: + - metric: f1 + aggregation: !function utils.micro_f1_score + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/bhtc.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/bhtc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..29b0a494923b249b68b4c71afcfec901b8986f91 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/bhtc.yaml @@ -0,0 +1,16 @@ +tag: basque-glue +task: bhtc_v2 +dataset_path: orai-nlp/basqueGLUE +dataset_name: bhtc +output_type: multiple_choice +validation_split: validation +test_split: test +doc_to_text: "Testua: {{text}}\nGaldera: Zein da aurreko testuaren gaia?\nErantzuna:" +doc_to_target: label +doc_to_choice: ['Ekonomia', 'Euskal Herria', 'Euskara', 'Gizartea', 'Historia', 'Ingurumena', 'Iritzia', 'Komunikazioa', 'Kultura', 'Nazioartea', 'Politika', 'Zientzia'] +metric_list: + - metric: f1 + aggregation: !function utils.micro_f1_score + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/coref.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/coref.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2f64b1927b41ba447d3643c34761b8f790289c2b --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/coref.yaml @@ -0,0 +1,16 @@ +tag: basque-glue +task: epec_koref_bin +dataset_path: orai-nlp/basqueGLUE +dataset_name: coref +output_type: multiple_choice +validation_split: validation +test_split: test +doc_to_text: !function utils.coref_doc_to_text +doc_to_target: label +doc_to_choice: ['ez', 'bai'] +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/qnli.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/qnli.yaml new file mode 100644 index 0000000000000000000000000000000000000000..93dbece6e15080a6b3e29ced5555100f89e7c4ee --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/qnli.yaml @@ -0,0 +1,16 @@ +tag: basque-glue +task: qnlieu +dataset_path: orai-nlp/basqueGLUE +dataset_name: qnli +output_type: multiple_choice +validation_split: validation +test_split: test +doc_to_text: "{{question}}\n{{sentence}}\nGaldera: aurreko galderari erantzuten al dio emandako testuak?\nErantzuna:" +doc_to_target: label +doc_to_choice: ['bai', 'ez'] +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/utils.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..401375f709f765dba749ea275df16bcb19643d9c --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/utils.py @@ -0,0 +1,78 @@ +import html +import re + +from datasets import load_metric + + +def general_detokenize(string): + string = re.sub(r"\s+([.,;:!?)])", r"\1", string) + string = re.sub(r"(\s+|^)\(\s+([^)]+)\s+\)", r"\1(\2)", string) + string = re.sub(r"(\s+|^)\[\s+([^)]+)\s+\]", r"\1[\2]", string) + string = re.sub(r'(\s+|^)"\s+([^"]+)\s+"', r'\1"\2"', string) + string = re.sub(r"(\s+|^)'\s+([^']+)\s+'", r"\1'\2'", string) + return string + + +def process_doc(string): + string = html.unescape(string) + string = general_detokenize(string) + return string + + +def process_wic_docs(dataset): + def _helper(doc): + # there's some issues with the encoding on this one + doc["sentence1"] = ( + process_doc(doc["sentence1"]).encode("latin-1").decode("utf-8") + ) + doc["sentence2"] = ( + process_doc(doc["sentence2"]).encode("latin-1").decode("utf-8") + ) + return doc + + return dataset.map(_helper) + + +def coref_doc_to_text(x): + def _span_in_context(span_index, span_text): + span_start = span_index + span_end = span_start + len(span_text.split(" ")) - 1 + tokens[span_start] = f"*{tokens[span_start]}" + tokens[span_end] = f"{tokens[span_end]}*" + + tokens = x["text"].split(" ") + _span_in_context(x["span1_index"], x["span1_text"]) + _span_in_context( + x["span2_index"] - 1, x["span2_text"] + ) # span1_index is 0-based but span2_index is 1-based ?? + context = process_doc(" ".join(tokens)) + span_1 = process_doc(x["span1_text"]) + span_2 = process_doc(x["span2_text"]) + text = ( + f"Testua: {context}\n" + + f'Galdera: Aurreko testuan, "*{span_1}*" eta "*{span_2}*" gauza bera dira?\n' + + "Erantzuna:" + ) + return text + + +# Measure F1 as in the benchmark repo: https://github.com/orai-nlp/BasqueGLUE/blob/main/eval_basqueglue.py + + +def micro_f1_score(items): + f1_metric = load_metric("f1") + golds, preds = list(zip(*items)) + f1_score = f1_metric.compute(references=golds, predictions=preds, average="micro")[ + "f1" + ] + return f1_score + + +def vaxx_f1_score(items): + f1_metric = load_metric("f1") + golds, preds = list(zip(*items)) + f1_class = f1_metric.compute( + references=golds, predictions=preds, labels=[0, 2], average=None + )["f1"] + f1_score = sum(f1_class) / len(f1_class) + return f1_score diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/vaxx.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/vaxx.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5d5ed6325071965537ab267464e9c51ad09c0bc2 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/vaxx.yaml @@ -0,0 +1,16 @@ +tag: basque-glue +task: vaxx_stance +dataset_path: orai-nlp/basqueGLUE +dataset_name: vaxx +output_type: multiple_choice +validation_split: validation +test_split: test +doc_to_text: "Testua: {{text}}\nGaldera: Nolako jarrera agertzen du aurreko testuak txertoei buruz?\nErantzuna:" +doc_to_target: label +doc_to_choice: ['aurka', 'neutrala', 'alde'] +metric_list: + - metric: f1 + aggregation: !function utils.vaxx_f1_score + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/wic.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/wic.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e64ab694d4f2685edbc2c1262e673cca65130d5c --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/basqueglue/wic.yaml @@ -0,0 +1,17 @@ +tag: basque-glue +task: wiceu +dataset_path: orai-nlp/basqueGLUE +dataset_name: wic +output_type: multiple_choice +validation_split: validation +test_split: test +process_docs: !function utils.process_wic_docs +doc_to_text: "1. esaldia: {{sentence1}}\n2. esaldia: {{sentence2}}\nGaldera: Aurreko bi esaldietan, \"{{word}}\" hitzak esanahi berdina du?\nErantzuna:" +doc_to_target: label +doc_to_choice: ['ez', 'bai'] +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_csatqa.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_csatqa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8b9e30131097d9123f3dbbae3ab250fbcf4f6ad3 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_csatqa.yaml @@ -0,0 +1,17 @@ +group: csatqa +task: + - csatqa_gr + - csatqa_li + - csatqa_rch + - csatqa_rcs + - csatqa_rcss + - csatqa_wr +aggregate_metric_list: + - metric: acc + aggregation: mean + weight_by_size: true + - metric: acc_norm + aggregation: mean + weight_by_size: true +metadata: + version: 0.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_default_csatqa_yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_default_csatqa_yaml new file mode 100644 index 0000000000000000000000000000000000000000..f9039cc1df759c9a5a5fdf502b8933b7664aeb3c --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_default_csatqa_yaml @@ -0,0 +1,16 @@ +dataset_path: EleutherAI/csatqa +test_split: test +output_type: multiple_choice +process_docs: !function utils.process_docs +doc_to_text: "{{question}}" +doc_to_choice: "{{choices}}" +doc_to_target: "{{gold}}" +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true + - metric: acc_norm + aggregation: mean + higher_is_better: true +metadata: + version: 0.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_generate_configs.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_generate_configs.py new file mode 100644 index 0000000000000000000000000000000000000000..567deeeac607c05a1a87dcae09bbd70f3fe71581 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/_generate_configs.py @@ -0,0 +1,51 @@ +""" +Take in a YAML, and output all other splits with this YAML +""" + +import argparse +import os + +import yaml +from tqdm import tqdm + +from lm_eval.logger import eval_logger + + +SUBSETS = ["WR", "GR", "RCS", "RCSS", "RCH", "LI"] + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--base_yaml_path", required=True) + parser.add_argument("--save_prefix_path", default="csatqa") + parser.add_argument("--task_prefix", default="") + 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) + + for name in tqdm(SUBSETS): + yaml_dict = { + "include": base_yaml_name, + "task": f"csatqa_{args.task_prefix}_{name}" + if args.task_prefix != "" + else f"csatqa_{name.lower()}", + "dataset_name": name, + } + + file_save_path = args.save_prefix_path + f"_{name.lower()}.yaml" + eval_logger.info(f"Saving yaml for subset {name} to {file_save_path}") + with open(file_save_path, "w", encoding="utf-8") as yaml_file: + yaml.dump( + yaml_dict, + yaml_file, + width=float("inf"), + allow_unicode=True, + default_style='"', + ) diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_gr.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_gr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..856ba617faa7953582bc8e7956f1a491b31cd2f2 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_gr.yaml @@ -0,0 +1,3 @@ +"dataset_name": "GR" +"include": "_default_csatqa_yaml" +"task": "csatqa_gr" diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_li.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_li.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eb7e178365b95d9562f47f8604a764f31817ea89 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_li.yaml @@ -0,0 +1,3 @@ +"dataset_name": "LI" +"include": "_default_csatqa_yaml" +"task": "csatqa_li" diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rch.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rch.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4eaffaa90c5d10fee0cbeb4c1d9b2b67361dfdc5 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rch.yaml @@ -0,0 +1,3 @@ +"dataset_name": "RCH" +"include": "_default_csatqa_yaml" +"task": "csatqa_rch" diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rcs.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rcs.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e2efcc1704195d51d1548c7b3527593c49be3be2 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rcs.yaml @@ -0,0 +1,3 @@ +"dataset_name": "RCS" +"include": "_default_csatqa_yaml" +"task": "csatqa_rcs" diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rcss.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rcss.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7b099fe2d56b06c3eda2c9624b5a27158c69c26e --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_rcss.yaml @@ -0,0 +1,3 @@ +"dataset_name": "RCSS" +"include": "_default_csatqa_yaml" +"task": "csatqa_rcss" diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_wr.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_wr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6276dfef9b0d53f96c9a7d5fb11fcf5e2d57e87f --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/csatqa_wr.yaml @@ -0,0 +1,3 @@ +"dataset_name": "WR" +"include": "_default_csatqa_yaml" +"task": "csatqa_wr" diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/utils.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..253bc1b6e4c1adeb26c230aca02890d8911e9088 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/csatqa/utils.py @@ -0,0 +1,20 @@ +import datasets + + +def process_docs(dataset: datasets.Dataset) -> datasets.Dataset: + def _process_doc(doc): + instruction = f"""다음을 읽고 정답으로 알맞은 것을 고르시요. +### Context: {doc["context"]} +### Question: {doc["question"]} +### Options: +(1) {doc['option#1']}\n(2) {doc["option#2"]}\n(3) {doc["option#3"]}\n(4) {doc['option#4']}\n(5) {doc['option#5']} +### Answer: 주어진 문제의 정답은""" + + out_doc = { + "question": instruction, + "choices": ["(1)", "(2)", "(3)", "(4)", "(5)"], + "gold": int(doc["gold"]) - 1, + } + return out_doc + + return dataset.map(_process_doc) diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/_fewshot_template_yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/_fewshot_template_yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b09a7c43c351cdafdafeb9fd6169bb5f1cf8a97 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/_fewshot_template_yaml @@ -0,0 +1,16 @@ +dataset_path: SaylorTwift/bbh +output_type: multiple_choice +test_split: test +doc_to_text: 'Q: {{input}} + + A:' +doc_to_target: "{{target}}" +metric_list: + - metric: acc_norm + aggregation: mean + higher_is_better: true +num_fewshot: 3 +fewshot_config: + sampler: first_n +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/causal_judgement.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/causal_judgement.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c3b13360ec9863b0ce431d7ac7ab7383da553f4b --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/causal_judgement.yaml @@ -0,0 +1,62 @@ +dataset_name: causal_judgement +description: 'Answer questions about causal attribution.' +doc_to_choice: ["Yes", "No"] +fewshot_config: + sampler: first_n + samples: + - input: 'How would a typical person answer each of the following questions about + causation? + + Frank T., had an ongoing dispute with his neighbor over a stretch of land and + one day decided to shoot his neighbor in the body. Frank T. had no experience + with guns, his hand slipped on the barrel of the gun, and the shot went wild. + Nonetheless, the bullet bounced off a large boulder several feet away and hit + the neighbor''s body, causing significant injury. Did Frank T. intentionally + shoot his neighbor in the body? + + Options: + + - Yes + + - No' + target: 'No' + - input: 'How would a typical person answer each of the following questions about + causation? + + Suzy and Billy are working on a project that is very important for our nation''s + security. The boss tells them both: "Be sure that you are here at exactly 9 + am. It is absolutely essential that you arrive at that time." Both Billy and + Suzy arrive at 9 am. As it happens, there was a motion detector installed in + the room where they arrived. The motion detector was set up to be triggered + if at least one person appeared in the room at the same time. So the motion + detector went off. Did Billy cause the motion detector to go off? + + Options: + + - Yes + + - No' + target: 'Yes' + - input: 'How would a typical person answer each of the following questions about + causation? + + George and his sister Lena reunite at their parents'' house for Thanksgiving. + Whereas George just got into medical school, Lena is unhappy in her marriage + and recently lost her job. Over the course of the day, George and Lena get into + a number of heated arguments. Later in the afternoon they play a game of darts. + They split the first two games, and the third game is close until the end. Who + will win comes down to George''s last shot. If he hits a high point region, + he wins; if he hits a low point region, Lena wins. George thinks of the difficult + time Lena is having, and he really wants to let her win. He aims the dart at + the low point region. He sets up his shot and the dart lands in the low point + region. After his shot, Lena wins the game and is very happy. Did George hit + the low point region intentionally? + + Options: + + - Yes + + - No' + target: 'Yes' +include: _fewshot_template_yaml +task: leaderboard_bbh_causal_judgement diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/date_understanding.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/date_understanding.yaml new file mode 100644 index 0000000000000000000000000000000000000000..92f35785d7ff4da93d372a87eaf5f0fdb3579187 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/date_understanding.yaml @@ -0,0 +1,55 @@ +dataset_name: date_understanding +description: 'Infer the date from context.' +doc_to_choice: ["(A)", "(B)", "(C)", "(D)", "(E)", "(F)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Today is Christmas Eve of 1937. What is the date 10 days ago in MM/DD/YYYY? + + Options: + + (A) 12/14/2026 + + (B) 12/14/1950 + + (C) 12/14/2007 + + (D) 12/14/1937 + + (E) 07/14/1938 + + (F) 12/14/1988' + target: (D) + - input: 'Tomorrow is 11/12/2019. What is the date one year ago from today in MM/DD/YYYY? + + Options: + + (A) 09/04/2018 + + (B) 11/11/2018 + + (C) 08/25/2018 + + (D) 11/02/2018 + + (E) 11/04/2018' + target: (B) + - input: 'Jane and John married on Jan 2, 1958. It is their 5-year anniversary today. + What is the date tomorrow in MM/DD/YYYY? + + Options: + + (A) 01/11/1961 + + (B) 01/03/1963 + + (C) 01/18/1961 + + (D) 10/14/1960 + + (E) 01/03/1982 + + (F) 12/03/1960' + target: (B) +include: _fewshot_template_yaml +task: leaderboard_bbh_date_understanding diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/disambiguation_qa.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/disambiguation_qa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..91b1ed99fae8eebddef3b023e66c09c3d3eb9861 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/disambiguation_qa.yaml @@ -0,0 +1,48 @@ +dataset_name: disambiguation_qa +description: 'Clarify the meaning of sentences with ambiguous pronouns.' +doc_to_choice: ["(A)", "(B)", "(C)"] +fewshot_config: + sampler: first_n + samples: + - input: 'In the following sentences, explain the antecedent of the pronoun (which + thing the pronoun refers to), or state that it is ambiguous. + + Sentence: The chief told the counselor that they took the day off. + + Options: + + (A) The chief took the day off + + (B) The counselor took the day off + + (C) Ambiguous' + target: (A) + - input: 'In the following sentences, explain the antecedent of the pronoun (which + thing the pronoun refers to), or state that it is ambiguous. + + Sentence: The manager sent a message to the secretary, but he didn''t reply + yet. + + Options: + + (A) The secretary didn''t reply yet + + (B) The manager didn''t reply yet + + (C) Ambiguous' + target: (A) + - input: 'In the following sentences, explain the antecedent of the pronoun (which + thing the pronoun refers to), or state that it is ambiguous. + + Sentence: Bailey will plan to meet the director at his office + + Options: + + (A) It will be Bailey''s office + + (B) It will be the director''s office + + (C) Ambiguous' + target: (C) +include: _fewshot_template_yaml +task: leaderboard_bbh_disambiguation_qa diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_five_objects.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_five_objects.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9f81dddacbc6902f292375ea4f5318cb814ee60f --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_five_objects.yaml @@ -0,0 +1,50 @@ +dataset_name: logical_deduction_five_objects +description: 'A logical deduction task which requires deducing the order of a sequence + of objects.' +doc_to_choice: ["(A)","(B)","(C)","(D)","(E)"] +fewshot_config: + sampler: first_n + samples: + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + In a golf tournament, there were three golfers: Amy, Eli, and Eve. Eve finished + above Amy. Eli finished below Amy. + + Options: + + (A) Amy finished last + + (B) Eli finished last + + (C) Eve finished last' + target: (B) + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + On a shelf, there are three books: a white book, a green book, and an orange + book. The green book is to the right of the white book. The orange book is the + rightmost. + + Options: + + (A) The white book is the leftmost + + (B) The green book is the leftmost + + (C) The orange book is the leftmost' + target: (A) + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + On a shelf, there are three books: a red book, a gray book, and a white book. + The white book is to the left of the gray book. The red book is the second from + the left. + + Options: + + (A) The red book is the leftmost + + (B) The gray book is the leftmost + + (C) The white book is the leftmost' + target: (C) +include: _fewshot_template_yaml +task: leaderboard_bbh_logical_deduction_five_objects diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_seven_objects.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_seven_objects.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ff426ce7ac517a4a3fe352dda8001bc23ad36e07 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_seven_objects.yaml @@ -0,0 +1,50 @@ +dataset_name: logical_deduction_seven_objects +description: 'A logical deduction task which requires deducing the order of a sequence + of objects.' +doc_to_choice: ["(A)","(B)","(C)","(D)","(E)","(F)","(G)"] +fewshot_config: + sampler: first_n + samples: + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + In a golf tournament, there were three golfers: Amy, Eli, and Eve. Eve finished + above Amy. Eli finished below Amy. + + Options: + + (A) Amy finished last + + (B) Eli finished last + + (C) Eve finished last' + target: (B) + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + On a shelf, there are three books: a white book, a green book, and an orange + book. The green book is to the right of the white book. The orange book is the + rightmost. + + Options: + + (A) The white book is the leftmost + + (B) The green book is the leftmost + + (C) The orange book is the leftmost' + target: (A) + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + On a shelf, there are three books: a red book, a gray book, and a white book. + The white book is to the left of the gray book. The red book is the second from + the left. + + Options: + + (A) The red book is the leftmost + + (B) The gray book is the leftmost + + (C) The white book is the leftmost' + target: (C) +include: _fewshot_template_yaml +task: leaderboard_bbh_logical_deduction_seven_objects diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_three_objects.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_three_objects.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e62fe2f412bb276dcee713450e4cdab9a565aca5 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/logical_deduction_three_objects.yaml @@ -0,0 +1,50 @@ +dataset_name: logical_deduction_three_objects +description: 'A logical deduction task which requires deducing the order of a sequence + of objects.' +doc_to_choice: ["(A)","(B)","(C)"] +fewshot_config: + sampler: first_n + samples: + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + In a golf tournament, there were three golfers: Amy, Eli, and Eve. Eve finished + above Amy. Eli finished below Amy. + + Options: + + (A) Amy finished last + + (B) Eli finished last + + (C) Eve finished last' + target: (B) + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + On a shelf, there are three books: a white book, a green book, and an orange + book. The green book is to the right of the white book. The orange book is the + rightmost. + + Options: + + (A) The white book is the leftmost + + (B) The green book is the leftmost + + (C) The orange book is the leftmost' + target: (A) + - input: 'The following paragraphs each describe a set of three objects arranged + in a fixed order. The statements are logically consistent within each paragraph. + On a shelf, there are three books: a red book, a gray book, and a white book. + The white book is to the left of the gray book. The red book is the second from + the left. + + Options: + + (A) The red book is the leftmost + + (B) The gray book is the leftmost + + (C) The white book is the leftmost' + target: (C) +include: _fewshot_template_yaml +task: leaderboard_bbh_logical_deduction_three_objects diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/movie_recommendation.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/movie_recommendation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..61f3bd8f8b5e85392bef2f6541b6a096c3fff1dd --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/movie_recommendation.yaml @@ -0,0 +1,52 @@ +dataset_name: movie_recommendation +description: 'Recommend movies similar to the given list of movies.' +doc_to_choice: ["(A)","(B)","(C)","(D)","(E)","(F)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Find a movie similar to Star Wars Episode IV - A New Hope, Indiana Jones + and the Last Crusade, Star Wars Episode V - The Empire Strikes Back, The Big + Lebowski: + + Options: + + (A) Tetsuo + + (B) the Ironman + + (C) The Princess Bride + + (D) The Barkley Marathons The Race That Eats Its Young + + (E) Bug' + target: (C) + - input: 'Find a movie similar to Twister, The Silence of the Lambs, Independence + Day, Braveheart: + + Options: + + (A) They Shoot Horses + + (B) Don''t They + + (C) Forrest Gump + + (D) The Salton Sea + + (E) Extreme Days' + target: (C) + - input: 'Find a movie similar to Minority Report, Total Recall, Inside Out, Forrest + Gump: + + Options: + + (A) Phenomena + + (B) Lilting + + (C) Catwoman + + (D) Edge of Tomorrow' + target: (D) +include: _fewshot_template_yaml +task: leaderboard_bbh_movie_recommendation diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/navigate.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/navigate.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a0f67261307eb8c7c68fa5e3d1d58177fb53d2f2 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/navigate.yaml @@ -0,0 +1,38 @@ +dataset_name: navigate +description: 'Given a series of navigation instructions, determine whether one would + end up back at the starting point.' +doc_to_choice: ["Yes","No"] +fewshot_config: + sampler: first_n + samples: + - input: 'If you follow these instructions, do you return to the starting point? + Turn left. Turn around. Turn left. Take 7 steps. Take 2 steps. Take 4 steps. + Take 8 steps. + + Options: + + - Yes + + - No' + target: 'No' + - input: 'If you follow these instructions, do you return to the starting point? + Turn around. Take 1 step. Take 6 steps. Turn around. Take 6 steps. Take 9 steps. + Take 1 step. + + Options: + + - Yes + + - No' + target: 'No' + - input: 'If you follow these instructions, do you return to the starting point? + Always face forward. Take 2 steps right. Take 9 steps left. Take 7 steps right. + + Options: + + - Yes + + - No' + target: 'Yes' +include: _fewshot_template_yaml +task: leaderboard_bbh_navigate diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/object_counting.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/object_counting.yaml new file mode 100644 index 0000000000000000000000000000000000000000..88168743ee3841a4daef5979452799e9e50aae1b --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/object_counting.yaml @@ -0,0 +1,18 @@ +dataset_name: object_counting +description: 'Questions that involve enumerating objects and asking the model to count + them.' +doc_to_choice: ["0","1","2","3","4","5","6","7","8","9","10", "11", "12", "13", "14", "15", "16", "17", "18"] +fewshot_config: + sampler: first_n + samples: + - input: I have a blackberry, a clarinet, a nectarine, a plum, a strawberry, a banana, + a flute, an orange, and a violin. How many fruits do I have? + target: '6' + - input: I have an orange, a raspberry, two peaches, a blackberry, an apple, a grape, + a nectarine, and three plums. How many fruits do I have? + target: '11' + - input: I have a lettuce head, a head of broccoli, an onion, a stalk of celery, + two carrots, a garlic, and a yam. How many vegetables do I have? + target: '8' +include: _fewshot_template_yaml +task: leaderboard_bbh_object_counting diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/penguins_in_a_table.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/penguins_in_a_table.yaml new file mode 100644 index 0000000000000000000000000000000000000000..206d6752e54c9ee1c47235eb5e33879c48c2429f --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/penguins_in_a_table.yaml @@ -0,0 +1,66 @@ +dataset_name: penguins_in_a_table +description: 'Answer questions about a table of penguins and their attributes.' +doc_to_choice: ["(A)","(B)","(C)","(D)","(E)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Here is a table where the first line is a header and each subsequent line + is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, + 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis + is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. We now add + a penguin to the table: + + James, 12, 90, 12 + + How many penguins are less than 8 years old? + + Options: + + (A) 1 + + (B) 2 + + (C) 3 + + (D) 4 + + (E) 5' + target: (B) + - input: 'Here is a table where the first line is a header and each subsequent line + is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, + 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis + is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. Which is + the youngest penguin? + + Options: + + (A) Louis + + (B) Bernard + + (C) Vincent + + (D) Gwen + + (E) James' + target: (B) + - input: 'Here is a table where the first line is a header and each subsequent line + is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, + 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis + is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. What is + the name of the second penguin sorted by alphabetic order? + + Options: + + (A) Louis + + (B) Bernard + + (C) Vincent + + (D) Gwen + + (E) James' + target: (D) +include: _fewshot_template_yaml +task: leaderboard_bbh_penguins_in_a_table diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/ruin_names.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/ruin_names.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f3c12367a6e8a67a195ef22d94dcafb9a62e98ba --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/ruin_names.yaml @@ -0,0 +1,48 @@ +dataset_name: ruin_names +description: 'Select the humorous edit that ''ruins'' the input movie or musical artist + name.' +doc_to_choice: ["(A)","(B)","(C)","(D)","(E)","(F)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Which of the following is a humorous edit of this artist or movie name: + ''whitesnake''? + + Options: + + (A) whitesnape + + (B) whitesnapke + + (C) whitesnuake + + (D) mwhitesnake' + target: (A) + - input: 'Which of the following is a humorous edit of this artist or movie name: + ''one of our dinosaurs is missing''? + + Options: + + (A) ofne of our dinosaurs is missing + + (B) one af our dinosaurs is missing + + (C) one of our dinosaurs is pissing + + (D) one of our dinosaur is missing' + target: (C) + - input: 'Which of the following is a humorous edit of this artist or movie name: + ''counting crows''? + + Options: + + (A) countingy crows + + (B) counting cows + + (C) courting crows + + (D) coutnting crows' + target: (B) +include: _fewshot_template_yaml +task: leaderboard_bbh_ruin_names diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/salient_translation_error_detection.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/salient_translation_error_detection.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2ef54c6fc577363c4281d719bedb7779a45fe383 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/salient_translation_error_detection.yaml @@ -0,0 +1,101 @@ +dataset_name: salient_translation_error_detection +description: 'Detect the type of error in an English translation of a German source + sentence.' +doc_to_choice: ["(A)","(B)","(C)","(D)","(E)","(F)"] +fewshot_config: + sampler: first_n + samples: + - input: "The following translations from German to English contain a particular + error. That error will be one of the following types: Named Entities: An entity + (names, places, locations, etc.) is changed to a different entity. Numerical + Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. + Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are + changed. Negation or Antonyms: Introduce or remove a negation or change comparatives + to their antonyms. Facts: Trivial factual errors not pertaining to the above + classes are introduced in the translations. Dropped Content: A significant clause + in the translation is removed. Please identify that error. Source: In der Liste + der Baudenkmale in Lenzen (Elbe) sind alle Baudenkmale der brandenburgischen + Stadt Lenzen (Elbe) und ihrer Ortsteile aufgelistet. + + Translation: In the list of architectural monuments in Lenzen all architectural + monuments of the Brandenburg city of Lenzen and its districts are listed. + + The translation contains an error pertaining to + + Options: + + (A) Modifiers or Adjectives + + (B) Numerical Values + + (C) Negation or Antonyms + + (D) Named Entities + + (E) Dropped Content + + (F) Facts" + target: (D) + - input: "The following translations from German to English contain a particular + error. That error will be one of the following types: Named Entities: An entity + (names, places, locations, etc.) is changed to a different entity. Numerical + Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. + Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are + changed. Negation or Antonyms: Introduce or remove a negation or change comparatives + to their antonyms. Facts: Trivial factual errors not pertaining to the above + classes are introduced in the translations. Dropped Content: A significant clause + in the translation is removed. Please identify that error. Source: Auf dieser + Seite sind die Baudenkm\xE4ler der oberbayerischen Gro\xDFen Kreisstadt Landsberg + am Lech zusammengestellt. + + Translation: On this page are compiled the architectural monuments of the town of + Landsberg am Lech. + + The translation contains an error pertaining to + + Options: + + (A) Modifiers or Adjectives + + (B) Numerical Values + + (C) Negation or Antonyms + + (D) Named Entities + + (E) Dropped Content + + (F) Facts" + target: (E) + - input: "The following translations from German to English contain a particular + error. That error will be one of the following types: Named Entities: An entity + (names, places, locations, etc.) is changed to a different entity. Numerical + Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. + Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are + changed. Negation or Antonyms: Introduce or remove a negation or change comparatives + to their antonyms. Facts: Trivial factual errors not pertaining to the above + classes are introduced in the translations. Dropped Content: A significant clause + in the translation is removed. Please identify that error. Source: \u0141eba ist + eine Kleinstadt und ein Badeort im Powiat L\u0119borski der polnischen Woiwodschaft + Pommern. + + Translation: Eba is not a small town and seaside resort in the Powiat L\xE9borski + county of the Pomeranian Voivodeship of Poland.\nThe translation contains an error + pertaining to + + Options: + + (A) Modifiers or Adjectives + + (B) Numerical Values + + (C) Negation or Antonyms + + (D) Named Entities + + (E) Dropped Content + + (F) Facts" + target: (C) +include: _fewshot_template_yaml +task: leaderboard_bbh_salient_translation_error_detection diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/snarks.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/snarks.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a4a02e581bb475a80cc61063f257bc2e59b2dd1d --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/snarks.yaml @@ -0,0 +1,42 @@ +dataset_name: snarks +description: 'Determine which of two sentences is sarcastic. + + + According to Cambridge University Dictionary, sarcasm is "the use of remarks that + clearly mean the opposite of what they say, made in order to hurt someone''s feelings + or to criticize something in a humorous way." Sarcastic sentences often contain + satirical or ironic utterances, hyperboles, ambivalent or witty remarks.' +doc_to_choice: ["(A)","(B)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Which statement is sarcastic? + + Options: + + (A) Yes, because having interests and actively researching them is a huge waste + + (B) Yes, because having interests and actively researching them is a huge deal' + target: (A) + - input: 'Which statement is sarcastic? + + Options: + + (A) No one is going to disagree with you on this. Avoiding ad hominem attacks + really help your case + + (B) No one is going to disagree with you on this. Ad hominem attacks really + help your case' + target: (B) + - input: 'Which statement is sarcastic? + + Options: + + (A) Consistency in the league''s punishments? What do you think this is supposed + to be, politics? + + (B) Consistency in the league''s punishments? What do you think this is supposed + to be, moral?' + target: (A) +include: _fewshot_template_yaml +task: leaderboard_bbh_snarks diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/sports_understanding.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/sports_understanding.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e3f3ea2290344b2df8349a627899d509155153de --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/sports_understanding.yaml @@ -0,0 +1,17 @@ +dataset_name: sports_understanding +description: 'Determine whether an artificially constructed sentence relating to sports + is plausible or not.' +doc_to_choice: ["yes","no"] +fewshot_config: + sampler: first_n + samples: + - input: Is the following sentence plausible? "Bam Adebayo scored a reverse layup + in the Western Conference Finals." + target: 'yes' + - input: Is the following sentence plausible? "Santi Cazorla scored a touchdown." + target: 'no' + - input: Is the following sentence plausible? "DeMar DeRozan was called for the + goal tend." + target: 'yes' +include: _fewshot_template_yaml +task: leaderboard_bbh_sports_understanding diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/temporal_sequences.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/temporal_sequences.yaml new file mode 100644 index 0000000000000000000000000000000000000000..543e711c04c1d3b8e143c748f4f87844bed3371f --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/temporal_sequences.yaml @@ -0,0 +1,99 @@ +dataset_name: temporal_sequences +description: 'Task description: Answer questions about which times certain events + could have occurred.' +doc_to_choice: ["(A)","(B)","(C)","(D)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Today, Emily went to the museum. Between what times could they have gone? + + We know that: + + Emily woke up at 1pm. + + Elizabeth saw Emily reading at the library from 2pm to 4pm. + + Jessica saw Emily watching a movie at the theater from 4pm to 5pm. + + Leslie saw Emily waiting at the airport from 5pm to 6pm. + + William saw Emily buying clothes at the mall from 6pm to 7pm. + + The museum was closed after 7pm. + + Between what times could Emily have gone to the museum? + + Options: + + (A) 1pm to 2pm + + (B) 6pm to 7pm + + (C) 5pm to 6pm + + (D) 2pm to 4pm' + target: (A) + - input: 'Today, Elizabeth went to the amusement park. Between what times could + they have gone? + + We know that: + + Elizabeth woke up at 7am. + + David saw Elizabeth fixing their computer at the electronic store from 1pm to + 2pm. + + Sarah saw Elizabeth playing tennis at the tennis court from 2pm to 3pm. + + Susan saw Elizabeth walking towards the Statue of Liberty from 3pm to 6pm. + + Andrew saw Elizabeth taking photos near the Eiffel Tower from 6pm to 9pm. + + Emily saw Elizabeth getting a coffee at the cafe from 9pm to 10pm. + + The amusement park was closed after 10pm. + + Between what times could Elizabeth have gone to the amusement park? + + Options: + + (A) 7am to 1pm + + (B) 9pm to 10pm + + (C) 1pm to 2pm + + (D) 3pm to 6pm' + target: (A) + - input: 'Today, Tiffany went to the beach. Between what times could they have gone? + + We know that: + + Tiffany woke up at 5am. + + Betty saw Tiffany getting a coffee at the cafe from 5am to 6am. + + Jessica saw Tiffany working at the office from 6am to 9am. + + John saw Tiffany stretching at a yoga studio from 9am to 12pm. + + Sean saw Tiffany sitting on a rooftop from 12pm to 2pm. + + Sarah saw Tiffany playing tennis at the tennis court from 2pm to 3pm. + + The beach was closed after 4pm. + + Between what times could Tiffany have gone to the beach? + + Options: + + (A) 9am to 12pm + + (B) 12pm to 2pm + + (C) 5am to 6am + + (D) 3pm to 4pm' + target: (D) +include: _fewshot_template_yaml +task: leaderboard_bbh_temporal_sequences diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/tracking_shuffled_objects_seven_objects.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/tracking_shuffled_objects_seven_objects.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d3ea87ccfce90fc2d8ee96d2c62731711399c726 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/tracking_shuffled_objects_seven_objects.yaml @@ -0,0 +1,57 @@ +dataset_name: tracking_shuffled_objects_seven_objects +description: 'A task requiring determining the final positions of a set of objects + given their initial positions and a description of a sequence of swaps.' +doc_to_choice: ["(A)","(B)","(C)","(D)","(E)","(F)","(G)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Alice, Bob, and Claire are playing a game. At the start of the game, they + are each holding a ball: Alice has a yellow ball, Bob has a blue ball, and Claire + has a pink ball. + + As the game progresses, pairs of players trade balls. First, Claire and Alice + swap balls. Then, Alice and Bob swap balls. Finally, Claire and Bob swap balls. + At the end of the game, Bob has the + + Options: + + (A) yellow ball + + (B) blue ball + + (C) pink ball' + target: (A) + - input: 'Alice, Bob, and Claire are playing a game. At the start of the game, they + are each holding a ball: Alice has a white ball, Bob has a purple ball, and + Claire has a pink ball. + + As the game progresses, pairs of players trade balls. First, Bob and Alice swap + balls. Then, Bob and Claire swap balls. Finally, Bob and Alice swap balls. At + the end of the game, Alice has the + + Options: + + (A) white ball + + (B) purple ball + + (C) pink ball' + target: (C) + - input: 'Alice, Bob, and Claire are dancers at a square dance. At the start of + a song, they each have a partner: Alice is dancing with Lola, Bob is dancing + with Rodrigo, and Claire is dancing with Patrick. + + Throughout the song, the dancers often trade partners. First, Alice and Bob + switch partners. Then, Claire and Bob switch partners. Finally, Bob and Alice + switch partners. At the end of the dance, Alice is dancing with + + Options: + + (A) Lola + + (B) Rodrigo + + (C) Patrick' + target: (C) +include: _fewshot_template_yaml +task: leaderboard_bbh_tracking_shuffled_objects_seven_objects diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/tracking_shuffled_objects_three_objects.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/tracking_shuffled_objects_three_objects.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7ab88a3c7d21fdceb1964d236bbc9c3d21f3c0b8 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/tracking_shuffled_objects_three_objects.yaml @@ -0,0 +1,57 @@ +dataset_name: tracking_shuffled_objects_three_objects +description: 'A task requiring determining the final positions of a set of objects + given their initial positions and a description of a sequence of swaps.' +doc_to_choice: ["(A)","(B)","(C)"] +fewshot_config: + sampler: first_n + samples: + - input: 'Alice, Bob, and Claire are playing a game. At the start of the game, they + are each holding a ball: Alice has a yellow ball, Bob has a blue ball, and Claire + has a pink ball. + + As the game progresses, pairs of players trade balls. First, Claire and Alice + swap balls. Then, Alice and Bob swap balls. Finally, Claire and Bob swap balls. + At the end of the game, Bob has the + + Options: + + (A) yellow ball + + (B) blue ball + + (C) pink ball' + target: (A) + - input: 'Alice, Bob, and Claire are playing a game. At the start of the game, they + are each holding a ball: Alice has a white ball, Bob has a purple ball, and + Claire has a pink ball. + + As the game progresses, pairs of players trade balls. First, Bob and Alice swap + balls. Then, Bob and Claire swap balls. Finally, Bob and Alice swap balls. At + the end of the game, Alice has the + + Options: + + (A) white ball + + (B) purple ball + + (C) pink ball' + target: (C) + - input: 'Alice, Bob, and Claire are dancers at a square dance. At the start of + a song, they each have a partner: Alice is dancing with Lola, Bob is dancing + with Rodrigo, and Claire is dancing with Patrick. + + Throughout the song, the dancers often trade partners. First, Alice and Bob + switch partners. Then, Claire and Bob switch partners. Finally, Bob and Alice + switch partners. At the end of the dance, Alice is dancing with + + Options: + + (A) Lola + + (B) Rodrigo + + (C) Patrick' + target: (C) +include: _fewshot_template_yaml +task: leaderboard_bbh_tracking_shuffled_objects_three_objects diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/web_of_lies.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/web_of_lies.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e25e5f731abd96459d169dec2d1b9916f5cebe9e --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/bbh_mc/web_of_lies.yaml @@ -0,0 +1,20 @@ +dataset_name: web_of_lies +description: 'Evaluate a random boolean function expressed as a word problem.' +doc_to_choice: ["Yes","No"] +fewshot_config: + sampler: first_n + samples: + - input: 'Question: Fidel tells the truth. Jerry says Fidel tells the truth. Vina + says Jerry tells the truth. Millicent says Vina lies. Raymond says Millicent + lies. Does Raymond tell the truth?' + target: 'Yes' + - input: 'Question: Kristian lies. Millie says Kristian lies. Maybelle says Millie + tells the truth. Fidel says Maybelle lies. Leda says Fidel lies. Does Leda tell + the truth?' + target: 'Yes' + - input: 'Question: Kristian tells the truth. Michaela says Kristian lies. Raymond + says Michaela tells the truth. Osvaldo says Raymond tells the truth. Jamey says + Osvaldo tells the truth. Does Jamey tell the truth?' + target: 'No' +include: _fewshot_template_yaml +task: leaderboard_bbh_web_of_lies diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/_leaderboard_gpqa.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/_leaderboard_gpqa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..448c14ac484bb6a1d7daeb15a5c19ec495f9a658 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/_leaderboard_gpqa.yaml @@ -0,0 +1,5 @@ +group: leaderboard_gpqa +task: + - leaderboard_gpqa_diamond + - leaderboard_gpqa_extended + - leaderboard_gpqa_main diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/_template_yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/_template_yaml new file mode 100644 index 0000000000000000000000000000000000000000..f4047292343005b69e259d0bb384126020ba16bc --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/_template_yaml @@ -0,0 +1,19 @@ +dataset_path: Idavidrein/gpqa +output_type: multiple_choice +process_docs: !function utils.process_docs +training_split: train +# Because huggingface dataset only has train split +validation_split: train +test_split: null +doc_to_text: "What is the correct answer to this question:{{Question}}\nChoices:\n(A) {{choice1}}\n(B) {{choice2}}\n(C) {{choice3}}\n(D) {{choice4}}\nAnswer: " +doc_to_target: answer +doc_to_choice: ["(A)", "(B)", "(C)", "(D)"] +num_fewshot: 0 +metric_list: + - metric: acc_norm + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 +fewshot_config: + sampler: first_n diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_diamond_zeroshot.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_diamond_zeroshot.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a38921657d611da44b841a1707ff01d6eba071d5 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_diamond_zeroshot.yaml @@ -0,0 +1,4 @@ +# Generated by _generate_configs.py +dataset_name: gpqa_diamond +include: _template_yaml +task: leaderboard_gpqa_diamond diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_extended_zeroshot.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_extended_zeroshot.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b481d960c8a186a99a72aaea1839f5efe2cdfdc4 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_extended_zeroshot.yaml @@ -0,0 +1,4 @@ +# Generated by _generate_configs.py +dataset_name: gpqa_extended +include: _template_yaml +task: leaderboard_gpqa_extended diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_main_zeroshot.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_main_zeroshot.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a15e45b63af0840f41ae97e15419f33ea61f52d4 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/gpqa_main_zeroshot.yaml @@ -0,0 +1,4 @@ +# Generated by _generate_configs.py +dataset_name: gpqa_main +include: _template_yaml +task: leaderboard_gpqa_main diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/utils.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..c2317e02efd132aea27ec8c8fad284df55ccd382 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/gpqa/utils.py @@ -0,0 +1,38 @@ +import random +import re + +import datasets + + +def preprocess(text): + if text is None: + return " " + text = text.strip() + text = text.replace(" [title]", ". ") + text = re.sub("\\[.*?\\]", "", text) + text = text.replace(" ", " ") + return text + + +def process_docs(dataset: datasets.Dataset) -> datasets.Dataset: + def _process_doc(doc): + choices = [ + preprocess(doc["Incorrect Answer 1"]), + preprocess(doc["Incorrect Answer 2"]), + preprocess(doc["Incorrect Answer 3"]), + preprocess(doc["Correct Answer"]), + ] + + random.shuffle(choices) + correct_answer_index = choices.index(preprocess(doc["Correct Answer"])) + + out_doc = { + "choice1": choices[0], + "choice2": choices[1], + "choice3": choices[2], + "choice4": choices[3], + "answer": f"({chr(65 + correct_answer_index)})", + } + return out_doc + + return dataset.map(_process_doc) diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/_leaderboard_math.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/_leaderboard_math.yaml new file mode 100644 index 0000000000000000000000000000000000000000..45cf8f13408cdae93860e78c260b92a162c93fb3 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/_leaderboard_math.yaml @@ -0,0 +1,9 @@ +group: leaderboard_math_hard +task: + - leaderboard_math_algebra_hard + - leaderboard_math_counting_and_prob_hard + - leaderboard_math_geometry_hard + - leaderboard_math_intermediate_algebra_hard + - leaderboard_math_num_theory_hard + - leaderboard_math_prealgebra_hard + - leaderboard_math_precalculus_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/_template_yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/_template_yaml new file mode 100644 index 0000000000000000000000000000000000000000..9c404b0c5e350fa67bd694d6094ebd84e7594c06 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/_template_yaml @@ -0,0 +1,26 @@ +dataset_path: lighteval/MATH-Hard +process_docs: !function utils.process_docs +output_type: generate_until +training_split: train +test_split: test +doc_to_text: !function utils.doc_to_text +process_results: !function utils.process_results +doc_to_target: "{{answer if few_shot is undefined else solution}}" +generation_kwargs: + until: + - "Problem:" + do_sample: false + temperature: 0 + max_gen_toks: 1024 +metric_list: + - metric: exact_match + aggregation: mean + higher_is_better: true +num_fewshot: 4 +metadata: + version: 1.0 +dataset_kwargs: + trust_remote_code: true +fewshot_config: + sampler: first_n + samples: !function utils.list_fewshot_samples diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_algebra.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_algebra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9e1d4753b0343f7df3f4f9625b14aaf117bf2571 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_algebra.yaml @@ -0,0 +1,3 @@ +include: _template_yaml +dataset_name: algebra +task: leaderboard_math_algebra_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_counting_and_prob.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_counting_and_prob.yaml new file mode 100644 index 0000000000000000000000000000000000000000..41767099ef9b26a721904b97516b1dba49a0e991 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_counting_and_prob.yaml @@ -0,0 +1,3 @@ +include: _template_yaml +dataset_name: counting_and_probability +task: leaderboard_math_counting_and_prob_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_geometry.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_geometry.yaml new file mode 100644 index 0000000000000000000000000000000000000000..189633c304d7e80a119d35f8f096b296a9c251c9 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_geometry.yaml @@ -0,0 +1,3 @@ +include: _template_yaml +dataset_name: geometry +task: leaderboard_math_geometry_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_intermediate_algebra.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_intermediate_algebra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9959bd18595827c5411ed115f19a549b033c473e --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_intermediate_algebra.yaml @@ -0,0 +1,3 @@ +include: _template_yaml +dataset_name: intermediate_algebra +task: leaderboard_math_intermediate_algebra_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_num_theory.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_num_theory.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a055d94dcbac940ab8af1f0e58a7dc4580696aab --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_num_theory.yaml @@ -0,0 +1,3 @@ +include: _template_yaml +dataset_name: number_theory +task: leaderboard_math_num_theory_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_prealgebra.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_prealgebra.yaml new file mode 100644 index 0000000000000000000000000000000000000000..474d7258f461ff77933e3f10e9facfce5a484bb3 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_prealgebra.yaml @@ -0,0 +1,3 @@ +include: _template_yaml +dataset_name: prealgebra +task: leaderboard_math_prealgebra_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_precalculus.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_precalculus.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4d63541e54cfd1b7510214450591404f8da4dc18 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/math_precalculus.yaml @@ -0,0 +1,3 @@ +include: _template_yaml +dataset_name: precalculus +task: leaderboard_math_precalculus_hard diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/utils.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..e3ebcf991bac2a3727098a437586faf0d2ce3a62 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/math/utils.py @@ -0,0 +1,294 @@ +import re +import signal +from typing import Dict, List, Optional + +import datasets + +from lm_eval.utils import eval_logger + + +try: + import sympy + from sympy.parsing.latex import parse_latex +except ModuleNotFoundError: + raise ModuleNotFoundError( + "`sympy` is required for generating translation task prompt templates. \ +please install sympy via pip install lm-eval[math] or pip install -e .[math]", + ) + + +# taken from +# https://github.com/wellecks/lm-evaluation-harness/blob/master/lm_eval/tasks/minerva_math.py +def doc_to_text(doc: dict) -> str: + return "Problem:" + "\n" + doc["problem"] + "\n\n" + "Solution:" + + +def process_docs(dataset: datasets.Dataset) -> datasets.Dataset: + def _process_doc(doc: dict) -> dict: + out_doc = { + "problem": doc["problem"], + "solution": doc["solution"], + "answer": normalize_final_answer( + remove_boxed(last_boxed_only_string(doc["solution"])) + ), + } + if getattr(doc, "few_shot", None) is not None: + out_doc["few_shot"] = True + return out_doc + + return dataset.map(_process_doc) + + +def list_fewshot_samples() -> list[dict]: + return [ + { + "problem": "Find the domain of the expression $\\frac{\\sqrt{x-2}}{\\sqrt{5-x}}$.}", + "solution": "The expressions inside each square root must be non-negative. Therefore, $x-2 \\ge 0$, so $x\\ge2$, and $5 - x \\ge 0$, so $x \\le 5$. Also, the denominator cannot be equal to zero, so $5-x>0$, which gives $x<5$. Therefore, the domain of the expression is $\\boxed{[2,5)}$.\nFinal Answer: The final answer is $[2,5)$. I hope it is correct.", + "few_shot": "1", + }, + { + "problem": "If $\\det \\mathbf{A} = 2$ and $\\det \\mathbf{B} = 12,$ then find $\\det (\\mathbf{A} \\mathbf{B}).$", + "solution": "We have that $\\det (\\mathbf{A} \\mathbf{B}) = (\\det \\mathbf{A})(\\det \\mathbf{B}) = (2)(12) = \\boxed{24}.$\nFinal Answer: The final answer is $24$. I hope it is correct.", + "few_shot": "1", + }, + { + "problem": "Terrell usually lifts two 20-pound weights 12 times. If he uses two 15-pound weights instead, how many times must Terrell lift them in order to lift the same total weight?", + "solution": "If Terrell lifts two 20-pound weights 12 times, he lifts a total of $2\\cdot 12\\cdot20=480$ pounds of weight. If he lifts two 15-pound weights instead for $n$ times, he will lift a total of $2\\cdot15\\cdot n=30n$ pounds of weight. Equating this to 480 pounds, we can solve for $n$:\n\\begin{align*}\n30n&=480\\\n\\Rightarrow\\qquad n&=480/30=\\boxed{16}\n\\end{align*}\nFinal Answer: The final answer is $16$. I hope it is correct.", + "few_shot": "1", + }, + { + "problem": "If the system of equations\n\n\\begin{align*}\n6x-4y&=a,\\\n6y-9x &=b.\n\\end{align*}has a solution $(x, y)$ where $x$ and $y$ are both nonzero,\nfind $\\frac{a}{b},$ assuming $b$ is nonzero.", + "solution": "If we multiply the first equation by $-\\frac{3}{2}$, we obtain\n\n$$6y-9x=-\\frac{3}{2}a.$$Since we also know that $6y-9x=b$, we have\n\n$$-\\frac{3}{2}a=b\\Rightarrow\\frac{a}{b}=\\boxed{-\\frac{2}{3}}.$$\nFinal Answer: The final answer is $-\\frac{2}{3}$. I hope it is correct.", + "few_shot": "1", + }, + ] + + +def process_results(doc: dict, results: List[str]) -> Dict[str, int]: + candidates = results[0] + + unnormalized_answer = get_unnormalized_answer(candidates) + answer = normalize_final_answer(unnormalized_answer) + + if is_equiv(answer, doc["answer"]): + retval = 1 + else: + retval = 0 + + results = { + "exact_match": retval, + } + return results + + +def last_boxed_only_string(string: str) -> Optional[str]: + idx = string.rfind("\\boxed") + if "\\boxed " in string: + return "\\boxed " + string.split("\\boxed ")[-1].split("$")[0] + if idx < 0: + idx = string.rfind("\\fbox") + if idx < 0: + return None + + i = idx + right_brace_idx = None + num_left_braces_open = 0 + while i < len(string): + if string[i] == "{": + num_left_braces_open += 1 + if string[i] == "}": + num_left_braces_open -= 1 + if num_left_braces_open == 0: + right_brace_idx = i + break + i += 1 + + if right_brace_idx is None: + retval = None + else: + retval = string[idx : right_brace_idx + 1] + + return retval + + +def remove_boxed(s: str) -> str: + if "\\boxed " in s: + left = "\\boxed " + assert s[: len(left)] == left + return s[len(left) :] + + left = "\\boxed{" + + assert s[: len(left)] == left + assert s[-1] == "}" + + return s[len(left) : -1] + + +class timeout: + def __init__(self, seconds=1, error_message="Timeout"): + self.seconds = seconds + self.error_message = error_message + + def handle_timeout(self, signum, frame): + raise TimeoutError(self.error_message) + + def __enter__(self): + signal.signal(signal.SIGALRM, self.handle_timeout) + signal.alarm(self.seconds) + + def __exit__(self, type, value, traceback): + signal.alarm(0) + + +def is_equiv(x1: str, x2: str) -> bool: + """ + x1 and x2 are normalized latex string + """ + try: + with timeout(seconds=5): + try: + parsed_x1 = parse_latex(x1) + parsed_x2 = parse_latex(x2) + except ( + sympy.parsing.latex.errors.LaTeXParsingError, + sympy.SympifyError, + TypeError, + ): + eval_logger.debug(f"couldn't parse one of {x1} or {x2}") + return False + + try: + diff = parsed_x1 - parsed_x2 + except TypeError: + eval_logger.debug(f"couldn't subtract {x1} and {x2}") + return False + + try: + if sympy.simplify(diff) == 0: + return True + else: + return False + except ValueError: + eval_logger.debug( + f"Had some trouble simplifying when comparing {x1} and {x2}" + ) + except TimeoutError: + eval_logger.debug(f"Timed out comparing {x1} and {x2}") + return False + except ImportError as e: + eval_logger.error(e) + raise + except Exception as e: + eval_logger.debug(f"Failed comparing {x1} and {x2} with {e}") + return False + + +def get_unnormalized_answer(text: str) -> str: + INVALID_ANSWER = "[invalidanswer]" + end_seq = "I hope it is correct." + text += end_seq + match = re.search( + r"Final Answer: The final answer is(.*?). I hope it is correct.", + text, + ) + if match: + return match.group(1).strip() + else: + return INVALID_ANSWER + + +SUBSTITUTIONS = [ + ("an ", ""), + ("a ", ""), + (".$", "$"), + ("\\$", ""), + (r"\ ", ""), + (" ", ""), + ("mbox", "text"), + (",\\text{and}", ","), + ("\\text{and}", ","), + ("\\text{m}", "\\text{}"), +] +REMOVED_EXPRESSIONS = [ + "square", + "ways", + "integers", + "dollars", + "mph", + "inches", + "ft", + "hours", + "km", + "units", + "\\ldots", + "sue", + "points", + "feet", + "minutes", + "digits", + "cents", + "degrees", + "cm", + "gm", + "pounds", + "meters", + "meals", + "edges", + "students", + "childrentickets", + "multiples", + "\\text{s}", + "\\text{.}", + "\\text{\ns}", + "\\text{}^2", + "\\text{}^3", + "\\text{\n}", + "\\text{}", + r"\mathrm{th}", + r"^\circ", + r"^{\circ}", + r"\;", + r",\!", + "{,}", + '"', + "\\dots", +] + + +def normalize_final_answer(final_answer: str) -> str: + """ + Normalize a final answer to a quantitative reasoning question. + + Copied character for character from appendix D of Lewkowycz et al. (2022) + """ + final_answer = final_answer.split("=")[-1] + + for before, after in SUBSTITUTIONS: + final_answer = final_answer.replace(before, after) + for expr in REMOVED_EXPRESSIONS: + final_answer = final_answer.replace(expr, "") + + # Extract answer that is in LaTeX math, is bold, + # is surrounded by a box, etc. + final_answer = re.sub(r"(.*?)(\$)(.*?)(\$)(.*)", "$\\3$", final_answer) + final_answer = re.sub(r"(\\text\{)(.*?)(\})", "\\2", final_answer) + final_answer = re.sub(r"(\\textbf\{)(.*?)(\})", "\\2", final_answer) + final_answer = re.sub(r"(\\overline\{)(.*?)(\})", "\\2", final_answer) + final_answer = re.sub(r"(\\boxed\{)(.*)(\})", "\\2", final_answer) + + # Normalize shorthand TeX: + # \fracab -> \frac{a}{b} + # \frac{abc}{bef} -> \frac{abc}{bef} + # \fracabc -> \frac{a}{b}c + # \sqrta -> \sqrt{a} + # \sqrtab -> sqrt{a}b + final_answer = re.sub(r"(frac)([^{])(.)", "frac{\\2}{\\3}", final_answer) + final_answer = re.sub(r"(sqrt)([^{])", "sqrt{\\2}", final_answer) + final_answer = final_answer.replace("$", "") + + # Normalize 100,000 -> 100000 + if final_answer.replace(",", "").isdigit(): + final_answer = final_answer.replace(",", "") + + return final_answer diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/mmlu_pro/mmlu_pro.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/mmlu_pro/mmlu_pro.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8ddabf148e767c63d320229c26f6f530d41026f3 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/mmlu_pro/mmlu_pro.yaml @@ -0,0 +1,17 @@ +dataset_path: TIGER-Lab/MMLU-Pro # a copy of `cais/leaderboard_mmlu` with no auxiliary_train split +task: leaderboard_mmlu_pro +test_split: test +fewshot_split: validation +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 +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true +num_fewshot: 5 +metadata: + version: 0.1 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/mmlu_pro/utils.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/mmlu_pro/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb398262ad66393d0abdd79c1dff7a92c2d67c8d --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/leaderboard/mmlu_pro/utils.py @@ -0,0 +1,15 @@ +import string + + +def doc_to_text(doc): + doc_to_text = f"{doc['question']}\n" + + for i in range(len(doc["options"])): + doc_to_text += f"{string.ascii_uppercase[i]}. {doc['options'][i]}\n" + + doc_to_text += "Answer:" + return doc_to_text + + +def doc_to_choice(doc): + return [string.ascii_uppercase[i] for i in range(len(doc["options"]))] diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/medmcqa/medmcqa.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/medmcqa/medmcqa.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8fb1c7cdba4983d8ccb509491f699d9be0afa17e --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/medmcqa/medmcqa.yaml @@ -0,0 +1,18 @@ +task: medmcqa +dataset_path: medmcqa +output_type: multiple_choice +training_split: train +validation_split: validation +test_split: validation +doc_to_text: !function utils_medmcqa.doc_to_text +doc_to_target: cop +doc_to_choice: [ 'A','B','C','D' ] +should_decontaminate: true +doc_to_decontamination_query: "{{question}}" +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true + - metric: acc_norm + aggregation: mean + higher_is_better: true diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/medmcqa/utils_medmcqa.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/medmcqa/utils_medmcqa.py new file mode 100644 index 0000000000000000000000000000000000000000..8ce7e6beece511dccdfe94790456711ee7e93eab --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/medmcqa/utils_medmcqa.py @@ -0,0 +1,24 @@ +# Copied from Master +def doc_to_text(doc) -> str: + """ + Question: + Choices: + A. + B. + C. + D. + Answer: + """ + choices = [doc["opa"], doc["opb"], doc["opc"], doc["opd"]] + option_choices = { + "A": choices[0], + "B": choices[1], + "C": choices[2], + "D": choices[3], + } + + prompt = "Question: " + doc["question"] + "\nChoices:\n" + for choice, option in option_choices.items(): + prompt += f"{choice.upper()}. {option}\n" + prompt += "Answer:" + return prompt diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/README.md b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/README.md new file mode 100644 index 0000000000000000000000000000000000000000..553ed20f49cab7d4e23bb4cda4619eb408c671f0 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/README.md @@ -0,0 +1,53 @@ +# NoticIA + +### Paper + +Title: `NoticIA: A Clickbait Article Summarization Dataset in Spanish` + +Abstract: https://arxiv.org/abs/2404.07611 + +We present NoticIA, a dataset consisting of 850 Spanish news articles featuring prominent clickbait headlines, each paired with high-quality, single-sentence generative summarizations written by humans. This task demands advanced text understanding and summarization abilities, challenging the models' capacity to infer and connect diverse pieces of information to meet the user's informational needs generated by the clickbait headline. We evaluate the Spanish text comprehension capabilities of a wide range of state-of-the-art large language models. Additionally, we use the dataset to train ClickbaitFighter, a task-specific model that achieves near-human performance in this task. + +Homepage: https://github.com/ikergarcia1996/NoticIA + +### Citation + +``` +@article{noticia2024, + title={NoticIA: A Clickbait Article Summarization Dataset in Spanish}, + author={Iker García-Ferrero and Begoña Altuna}, + year={2024}, + journal = {Procesamiento del Lenguaje Natural}, + volume = {73}, + number = {0}, + archivePrefix={arXiv}, + primaryClass={cs.CL} +} +``` + +### Groups and Tasks + +#### Groups + +* Not part of a group yet. + +#### Tasks + +* `noticia` + +#### Metrics + +Following the original implementation, this task will compute the 'Rouge1 score' and 'Average Summary Length.' + +### Checklist + +For adding novel benchmarks/datasets to the library: +* [x] Is the task an existing benchmark in the literature? + * [x] Have you referenced the original paper that introduced the task? + * [x] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [x] Is the "Main" variant of this task clearly denoted? +* [x] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [x] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/noticia.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/noticia.yaml new file mode 100644 index 0000000000000000000000000000000000000000..33fd6ebc47d27a70faccdd46109985c1a1bf8ee8 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/noticia.yaml @@ -0,0 +1,29 @@ +task: noticia +dataset_path: Iker/NoticIA +dataset_name: null +output_type: generate_until +generation_kwargs: + until: + - "\n\n" + - "\n" + do_sample: false + temperature: 0.0 +training_split: null +validation_split: null +test_split: test +fewshot_split: null +doc_to_text: "Ahora eres una Inteligencia Artificial experta en desmontar titulares sensacionalistas o clickbait. Tu tarea consiste en analizar noticias con titulares sensacionalistas y generar un resumen de una sola frase que revele la verdad detrás del titular.\nEste es el titular de la noticia: {{web_headline}}\nEl titular plantea una pregunta o proporciona información incompleta. Debes buscar en el cuerpo de la noticia una frase que responda lo que se sugiere en el título. Responde siempre que puedas parafraseando el texto original. Usa siempre las mínimas palabras posibles. Recuerda responder siempre en Español.\nEste es el cuerpo de la noticia:\n{{web_text}}" +doc_to_target: summary +target_delimiter: " " +num_fewshot: 0 +should_decontaminate: false +doc_to_decontamination_query: sentence +metric_list: + - metric: !function utils.rouge1 + higher_is_better: true + aggregation: !function utils.rouge1_agg + - metric: !function utils.average_len + higher_is_better: false + aggregation: !function utils.average_len_agg +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/utils.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..27a3a4363757cc5fca7b5b7ff683db5f8f556643 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/noticia/utils.py @@ -0,0 +1,55 @@ +import string + +import evaluate + + +def clean_text(text: str) -> str: + # Remove punctuation + text = text.translate(str.maketrans("", "", string.punctuation)) + + # Remove newlines and multiple spaces + text = text.replace("\n", " ").strip() + text = " ".join(text.split()).strip() + + # lowercase + text = text.lower() + + return text + + +def rouge1(items): + """ + # passthrough for efficiency + """ + return items + + +def average_len(items): + """ + # passthrough for efficiency + """ + return items + + +def rouge1_agg(items): + """ + Higher is better + """ + + refs = list(zip(*items))[0] + refs = [[clean_text(ref)] for ref in refs] + # print("refs", refs) + preds = [clean_text(x) for x in list(zip(*items))[1]] + # print("preds", preds) + rouge_scorer = evaluate.load("rouge") + return rouge_scorer.compute(predictions=preds, references=refs)["rouge1"] + + +def average_len_agg(items): + """ + Higher is better + """ + + preds = [clean_text(x) for x in list(zip(*items))[1]] + + return sum(len(x.split()) for x in preds) / len(preds) diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/prost/README.md b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/prost/README.md new file mode 100644 index 0000000000000000000000000000000000000000..97752fc0c669b63d9a825110c8da8779f7e3a2e2 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/prost/README.md @@ -0,0 +1,62 @@ +# PROST + +### Paper + +Title: `PROST: Physical Reasoning about Objects Through Space and Time` + +Abstract: https://arxiv.org/abs/2106.03634 + +PROST, Physical Reasoning about Objects Through Space and Time, is a dataset +consisting of 18,736 multiple-choice questions made from 14 manually curated +templates, covering 10 physical reasoning concepts. All questions are designed +to probe both causal and masked language models in a zero-shot setting. + +NOTE: PROST is limited to the zero-shot setting to adhere to authors' intentions +as discussed in section 7 of the paper: "We hope that the community will use +this dataset in the intended way: in a zero-shot setting to probe models which +have been trained on data not specifically collected to succeed on PROST." + +Homepage: https://github.com/nala-cub/prost + + +### Citation + +``` +@inproceedings{aroca-ouellette-etal-2021-prost, + title = "{PROST}: {P}hysical Reasoning about Objects through Space and Time", + author = "Aroca-Ouellette, St{\'e}phane and + Paik, Cory and + Roncone, Alessandro and + Kann, Katharina", + booktitle = "Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021", + month = aug, + year = "2021", + address = "Online", + publisher = "Association for Computational Linguistics", + url = "https://aclanthology.org/2021.findings-acl.404", + pages = "4597--4608", +} +``` + +### Groups and Tasks + +#### Groups + +* Not part of a group yet. + +#### Tasks + +* `prost` + +### Checklist + +For adding novel benchmarks/datasets to the library: +* [ ] Is the task an existing benchmark in the literature? + * [ ] Have you referenced the original paper that introduced the task? + * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [ ] Is the "Main" variant of this task clearly denoted? +* [ ] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/prost/corypaik_prost.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/prost/corypaik_prost.yaml new file mode 100644 index 0000000000000000000000000000000000000000..adf7a8d232d661627f2be03fc2fbf0d38ee07504 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/prost/corypaik_prost.yaml @@ -0,0 +1,19 @@ +task: prost +dataset_path: corypaik/prost +dataset_name: null +output_type: multiple_choice +test_split: test +doc_to_text: "{{context}}\nQuestion: {{ex_question}}\nAnswer:" +doc_to_target: label +doc_to_choice: "{{[A, B, C, D]}}" +should_decontaminate: true +doc_to_decontamination_query: "{{context}}\nQuestion: {{ex_question}}\nAnswer:" +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true + - metric: acc_norm + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/README.md b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d97dfe1693569de3386532af9b75ef7331ece3e3 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/README.md @@ -0,0 +1,61 @@ +# Task-name + +### Paper + +Title: `It's All in the Heads: Using Attention Heads as a Baseline for Cross-Lingual Transfer in Commonsense Reasoning` +Abstract: `https://arxiv.org/abs/2106.12066` + +Multilingual winograd schema challenge that includes English, French, Japanese, Portuguese, Russian and Chinese. Winograd schema challenges come from the XWinograd dataset introduced in Tikhonov et al. As it only contains 16 Chinese schemas, we add 488 Chinese schemas from clue/cluewsc2020. + +Homepage: `https://huggingface.co/datasets/Muennighoff/xwinograd` + + +### Citation + +``` +@misc{muennighoff2022crosslingual, + title={Crosslingual Generalization through Multitask Finetuning}, + author={Niklas Muennighoff and Thomas Wang and Lintang Sutawika and Adam Roberts and Stella Biderman and Teven Le Scao and M Saiful Bari and Sheng Shen and Zheng-Xin Yong and Hailey Schoelkopf and Xiangru Tang and Dragomir Radev and Alham Fikri Aji and Khalid Almubarak and Samuel Albanie and Zaid Alyafeai and Albert Webson and Edward Raff and Colin Raffel}, + year={2022}, + eprint={2211.01786}, + archivePrefix={arXiv}, + primaryClass={cs.CL} +} +@misc{tikhonov2021heads, + title={It's All in the Heads: Using Attention Heads as a Baseline for Cross-Lingual Transfer in Commonsense Reasoning}, + author={Alexey Tikhonov and Max Ryabinin}, + year={2021}, + eprint={2106.12066}, + archivePrefix={arXiv}, + primaryClass={cs.CL} +} +``` + +### Groups and Tasks + +#### Groups + +* `xwinograd` + +#### Tasks + +List or describe tasks defined in this folder, and their names here: +* `xwinograd_en`: Winograd schema challenges in English. +* `xwinograd_fr`: Winograd schema challenges in French. +* `xwinograd_jp`: Winograd schema challenges in Japanese. +* `xwinograd_pt`: Winograd schema challenges in Portuguese. +* `xwinograd_ru`: Winograd schema challenges in Russian. +* `xwinograd_zh`: Winograd schema challenges in Chinese. + +### Checklist + +For adding novel benchmarks/datasets to the library: + * [x] Is the task an existing benchmark in the literature? + * [x] Have you referenced the original paper that introduced the task? + * [ ] If yes, does the original paper provide a reference implementation? If so, have you checked against the reference implementation and documented how to run such a test? + + +If other tasks on this dataset are already supported: +* [ ] Is the "Main" variant of this task clearly denoted? +* [x] Have you provided a short sentence in a README on what each new variant adds / evaluates? +* [ ] Have you noted which, if any, published evaluation setups are matched by this variant? diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/_xwinograd.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/_xwinograd.yaml new file mode 100644 index 0000000000000000000000000000000000000000..24fbcdefacca2c9a6798504030c86ed2ad50b9ac --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/_xwinograd.yaml @@ -0,0 +1,14 @@ +group: xwinograd +task: + - xwinograd_en + - xwinograd_fr + - xwinograd_jp + - xwinograd_pt + - xwinograd_ru + - xwinograd_zh +aggregate_metric_list: + - metric: acc + aggregation: mean + weight_by_size: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/utils.py b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..5e350d6e9f43baafdddc18d573ddc0bfa7c837e5 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/utils.py @@ -0,0 +1,94 @@ +import argparse +from typing import Dict, List + +import yaml + + +# Different languages that are part of xwinograd. +# These correspond to dataset names (Subsets) on HuggingFace. +# A yaml file is generated by this script for each language. +LANGUAGES = ["en", "fr", "jp", "pt", "ru", "zh"] + + +def doc_to_text(doc: Dict) -> int: + """ + Return index of the correct choice. + + Note: We are using the "multiple input" mode of the multiple-choice + output-type, which means we use different contexts with the same target + for the different choices, rather than the same context and different targets. + """ + answer_to_num = {"1": 0, "2": 1} + return answer_to_num[doc["answer"]] + + +def doc_to_target(doc: Dict) -> str: + """ + Return the target completion. + + Note that this does not depend on the correct choice as we are using + "multiple input" mode. + """ + idx = doc["sentence"].index("_") + 1 + return doc["sentence"][idx:].strip() + + +def doc_to_choice(doc: Dict) -> List[str]: + """Return the choices that will be used as contexts in "multiple input" mode.""" + idx = doc["sentence"].index("_") + options = [doc["option1"], doc["option2"]] + return [doc["sentence"][:idx] + opt for opt in options] + + +def gen_lang_yamls(output_dir: str, overwrite: bool) -> None: + """ + Generate a yaml file for each language. + + :param output_dir: The directory to output the files to. + :param overwrite: Whether to overwrite files if they already exist. + """ + err = [] + for lang in LANGUAGES: + file_name = f"xwinograd_{lang}.yaml" + try: + with open( + f"{output_dir}/{file_name}", "w" if overwrite else "x", encoding="utf-8" + ) as f: + f.write("# Generated by utils.py\n") + yaml.dump( + { + "include": "xwinograd_common_yaml", + "dataset_name": lang, + "task": f"xwinograd_{lang}", + }, + f, + ) + except FileExistsError: + err.append(file_name) + + if len(err) > 0: + raise FileExistsError( + "Files were not created because they already exist (use --overwrite flag):" + f" {', '.join(err)}" + ) + + +def main() -> None: + """Parse CLI args and generate language-specific yaml files.""" + parser = argparse.ArgumentParser() + parser.add_argument( + "--overwrite", + default=False, + action="store_true", + help="Overwrite files if they already exist", + ) + parser.add_argument( + "--output-dir", default=".", help="Directory to write yaml files to" + ) + args = parser.parse_args() + + gen_lang_yamls(output_dir=args.output_dir, overwrite=args.overwrite) + + +if __name__ == "__main__": + main() diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_common_yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_common_yaml new file mode 100644 index 0000000000000000000000000000000000000000..b3e683262e676948907a2641ef9782fa29655ac0 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_common_yaml @@ -0,0 +1,18 @@ +# This file will be included in the generated language-specific task configs. +# It doesn't have a yaml file extension as it is not meant to be imported directly +# by the harness. +dataset_path: Muennighoff/xwinograd +dataset_name: null # Overridden by language-specific config. +output_type: multiple_choice +training_split: null +validation_split: null +test_split: test +doc_to_text: !function utils.doc_to_text +doc_to_target: !function utils.doc_to_target +doc_to_choice: !function utils.doc_to_choice +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true +metadata: + version: 1.0 diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_en.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_en.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7ae486ac1804443f5a76a71a1df331a0b4ed67ef --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_en.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: en +include: xwinograd_common_yaml +task: xwinograd_en diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_fr.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_fr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f93bbcd0600a3b32867171514d5c4f085f814a1c --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_fr.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: fr +include: xwinograd_common_yaml +task: xwinograd_fr diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_jp.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_jp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ef8b99bf51e8e6fd5e1210c748f3a8cabde59957 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_jp.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: jp +include: xwinograd_common_yaml +task: xwinograd_jp diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_pt.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_pt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..981287f9b1890a7d43b299d8a52816023c08e77a --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_pt.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: pt +include: xwinograd_common_yaml +task: xwinograd_pt diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_ru.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_ru.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2bb84bf9d80bbbe4c832a61eb3927a8ec88f29a2 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_ru.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: ru +include: xwinograd_common_yaml +task: xwinograd_ru diff --git a/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_zh.yaml b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_zh.yaml new file mode 100644 index 0000000000000000000000000000000000000000..17d9227c162d51ff2858ff663574dd08b43042a9 --- /dev/null +++ b/scripts/yans/lm-evaluation-harness/lm_eval/tasks/xwinograd/xwinograd_zh.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: zh +include: xwinograd_common_yaml +task: xwinograd_zh