diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d8707c01bf555d54f14d825501f54428c33cbe89 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/README.md @@ -0,0 +1,50 @@ +# ACLUE + +### Paper + +Can Large Language Model Comprehend Ancient Chinese? A Preliminary Test on ACLUE +https://arxiv.org/abs/2310.09550 + +The Ancient Chinese Language Understanding Evaluation (ACLUE) is an evaluation benchmark focused on ancient Chinese language comprehension. It aims to assess the performance of large-scale language models on understanding ancient Chinese. The benchmark comprises 15 tasks spanning various domains, including lexical, syntactic, semantic, inference, and knowledge. ACLUE's tasks are derived from a combination of manually curated questions from publicly available resources, and automatically +generated questions from classical Chinese language corpora. The range of questions span from the Xia dynasty (2070 BCE) to the Ming dynasty (1368 CE). ACLUE adopts a multiple-choice question format for all tasks. + +Homepage: https://github.com/isen-zhang/ACLUE + +### Citation + +```bibtex +@inproceedings{zhang-li-2023-large, + title = "Can Large Langauge Model Comprehend {A}ncient {C}hinese? A Preliminary Test on {ACLUE}", + author = "Zhang, Yixuan and Li, Haonan", + booktitle = "Proceedings of the Ancient Language Processing Workshop", + month = sep, + year = "2023", + address = "Varna, Bulgaria", + publisher = "INCOMA Ltd., Shoumen, Bulgaria", + url = "https://aclanthology.org/2023.alp-1.9", + pages = "80--87" +} +``` + +### Groups and Tasks + +#### Groups + +- `aclue`: All 15 subjects of the ACLUE dataset, evaluated following the methodology in CMMLU's original implementation. + +#### Tasks + +The following tasks evaluate subjects in the ACLUE dataset using loglikelihood-based multiple-choice scoring: +- `aclue_{subject_english}` + +### Checklist + +* [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? + * [x] Yes, original implementation contributed by author of the benchmark + +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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/_default_template_yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/_default_template_yaml new file mode 100644 index 0000000000000000000000000000000000000000..d93ce382d57e8a449868deb79ab544551f7e605b --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/_default_template_yaml @@ -0,0 +1,19 @@ +group: aclue +dataset_path: tyouisen/aclue +test_split: test +fewshot_split: dev +fewshot_config: + sampler: first_n +output_type: multiple_choice +doc_to_text: "{{Question.strip()}}\nA. {{A}}\nB. {{B}}\nC. {{C}}\nD. {{D}}\n答案:" +doc_to_choice: ["A", "B", "C", "D"] +doc_to_target: "{{['A', 'B', 'C', 'D'].index(Answer)}}" +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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/_generate_configs.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/_generate_configs.py new file mode 100644 index 0000000000000000000000000000000000000000..8bd1792ae3d200b422c6f804ef7d89252591b2a7 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/_generate_configs.py @@ -0,0 +1,82 @@ +""" +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.utils import eval_logger + + +SUBJECTS = { + "古文单字多义": "polysemy_resolution", + "诗词情感分类": "poetry_sentiment_analysis", + "古汉语命名体识别": "named_entity_recognition", + "古汉语知识": "basic_ancient_chinese", + "古诗词上下句预测": "poetry_context_prediction", + "古文断句": "sentence_segmentation", + "对联": "couplet_prediction", + "古诗词曲鉴赏": "poetry_appreciate", + "国学常识": "ancient_chinese_culture", + "古音学": "ancient_phonetics", + "通假字": "homographic_character_resolution", + "古代文学知识": "ancient_literature", + "医古文": "ancient_medical", + "古诗词质量评估": "poetry_quality_assessment", + "古文阅读理解": "reading_comprehension", +} + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--base_yaml_path", required=True) + parser.add_argument("--save_prefix_path", default="aclue") + parser.add_argument("--cot_prompt_path", default=None) + 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) + + if args.cot_prompt_path is not None: + import json + + with open(args.cot_prompt_path, encoding="utf-8") as f: + cot_file = json.load(f) + + for subject_zh, subject_eng in tqdm(SUBJECTS.items()): + if args.cot_prompt_path is not None: + description = cot_file[subject_eng] + else: + description = ( + f"以下是关于{subject_zh}的单项选择题,请直接给出正确答案的选项。\n\n" + ) + + yaml_dict = { + "include": base_yaml_name, + "task": f"aclue_{args.task_prefix}_{subject_eng}" + if args.task_prefix != "" + else f"aclue_{subject_eng}", + "dataset_name": subject_eng, + "description": description, + } + + file_save_path = args.save_prefix_path + f"_{subject_eng}.yaml" + eval_logger.info(f"Saving yaml for subset {subject_eng} 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_chinese_culture.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_chinese_culture.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c9f52077dedd24ce500247a4b606eea83fac6320 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_chinese_culture.yaml @@ -0,0 +1,4 @@ +"dataset_name": "ancient_chinese_culture" +"description": "以下是关于国学常识的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_ancient_chinese_culture" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_literature.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_literature.yaml new file mode 100644 index 0000000000000000000000000000000000000000..641befa3aa1920d8dca1c7007a4fe8cd24ab8e77 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_literature.yaml @@ -0,0 +1,4 @@ +"dataset_name": "ancient_literature" +"description": "以下是关于古代文学知识的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_ancient_literature" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_medical.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_medical.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bceaa702c53a1526fc84cf8f5141570352581a44 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_medical.yaml @@ -0,0 +1,4 @@ +"dataset_name": "ancient_medical" +"description": "以下是关于医古文的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_ancient_medical" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_phonetics.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_phonetics.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2fe908e531a07466a66f58f2f5009d5111d5a02d --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_ancient_phonetics.yaml @@ -0,0 +1,4 @@ +"dataset_name": "ancient_phonetics" +"description": "以下是关于古音学的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_ancient_phonetics" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_basic_ancient_chinese.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_basic_ancient_chinese.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5afb88be88b8778fde06cff3a2084bce14397174 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_basic_ancient_chinese.yaml @@ -0,0 +1,4 @@ +"dataset_name": "basic_ancient_chinese" +"description": "以下是关于古汉语知识的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_basic_ancient_chinese" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_couplet_prediction.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_couplet_prediction.yaml new file mode 100644 index 0000000000000000000000000000000000000000..63124eed8eb2c2987e7145ee4633e010407641be --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_couplet_prediction.yaml @@ -0,0 +1,4 @@ +"dataset_name": "couplet_prediction" +"description": "以下是关于对联的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_couplet_prediction" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_homographic_character_resolution.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_homographic_character_resolution.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7d50e35d5f31badfc13b1815fffa487b3fc64c82 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_homographic_character_resolution.yaml @@ -0,0 +1,4 @@ +"dataset_name": "homographic_character_resolution" +"description": "以下是关于通假字的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_homographic_character_resolution" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_named_entity_recognition.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_named_entity_recognition.yaml new file mode 100644 index 0000000000000000000000000000000000000000..566e93019b994528bb003f46fb458ed725ef8af1 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_named_entity_recognition.yaml @@ -0,0 +1,4 @@ +"dataset_name": "named_entity_recognition" +"description": "以下是关于古汉语命名体识别的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_named_entity_recognition" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_appreciate.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_appreciate.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4642992674a1f159fe101859dead4509df6c8166 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_appreciate.yaml @@ -0,0 +1,4 @@ +"dataset_name": "poetry_appreciate" +"description": "以下是关于古诗词曲鉴赏的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_poetry_appreciate" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_context_prediction.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_context_prediction.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1b408b659657b4677e056f93c59f2a59ef60cb95 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_context_prediction.yaml @@ -0,0 +1,4 @@ +"dataset_name": "poetry_context_prediction" +"description": "以下是关于古诗词上下句预测的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_poetry_context_prediction" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_quality_assessment.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_quality_assessment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a7a7bee2c4ca59e0dc7b2f3fdc08371a9a585d42 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_quality_assessment.yaml @@ -0,0 +1,4 @@ +"dataset_name": "poetry_quality_assessment" +"description": "以下是关于古诗词质量评估的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_poetry_quality_assessment" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_sentiment_analysis.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_sentiment_analysis.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6e1367f8043d7e1e9ebcd01dfbaacfbdeb0f9fec --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_poetry_sentiment_analysis.yaml @@ -0,0 +1,4 @@ +"dataset_name": "poetry_sentiment_analysis" +"description": "以下是关于诗词情感分类的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_poetry_sentiment_analysis" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_polysemy_resolution.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_polysemy_resolution.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ee0deea16f6bcb6906fd68e2e65bf72ea276e74a --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_polysemy_resolution.yaml @@ -0,0 +1,4 @@ +"dataset_name": "polysemy_resolution" +"description": "以下是关于古文单字多义的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_polysemy_resolution" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_reading_comprehension.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_reading_comprehension.yaml new file mode 100644 index 0000000000000000000000000000000000000000..92f2455d8089bcc3b7d1ff8b99c03144b5b7d61d --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_reading_comprehension.yaml @@ -0,0 +1,4 @@ +"dataset_name": "reading_comprehension" +"description": "以下是关于古文阅读理解的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_reading_comprehension" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_sentence_segmentation.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_sentence_segmentation.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9d81c3fe6eae35a6adc888d9c73430aa891bfe86 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/aclue/aclue_sentence_segmentation.yaml @@ -0,0 +1,4 @@ +"dataset_name": "sentence_segmentation" +"description": "以下是关于古文断句的单项选择题,请直接给出正确答案的选项。\n\n" +"include": "_default_template_yaml" +"task": "aclue_sentence_segmentation" diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/README.md new file mode 100644 index 0000000000000000000000000000000000000000..5e1c6e401ab2b9b5ad112b0e5488a6b4178303a1 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/README.md @@ -0,0 +1,12 @@ +# arc mt + +arc mt is an implementation of tasks to support machine translated arc +challenge evals, to improve eval support across a number of additional +languages. + +The main page for the effort is +[here](https://huggingface.co/datasets/LumiOpen/arc_challenge_mt) and we will +include more data and analysis there. + +Initial datasets include a number of European languages, and we plan to expand +more in the future. diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_da.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_da.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f3efdc4ccafc6b2d710b445151dd21bc15649d62 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_da.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_da +dataset_name: da diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_de.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_de.yaml new file mode 100644 index 0000000000000000000000000000000000000000..36fdf7be9653d8b9c4441c8eb975075d4c93f447 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_de.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_de +dataset_name: de diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_el.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_el.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d97580b09e1b49855d2aa2a83192e7b01a06eadc --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_el.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_el +dataset_name: el diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_es.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_es.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7dffc6c7b976c84c71fb9f1468d6af65c2d00d20 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_es.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_es +dataset_name: es diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_fi.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_fi.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d2032e34a4f25b3e83371aac1dad1e59ac6a176d --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_fi.yaml @@ -0,0 +1,23 @@ +group: + - arc_challenge_mt +task: arc_challenge_mt_fi +dataset_path: LumiOpen/arc_challenge_mt +dataset_name: fi +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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_hu.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_hu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..03d5ac1725ca425bd25790d1910a986648dbd442 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_hu.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_hu +dataset_name: hu diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_is.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_is.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1591d7eb8f55d5b80597d1a059c5a76eb98192b9 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_is.yaml @@ -0,0 +1,22 @@ +group: + - arc_challenge_mt +task: arc_challenge_mt_is +dataset_path: mideind/icelandic-arc-challenge +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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_it.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_it.yaml new file mode 100644 index 0000000000000000000000000000000000000000..995f7a3dc944279b760c8433c552f0ecee78367a --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_it.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_it +dataset_name: it diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_nb.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_nb.yaml new file mode 100644 index 0000000000000000000000000000000000000000..aceaa14b5f4dc28d13a49f1e2a932f82a32e264e --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_nb.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_nb +dataset_name: nb diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_pl.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_pl.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3b9a332f682a3a63cbb543a7070ecfe5c3d23e66 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_pl.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_pl +dataset_name: pl diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_pt.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_pt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..748743fc8d934037f854cd0f5904871723fa638e --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_pt.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_pt +dataset_name: pt diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_sv.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_sv.yaml new file mode 100644 index 0000000000000000000000000000000000000000..09d97c51eb67a70069bbd47ca8661ead17e428ad --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/arc_mt/arc_challenge_mt_sv.yaml @@ -0,0 +1,3 @@ +include: arc_challenge_mt_fi.yaml +task: arc_challenge_mt_sv +dataset_name: sv diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/README.md new file mode 100644 index 0000000000000000000000000000000000000000..9ba47b224e89b1d835b69fa76b7d268a92f1eecc --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/README.md @@ -0,0 +1,72 @@ +# 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 and Tasks + +#### Groups + +* `basque-glue`: First version of the implementation + +#### 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/bec.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/bec.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fd15aea4990146cfff2e49d0897ec0ef4211ac6b --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/bec.yaml @@ -0,0 +1,16 @@ +group: 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/bhtc.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/bhtc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f3c5c432d5c2cc96d91dfaeaf643e2cf09c7551a --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/bhtc.yaml @@ -0,0 +1,16 @@ +group: 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/coref.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/coref.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6e9e8bdeaf8481b5844844af33e00482b472167b --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/coref.yaml @@ -0,0 +1,16 @@ +group: 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/qnli.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/qnli.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1a7d96ef7fc8ff5723bbe421dbb83f3ab378bd0c --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/qnli.yaml @@ -0,0 +1,16 @@ +group: 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/utils.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..401375f709f765dba749ea275df16bcb19643d9c --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/vaxx.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/vaxx.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e58507fdb6c1f09b7b30b8805ae09c4f52f1b94f --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/vaxx.yaml @@ -0,0 +1,16 @@ +group: 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/wic.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/wic.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ee334043d8eab3d297ccd442d6bdd247f03d30ea --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/basqueglue/wic.yaml @@ -0,0 +1,17 @@ +group: 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d3877a23866e75bd666b877c1225b956a226ba81 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/README.md @@ -0,0 +1,52 @@ +# Task-name + +### Paper + +Title: `BLiMP: A Benchmark of Linguistic Minimal Pairs for English` +Abstract: `https://arxiv.org/abs/1912.00582` + +BLiMP is a challenge set for evaluating what language models (LMs) know about +major grammatical phenomena in English. BLiMP consists of 67 sub-datasets, each +containing 1000 minimal pairs isolating specific contrasts in syntax, morphology, +or semantics. The data is automatically generated according to expert-crafted +grammars. + +Homepage: https://github.com/alexwarstadt/blimp + + +### Citation + +``` +@article{warstadt2019blimp, + author = {Warstadt, Alex and Parrish, Alicia and Liu, Haokun and Mohananey, Anhad and Peng, Wei and Wang, Sheng-Fu and Bowman, Samuel R.}, + title = {BLiMP: The Benchmark of Linguistic Minimal Pairs for English}, + journal = {Transactions of the Association for Computational Linguistics}, + volume = {8}, + number = {}, + pages = {377-392}, + year = {2020}, + doi = {10.1162/tacl\_a\_00321}, + URL = {https://doi.org/10.1162/tacl_a_00321}, + eprint = {https://doi.org/10.1162/tacl_a_00321}, + abstract = { We introduce The Benchmark of Linguistic Minimal Pairs (BLiMP),1 a challenge set for evaluating the linguistic knowledge of language models (LMs) on major grammatical phenomena in English. BLiMP consists of 67 individual datasets, each containing 1,000 minimal pairs—that is, pairs of minimally different sentences that contrast in grammatical acceptability and isolate specific phenomenon in syntax, morphology, or semantics. We generate the data according to linguist-crafted grammar templates, and human aggregate agreement with the labels is 96.4\%. We evaluate n-gram, LSTM, and Transformer (GPT-2 and Transformer-XL) LMs by observing whether they assign a higher probability to the acceptable sentence in each minimal pair. We find that state-of-the-art models identify morphological contrasts related to agreement reliably, but they struggle with some subtle semantic and syntactic phenomena, such as negative polarity items and extraction islands. } +} +``` + +### Subtasks + +List or describe tasks defined in this folder, and their names here: +* `task_name`: `1-sentence description of what this particular task does` +* `task_name2`: ..... + +### 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/anaphor_gender_agreement.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/anaphor_gender_agreement.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9117dafad3c43968010d4c595d0ffafcc377de44 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/anaphor_gender_agreement.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: anaphor_gender_agreement +include: _template_yaml +task: blimp_anaphor_gender_agreement diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/anaphor_number_agreement.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/anaphor_number_agreement.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e63200c83f41a0f03bd4afba0795e8071952cebd --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/anaphor_number_agreement.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: anaphor_number_agreement +include: _template_yaml +task: blimp_anaphor_number_agreement diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/animate_subject_trans.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/animate_subject_trans.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d15eb2c77d454ae8e2791cac85601a803f4bd785 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/animate_subject_trans.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: animate_subject_trans +include: _template_yaml +task: blimp_animate_subject_trans diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/complex_NP_island.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/complex_NP_island.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f4ccfe41fa0e6e5d3b8d5b46d6f2edaac60606f9 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/complex_NP_island.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: complex_NP_island +include: _template_yaml +task: blimp_complex_NP_island diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_1.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6c27935e834d8ee21001dc897714c9c6e3b4a390 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_1.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: determiner_noun_agreement_1 +include: _template_yaml +task: blimp_determiner_noun_agreement_1 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_with_adj_2.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_with_adj_2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eb8dba60ef1b9aa3a5af3652b86637fe10577116 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_with_adj_2.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: determiner_noun_agreement_with_adj_2 +include: _template_yaml +task: blimp_determiner_noun_agreement_with_adj_2 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_with_adj_irregular_1.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_with_adj_irregular_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..57f12ecade63b595378cb2c9aadf710725e9d4b0 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/determiner_noun_agreement_with_adj_irregular_1.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: determiner_noun_agreement_with_adj_irregular_1 +include: _template_yaml +task: blimp_determiner_noun_agreement_with_adj_irregular_1 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/drop_argument.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/drop_argument.yaml new file mode 100644 index 0000000000000000000000000000000000000000..db3b1fed109c802774c1ac8e347a931febc89646 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/drop_argument.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: drop_argument +include: _template_yaml +task: blimp_drop_argument diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/ellipsis_n_bar_1.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/ellipsis_n_bar_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3686534f3edf83df2c470a7907678db8ebe85abc --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/ellipsis_n_bar_1.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: ellipsis_n_bar_1 +include: _template_yaml +task: blimp_ellipsis_n_bar_1 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/existential_there_quantifiers_1.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/existential_there_quantifiers_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..15396ae3acadcada2e12549deeacd66b856d5a69 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/existential_there_quantifiers_1.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: existential_there_quantifiers_1 +include: _template_yaml +task: blimp_existential_there_quantifiers_1 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/existential_there_subject_raising.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/existential_there_subject_raising.yaml new file mode 100644 index 0000000000000000000000000000000000000000..45e18aebb660ed759099230686c0e1ae24ea3f86 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/existential_there_subject_raising.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: existential_there_subject_raising +include: _template_yaml +task: blimp_existential_there_subject_raising diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/generate_configs.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/generate_configs.py new file mode 100644 index 0000000000000000000000000000000000000000..a32c366834592041bde8b5fcaf2cc3c821f40f6f --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/generate_configs.py @@ -0,0 +1,94 @@ +import yaml + + +all_subtasks = [ + "adjunct_island", + "anaphor_gender_agreement", + "anaphor_number_agreement", + "animate_subject_passive", + "animate_subject_trans", + "causative", + "complex_NP_island", + "coordinate_structure_constraint_complex_left_branch", + "coordinate_structure_constraint_object_extraction", + "determiner_noun_agreement_1", + "determiner_noun_agreement_2", + "determiner_noun_agreement_irregular_1", + "determiner_noun_agreement_irregular_2", + "determiner_noun_agreement_with_adj_2", + "determiner_noun_agreement_with_adj_irregular_1", + "determiner_noun_agreement_with_adj_irregular_2", + "determiner_noun_agreement_with_adjective_1", + "distractor_agreement_relational_noun", + "distractor_agreement_relative_clause", + "drop_argument", + "ellipsis_n_bar_1", + "ellipsis_n_bar_2", + "existential_there_object_raising", + "existential_there_quantifiers_1", + "existential_there_quantifiers_2", + "existential_there_subject_raising", + "expletive_it_object_raising", + "inchoative", + "intransitive", + "irregular_past_participle_adjectives", + "irregular_past_participle_verbs", + "irregular_plural_subject_verb_agreement_1", + "irregular_plural_subject_verb_agreement_2", + "left_branch_island_echo_question", + "left_branch_island_simple_question", + "matrix_question_npi_licensor_present", + "npi_present_1", + "npi_present_2", + "only_npi_licensor_present", + "only_npi_scope", + "passive_1", + "passive_2", + "principle_A_c_command", + "principle_A_case_1", + "principle_A_case_2", + "principle_A_domain_1", + "principle_A_domain_2", + "principle_A_domain_3", + "principle_A_reconstruction", + "regular_plural_subject_verb_agreement_1", + "regular_plural_subject_verb_agreement_2", + "sentential_negation_npi_licensor_present", + "sentential_negation_npi_scope", + "sentential_subject_island", + "superlative_quantifiers_1", + "superlative_quantifiers_2", + "tough_vs_raising_1", + "tough_vs_raising_2", + "transitive", + "wh_island", + "wh_questions_object_gap", + "wh_questions_subject_gap", + "wh_questions_subject_gap_long_distance", + "wh_vs_that_no_gap", + "wh_vs_that_no_gap_long_distance", + "wh_vs_that_with_gap", + "wh_vs_that_with_gap_long_distance", +] + + +def main() -> None: + for task in all_subtasks: + file_name = f"{task}.yaml" + try: + with open(f"{file_name}", "w", encoding="utf-8") as f: + f.write("# Generated by utils.py\n") + yaml.dump( + { + "include": "_template_yaml", + "task": "blimp_" + task, + "dataset_name": task, + }, + f, + ) + except FileExistsError: + pass + + +if __name__ == "__main__": + main() diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_past_participle_adjectives.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_past_participle_adjectives.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fe9097d6673f9a3d5d05f511f9ea48940f41d44f --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_past_participle_adjectives.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: irregular_past_participle_adjectives +include: _template_yaml +task: blimp_irregular_past_participle_adjectives diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_past_participle_verbs.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_past_participle_verbs.yaml new file mode 100644 index 0000000000000000000000000000000000000000..906fb347710e46c3159aaee05def45730b30929f --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_past_participle_verbs.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: irregular_past_participle_verbs +include: _template_yaml +task: blimp_irregular_past_participle_verbs diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_plural_subject_verb_agreement_2.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_plural_subject_verb_agreement_2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5d3b84fceab0e3907ab6b1bd3e44a0e6c9445416 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/irregular_plural_subject_verb_agreement_2.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: irregular_plural_subject_verb_agreement_2 +include: _template_yaml +task: blimp_irregular_plural_subject_verb_agreement_2 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/left_branch_island_echo_question.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/left_branch_island_echo_question.yaml new file mode 100644 index 0000000000000000000000000000000000000000..409e8ccca8a101366a0f881e775a7dcf9ff317b6 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/left_branch_island_echo_question.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: left_branch_island_echo_question +include: _template_yaml +task: blimp_left_branch_island_echo_question diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/matrix_question_npi_licensor_present.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/matrix_question_npi_licensor_present.yaml new file mode 100644 index 0000000000000000000000000000000000000000..712cf4313ee90bc407b86d51c49fcaa3198247f8 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/matrix_question_npi_licensor_present.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: matrix_question_npi_licensor_present +include: _template_yaml +task: blimp_matrix_question_npi_licensor_present diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/only_npi_licensor_present.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/only_npi_licensor_present.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8dbce62337d39d44aed2f0f14cfd51dec367a42c --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/only_npi_licensor_present.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: only_npi_licensor_present +include: _template_yaml +task: blimp_only_npi_licensor_present diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/only_npi_scope.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/only_npi_scope.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4386575f591b9f03cf12f37e04ee8632c4fbec79 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/only_npi_scope.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: only_npi_scope +include: _template_yaml +task: blimp_only_npi_scope diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/passive_1.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/passive_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0dd6aca0535d448d9269ae1959063d687955a17f --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/passive_1.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: passive_1 +include: _template_yaml +task: blimp_passive_1 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/principle_A_domain_1.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/principle_A_domain_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..eb06e731c5836934df3cbf8f77b1a768e248271d --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/principle_A_domain_1.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: principle_A_domain_1 +include: _template_yaml +task: blimp_principle_A_domain_1 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/regular_plural_subject_verb_agreement_2.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/regular_plural_subject_verb_agreement_2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..37cdb781391d0280c96458b6cf8493d65ca00d3c --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/regular_plural_subject_verb_agreement_2.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: regular_plural_subject_verb_agreement_2 +include: _template_yaml +task: blimp_regular_plural_subject_verb_agreement_2 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/superlative_quantifiers_2.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/superlative_quantifiers_2.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ac031c4ecc1acf46bed9c5dbf333f140daa18155 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/superlative_quantifiers_2.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: superlative_quantifiers_2 +include: _template_yaml +task: blimp_superlative_quantifiers_2 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/tough_vs_raising_1.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/tough_vs_raising_1.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7abc4dc28ddb4074bcb2db2f8d706119b1ca08d3 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/tough_vs_raising_1.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: tough_vs_raising_1 +include: _template_yaml +task: blimp_tough_vs_raising_1 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/transitive.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/transitive.yaml new file mode 100644 index 0000000000000000000000000000000000000000..18864352a9b1bfdb26c146af8333f9c0dfc4beec --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/transitive.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: transitive +include: _template_yaml +task: blimp_transitive diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/wh_questions_subject_gap.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/wh_questions_subject_gap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..b956919c455893a0282a7d3842fc57eefe624114 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/blimp/wh_questions_subject_gap.yaml @@ -0,0 +1,4 @@ +# Generated by utils.py +dataset_name: wh_questions_subject_gap +include: _template_yaml +task: blimp_wh_questions_subject_gap diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/commonsense_qa/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/commonsense_qa/README.md new file mode 100644 index 0000000000000000000000000000000000000000..94ef87a57a20ea744c11ec7f1304ff545470247f --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/commonsense_qa/README.md @@ -0,0 +1,60 @@ +# Task-name + +### Paper + +Title: `COMMONSENSEQA: A Question Answering Challenge Targeting +Commonsense Knowledge` + +Abstract: https://arxiv.org/pdf/1811.00937.pdf + +CommonsenseQA is a multiple-choice question answering dataset that requires different types of commonsense knowledge to predict the correct answers. +It contains 12,102 questions with one correct answer and four distractor answers. + +Homepage: https://www.tau-nlp.org/commonsenseqa + + +### Citation + +``` +@inproceedings{talmor-etal-2019-commonsenseqa, + title = "{C}ommonsense{QA}: A Question Answering Challenge Targeting Commonsense Knowledge", + author = "Talmor, Alon and + Herzig, Jonathan and + Lourie, Nicholas and + Berant, Jonathan", + booktitle = "Proceedings of the 2019 Conference of the North {A}merican Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers)", + month = jun, + year = "2019", + address = "Minneapolis, Minnesota", + publisher = "Association for Computational Linguistics", + url = "https://aclanthology.org/N19-1421", + doi = "10.18653/v1/N19-1421", + pages = "4149--4158", + archivePrefix = "arXiv", + eprint = "1811.00937", + primaryClass = "cs", +} +``` + +### Groups and Tasks + +#### Groups + +* Not part of a group yet. + +#### Tasks + +* `commonsense_qa`: Represents the "random" split from the paper. Uses an MMLU-style prompt, as (presumably) used by Llama evaluations. + +### 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: +* [ ] 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/commonsense_qa/default.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/commonsense_qa/default.yaml new file mode 100644 index 0000000000000000000000000000000000000000..31d31b01253698a83d40cf6f4fa8a2dc4aa47d3e --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/commonsense_qa/default.yaml @@ -0,0 +1,12 @@ +task: commonsense_qa +dataset_path: tau/commonsense_qa +training_split: train +validation_split: validation +output_type: multiple_choice +doc_to_text: "Question: {{ question.strip() }}\nA. {{choices['text'][0]}}\nB. {{choices['text'][1]}}\nC. {{choices['text'][2]}}\nD. {{choices['text'][3]}}\nE. {{choices['text'][4]}}\nAnswer:" +doc_to_target: answerKey +doc_to_choice: ['A', 'B', 'C', 'D', 'E'] +metric_list: + - metric: acc + aggregation: mean + higher_is_better: true diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/gpqa/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/gpqa/README.md new file mode 100644 index 0000000000000000000000000000000000000000..03c94bd14c0caa93af58b1e61cbce14c3ea5fe2b --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/gpqa/README.md @@ -0,0 +1,55 @@ +# GPQA + +### Paper + +Title: GPQA: A Graduate-Level Google-Proof Q&A Benchmark + +Abstract: https://arxiv.org/abs/2311.12022 + +We present GPQA, a challenging dataset of 448 multiple-choice questions written by domain experts in biology, physics, and chemistry. We ensure that the questions are high-quality and extremely difficult: experts who have or are pursuing PhDs in the corresponding domains reach 65% accuracy (74% when discounting clear mistakes the experts identified in retrospect), while highly skilled non-expert validators only reach 34% accuracy, despite spending on average over 30 minutes with unrestricted access to the web (i.e., the questions are “Google-proof”). The questions are also difficult for state-of-the-art AI systems, with our strongest GPT-4–based baseline achieving 39% accuracy. If we are to use future AI systems to help us answer very hard questions—for example, when developing new scientific knowledge—we need to develop *scalable oversight* methods that enable humans to supervise their outputs, which may be difficult even if the supervisors are themselves skilled and knowledgeable. The difficulty of GPQA both for skilled non-experts and frontier AI systems should enable realistic scalable oversight experiments, which we hope can help devise ways for human experts to reliably get truthful information from AI systems that surpass human capabilities. + +Homepage: `https://github.com/idavidrein/gpqa/tree/main` + +### Citation + +``` +@misc{rein2023gpqa, + title={GPQA: A Graduate-Level Google-Proof Q&A Benchmark}, + author={David Rein and Betty Li Hou and Asa Cooper Stickland and Jackson Petty and Richard Yuanzhe Pang and Julien Dirani and Julian Michael and Samuel R. Bowman}, + year={2023}, + eprint={2311.12022}, + archivePrefix={arXiv}, + primaryClass={cs.AI} +} +``` + +This dataset is gated, so you will have to accept the terms of use at https://huggingface.co/datasets/Idavidrein/gpqa and login via `huggingface-cli login` using your HF Hub token before running this task. + +### Groups and Tasks + +#### Groups + +* `gpqa` + +#### Tasks + +* `gpqa_{main, diamond, extended}_zeroshot` +* `gpqa_{main, diamond, extended}_n_shot` +* `gpqa_{main, diamond, extended}_generative_n_shot` +* `gpqa_{main, diamond, extended}_cot_zeroshot` +* `gpqa_{main, diamond, extended}_cot_n_shot` + +### 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: + +* [ ] 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/README.md new file mode 100644 index 0000000000000000000000000000000000000000..aced2e78bb5adfd0ff413b4ee72c53e0fa3d5cc6 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/README.md @@ -0,0 +1,45 @@ +# IFEval + +### Paper + +Title: Instruction-Following Evaluation for Large Language Models +Abstract: https://arxiv.org/abs/2311.07911 + +One core capability of Large Language Models (LLMs) is to follow natural language instructions. However, the evaluation of such abilities is not standardized: Human evaluations are expensive, slow, and not objectively reproducible, while LLM-based auto-evaluation is potentially biased or limited by the ability of the evaluator LLM. To overcome these issues, we introduce Instruction-Following Eval (IFEval) for large language models. IFEval is a straightforward and easy-to-reproduce evaluation benchmark. It focuses on a set of "verifiable instructions" such as "write in more than 400 words" and "mention the keyword of AI at least 3 times". We identified 25 types of those verifiable instructions and constructed around 500 prompts, with each prompt containing one or more verifiable instructions. We show evaluation results of two widely available LLMs on the market. Our code and data can be found at https://github.com/google-research/google-research/tree/master/instruction_following_eval + +Homepage: https://github.com/google-research/google-research/tree/master/instruction_following_eval + + +### Citation + +``` +@article{zhou2023instructionfollowing, + title={Instruction-Following Evaluation for Large Language Models}, + author={Jeffrey Zhou and Tianjian Lu and Swaroop Mishra and Siddhartha Brahma and Sujoy Basu and Yi Luan and Denny Zhou and Le Hou}, + journal={arXiv preprint arXiv:2311.07911}, + year={2023}, +} +``` + +### Groups and Tasks + +#### Groups + +* Not part of a group yet + +#### Tasks + +* `ifeval` + +### 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: +* [ ] 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/ifeval.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/ifeval.yaml new file mode 100644 index 0000000000000000000000000000000000000000..97e760144a517d723aca5371ae568ae28ab6dcf6 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/ifeval.yaml @@ -0,0 +1,29 @@ +task: ifeval +dataset_path: wis-k/instruction-following-eval +dataset_name: null +output_type: generate_until +test_split: train +num_fewshot: 0 +doc_to_text: prompt +doc_to_target: 0 +generation_kwargs: + until: [] + do_sample: false + temperature: 0.0 + max_gen_toks: 1280 +process_results: !function utils.process_results +metric_list: + - metric: prompt_level_strict_acc + aggregation: mean + higher_is_better: true + - metric: inst_level_strict_acc + aggregation: !function utils.agg_inst_level_acc + higher_is_better: true + - metric: prompt_level_loose_acc + aggregation: mean + higher_is_better: true + - metric: inst_level_loose_acc + aggregation: !function utils.agg_inst_level_acc + higher_is_better: true +metadata: + version: 2.0 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions.py new file mode 100644 index 0000000000000000000000000000000000000000..5c352af3f70e8e25561a755b877f36ce28b13c11 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions.py @@ -0,0 +1,1612 @@ +# Copyright 2023 The Google Research Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Library of instructions.""" + +import collections +import json +import logging +import random +import re +import string +from typing import Dict, Optional, Sequence, Union + +import langdetect + +from lm_eval.tasks.ifeval import instructions_util + + +logger = logging.getLogger(__name__) + +_InstructionArgsDtype = Optional[Dict[str, Union[int, str, Sequence[str]]]] + +_LANGUAGES = instructions_util.LANGUAGE_CODES + +# The relational operation for comparison. +_COMPARISON_RELATION = ("less than", "at least") + +# The maximum number of sentences. +_MAX_NUM_SENTENCES = 20 + +# The number of placeholders. +_NUM_PLACEHOLDERS = 4 + +# The number of bullet lists. +_NUM_BULLETS = 5 + +# The options of constrained response. +_CONSTRAINED_RESPONSE_OPTIONS = ( + "My answer is yes.", + "My answer is no.", + "My answer is maybe.", +) + +# The options of starter keywords. +_STARTER_OPTIONS = ( + "I would say", + "My answer is", + "I believe", + "In my opinion", + "I think", + "I reckon", + "I feel", + "From my perspective", + "As I see it", + "According to me", + "As far as I'm concerned", + "To my understanding", + "In my view", + "My take on it is", + "As per my perception", +) + +# The options of ending keywords. +# TODO(jeffreyzhou) add more ending options +_ENDING_OPTIONS = ("Any other questions?", "Is there anything else I can help with?") + +# The number of highlighted sections. +_NUM_HIGHLIGHTED_SECTIONS = 4 + +# The section spliter. +_SECTION_SPLITER = ("Section", "SECTION") + +# The number of sections. +_NUM_SECTIONS = 5 + +# The number of paragraphs. +_NUM_PARAGRAPHS = 5 + +# The postscript marker. +_POSTSCRIPT_MARKER = ("P.S.", "P.P.S") + +# The number of keywords. +_NUM_KEYWORDS = 2 + +# The occurrences of a single keyword. +_KEYWORD_FREQUENCY = 3 + +# The occurrences of a single letter. +_LETTER_FREQUENCY = 10 + +# The occurrences of words with all capital letters. +_ALL_CAPITAL_WORD_FREQUENCY = 20 + +# The number of words in the response. +_NUM_WORDS_LOWER_LIMIT = 100 +_NUM_WORDS_UPPER_LIMIT = 500 + + +class Instruction: + """An instruction template.""" + + def __init__(self, instruction_id): + self.id = instruction_id + + def build_description(self, **kwargs): + raise NotImplementedError("`build_description` not implemented.") + + def get_instruction_args(self): + raise NotImplementedError("`get_instruction_args` not implemented.") + + def get_instruction_args_keys(self): + raise NotImplementedError("`get_instruction_args_keys` not implemented.") + + def check_following(self, value): + raise NotImplementedError("`check_following` not implemented.") + + +class ResponseLanguageChecker(Instruction): + """Check the language of the entire response.""" + + def build_description(self, *, language=None): + """Build the instruction description. + + Args: + language: A string representing the expected language of the response. The + language has to comply to the 97 types defined in + `langid.py` (https://pypi.org/project/langid/1.1.5/), which follows + ISO 639-1 codes (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes); + for example, `en` for English, `zh` for Chinese, `fr` for French. + + Returns: + A string representing the instruction description. + """ + self._language = language + if self._language is None: + self._language = random.choice(list(_LANGUAGES.keys())) + # TODO(tianjianlu): opens the description generation to more choices. + self._description_pattern = ( + "Your ENTIRE response should be in {language} language, no other " + + "language is allowed." + ) + return self._description_pattern.format(language=_LANGUAGES[self._language]) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"language": self._language} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["language"] + + def check_following(self, value): + """Check if the language of the entire response follows the instruction. + + Args: + value: A string representing the response. + + Returns: + True if the language of `value` follows instruction; otherwise False. + """ + assert isinstance(value, str) + + try: + return langdetect.detect(value) == self._language + except langdetect.LangDetectException as e: + # Count as instruction is followed. + logging.error( + "Unable to detect language for text %s due to %s", value, e + ) # refex: disable=pytotw.037 + return True + + +class NumberOfSentences(Instruction): + """Check the number of sentences.""" + + def build_description(self, *, num_sentences=None, relation=None): + """Build the instruction description. + + Args: + num_sentences: An integer specifying the number of sentences as a + threshold. + relation: A string in (`less than`, `at least`), defining the relational + operator for comparison. + Two relational comparisons are supported for now: + if 'less than', the actual number of sentences < the threshold; + if 'at least', the actual number of sentences >= the threshold. + + Returns: + A string representing the instruction description. + """ + # The number of sentences as a threshold for comparison. + self._num_sentences_threshold = num_sentences + if self._num_sentences_threshold is None or self._num_sentences_threshold < 0: + self._num_sentences_threshold = random.randint(1, _MAX_NUM_SENTENCES) + + if relation is None: + self._comparison_relation = random.choice(_COMPARISON_RELATION) + elif relation not in _COMPARISON_RELATION: + raise ValueError( + "The supported relation for comparison must be in " + f"{_COMPARISON_RELATION}, but {relation} is given." + ) + else: + self._comparison_relation = relation + + self._description_pattern = ( + "Your response should contain {relation} {num_sentences} sentences." + ) + return self._description_pattern.format( + relation=self._comparison_relation, + num_sentences=self._num_sentences_threshold, + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return { + "num_sentences": self._num_sentences_threshold, + "relation": self._comparison_relation, + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_sentences", "relation"] + + def check_following(self, value): + """Check if the number of sentences follows the instruction. + + Args: + value: A string representing the response. + + Returns: + True if the response follows the instruction. + + Raise: + ValueError if the string in `instruction_args` is not in + [`less_than`, `at_least`]. + """ + num_sentences = instructions_util.count_sentences(value) + if self._comparison_relation == _COMPARISON_RELATION[0]: + return num_sentences < self._num_sentences_threshold + elif self._comparison_relation == _COMPARISON_RELATION[1]: + return num_sentences >= self._num_sentences_threshold + + +class PlaceholderChecker(Instruction): + """Check the placeholders in template writing.""" + + def build_description(self, *, num_placeholders=None): + """Build the instruction description. + + Args: + num_placeholders: An integer denoting the minimum number of + placeholders required in the response. + + Returns: + A string representing the instruction description. + """ + self._num_placeholders = num_placeholders + if self._num_placeholders is None or self._num_placeholders < 0: + self._num_placeholders = random.randint(1, _NUM_PLACEHOLDERS) + self._description_pattern = ( + "The response must contain at least {num_placeholders} placeholders " + + "represented by square brackets, such as [address]." + ) + return self._description_pattern.format(num_placeholders=self._num_placeholders) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"num_placeholders": self._num_placeholders} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_placeholders"] + + def check_following(self, value): + """Check if the number of placeholders follows the instruction. + + Args: + value: A string representing the response. + + Returns: + True if the actual number of placeholders in the response is greater than + or equal to `num_placeholders`; otherwise, False. + """ + placeholders = re.findall(r"\[.*?\]", value) + num_placeholders = len(placeholders) + return num_placeholders >= self._num_placeholders + + +class BulletListChecker(Instruction): + """Checks the bullet list in the prompt.""" + + def build_description(self, *, num_bullets=None): + """Build the instruction description. + + Args: + num_bullets: An integer specifying the exact number of bullet lists + that is required to appear in the response. + + Returns: + A string representing the instruction description. + """ + self._num_bullets = num_bullets + if self._num_bullets is None or self._num_bullets < 0: + self._num_bullets = random.randint(1, _NUM_BULLETS) + self._description_pattern = ( + "Your answer must contain exactly {num_bullets} bullet points. " + + "Use the markdown bullet points such as:\n" + + "* This is point 1. \n" + + "* This is point 2" + ) + return self._description_pattern.format(num_bullets=self._num_bullets) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"num_bullets": self._num_bullets} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_bullets"] + + def check_following(self, value): + r"""Check if the number of bullet lists meets the requirement. + + Args: + value: A string representing the response. The response is expected to + contain some bullet lists that start with `\*`. + + Returns: + True if the actual number of bullet lists in the response meets the + requirement. + """ + bullet_lists = re.findall(r"^\s*\*[^\*].*$", value, flags=re.MULTILINE) + bullet_lists_2 = re.findall(r"^\s*-.*$", value, flags=re.MULTILINE) + num_bullet_lists = len(bullet_lists) + len(bullet_lists_2) + return num_bullet_lists == self._num_bullets + + +class ConstrainedResponseChecker(Instruction): + """Checks the constrained response.""" + + def build_description(self): + """Build the instruction description.""" + # A sequence of string(s) representing the options of the expected response. + self._constrained_responses = _CONSTRAINED_RESPONSE_OPTIONS + self._description_pattern = ( + "Answer with one of the following options: {response_options}" + ) + return self._description_pattern.format( + response_options=self._constrained_responses + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + """Checks if the response matches the constrained options. + + Args: + value: A string representing the response. + + Returns: + True if the actual response contains one of the options in the constrained + responses; otherwise False. + """ + value = value.strip() + for constrained_response in self._constrained_responses: + if constrained_response in value: + return True + return False + + +class ConstrainedStartChecker(Instruction): + """Checks the response start.""" + + def build_description(self, *, starter=None): + """Build the instruction description. + + Args: + starter: A string representing the keyward that the response should start + with. + + Returns: + A string representing the instruction description. + """ + self._starter = starter.strip() if isinstance(starter, str) else starter + if self._starter is None: + self._starter = random.choice(_STARTER_OPTIONS) + self._description_pattern = ( + "During the conversation, when it is your turn, " + + "please always start with {starter}" + ) + return self._description_pattern.format(starter=self._starter) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"starter": self._starter} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["starter"] + + def check_following(self, value): + """Checks if the response starts with the constrained keyword or phrase. + + Args: + value: A string representing the response. + + Returns: + True if the response starts with the given phrase or keyword that is + contained in `instruction_args`; otherwise, False. + """ + response_pattern = r"^\s*" + self._starter + r".*$" + response_with_constrained_start = re.search( + response_pattern, value, flags=re.MULTILINE + ) + return True if response_with_constrained_start else False + + +class HighlightSectionChecker(Instruction): + """Checks the highlighted section.""" + + def build_description(self, *, num_highlights=None): + """Build the instruction description. + + Args: + num_highlights: An integer specifying the minimum number of highlighted + sections. + + Returns: + A string representing the instruction description. + """ + self._num_highlights = num_highlights + if self._num_highlights is None or self._num_highlights < 0: + self._num_highlights = random.randint(1, _NUM_HIGHLIGHTED_SECTIONS) + + self._description_pattern = ( + "Highlight at least {num_highlights} sections in your answer with " + + "markdown, i.e. *highlighted section*." + ) + + return self._description_pattern.format(num_highlights=self._num_highlights) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"num_highlights": self._num_highlights} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_highlights"] + + def check_following(self, value): + """Checks if the number of highlighted sections meets the requirement. + + Args: + value: a string repesenting the response. The response is expected to + contain highlighted sections in the format of *highlighted*. + + Returns: + True if the actual number of highlighted sections in the format of + *highlighed sections* meets the minimum requirement; otherwise False. + """ + num_highlights = 0 + highlights = re.findall(r"\*[^\n\*]*\*", value) + double_highlights = re.findall(r"\*\*[^\n\*]*\*\*", value) + for highlight in highlights: + if highlight.strip("*").strip(): + num_highlights += 1 + for highlight in double_highlights: + if highlight.removeprefix("**").removesuffix("**").strip(): + num_highlights += 1 + + return num_highlights >= self._num_highlights + + +class SectionChecker(Instruction): + """Checks the sections.""" + + def build_description(self, *, section_spliter=None, num_sections=None): + """Build the instruction description. + + Args: + section_spliter: A string represents the section spliter keyword that + marks a new section, i.e., `Section` or `SECTION`. + num_sections: An integer specifying the number of sections. + + Returns: + A string representing the instruction description. + """ + self._section_spliter = ( + section_spliter.strip() + if isinstance(section_spliter, str) + else section_spliter + ) + if self._section_spliter is None: + self._section_spliter = random.choice(_SECTION_SPLITER) + + self._num_sections = num_sections + if self._num_sections is None or self._num_sections < 0: + self._num_sections = random.randint(1, _NUM_SECTIONS) + + self._description_pattern = ( + "Your response must have {num_sections} sections. Mark the beginning " + + "of each section with {section_spliter} X, such as:\n" + + "{section_spliter} 1\n" + + "[content of section 1]\n" + + "{section_spliter} 2\n" + + "[content of section 2]" + ) + + return self._description_pattern.format( + num_sections=self._num_sections, section_spliter=self._section_spliter + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return { + "section_spliter": self._section_spliter, + "num_sections": self._num_sections, + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["section_spliter", "num_sections"] + + def check_following(self, value): + """Checks the response contains multiple sections. + + Args: + value: A string representing the response. The response is expected + to contain multiple sections (number of sections is greater than 1). + A new section starts with `Section 1`, where the number denotes the + section index. + + Returns: + True if the number of sections in the response is greater than or equal to + the minimum number of sections; otherwise, False. + """ + section_splitter_patten = r"\s?" + self._section_spliter + r"\s?\d+\s?" + sections = re.split(section_splitter_patten, value) + num_sections = len(sections) - 1 + return num_sections >= self._num_sections + + +class ParagraphChecker(Instruction): + """Checks the paragraphs.""" + + def build_description(self, *, num_paragraphs=None): + """Build the instruction description. + + Args: + num_paragraphs: An integer specifying the number of paragraphs. + + Returns: + A string representing the instruction description. + """ + self._num_paragraphs = num_paragraphs + if self._num_paragraphs is None or self._num_paragraphs < 0: + self._num_paragraphs = random.randint(1, _NUM_PARAGRAPHS) + + self._description_pattern = ( + "There should be {num_paragraphs} paragraphs. " + + "Paragraphs are separated with the markdown divider: ***" + ) + + return self._description_pattern.format(num_paragraphs=self._num_paragraphs) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"num_paragraphs": self._num_paragraphs} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_paragraphs"] + + def check_following(self, value): + """Checks the response contains required number of paragraphs. + + Args: + value: A string representing the response. The response may contain + paragraphs that are separated by the markdown divider: `***`. + + Returns: + True if the actual number of paragraphs is the same as required; + otherwise, False. + """ + paragraphs = re.split(r"\s?\*\*\*\s?", value) + num_paragraphs = len(paragraphs) + + for index, paragraph in enumerate(paragraphs): + if not paragraph.strip(): + if index == 0 or index == len(paragraphs) - 1: + num_paragraphs -= 1 + else: + return False + + return num_paragraphs == self._num_paragraphs + + +class PostscriptChecker(Instruction): + """Checks the postscript.""" + + def build_description(self, *, postscript_marker=None): + """Build the instruction description. + + Args: + postscript_marker: A string containing the keyword that marks the start + of the postscript section. + + Returns: + A string representing the instruction description. + """ + self._postscript_marker = ( + postscript_marker.strip() + if isinstance(postscript_marker, str) + else postscript_marker + ) + if self._postscript_marker is None: + self._postscript_marker = random.choice(_POSTSCRIPT_MARKER) + + self._description_pattern = ( + "At the end of your response, please explicitly add a postscript " + + "starting with {postscript}" + ) + + return self._description_pattern.format(postscript=self._postscript_marker) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"postscript_marker": self._postscript_marker} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["postscript_marker"] + + def check_following(self, value): + """Checks if the response follows the postscript format. + + Args: + value: a string representing the response. The response is expected to + contain a postscript section. + + Returns: + True if the response contains a postscript section starting with + the keyword containing in the `instruction_args`; otherwise False. + """ + value = value.lower() + if self._postscript_marker == "P.P.S": + postscript_pattern = r"\s*p\.\s?p\.\s?s.*$" + elif self._postscript_marker == "P.S.": + postscript_pattern = r"\s*p\.\s?s\..*$" + else: + postscript_pattern = r"\s*" + self._postscript_marker.lower() + r".*$" + postscript = re.findall(postscript_pattern, value, flags=re.MULTILINE) + return True if postscript else False + + +class RephraseChecker(Instruction): + """Checks the repharse.""" + + def build_description(self, *, original_message): + """Build the instruction description. + + Args: + original_message: A string representing the original message. The + rephrased response should only change its words/sentences in between + its two asterisks, for example, *change me*. Both original and rephrased + messages should contain the changes in the form of *change me*. + + Returns: + A string representing the instruction description. + """ + if not self.is_change(original_message): + raise ValueError( + f"Message {original_message} does not contain changes " + "in the form of *change me*." + ) + + self._reference_without_change = original_message + self._description = ( + "Rephrasing: Your rephrased response should only" + + "change the words/sentences in between two asterisks" + + "such as *change me*." + ) + return self._description + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"original_message": self._reference_without_change} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["original_message"] + + def check_following(self, value): + r"""Checks if the rephrasing follows the instruction. + + Args: + value: A string representing the response, which is expected to rephras + the string of `instruction_args`. + + Returns: + True if `value` and `instruction_args` only differ by the words/sentences + in between two asterisks such as *change me*; otherwise, False. + """ + + if not self.is_change(value): + raise ValueError( + f"value {value} does not contain " "changes in the form of *change me*." + ) + + response_without_changes = self.strip_changes(value) + reference_without_changes = self.strip_changes(self._reference_without_change) + + return response_without_changes == reference_without_changes + + def is_change(self, response): + """Check if there is change in the response in the form of *change me*.""" + return re.search(r"\*.*\*", response) + + def strip_changes(self, response): + """Strips off the changes.""" + return re.sub(r"\*.*\*", "", response) + + +class KeywordChecker(Instruction): + """Check the exisitence of certain keywords.""" + + def build_description(self, *, keywords=None): + """Build the instruction description. + + Args: + keywords: A sequence of strings representing the keywords that are + expected in the response. + + Returns: + A string representing the instruction description. + """ + + if not keywords: + self._keywords = instructions_util.generate_keywords( + num_keywords=_NUM_KEYWORDS + ) + else: + self._keywords = keywords + self._keywords = sorted(self._keywords) + + self._description_pattern = "Include keywords {keywords} in the response." + + return self._description_pattern.format(keywords=self._keywords) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"keywords": self._keywords} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["keywords"] + + def check_following(self, value): + """Check if the response contain the expected keywords.""" + for keyword in self._keywords: + if not re.search(keyword, value, flags=re.IGNORECASE): + return False + return True + + +class KeywordFrequencyChecker(Instruction): + """Check the keyword frequency.""" + + def build_description(self, *, keyword=None, frequency=None, relation=None): + """Build the instruction description. + + Args: + keyword: A string representing a keyword that is expected in the response. + frequency: An integer specifying the number of times `keyword` is expected + to appear in the response. + relation: A string in (`less than`, `at least`), defining the relational + operator for comparison. + Two relational comparisons are supported for now: + if 'less than', the actual number of occurrences < frequency; + if 'at least', the actual number of occurrences >= frequency. + + Returns: + A string representing the instruction description. + """ + if not keyword: + self._keyword = instructions_util.generate_keywords(num_keywords=1)[0] + else: + self._keyword = keyword.strip() + + self._frequency = frequency + if self._frequency is None or self._frequency < 0: + self._frequency = random.randint(1, _KEYWORD_FREQUENCY) + + if relation is None: + self._comparison_relation = random.choice(_COMPARISON_RELATION) + elif relation not in _COMPARISON_RELATION: + raise ValueError( + "The supported relation for comparison must be in " + f"{_COMPARISON_RELATION}, but {relation} is given." + ) + else: + self._comparison_relation = relation + + self._description_pattern = ( + "In your response, the word {keyword} should appear {relation} " + + "{frequency} times." + ) + + return self._description_pattern.format( + keyword=self._keyword, + relation=self._comparison_relation, + frequency=self._frequency, + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return { + "keyword": self._keyword, + "frequency": self._frequency, + "relation": self._comparison_relation, + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["keyword", "frequency", "relation"] + + def check_following(self, value): + """Checks if the response contain the keyword with required frequency.""" + actual_occurrences = len(re.findall(self._keyword, value, flags=re.IGNORECASE)) + + if self._comparison_relation == _COMPARISON_RELATION[0]: + return actual_occurrences < self._frequency + elif self._comparison_relation == _COMPARISON_RELATION[1]: + return actual_occurrences >= self._frequency + + +class NumberOfWords(Instruction): + """Checks the number of words.""" + + def build_description(self, *, num_words=None, relation=None): + """Build the instruction description. + + Args: + num_words: An integer specifying the number of words contained in the + response. + relation: A string in (`less than`, `at least`), defining the relational + operator for comparison. + Two relational comparisons are supported for now: + if 'less than', the actual number of words < num_words; + if 'at least', the actual number of words >= num_words. + + Returns: + A string representing the instruction description. + """ + + self._num_words = num_words + if self._num_words is None or self._num_words < 0: + self._num_words = random.randint( + _NUM_WORDS_LOWER_LIMIT, _NUM_WORDS_UPPER_LIMIT + ) + + if relation is None: + self._comparison_relation = random.choice(_COMPARISON_RELATION) + elif relation not in _COMPARISON_RELATION: + raise ValueError( + "The supported relation for comparison must be in " + f"{_COMPARISON_RELATION}, but {relation} is given." + ) + else: + self._comparison_relation = relation + + self._description_pattern = "Answer with {relation} {num_words} words." + + return self._description_pattern.format( + relation=self._comparison_relation, num_words=self._num_words + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"num_words": self._num_words, "relation": self._comparison_relation} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_words", "relation"] + + def check_following(self, value): + """Checks if the response contains the expected number of words.""" + num_words = instructions_util.count_words(value) + + if self._comparison_relation == _COMPARISON_RELATION[0]: + return num_words < self._num_words + elif self._comparison_relation == _COMPARISON_RELATION[1]: + return num_words >= self._num_words + + +class JsonFormat(Instruction): + """Check the Json format.""" + + def build_description(self): + self._description_pattern = ( + "Entire output should be wrapped in JSON format. You can use markdown" + " ticks such as ```." + ) + return self._description_pattern + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + value = ( + value.strip() + .removeprefix("```json") + .removeprefix("```Json") + .removeprefix("```JSON") + .removeprefix("```") + .removesuffix("```") + .strip() + ) + try: + json.loads(value) + except ValueError: + return False + return True + + +class ParagraphFirstWordCheck(Instruction): + """Check the paragraph and the first word of the nth paragraph.""" + + def build_description( + self, num_paragraphs=None, nth_paragraph=None, first_word=None + ): + r"""Build the instruction description. + + Args: + num_paragraphs: An integer indicating the number of paragraphs expected + in the response. A paragraph is a subset of the string that is + expected to be separated by '\n\n'. + nth_paragraph: An integer indicating the paragraph number that we look at. + Note that n starts from 1. + first_word: A string that represent the first word of the bth paragraph. + + Returns: + A string representing the instruction description. + """ + self._num_paragraphs = num_paragraphs + if self._num_paragraphs is None or self._num_paragraphs < 0: + self._num_paragraphs = random.randint(1, _NUM_PARAGRAPHS) + + self._nth_paragraph = nth_paragraph + if ( + self._nth_paragraph is None + or self._nth_paragraph <= 0 + or self._nth_paragraph > self._num_paragraphs + ): + self._nth_paragraph = random.randint(1, self._num_paragraphs + 1) + + self._first_word = first_word + if self._first_word is None: + self._first_word = instructions_util.generate_keywords(num_keywords=1)[0] + self._first_word = self._first_word.lower() + + self._description_pattern = ( + "There should be {num_paragraphs} paragraphs. " + + "Paragraphs and only paragraphs are separated with each other by two " + + "new lines as if it was '\\n\\n' in python. " + + "Paragraph {nth_paragraph} must start with word {first_word}." + ) + + return self._description_pattern.format( + num_paragraphs=self._num_paragraphs, + nth_paragraph=self._nth_paragraph, + first_word=self._first_word, + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return { + "num_paragraphs": self._num_paragraphs, + "nth_paragraph": self._nth_paragraph, + "first_word": self._first_word, + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_paragraphs", "nth_paragraph", "first_word"] + + def check_following(self, value): + """Checks for required number of paragraphs and correct first word. + + Args: + value: a string representing the response. The response may contain + paragraphs that are separated by two new lines and the first word of + the nth paragraph will have to match a specified word. + + Returns: + True if the number of paragraphs is the same as required and the first + word of the specified paragraph is the same as required. Otherwise, false. + """ + + paragraphs = re.split(r"\n\n", value) + num_paragraphs = len(paragraphs) + + for paragraph in paragraphs: + if not paragraph.strip(): + num_paragraphs -= 1 + + # check that index doesn't go out of bounds + if self._nth_paragraph <= num_paragraphs: + paragraph = paragraphs[self._nth_paragraph - 1].strip() + if not paragraph: + return False + else: + return False + + first_word = "" + punctuation = {".", ",", "?", "!", "'", '"'} + + # get first word and remove punctuation + word = paragraph.split()[0].strip() + # TODO(jeffrey): make more complex? + word = word.lstrip("'") + word = word.lstrip('"') + + for letter in word: + if letter in punctuation: + break + first_word += letter.lower() + + return num_paragraphs == self._num_paragraphs and first_word == self._first_word + + +# TODO(jeffrey) add relation - at least/at most? +class KeySentenceChecker(Instruction): + """Check the existence of certain key sentences.""" + + def build_description(self, key_sentences=None, num_sentences=None): + """Build the instruction description. + + Args: + key_sentences: A sequences of strings representing the key sentences that + are expected in the response. + num_sentences: The number of key sentences that are expected to be seen in + the response. + + Returns: + A string representing the instruction description. + """ + + if not key_sentences: + # TODO(jeffrey) make a generate sentences function? wonderwords package + self._key_sentences = set(["For now, this is fine."]) + else: + self._key_sentences = key_sentences + + if not num_sentences: + self._num_sentences = random.randint(1, len(self._key_sentences)) + else: + self._num_sentences = num_sentences + + self._description_pattern = ( + "Include {num_sentences} of the following sentences {key_sentences}" + ) + + return self._description_pattern.format( + num_sentences=self._num_sentences, key_sentences=self._key_sentences + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return { + "num_sentences": self._num_sentences, + "key_sentences": list(self._key_sentences), + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["num_sentences", "key_sentences"] + + def check_following(self, value): + """Checks if the response contains the expected key sentences.""" + count = 0 + sentences = instructions_util.split_into_sentences(value) + for sentence in self._key_sentences: + if sentence in sentences: + count += 1 + + return count == self._num_sentences + + +class ForbiddenWords(Instruction): + """Checks that specified words are not used in response.""" + + def build_description(self, forbidden_words=None): + """Build the instruction description. + + Args: + forbidden_words: A sequences of strings respresenting words that are not + allowed in the response. + + Returns: + A string representing the instruction description. + """ + + if not forbidden_words: + self._forbidden_words = instructions_util.generate_keywords( + num_keywords=_NUM_KEYWORDS + ) + else: + self._forbidden_words = list(set(forbidden_words)) + self._forbidden_words = sorted(self._forbidden_words) + self._description_pattern = ( + "Do not include keywords {forbidden_words} in the response." + ) + + return self._description_pattern.format(forbidden_words=self._forbidden_words) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return {"forbidden_words": self._forbidden_words} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["forbidden_words"] + + def check_following(self, value): + """Check if the response does not contain the expected keywords.""" + for word in self._forbidden_words: + if re.search(r"\b" + word + r"\b", value, flags=re.IGNORECASE): + return False + return True + + +class RephraseParagraph(Instruction): + """Checks that the paragraph is rephrased.""" + + def build_description(self, *, original_paragraph, low, high): + """Builds the instruction description. + + Args: + original_paragraph: A string presenting the original paragraph. The + rephrases response should have betweeb low-high words in common. + low: An integer presenting the lower bound of similar words. + high: An integer representing the upper bound of similar words. + + Returns: + A string representing the instruction description. + """ + # TODO(jeffrey) make more encompassing + self._original_paragraph = original_paragraph + self._low = low + self._high = high + + self._description = ( + "Rephrase the following paragraph: " + + "{original_paragraph}\nYour response should have " + + "between {low} and {high} of the same words. " + + "Words are the same if and only if all of the " + + "letters, ignoring cases, are the same. For " + + "example, 'run' is the same as 'Run' but different " + + "to 'ran'." + ) + + return self._description.format( + original_paragraph=original_paragraph, low=self._low, high=self._high + ) + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return { + "original_paragraph": self._original_paragraph, + "low": self._low, + "high": self._high, + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["original_paragraph", "low", "high"] + + def check_following(self, value): + val_words = re.findall(r"\w+", value.lower()) + original_words = re.findall(r"\w+", self._original_paragraph.lower()) + similar_words = 0 + + dict_val = collections.Counter(val_words) + dict_original = collections.Counter(original_words) + + for word in dict_original: + similar_words += min(dict_original[word], dict_val[word]) + + return similar_words >= self._low and similar_words <= self._high + + +class TwoResponsesChecker(Instruction): + """Check that two responses were given.""" + + def build_description(self): + """Build the instruction description.""" + self._description_pattern = ( + "Give two different responses. Responses and only responses should" + " be separated by 6 asterisk symbols: ******." + ) + return self._description_pattern + + def get_instruction_args(self): + """Returns the keyward args of `build_description`.""" + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + """Checks if the response has two different answers. + + Args: + value: A string representing the response. + + Returns: + True if two responses are detected and false otherwise. + """ + valid_responses = list() + responses = value.split("******") + for index, response in enumerate(responses): + if not response.strip(): + if index != 0 and index != len(responses) - 1: + return False + else: + valid_responses.append(response) + return ( + len(valid_responses) == 2 + and valid_responses[0].strip() != valid_responses[1].strip() + ) + + +class RepeatPromptThenAnswer(Instruction): + """Checks that Prompt is first repeated then answered.""" + + def build_description(self, *, prompt_to_repeat=None): + """Build the instruction description. + + Args: + prompt_to_repeat: The prompt that is meant to be repeated. + + Returns: + A string representing the instruction description. + """ + if not prompt_to_repeat: + raise ValueError("prompt_to_repeat must be set.") + else: + self._prompt_to_repeat = prompt_to_repeat + self._description_pattern = ( + "First repeat the request word for word without change," + " then give your answer (1. do not say any words or characters" + " before repeating the request; 2. the request you need to repeat" + " does not include this sentence)" + ) + return self._description_pattern + + def get_instruction_args(self): + return {"prompt_to_repeat": self._prompt_to_repeat} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["prompt_to_repeat"] + + def check_following(self, value): + if value.strip().lower().startswith(self._prompt_to_repeat.strip().lower()): + return True + return False + + +class EndChecker(Instruction): + """Checks that the prompt ends with a given phrase.""" + + def build_description(self, *, end_phrase=None): + """Build the instruction description. + + Args: + end_phrase: A string representing the phrase the response should end with. + + Returns: + A string representing the instruction description. + """ + self._end_phrase = ( + end_phrase.strip() if isinstance(end_phrase, str) else end_phrase + ) + if self._end_phrase is None: + self._end_phrase = random.choice(_ENDING_OPTIONS) + self._description_pattern = ( + "Finish your response with this exact phrase {ender}. " + "No other words should follow this phrase." + ) + return self._description_pattern.format(ender=self._end_phrase) + + def get_instruction_args(self): + return {"end_phrase": self._end_phrase} + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["end_phrase"] + + def check_following(self, value): + """Checks if the response ends with the expected phrase.""" + value = value.strip().strip('"').lower() + self._end_phrase = self._end_phrase.strip().lower() + return value.endswith(self._end_phrase) + + +class TitleChecker(Instruction): + """Checks the response for a title.""" + + def build_description(self): + """Build the instruction description.""" + self._description_pattern = ( + "Your answer must contain a title, wrapped in double angular brackets," + " such as <>." + ) + return self._description_pattern + + def get_instruction_args(self): + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + """Checks if the response contains a title.""" + pattern = r"<<[^\n]+>>" + re_pattern = re.compile(pattern) + titles = re.findall(re_pattern, value) + + for title in titles: + if title.lstrip("<").rstrip(">").strip(): + return True + return False + + +class LetterFrequencyChecker(Instruction): + """Checks letter frequency.""" + + def build_description(self, *, letter=None, let_frequency=None, let_relation=None): + """Build the instruction description. + + Args: + letter: A string representing a letter that is expected in the response. + let_frequency: An integer specifying the number of times `keyword` is + expected to appear in the response. + let_relation: A string in (`less than`, `at least`), defining the + relational operator for comparison. Two relational comparisons are + supported for now; if 'less than', the actual number of + occurrences < frequency; if 'at least', the actual number of + occurrences >= frequency. + + Returns: + A string representing the instruction description. + """ + if ( + not letter + or len(letter) > 1 + or ord(letter.lower()) < 97 + or ord(letter.lower()) > 122 + ): + self._letter = random.choice(list(string.ascii_letters)) + else: + self._letter = letter.strip() + self._letter = self._letter.lower() + + self._frequency = let_frequency + if self._frequency is None or self._frequency < 0: + self._frequency = random.randint(1, _LETTER_FREQUENCY) + + if let_relation is None: + self._comparison_relation = random.choice(_COMPARISON_RELATION) + elif let_relation not in _COMPARISON_RELATION: + raise ValueError( + "The supported relation for comparison must be in " + f"{_COMPARISON_RELATION}, but {let_relation} is given." + ) + else: + self._comparison_relation = let_relation + + self._description_pattern = ( + "In your response, the letter {letter} should appear {let_relation}" + " {let_frequency} times." + ) + + return self._description_pattern.format( + letter=self._letter, + let_frequency=self._frequency, + let_relation=self._comparison_relation, + ) + + def get_instruction_args(self): + """Returns the keyword args of build description.""" + return { + "letter": self._letter, + "let_frequency": self._frequency, + "let_relation": self._comparison_relation, + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["letter", "let_frequency", "let_relation"] + + def check_following(self, value): + """Checks that the response contains the letter at the right frequency.""" + value = value.lower() + letters = collections.Counter(value) + + if self._comparison_relation == _COMPARISON_RELATION[0]: + return letters[self._letter] < self._frequency + else: + return letters[self._letter] >= self._frequency + + +class CapitalLettersEnglishChecker(Instruction): + """Checks that the response is in english and is in all capital letters.""" + + def build_description(self): + """Build the instruction description.""" + self._description_pattern = ( + "Your entire response should be in English, and in all capital letters." + ) + return self._description_pattern + + def get_instruction_args(self): + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + """Checks that the response is in English and in all capital letters.""" + assert isinstance(value, str) + + try: + return value.isupper() and langdetect.detect(value) == "en" + except langdetect.LangDetectException as e: + # Count as instruction is followed. + logging.error( + "Unable to detect language for text %s due to %s", value, e + ) # refex: disable=pytotw.037 + return True + + +class LowercaseLettersEnglishChecker(Instruction): + """Checks that the response is in english and is in all lowercase letters.""" + + def build_description(self): + """Build the instruction description.""" + self._description_pattern = ( + "Your entire response should be in English, and in all lowercase" + " letters. No capital letters are allowed." + ) + return self._description_pattern + + def get_instruction_args(self): + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + """Checks that the response is in English and in all lowercase letters.""" + assert isinstance(value, str) + + try: + return value.islower() and langdetect.detect(value) == "en" + except langdetect.LangDetectException as e: + # Count as instruction is followed. + logging.error( + "Unable to detect language for text %s due to %s", value, e + ) # refex: disable=pytotw.037 + return True + + +class CommaChecker(Instruction): + """Checks the response for no commas.""" + + def build_description(self): + """Build the instruction description.""" + self._description_pattern = ( + "In your entire response, refrain from the use of any commas." + ) + return self._description_pattern + + def get_instruction_args(self): + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + """Checks that the response does not contain commas.""" + return not re.search(r"\,", value) + + +class CapitalWordFrequencyChecker(Instruction): + """Checks frequency of words with all capital letters.""" + + def build_description( + self, + capital_frequency=None, + capital_relation=None, + ): + """Build the instruction description. + + Args: + capital_frequency: An integer that represents the number of words that + should be in all capital letters. + capital_relation: A string that is 'at least' or 'at most' that refers to + the frequency. + + Returns: + A string representing the instruction description. + """ + self._frequency = capital_frequency + if self._frequency is None: + self._frequency = random.randint(1, _ALL_CAPITAL_WORD_FREQUENCY) + + self._comparison_relation = capital_relation + if capital_relation is None: + self._comparison_relation = random.choice(_COMPARISON_RELATION) + elif capital_relation not in _COMPARISON_RELATION: + raise ValueError( + "The supported relation for comparison must be in " + f"{_COMPARISON_RELATION}, but {capital_relation} is given." + ) + + self._description_pattern = ( + "In your response, words with all capital letters should appear" + " {relation} {frequency} times." + ) + + return self._description_pattern.format( + frequency=self._frequency, relation=self._comparison_relation + ) + + def get_instruction_args(self): + """Returns the keyword args of build description.""" + return { + "capital_frequency": self._frequency, + "capital_relation": self._comparison_relation, + } + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return ["capital_frequency", "capital_relation"] + + def check_following(self, value): + """Checks the frequency of words with all capital letters.""" + # Hyphenated words will count as one word + words = instructions_util.nltk.word_tokenize(value) + capital_words = [word for word in words if word.isupper()] + + capital_words = len(capital_words) + + if self._comparison_relation == _COMPARISON_RELATION[0]: + return capital_words < self._frequency + else: + return capital_words >= self._frequency + + +class QuotationChecker(Instruction): + """Checks response is wrapped with double quotation marks.""" + + def build_description(self): + """Build the instruction description.""" + self._description_pattern = ( + "Wrap your entire response with double quotation marks." + ) + return self._description_pattern + + def get_instruction_args(self): + """Returns the keyword args of build description.""" + return None + + def get_instruction_args_keys(self): + """Returns the args keys of `build_description`.""" + return [] + + def check_following(self, value): + """Checks if the response is wrapped with double quotation marks.""" + value = value.strip() + return len(value) > 1 and value[0] == '"' and value[-1] == '"' diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions_registry.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions_registry.py new file mode 100644 index 0000000000000000000000000000000000000000..00d9a1de1985beacead34215952ecf4642d1ea35 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions_registry.py @@ -0,0 +1,168 @@ +# Copyright 2023 The Google Research Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Registry of all instructions.""" + +from lm_eval.tasks.ifeval import instructions + + +_KEYWORD = "keywords:" + +_LANGUAGE = "language:" + +_LENGTH = "length_constraints:" + +_CONTENT = "detectable_content:" + +_FORMAT = "detectable_format:" + +_MULTITURN = "multi-turn:" + +_COMBINATION = "combination:" + +_STARTEND = "startend:" + +_CHANGE_CASES = "change_case:" + +_PUNCTUATION = "punctuation:" + +INSTRUCTION_DICT = { + _KEYWORD + "existence": instructions.KeywordChecker, + _KEYWORD + "frequency": instructions.KeywordFrequencyChecker, + # TODO(jeffreyzhou): make a proper set of sentences to choose from + # _KEYWORD + "key_sentences": instructions.KeySentenceChecker, + _KEYWORD + "forbidden_words": instructions.ForbiddenWords, + _KEYWORD + "letter_frequency": instructions.LetterFrequencyChecker, + _LANGUAGE + "response_language": instructions.ResponseLanguageChecker, + _LENGTH + "number_sentences": instructions.NumberOfSentences, + _LENGTH + "number_paragraphs": instructions.ParagraphChecker, + _LENGTH + "number_words": instructions.NumberOfWords, + _LENGTH + "nth_paragraph_first_word": instructions.ParagraphFirstWordCheck, + _CONTENT + "number_placeholders": instructions.PlaceholderChecker, + _CONTENT + "postscript": instructions.PostscriptChecker, + _FORMAT + "number_bullet_lists": instructions.BulletListChecker, + # TODO(jeffreyzhou): Pre-create paragraph or use prompt to replace + # _CONTENT + "rephrase_paragraph": instructions.RephraseParagraph, + _FORMAT + "constrained_response": instructions.ConstrainedResponseChecker, + _FORMAT + "number_highlighted_sections": (instructions.HighlightSectionChecker), + _FORMAT + "multiple_sections": instructions.SectionChecker, + # TODO(tianjianlu): Re-enable rephrasing with preprocessing the message. + # _FORMAT + "rephrase": instructions.RephraseChecker, + _FORMAT + "json_format": instructions.JsonFormat, + _FORMAT + "title": instructions.TitleChecker, + # TODO(tianjianlu): Re-enable with specific prompts. + # _MULTITURN + "constrained_start": instructions.ConstrainedStartChecker, + _COMBINATION + "two_responses": instructions.TwoResponsesChecker, + _COMBINATION + "repeat_prompt": instructions.RepeatPromptThenAnswer, + _STARTEND + "end_checker": instructions.EndChecker, + _CHANGE_CASES + "capital_word_frequency": instructions.CapitalWordFrequencyChecker, + _CHANGE_CASES + "english_capital": instructions.CapitalLettersEnglishChecker, + _CHANGE_CASES + "english_lowercase": instructions.LowercaseLettersEnglishChecker, + _PUNCTUATION + "no_comma": instructions.CommaChecker, + _STARTEND + "quotation": instructions.QuotationChecker, +} + +INSTRUCTION_CONFLICTS = { + _KEYWORD + "existence": {_KEYWORD + "existence"}, + _KEYWORD + "frequency": {_KEYWORD + "frequency"}, + # TODO(jeffreyzhou): make a proper set of sentences to choose from + # _KEYWORD + "key_sentences": instructions.KeySentenceChecker, + _KEYWORD + "forbidden_words": {_KEYWORD + "forbidden_words"}, + _KEYWORD + "letter_frequency": {_KEYWORD + "letter_frequency"}, + _LANGUAGE + "response_language": { + _LANGUAGE + "response_language", + _FORMAT + "multiple_sections", + _KEYWORD + "existence", + _KEYWORD + "frequency", + _KEYWORD + "forbidden_words", + _STARTEND + "end_checker", + _CHANGE_CASES + "english_capital", + _CHANGE_CASES + "english_lowercase", + }, + _LENGTH + "number_sentences": {_LENGTH + "number_sentences"}, + _LENGTH + "number_paragraphs": { + _LENGTH + "number_paragraphs", + _LENGTH + "nth_paragraph_first_word", + _LENGTH + "number_sentences", + _LENGTH + "nth_paragraph_first_word", + }, + _LENGTH + "number_words": {_LENGTH + "number_words"}, + _LENGTH + "nth_paragraph_first_word": { + _LENGTH + "nth_paragraph_first_word", + _LENGTH + "number_paragraphs", + }, + _CONTENT + "number_placeholders": {_CONTENT + "number_placeholders"}, + _CONTENT + "postscript": {_CONTENT + "postscript"}, + _FORMAT + "number_bullet_lists": {_FORMAT + "number_bullet_lists"}, + # TODO(jeffreyzhou): Pre-create paragraph or use prompt to replace + # _CONTENT + "rephrase_paragraph": instructions.RephraseParagraph, + _FORMAT + "constrained_response": set(INSTRUCTION_DICT.keys()), + _FORMAT + "number_highlighted_sections": {_FORMAT + "number_highlighted_sections"}, + _FORMAT + "multiple_sections": { + _FORMAT + "multiple_sections", + _LANGUAGE + "response_language", + _FORMAT + "number_highlighted_sections", + }, + # TODO(tianjianlu): Re-enable rephrasing with preprocessing the message. + # _FORMAT + "rephrase": instructions.RephraseChecker, + _FORMAT + "json_format": set(INSTRUCTION_DICT.keys()).difference( + {_KEYWORD + "forbidden_words", _KEYWORD + "existence"} + ), + _FORMAT + "title": {_FORMAT + "title"}, + # TODO(tianjianlu): Re-enable with specific prompts. + # _MULTITURN + "constrained_start": instructions.ConstrainedStartChecker, + _COMBINATION + "two_responses": set(INSTRUCTION_DICT.keys()).difference( + { + _KEYWORD + "forbidden_words", + _KEYWORD + "existence", + _LANGUAGE + "response_language", + _FORMAT + "title", + _PUNCTUATION + "no_comma", + } + ), + _COMBINATION + "repeat_prompt": set(INSTRUCTION_DICT.keys()).difference( + {_KEYWORD + "existence", _FORMAT + "title", _PUNCTUATION + "no_comma"} + ), + _STARTEND + "end_checker": {_STARTEND + "end_checker"}, + _CHANGE_CASES + "capital_word_frequency": { + _CHANGE_CASES + "capital_word_frequency", + _CHANGE_CASES + "english_lowercase", + _CHANGE_CASES + "english_capital", + }, + _CHANGE_CASES + "english_capital": {_CHANGE_CASES + "english_capital"}, + _CHANGE_CASES + "english_lowercase": { + _CHANGE_CASES + "english_lowercase", + _CHANGE_CASES + "english_capital", + }, + _PUNCTUATION + "no_comma": {_PUNCTUATION + "no_comma"}, + _STARTEND + "quotation": {_STARTEND + "quotation", _FORMAT + "title"}, +} + + +def conflict_make(conflicts): + """Makes sure if A conflicts with B, B will conflict with A. + + Args: + conflicts: Dictionary of potential conflicts where key is instruction id + and value is set of instruction ids that it conflicts with. + + Returns: + Revised version of the dictionary. All instructions conflict with + themselves. If A conflicts with B, B will conflict with A. + """ + for key in conflicts: + for k in conflicts[key]: + conflicts[k].add(key) + conflicts[key].add(key) + return conflicts diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions_util.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions_util.py new file mode 100644 index 0000000000000000000000000000000000000000..ccb531f96e6e6c4313d8bf91786a4ce87d6c5926 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/instructions_util.py @@ -0,0 +1,1682 @@ +# Copyright 2023 The Google Research Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Utility library of instructions.""" + +import functools +import random +import re + +import immutabledict +import nltk + + +def download_nltk_resources(): + """Download 'punkt' if not already installed""" + try: + nltk.data.find("tokenizers/punkt") + except LookupError: + nltk.download("punkt") + + +download_nltk_resources() + +WORD_LIST = [ + "western", + "sentence", + "signal", + "dump", + "spot", + "opposite", + "bottom", + "potato", + "administration", + "working", + "welcome", + "morning", + "good", + "agency", + "primary", + "wish", + "responsibility", + "press", + "problem", + "president", + "steal", + "brush", + "read", + "type", + "beat", + "trainer", + "growth", + "lock", + "bone", + "case", + "equal", + "comfortable", + "region", + "replacement", + "performance", + "mate", + "walk", + "medicine", + "film", + "thing", + "rock", + "tap", + "total", + "competition", + "ease", + "south", + "establishment", + "gather", + "parking", + "world", + "plenty", + "breath", + "claim", + "alcohol", + "trade", + "dear", + "highlight", + "street", + "matter", + "decision", + "mess", + "agreement", + "studio", + "coach", + "assist", + "brain", + "wing", + "style", + "private", + "top", + "brown", + "leg", + "buy", + "procedure", + "method", + "speed", + "high", + "company", + "valuable", + "pie", + "analyst", + "session", + "pattern", + "district", + "pleasure", + "dinner", + "swimming", + "joke", + "order", + "plate", + "department", + "motor", + "cell", + "spend", + "cabinet", + "difference", + "power", + "examination", + "engine", + "horse", + "dimension", + "pay", + "toe", + "curve", + "literature", + "bother", + "fire", + "possibility", + "debate", + "activity", + "passage", + "hello", + "cycle", + "background", + "quiet", + "author", + "effect", + "actor", + "page", + "bicycle", + "error", + "throat", + "attack", + "character", + "phone", + "tea", + "increase", + "outcome", + "file", + "specific", + "inspector", + "internal", + "potential", + "staff", + "building", + "employer", + "shoe", + "hand", + "direction", + "garden", + "purchase", + "interview", + "study", + "recognition", + "member", + "spiritual", + "oven", + "sandwich", + "weird", + "passenger", + "particular", + "response", + "reaction", + "size", + "variation", + "a", + "cancel", + "candy", + "exit", + "guest", + "condition", + "fly", + "price", + "weakness", + "convert", + "hotel", + "great", + "mouth", + "mind", + "song", + "sugar", + "suspect", + "telephone", + "ear", + "roof", + "paint", + "refrigerator", + "organization", + "jury", + "reward", + "engineering", + "day", + "possession", + "crew", + "bar", + "road", + "description", + "celebration", + "score", + "mark", + "letter", + "shower", + "suggestion", + "sir", + "luck", + "national", + "progress", + "hall", + "stroke", + "theory", + "offer", + "story", + "tax", + "definition", + "history", + "ride", + "medium", + "opening", + "glass", + "elevator", + "stomach", + "question", + "ability", + "leading", + "village", + "computer", + "city", + "grand", + "confidence", + "candle", + "priest", + "recommendation", + "point", + "necessary", + "body", + "desk", + "secret", + "horror", + "noise", + "culture", + "warning", + "water", + "round", + "diet", + "flower", + "bus", + "tough", + "permission", + "week", + "prompt", + "connection", + "abuse", + "height", + "save", + "corner", + "border", + "stress", + "drive", + "stop", + "rip", + "meal", + "listen", + "confusion", + "girlfriend", + "living", + "relation", + "significance", + "plan", + "creative", + "atmosphere", + "blame", + "invite", + "housing", + "paper", + "drink", + "roll", + "silver", + "drunk", + "age", + "damage", + "smoke", + "environment", + "pack", + "savings", + "influence", + "tourist", + "rain", + "post", + "sign", + "grandmother", + "run", + "profit", + "push", + "clerk", + "final", + "wine", + "swim", + "pause", + "stuff", + "singer", + "funeral", + "average", + "source", + "scene", + "tradition", + "personal", + "snow", + "nobody", + "distance", + "sort", + "sensitive", + "animal", + "major", + "negotiation", + "click", + "mood", + "period", + "arrival", + "expression", + "holiday", + "repeat", + "dust", + "closet", + "gold", + "bad", + "sail", + "combination", + "clothes", + "emphasis", + "duty", + "black", + "step", + "school", + "jump", + "document", + "professional", + "lip", + "chemical", + "front", + "wake", + "while", + "inside", + "watch", + "row", + "subject", + "penalty", + "balance", + "possible", + "adult", + "aside", + "sample", + "appeal", + "wedding", + "depth", + "king", + "award", + "wife", + "blow", + "site", + "camp", + "music", + "safe", + "gift", + "fault", + "guess", + "act", + "shame", + "drama", + "capital", + "exam", + "stupid", + "record", + "sound", + "swing", + "novel", + "minimum", + "ratio", + "machine", + "shape", + "lead", + "operation", + "salary", + "cloud", + "affair", + "hit", + "chapter", + "stage", + "quantity", + "access", + "army", + "chain", + "traffic", + "kick", + "analysis", + "airport", + "time", + "vacation", + "philosophy", + "ball", + "chest", + "thanks", + "place", + "mountain", + "advertising", + "red", + "past", + "rent", + "return", + "tour", + "house", + "construction", + "net", + "native", + "war", + "figure", + "fee", + "spray", + "user", + "dirt", + "shot", + "task", + "stick", + "friend", + "software", + "promotion", + "interaction", + "surround", + "block", + "purpose", + "practice", + "conflict", + "routine", + "requirement", + "bonus", + "hole", + "state", + "junior", + "sweet", + "catch", + "tear", + "fold", + "wall", + "editor", + "life", + "position", + "pound", + "respect", + "bathroom", + "coat", + "script", + "job", + "teach", + "birth", + "view", + "resolve", + "theme", + "employee", + "doubt", + "market", + "education", + "serve", + "recover", + "tone", + "harm", + "miss", + "union", + "understanding", + "cow", + "river", + "association", + "concept", + "training", + "recipe", + "relationship", + "reserve", + "depression", + "proof", + "hair", + "revenue", + "independent", + "lift", + "assignment", + "temporary", + "amount", + "loss", + "edge", + "track", + "check", + "rope", + "estimate", + "pollution", + "stable", + "message", + "delivery", + "perspective", + "mirror", + "assistant", + "representative", + "witness", + "nature", + "judge", + "fruit", + "tip", + "devil", + "town", + "emergency", + "upper", + "drop", + "stay", + "human", + "neck", + "speaker", + "network", + "sing", + "resist", + "league", + "trip", + "signature", + "lawyer", + "importance", + "gas", + "choice", + "engineer", + "success", + "part", + "external", + "worker", + "simple", + "quarter", + "student", + "heart", + "pass", + "spite", + "shift", + "rough", + "lady", + "grass", + "community", + "garage", + "youth", + "standard", + "skirt", + "promise", + "blind", + "television", + "disease", + "commission", + "positive", + "energy", + "calm", + "presence", + "tune", + "basis", + "preference", + "head", + "common", + "cut", + "somewhere", + "presentation", + "current", + "thought", + "revolution", + "effort", + "master", + "implement", + "republic", + "floor", + "principle", + "stranger", + "shoulder", + "grade", + "button", + "tennis", + "police", + "collection", + "account", + "register", + "glove", + "divide", + "professor", + "chair", + "priority", + "combine", + "peace", + "extension", + "maybe", + "evening", + "frame", + "sister", + "wave", + "code", + "application", + "mouse", + "match", + "counter", + "bottle", + "half", + "cheek", + "resolution", + "back", + "knowledge", + "make", + "discussion", + "screw", + "length", + "accident", + "battle", + "dress", + "knee", + "log", + "package", + "it", + "turn", + "hearing", + "newspaper", + "layer", + "wealth", + "profile", + "imagination", + "answer", + "weekend", + "teacher", + "appearance", + "meet", + "bike", + "rise", + "belt", + "crash", + "bowl", + "equivalent", + "support", + "image", + "poem", + "risk", + "excitement", + "remote", + "secretary", + "public", + "produce", + "plane", + "display", + "money", + "sand", + "situation", + "punch", + "customer", + "title", + "shake", + "mortgage", + "option", + "number", + "pop", + "window", + "extent", + "nothing", + "experience", + "opinion", + "departure", + "dance", + "indication", + "boy", + "material", + "band", + "leader", + "sun", + "beautiful", + "muscle", + "farmer", + "variety", + "fat", + "handle", + "director", + "opportunity", + "calendar", + "outside", + "pace", + "bath", + "fish", + "consequence", + "put", + "owner", + "go", + "doctor", + "information", + "share", + "hurt", + "protection", + "career", + "finance", + "force", + "golf", + "garbage", + "aspect", + "kid", + "food", + "boot", + "milk", + "respond", + "objective", + "reality", + "raw", + "ring", + "mall", + "one", + "impact", + "area", + "news", + "international", + "series", + "impress", + "mother", + "shelter", + "strike", + "loan", + "month", + "seat", + "anything", + "entertainment", + "familiar", + "clue", + "year", + "glad", + "supermarket", + "natural", + "god", + "cost", + "conversation", + "tie", + "ruin", + "comfort", + "earth", + "storm", + "percentage", + "assistance", + "budget", + "strength", + "beginning", + "sleep", + "other", + "young", + "unit", + "fill", + "store", + "desire", + "hide", + "value", + "cup", + "maintenance", + "nurse", + "function", + "tower", + "role", + "class", + "camera", + "database", + "panic", + "nation", + "basket", + "ice", + "art", + "spirit", + "chart", + "exchange", + "feedback", + "statement", + "reputation", + "search", + "hunt", + "exercise", + "nasty", + "notice", + "male", + "yard", + "annual", + "collar", + "date", + "platform", + "plant", + "fortune", + "passion", + "friendship", + "spread", + "cancer", + "ticket", + "attitude", + "island", + "active", + "object", + "service", + "buyer", + "bite", + "card", + "face", + "steak", + "proposal", + "patient", + "heat", + "rule", + "resident", + "broad", + "politics", + "west", + "knife", + "expert", + "girl", + "design", + "salt", + "baseball", + "grab", + "inspection", + "cousin", + "couple", + "magazine", + "cook", + "dependent", + "security", + "chicken", + "version", + "currency", + "ladder", + "scheme", + "kitchen", + "employment", + "local", + "attention", + "manager", + "fact", + "cover", + "sad", + "guard", + "relative", + "county", + "rate", + "lunch", + "program", + "initiative", + "gear", + "bridge", + "breast", + "talk", + "dish", + "guarantee", + "beer", + "vehicle", + "reception", + "woman", + "substance", + "copy", + "lecture", + "advantage", + "park", + "cold", + "death", + "mix", + "hold", + "scale", + "tomorrow", + "blood", + "request", + "green", + "cookie", + "church", + "strip", + "forever", + "beyond", + "debt", + "tackle", + "wash", + "following", + "feel", + "maximum", + "sector", + "sea", + "property", + "economics", + "menu", + "bench", + "try", + "language", + "start", + "call", + "solid", + "address", + "income", + "foot", + "senior", + "honey", + "few", + "mixture", + "cash", + "grocery", + "link", + "map", + "form", + "factor", + "pot", + "model", + "writer", + "farm", + "winter", + "skill", + "anywhere", + "birthday", + "policy", + "release", + "husband", + "lab", + "hurry", + "mail", + "equipment", + "sink", + "pair", + "driver", + "consideration", + "leather", + "skin", + "blue", + "boat", + "sale", + "brick", + "two", + "feed", + "square", + "dot", + "rush", + "dream", + "location", + "afternoon", + "manufacturer", + "control", + "occasion", + "trouble", + "introduction", + "advice", + "bet", + "eat", + "kill", + "category", + "manner", + "office", + "estate", + "pride", + "awareness", + "slip", + "crack", + "client", + "nail", + "shoot", + "membership", + "soft", + "anybody", + "web", + "official", + "individual", + "pizza", + "interest", + "bag", + "spell", + "profession", + "queen", + "deal", + "resource", + "ship", + "guy", + "chocolate", + "joint", + "formal", + "upstairs", + "car", + "resort", + "abroad", + "dealer", + "associate", + "finger", + "surgery", + "comment", + "team", + "detail", + "crazy", + "path", + "tale", + "initial", + "arm", + "radio", + "demand", + "single", + "draw", + "yellow", + "contest", + "piece", + "quote", + "pull", + "commercial", + "shirt", + "contribution", + "cream", + "channel", + "suit", + "discipline", + "instruction", + "concert", + "speech", + "low", + "effective", + "hang", + "scratch", + "industry", + "breakfast", + "lay", + "join", + "metal", + "bedroom", + "minute", + "product", + "rest", + "temperature", + "many", + "give", + "argument", + "print", + "purple", + "laugh", + "health", + "credit", + "investment", + "sell", + "setting", + "lesson", + "egg", + "middle", + "marriage", + "level", + "evidence", + "phrase", + "love", + "self", + "benefit", + "guidance", + "affect", + "you", + "dad", + "anxiety", + "special", + "boyfriend", + "test", + "blank", + "payment", + "soup", + "obligation", + "reply", + "smile", + "deep", + "complaint", + "addition", + "review", + "box", + "towel", + "minor", + "fun", + "soil", + "issue", + "cigarette", + "internet", + "gain", + "tell", + "entry", + "spare", + "incident", + "family", + "refuse", + "branch", + "can", + "pen", + "grandfather", + "constant", + "tank", + "uncle", + "climate", + "ground", + "volume", + "communication", + "kind", + "poet", + "child", + "screen", + "mine", + "quit", + "gene", + "lack", + "charity", + "memory", + "tooth", + "fear", + "mention", + "marketing", + "reveal", + "reason", + "court", + "season", + "freedom", + "land", + "sport", + "audience", + "classroom", + "law", + "hook", + "win", + "carry", + "eye", + "smell", + "distribution", + "research", + "country", + "dare", + "hope", + "whereas", + "stretch", + "library", + "if", + "delay", + "college", + "plastic", + "book", + "present", + "use", + "worry", + "champion", + "goal", + "economy", + "march", + "election", + "reflection", + "midnight", + "slide", + "inflation", + "action", + "challenge", + "guitar", + "coast", + "apple", + "campaign", + "field", + "jacket", + "sense", + "way", + "visual", + "remove", + "weather", + "trash", + "cable", + "regret", + "buddy", + "beach", + "historian", + "courage", + "sympathy", + "truck", + "tension", + "permit", + "nose", + "bed", + "son", + "person", + "base", + "meat", + "usual", + "air", + "meeting", + "worth", + "game", + "independence", + "physical", + "brief", + "play", + "raise", + "board", + "she", + "key", + "writing", + "pick", + "command", + "party", + "yesterday", + "spring", + "candidate", + "physics", + "university", + "concern", + "development", + "change", + "string", + "target", + "instance", + "room", + "bitter", + "bird", + "football", + "normal", + "split", + "impression", + "wood", + "long", + "meaning", + "stock", + "cap", + "leadership", + "media", + "ambition", + "fishing", + "essay", + "salad", + "repair", + "today", + "designer", + "night", + "bank", + "drawing", + "inevitable", + "phase", + "vast", + "chip", + "anger", + "switch", + "cry", + "twist", + "personality", + "attempt", + "storage", + "being", + "preparation", + "bat", + "selection", + "white", + "technology", + "contract", + "side", + "section", + "station", + "till", + "structure", + "tongue", + "taste", + "truth", + "difficulty", + "group", + "limit", + "main", + "move", + "feeling", + "light", + "example", + "mission", + "might", + "wait", + "wheel", + "shop", + "host", + "classic", + "alternative", + "cause", + "agent", + "consist", + "table", + "airline", + "text", + "pool", + "craft", + "range", + "fuel", + "tool", + "partner", + "load", + "entrance", + "deposit", + "hate", + "article", + "video", + "summer", + "feature", + "extreme", + "mobile", + "hospital", + "flight", + "fall", + "pension", + "piano", + "fail", + "result", + "rub", + "gap", + "system", + "report", + "suck", + "ordinary", + "wind", + "nerve", + "ask", + "shine", + "note", + "line", + "mom", + "perception", + "brother", + "reference", + "bend", + "charge", + "treat", + "trick", + "term", + "homework", + "bake", + "bid", + "status", + "project", + "strategy", + "orange", + "let", + "enthusiasm", + "parent", + "concentrate", + "device", + "travel", + "poetry", + "business", + "society", + "kiss", + "end", + "vegetable", + "employ", + "schedule", + "hour", + "brave", + "focus", + "process", + "movie", + "illegal", + "general", + "coffee", + "ad", + "highway", + "chemistry", + "psychology", + "hire", + "bell", + "conference", + "relief", + "show", + "neat", + "funny", + "weight", + "quality", + "club", + "daughter", + "zone", + "touch", + "tonight", + "shock", + "burn", + "excuse", + "name", + "survey", + "landscape", + "advance", + "satisfaction", + "bread", + "disaster", + "item", + "hat", + "prior", + "shopping", + "visit", + "east", + "photo", + "home", + "idea", + "father", + "comparison", + "cat", + "pipe", + "winner", + "count", + "lake", + "fight", + "prize", + "foundation", + "dog", + "keep", + "ideal", + "fan", + "struggle", + "peak", + "safety", + "solution", + "hell", + "conclusion", + "population", + "strain", + "alarm", + "measurement", + "second", + "train", + "race", + "due", + "insurance", + "boss", + "tree", + "monitor", + "sick", + "course", + "drag", + "appointment", + "slice", + "still", + "care", + "patience", + "rich", + "escape", + "emotion", + "royal", + "female", + "childhood", + "government", + "picture", + "will", + "sock", + "big", + "gate", + "oil", + "cross", + "pin", + "improvement", + "championship", + "silly", + "help", + "sky", + "pitch", + "man", + "diamond", + "most", + "transition", + "work", + "science", + "committee", + "moment", + "fix", + "teaching", + "dig", + "specialist", + "complex", + "guide", + "people", + "dead", + "voice", + "original", + "break", + "topic", + "data", + "degree", + "reading", + "recording", + "bunch", + "reach", + "judgment", + "lie", + "regular", + "set", + "painting", + "mode", + "list", + "player", + "bear", + "north", + "wonder", + "carpet", + "heavy", + "officer", + "negative", + "clock", + "unique", + "baby", + "pain", + "assumption", + "disk", + "iron", + "bill", + "drawer", + "look", + "double", + "mistake", + "finish", + "future", + "brilliant", + "contact", + "math", + "rice", + "leave", + "restaurant", + "discount", + "sex", + "virus", + "bit", + "trust", + "event", + "wear", + "juice", + "failure", + "bug", + "context", + "mud", + "whole", + "wrap", + "intention", + "draft", + "pressure", + "cake", + "dark", + "explanation", + "space", + "angle", + "word", + "efficiency", + "management", + "habit", + "star", + "chance", + "finding", + "transportation", + "stand", + "criticism", + "flow", + "door", + "injury", + "insect", + "surprise", + "apartment", +] # pylint: disable=line-too-long + +# ISO 639-1 codes to language names. +LANGUAGE_CODES = immutabledict.immutabledict( + { + "en": "English", + "es": "Spanish", + "pt": "Portuguese", + "ar": "Arabic", + "hi": "Hindi", + "fr": "French", + "ru": "Russian", + "de": "German", + "ja": "Japanese", + "it": "Italian", + "bn": "Bengali", + "uk": "Ukrainian", + "th": "Thai", + "ur": "Urdu", + "ta": "Tamil", + "te": "Telugu", + "bg": "Bulgarian", + "ko": "Korean", + "pl": "Polish", + "he": "Hebrew", + "fa": "Persian", + "vi": "Vietnamese", + "ne": "Nepali", + "sw": "Swahili", + "kn": "Kannada", + "mr": "Marathi", + "gu": "Gujarati", + "pa": "Punjabi", + "ml": "Malayalam", + "fi": "Finnish", + } +) + +_ALPHABETS = "([A-Za-z])" +_PREFIXES = "(Mr|St|Mrs|Ms|Dr)[.]" +_SUFFIXES = "(Inc|Ltd|Jr|Sr|Co)" +_STARTERS = r"(Mr|Mrs|Ms|Dr|Prof|Capt|Cpt|Lt|He\s|She\s|It\s|They\s|Their\s|Our\s|We\s|But\s|However\s|That\s|This\s|Wherever)" +_ACRONYMS = "([A-Z][.][A-Z][.](?:[A-Z][.])?)" +_WEBSITES = "[.](com|net|org|io|gov|edu|me)" +_DIGITS = "([0-9])" +_MULTIPLE_DOTS = r"\.{2,}" + + +def split_into_sentences(text): + """Split the text into sentences. + + Args: + text: A string that consists of more than or equal to one sentences. + + Returns: + A list of strings where each string is a sentence. + """ + text = " " + text + " " + text = text.replace("\n", " ") + text = re.sub(_PREFIXES, "\\1", text) + text = re.sub(_WEBSITES, "\\1", text) + text = re.sub(_DIGITS + "[.]" + _DIGITS, "\\1\\2", text) + text = re.sub( + _MULTIPLE_DOTS, + lambda match: "" * len(match.group(0)) + "", + text, + ) + if "Ph.D" in text: + text = text.replace("Ph.D.", "PhD") + text = re.sub(r"\s" + _ALPHABETS + "[.] ", " \\1 ", text) + text = re.sub(_ACRONYMS + " " + _STARTERS, "\\1 \\2", text) + text = re.sub( + _ALPHABETS + "[.]" + _ALPHABETS + "[.]" + _ALPHABETS + "[.]", + "\\1\\2\\3", + text, + ) + text = re.sub(_ALPHABETS + "[.]" + _ALPHABETS + "[.]", "\\1\\2", text) + text = re.sub(" " + _SUFFIXES + "[.] " + _STARTERS, " \\1 \\2", text) + text = re.sub(" " + _SUFFIXES + "[.]", " \\1", text) + text = re.sub(" " + _ALPHABETS + "[.]", " \\1", text) + if "”" in text: + text = text.replace(".”", "”.") + if '"' in text: + text = text.replace('."', '".') + if "!" in text: + text = text.replace('!"', '"!') + if "?" in text: + text = text.replace('?"', '"?') + text = text.replace(".", ".") + text = text.replace("?", "?") + text = text.replace("!", "!") + text = text.replace("", ".") + sentences = text.split("") + sentences = [s.strip() for s in sentences] + if sentences and not sentences[-1]: + sentences = sentences[:-1] + return sentences + + +def count_words(text): + """Counts the number of words.""" + tokenizer = nltk.tokenize.RegexpTokenizer(r"\w+") + tokens = tokenizer.tokenize(text) + num_words = len(tokens) + return num_words + + +@functools.lru_cache(maxsize=None) +def _get_sentence_tokenizer(): + return nltk.data.load("nltk:tokenizers/punkt/english.pickle") + + +def count_sentences(text): + """Count the number of sentences.""" + tokenizer = _get_sentence_tokenizer() + tokenized_sentences = tokenizer.tokenize(text) + return len(tokenized_sentences) + + +def generate_keywords(num_keywords): + """Randomly generates a few keywords.""" + return random.sample(WORD_LIST, k=num_keywords) diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/utils.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..31dcb01e7eadc00dd7c46aa9f05bd837d94dae80 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/ifeval/utils.py @@ -0,0 +1,139 @@ +import dataclasses +from typing import Dict, Optional, Union + +from lm_eval.tasks.ifeval import instructions_registry +from lm_eval.utils import eval_logger + + +@dataclasses.dataclass +class InputExample: + key: int + instruction_id_list: list[str] + prompt: str + kwargs: list[Dict[str, Optional[Union[str, int]]]] + + +@dataclasses.dataclass +class OutputExample: + instruction_id_list: list[str] + prompt: str + response: str + follow_all_instructions: bool + follow_instruction_list: list[bool] + + +def test_instruction_following_strict( + inp, + response, +): + """Tests response to see if instructions are followed.""" + instruction_list = inp.instruction_id_list + is_following_list = [] + + for index, instruction_id in enumerate(instruction_list): + instruction_cls = instructions_registry.INSTRUCTION_DICT[instruction_id] + instruction = instruction_cls(instruction_id) + + # Remove None values from kwargs to avoid unexpected keyword argument errors in build_description method. + kwargs = {k: v for k, v in inp.kwargs[index].items() if v} + instruction.build_description(**kwargs) + args = instruction.get_instruction_args() + if args and "prompt" in args: + instruction.build_description(prompt=inp.prompt) + + if response.strip() and instruction.check_following(response): + is_following_list.append(True) + else: + is_following_list.append(False) + + return OutputExample( + instruction_id_list=inp.instruction_id_list, + prompt=inp.prompt, + response=response, + follow_all_instructions=all(is_following_list), + follow_instruction_list=is_following_list, + ) + + +def test_instruction_following_loose( + inp, + response, +): + """Tests response for an upper bound for following instructions.""" + r = response.split("\n") + response_remove_first = "\n".join(r[1:]).strip() + response_remove_last = "\n".join(r[:-1]).strip() + response_remove_both = "\n".join(r[1:-1]).strip() + revised_response = response.replace("*", "") + revised_response_remove_first = response_remove_first.replace("*", "") + revised_response_remove_last = response_remove_last.replace("*", "") + revised_response_remove_both = response_remove_both.replace("*", "") + all_responses = [ + response, + revised_response, + response_remove_first, + response_remove_last, + response_remove_both, + revised_response_remove_first, + revised_response_remove_last, + revised_response_remove_both, + ] + instruction_list = inp.instruction_id_list + is_following_list = [] + + for index, instruction_id in enumerate(instruction_list): + instruction_cls = instructions_registry.INSTRUCTION_DICT[instruction_id] + instruction = instruction_cls(instruction_id) + + # Remove None values from kwargs to avoid unexpected keyword argument errors in build_description method. + kwargs = {k: v for k, v in inp.kwargs[index].items() if v} + instruction.build_description(**kwargs) + args = instruction.get_instruction_args() + if args and "prompt" in args: + instruction.build_description(prompt=inp.prompt) + + is_following = False + for r in all_responses: + if r.strip() and instruction.check_following(r): + is_following = True + break + + is_following_list.append(is_following) + + return OutputExample( + instruction_id_list=inp.instruction_id_list, + prompt=inp.prompt, + response=response, + follow_all_instructions=all(is_following_list), + follow_instruction_list=is_following_list, + ) + + +def process_results(doc, results): + eval_logger.warning( + "This task is meant for chat-finetuned models, and may not give meaningful results for models other than `openai` or `anthropic` if `doc_to_text` in its YAML is not wrapped in the appropriate chat template string. This warning will be removed when chat templating support is added natively to local models" + ) + + inp = InputExample( + key=doc["key"], + instruction_id_list=doc["instruction_id_list"], + prompt=doc["prompt"], + kwargs=doc["kwargs"], + ) + response = results[0] + + out_strict = test_instruction_following_strict(inp, response) + out_loose = test_instruction_following_loose(inp, response) + + return { + "prompt_level_strict_acc": out_strict.follow_all_instructions, + "inst_level_strict_acc": out_strict.follow_instruction_list, + "prompt_level_loose_acc": out_loose.follow_all_instructions, + "inst_level_loose_acc": out_loose.follow_instruction_list, + } + + +def agg_inst_level_acc(items): + flat_items = [item for sublist in items for item in sublist] + inst_level_acc = sum(flat_items) / len(flat_items) + return inst_level_acc diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/mmlu/_generate_configs.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/mmlu/_generate_configs.py new file mode 100644 index 0000000000000000000000000000000000000000..cb4a076d438be52bcbf4a18ec796d655c541cc01 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/mmlu/_generate_configs.py @@ -0,0 +1,159 @@ +""" +Take in a YAML, and output all "other" splits with this YAML +""" + +import argparse +import logging +import os + +import yaml +from tqdm import tqdm + + +eval_logger = logging.getLogger("lm-eval") + + +SUBJECTS = { + "abstract_algebra": "stem", + "anatomy": "stem", + "astronomy": "stem", + "business_ethics": "other", + "clinical_knowledge": "other", + "college_biology": "stem", + "college_chemistry": "stem", + "college_computer_science": "stem", + "college_mathematics": "stem", + "college_medicine": "other", + "college_physics": "stem", + "computer_security": "stem", + "conceptual_physics": "stem", + "econometrics": "social_sciences", + "electrical_engineering": "stem", + "elementary_mathematics": "stem", + "formal_logic": "humanities", + "global_facts": "other", + "high_school_biology": "stem", + "high_school_chemistry": "stem", + "high_school_computer_science": "stem", + "high_school_european_history": "humanities", + "high_school_geography": "social_sciences", + "high_school_government_and_politics": "social_sciences", + "high_school_macroeconomics": "social_sciences", + "high_school_mathematics": "stem", + "high_school_microeconomics": "social_sciences", + "high_school_physics": "stem", + "high_school_psychology": "social_sciences", + "high_school_statistics": "stem", + "high_school_us_history": "humanities", + "high_school_world_history": "humanities", + "human_aging": "other", + "human_sexuality": "social_sciences", + "international_law": "humanities", + "jurisprudence": "humanities", + "logical_fallacies": "humanities", + "machine_learning": "stem", + "management": "other", + "marketing": "other", + "medical_genetics": "other", + "miscellaneous": "other", + "moral_disputes": "humanities", + "moral_scenarios": "humanities", + "nutrition": "other", + "philosophy": "humanities", + "prehistory": "humanities", + "professional_accounting": "other", + "professional_law": "humanities", + "professional_medicine": "other", + "professional_psychology": "social_sciences", + "public_relations": "social_sciences", + "security_studies": "social_sciences", + "sociology": "social_sciences", + "us_foreign_policy": "social_sciences", + "virology": "other", + "world_religions": "humanities", +} + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("--base_yaml_path", required=True) + parser.add_argument("--save_prefix_path", default="mmlu") + parser.add_argument("--cot_prompt_path", default=None) + parser.add_argument("--task_prefix", default="") + parser.add_argument("--group_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) + + if args.cot_prompt_path is not None: + import json + + with open(args.cot_prompt_path, encoding="utf-8") as f: + cot_file = json.load(f) + + ALL_CATEGORIES = [] + for subject, category in tqdm(SUBJECTS.items()): + if category not in ALL_CATEGORIES: + ALL_CATEGORIES.append(category) + + if args.cot_prompt_path is not None: + description = cot_file[subject] + else: + description = f"The following are multiple choice questions (with answers) about {' '.join(subject.split('_'))}.\n\n" + + yaml_dict = { + "include": base_yaml_name, + "group": f"mmlu_{args.task_prefix}_{category}" + if args.task_prefix != "" + else f"mmlu_{category}", + "group_alias": category.replace("_", " "), + "task": f"mmlu_{args.task_prefix}_{subject}" + if args.task_prefix != "" + else f"mmlu_{subject}", + "task_alias": subject.replace("_", " "), + "dataset_name": subject, + "description": description, + } + + file_save_path = args.save_prefix_path + f"_{subject}.yaml" + eval_logger.info(f"Saving yaml for subset {subject} to {file_save_path}") + with open(file_save_path, "w", encoding="utf-8") as yaml_file: + yaml.dump( + yaml_dict, + yaml_file, + allow_unicode=True, + default_style='"', + ) + + if args.task_prefix != "": + mmlu_subcategories = [ + f"mmlu_{args.task_prefix}_{category}" for category in ALL_CATEGORIES + ] + else: + mmlu_subcategories = [f"mmlu_{category}" for category in ALL_CATEGORIES] + + if args.group_prefix != "": + file_save_path = args.group_prefix + ".yaml" + else: + file_save_path = args.save_prefix_path + ".yaml" + + eval_logger.info(f"Saving benchmark config to {file_save_path}") + with open(file_save_path, "w", encoding="utf-8") as yaml_file: + yaml.dump( + { + "group": f"mmlu_{args.task_prefix}" + if args.task_prefix != "" + else "mmlu", + "task": mmlu_subcategories, + }, + yaml_file, + indent=4, + default_flow_style=False, + ) diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/pile_10k/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/pile_10k/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a5311b53c31a32e13123d9219787e1f9e2cef807 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/pile_10k/README.md @@ -0,0 +1,45 @@ +# Pile-10k + +### Paper + +Title: `NeelNanda/pile-10k` + +Abstract: The first 10K elements of [The Pile](https://pile.eleuther.ai/), useful for debugging models trained on it. See the [HuggingFace page for the full Pile](https://huggingface.co/datasets/the_pile) for more info. Inspired by [stas' great resource](https://huggingface.co/datasets/stas/openwebtext-10k) doing the same for OpenWebText + +Homepage: [https://huggingface.co/datasets/NeelNanda/pile-10k](https://huggingface.co/datasets/NeelNanda/pile-10k) + + +### Citation + +``` +@misc{Nanda2022Pile10K, + author = {Nanda, Neel}, + title = {{NeelNanda/pile-10k} \textendash\ Datasets at Hugging Face}, + year = {2022}, + howpublished = {\url{https://huggingface.co/datasets/NeelNanda/pile-10k}}, +} +``` + +### Groups and Tasks + +#### Groups + +* Not part of a group yet. + + +#### Tasks + +* `pile_10k`: `The first 10K elements of The Pile, useful for debugging models trained on it.` + +### 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/pile_10k/pile_10k.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/pile_10k/pile_10k.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9eda0ffa442550e22c7063346b21fb00b46e1112 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/pile_10k/pile_10k.yaml @@ -0,0 +1,19 @@ +task: pile_10k +dataset_path: NeelNanda/pile-10k +dataset_name: null +output_type: loglikelihood_rolling +test_split: train +doc_to_text: "" +doc_to_target: "text" +metric_list: + - metric: word_perplexity + aggregation: weighted_perplexity + higher_is_better: false + - metric: byte_perplexity + aggregation: weighted_perplexity + higher_is_better: false + - metric: bits_per_byte + aggregation: bits_per_byte + higher_is_better: false +metadata: + version: 1.0 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7f5ea3c3be4f84c0bf5c733dccce3c8d95931bda --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/README.md @@ -0,0 +1,60 @@ +# XCOPA + +### Paper + +Title: `XCOPA: A Multilingual Dataset for Causal Commonsense Reasoning` + +Abstract: https://ducdauge.github.io/files/xcopa.pdf + +The Cross-lingual Choice of Plausible Alternatives dataset is a benchmark to evaluate the ability of machine learning models to transfer commonsense reasoning across languages. +The dataset is the translation and reannotation of the English COPA (Roemmele et al. 2011) and covers 11 languages from 11 families and several areas around the globe. +The dataset is challenging as it requires both the command of world knowledge and the ability to generalise to new languages. +All the details about the creation of XCOPA and the implementation of the baselines are available in the paper. + +Homepage: https://github.com/cambridgeltl/xcopa + +### Citation + +``` +@inproceedings{ponti2020xcopa, + title={{XCOPA: A} Multilingual Dataset for Causal Commonsense Reasoning}, + author={Edoardo M. Ponti, Goran Glava\v{s}, Olga Majewska, Qianchu Liu, Ivan Vuli\'{c} and Anna Korhonen}, + booktitle={Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP)}, + year={2020}, + url={https://ducdauge.github.io/files/xcopa.pdf} +} +``` + +### Groups and Tasks + +#### Groups + +* `xcopa` + +#### Tasks + +* `xcopa_et`: Estonian +* `xcopa_ht`: Haitian Creole +* `xcopa_id`: Indonesian +* `xcopa_it`: Italian +* `xcopa_qu`: Cusco-Collao Quechua +* `xcopa_sw`: Kiswahili +* `xcopa_ta`: Tamil +* `xcopa_th`: Thai +* `xcopa_tr`: Turkish +* `xcopa_vi`: Vietnamese +* `xcopa_zh`: Mandarin Chinese + + +### 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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_et.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_et.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9f2b0b73b585ab1a6e4c946237e52dba283a830a --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_et.yaml @@ -0,0 +1,14 @@ +group: xcopa +task: xcopa_et +dataset_path: xcopa +dataset_name: et +output_type: multiple_choice +validation_split: validation +test_split: test +doc_to_text: !function utils.doc_to_text_et +doc_to_target: label +doc_to_choice: !function utils.doc_to_choice +metric_list: + - metric: acc +metadata: + version: 1.0 diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_ht.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_ht.yaml new file mode 100644 index 0000000000000000000000000000000000000000..21e22e1a6ecfe560de9f8ee2f19423b182d0df39 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_ht.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_ht +dataset_name: ht +doc_to_text: !function utils.doc_to_text_ht diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_id.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_id.yaml new file mode 100644 index 0000000000000000000000000000000000000000..08fda55c8bba30023936fc11c2efa8de6007125c --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_id.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_id +dataset_name: id +doc_to_text: !function utils.doc_to_text_id diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_it.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_it.yaml new file mode 100644 index 0000000000000000000000000000000000000000..51ba1002cb4cd0c97e2f9ec1e96c249a4b449db5 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_it.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_it +dataset_name: it +doc_to_text: !function utils.doc_to_text_it diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_qu.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_qu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c6f356001076e79a09cd8020b6fb6b0a4c052c25 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_qu.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_qu +dataset_name: qu +doc_to_text: !function utils.doc_to_text_qu diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_sw.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_sw.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4174cb0ef3b639ad5d2817dc45640c66bd9401c7 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_sw.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_sw +dataset_name: sw +doc_to_text: !function utils.doc_to_text_sw diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_ta.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_ta.yaml new file mode 100644 index 0000000000000000000000000000000000000000..216cacf89bd233858e613909e32e4b909c6bb338 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_ta.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_ta +dataset_name: ta +doc_to_text: !function utils.doc_to_text_ta diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_th.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_th.yaml new file mode 100644 index 0000000000000000000000000000000000000000..90346b8c85be2ccff6e12ffcd64f3bd9ccb1ed70 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_th.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_th +dataset_name: th +doc_to_text: !function utils.doc_to_text_th diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_tr.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_tr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..81dac28670f00227b641fe4af46ad1542f7d173e --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_tr.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_tr +dataset_name: tr +doc_to_text: !function utils.doc_to_text_tr diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_vi.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_vi.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c08cdd1a2c08c86e792f0d91ce46838c4a27798a --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_vi.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_vi +dataset_name: vi +doc_to_text: !function utils.doc_to_text_vi diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_zh.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_zh.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ad681e6a86dca8a3aae5b06af8835eb96bf1768c --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/default_zh.yaml @@ -0,0 +1,4 @@ +include: default_et.yaml +task: xcopa_zh +dataset_name: zh +doc_to_text: !function utils.doc_to_text_zh diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/utils.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..fe9d85920baa7098fd20f853da6eadcbc787dedd --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xcopa/utils.py @@ -0,0 +1,114 @@ +from functools import partial + + +def convert_choice(choice): + return choice[0].lower() + choice[1:] + + +def doc_to_text(doc, connector): + # Drop the period + conn = connector[doc["question"]] + return doc["premise"].strip()[:-1] + f" {conn}" + + +def doc_to_choice(doc): + return [convert_choice(doc["choice1"]), convert_choice(doc["choice2"])] + + +doc_to_text_et = partial( + doc_to_text, + connector={ + "cause": "sest", + "effect": "seetõttu", + }, +) + + +doc_to_text_ht = partial( + doc_to_text, + connector={ + "cause": "poukisa", + "effect": "donk sa", + }, +) + + +doc_to_text_it = partial( + doc_to_text, + connector={ + "cause": "perché", + "effect": "quindi", + }, +) + + +doc_to_text_id = partial( + doc_to_text, + connector={ + "cause": "karena", + "effect": "maka", + }, +) + + +doc_to_text_qu = partial( + doc_to_text, + connector={ + "cause": "imataq", + "effect": "chaymi", + }, +) + + +doc_to_text_sw = partial( + doc_to_text, + connector={ + "cause": "kwa sababu", + "effect": "kwa hiyo", + }, +) + + +doc_to_text_zh = partial( + doc_to_text, + connector={ + "cause": "因为", + "effect": "所以", + }, +) + + +doc_to_text_ta = partial( + doc_to_text, + connector={ + "cause": "காரணமாக", + "effect": "எனவே", + }, +) + + +doc_to_text_th = partial( + doc_to_text, + connector={ + "cause": "เพราะ", + "effect": "ดังนั้น", + }, +) + + +doc_to_text_tr = partial( + doc_to_text, + connector={ + "cause": "çünkü", + "effect": "bu yüzden", + }, +) + + +doc_to_text_vi = partial( + doc_to_text, + connector={ + "cause": "bởi vì", + "effect": "vì vậy", + }, +) diff --git a/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/README.md b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d97dfe1693569de3386532af9b75ef7331ece3e3 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/utils.py b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..5e350d6e9f43baafdddc18d573ddc0bfa7c837e5 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_common_yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_common_yaml new file mode 100644 index 0000000000000000000000000000000000000000..86554820e9aa6087b00bb6f552c70638cd02eaeb --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_common_yaml @@ -0,0 +1,20 @@ +# 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. +group: + - xwinograd +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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_en.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_en.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7ae486ac1804443f5a76a71a1df331a0b4ed67ef --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_fr.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_fr.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f93bbcd0600a3b32867171514d5c4f085f814a1c --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_jp.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_jp.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ef8b99bf51e8e6fd5e1210c748f3a8cabde59957 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_pt.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_pt.yaml new file mode 100644 index 0000000000000000000000000000000000000000..981287f9b1890a7d43b299d8a52816023c08e77a --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_ru.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_ru.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2bb84bf9d80bbbe4c832a61eb3927a8ec88f29a2 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_zh.yaml b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/lm_eval/tasks/xwinograd/xwinograd_zh.yaml new file mode 100644 index 0000000000000000000000000000000000000000..17d9227c162d51ff2858ff663574dd08b43042a9 --- /dev/null +++ b/data/tefig/envs/olmes-eval/lib/python3.10/site-packages/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