diff --git a/.gitignore b/.gitignore index 90cd841c..d4e2d42f 100644 --- a/.gitignore +++ b/.gitignore @@ -142,3 +142,12 @@ cython_debug/ # pycharm stuff .idea + +# megatron core +/megatron/ + +# User stuff +/kernel*/ +/logs/ +/model_from_hf/ +/model_weights/ \ No newline at end of file diff --git a/evaluation.py b/evaluation.py index 775dccc1..75640897 100644 --- a/evaluation.py +++ b/evaluation.py @@ -117,7 +117,8 @@ def mmlu(eval_args, agent): if data_path: mmlu_eval = MmluEval(test_dir=data_path, batch_size=eval_args.evaluation_batch_size) answer, score_df = mmlu_eval.eval(chat=agent) - logger.info(score_df) + if rank == 0: + logger.info('\n{}'.format(score_df)) except Exception as e: logger.info(e) @@ -131,7 +132,8 @@ def gsm8k(eval_args, agent): if data_path: gsm8k_eval = Gsm8kEval(test_dir=data_path, batch_size=eval_args.evaluation_batch_size) answer, score_df = gsm8k_eval.eval(chat=agent) - logger.info(score_df) + if rank == 0: + logger.info('\n{}'.format(score_df)) except Exception as e: logger.info(e) @@ -145,7 +147,8 @@ def boolq(eval_args, agent): if data_path: boolq_eval = BoolqEval(test_dir=data_path, batch_size=eval_args.evaluation_batch_size) answer, score_df = boolq_eval.eval(chat=agent) - logger.info(score_df) + if rank == 0: + logger.info('\n{}'.format(score_df)) except Exception as e: logger.info(e) @@ -159,7 +162,8 @@ def ceval(eval_args, agent): if data_path: ceval_exam = CEvalExam(test_dir=data_path, batch_size=eval_args.evaluation_batch_size) answer, score_df = ceval_exam.eval(chat=agent) - logger.info(score_df) + if rank == 0: + logger.info('\n{}'.format(score_df)) except Exception as e: logger.info(e) @@ -173,7 +177,8 @@ def human_eval(eval_args, agent): if data_path: human_eval_exam = HumanEval(test_dir=data_path, instruction_template=eval_args.instruction_template) answer, score_df = human_eval_exam.eval(chat=agent) - logger.info(score_df) + if rank == 0: + logger.info('\n{}'.format(score_df)) except Exception as e: logger.info(e) @@ -187,7 +192,8 @@ def agi_eval(eval_args, agent): if data_path: agieval_exam = AGIEvalExam(test_dir=data_path, batch_size=eval_args.evaluation_batch_size) answer, score_df = agieval_exam.eval(chat=agent) - logger.info(score_df) + if rank == 0: + logger.info('\n{}'.format(score_df)) except Exception as e: logger.info(e) @@ -201,7 +207,8 @@ def bbh_eval(eval_args, agent): if data_path: bbh = BBHEval(test_dir=data_path, batch_size=eval_args.evaluation_batch_size) answer, score_df = bbh.eval(chat=agent) - logger.info(score_df) + if rank == 0: + logger.info('\n{}'.format(score_df)) except Exception as e: logger.info(e) @@ -217,32 +224,40 @@ if __name__ == "__main__": ) tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_name_or_path, trust_remote_code=True) max_new_tokens = args.max_new_tokens + rank = dist.get_rank() if 'mmlu' in args.task: a = time.time() mmlu(args, LLMChat(args)) - logger.info(f'MMLU Running Time:, {time.time() - a}') + if rank == 0: + logger.info(f'MMLU Running Time:, {time.time() - a}') if 'gsm8k' in args.task: a = time.time() gsm8k(args, LLMChat(args)) - logger.info(f'GSM8k Running Time: {time.time() - a}') + if rank == 0: + logger.info(f'GSM8k Running Time: {time.time() - a}') if 'boolq' in args.task: a = time.time() boolq(args, LLMChat(args)) - logger.info(f'Boolq Running Time: {time.time() - a}') + if rank == 0: + logger.info(f'Boolq Running Time: {time.time() - a}') if 'ceval' in args.task: a = time.time() ceval(args, LLMChat(args)) - logger.info(f'Ceval Running Time: {time.time() - a}') + if rank == 0: + logger.info(f'Ceval Running Time: {time.time() - a}') if 'bbh' in args.task: a = time.time() bbh_eval(args, LLMChat(args)) - logger.info(f'bbh Running Time: {time.time() - a}') + if rank == 0: + logger.info(f'bbh Running Time: {time.time() - a}') if 'agieval' in args.task: a = time.time() agi_eval(args, LLMChat(args)) - logger.info(f'agi_eval Running Time: {time.time() - a}') + if rank == 0: + logger.info(f'agi_eval Running Time: {time.time() - a}') if 'human_eval' in args.task: a = time.time() human_eval(args, LLMChat(args)) - logger.info(f'Human_eval Running Time: {time.time() - a}') + if rank == 0: + logger.info(f'Human_eval Running Time: {time.time() - a}') diff --git a/modellink/log_handler.py b/modellink/log_handler.py new file mode 100644 index 00000000..0273f454 --- /dev/null +++ b/modellink/log_handler.py @@ -0,0 +1,17 @@ +from tqdm import tqdm +from torch import distributed as dist + + +def emit(self, record): + try: + rank = dist.get_rank() + except Exception: + rank = -1 # 如果获取rank失败,则设置为一个不合法的rank + + if rank == 0 or rank == -1: + try: + msg = self.format(record) + tqdm.write(msg) + self.flush() + except Exception: + self.handleError(record) \ No newline at end of file diff --git a/modellink/patchs/megatron_patch.py b/modellink/patchs/megatron_patch.py index d0070f0e..7a667a59 100644 --- a/modellink/patchs/megatron_patch.py +++ b/modellink/patchs/megatron_patch.py @@ -43,6 +43,7 @@ from ..tokenizer import build_tokenizer from ..arguments import parse_args_decorator, validate_args_decorator from ..checkpointing import _load_base_checkpoint_wrapper, load_checkpoint_wrapper from ..initialize import initialize_megatron +from ..log_handler import emit def exec_patch(): @@ -65,6 +66,7 @@ def patch_megatron_noncore(): patch_model() patch_initialize() patch_training() + patch_log_handler() def patch_fusions(): @@ -198,3 +200,8 @@ def patch_datasets(): from megatron.core.datasets.gpt_dataset import GPTDataset GPTDataset._build_document_sample_shuffle_indices = _build_document_sample_shuffle_indices BlendedMegatronDatasetBuilder._build_generic_dataset = _build_generic_dataset + + +def patch_log_handler(): + from megatron.log_handler import CustomHandler + CustomHandler.emit = emit \ No newline at end of file diff --git a/modellink/tasks/evaluation/eval_impl/agi_eval.py b/modellink/tasks/evaluation/eval_impl/agi_eval.py index 9d8c3f30..3840d354 100644 --- a/modellink/tasks/evaluation/eval_impl/agi_eval.py +++ b/modellink/tasks/evaluation/eval_impl/agi_eval.py @@ -15,8 +15,11 @@ import os import logging import json +import re import pandas as pd import tqdm + +from torch import distributed as dist from .template import AGIEVAL_TEMPLATE_DIR from ..eval_api.dataset_eval import DatasetEval from ..eval_api.chat import Chat @@ -32,6 +35,9 @@ class AGIEvalExam(DatasetEval): self.test_dir = test_dir self.instruction_template = instruction_template self.batch_size = batch_size + self.rank = dist.get_rank() + self.file_pbar = None + self.task_pbar = None def eval(self, chat: Chat) -> (dict, pd.DataFrame): answer_result = {} @@ -40,20 +46,35 @@ class AGIEvalExam(DatasetEval): score_datas = [] sample_n = 0 rank = None + with open(AGIEVAL_TEMPLATE_DIR, encoding='utf-8') as f: AGI_few_shot_template = json.load(f) - for file in tqdm.tqdm(os.listdir(self.test_dir)): + + if self.rank == 0: + self.file_pbar = tqdm.tqdm(total=len(os.listdir(self.test_dir)), desc="total") + + for file in os.listdir(self.test_dir): file_path = os.path.join(self.test_dir, file) with open(file_path, encoding='utf-8') as f: agi_question_list = [] for line in f.readlines(): agi_question_list.append(json.loads(line)) - subject_name = file[0: -6] + subject_name = re.sub(r'(?:_test|_val|_dev)?\.\w+$', "", file) subject_result = {} sample_n += len(agi_question_list) acc_n = 0 instructions = [] corrects = [] + + if subject_name not in AGI_few_shot_template: + logging.error(f"missing '{subject_name}' instruction_template in {AGIEVAL_TEMPLATE_DIR}") + if self.file_pbar is not None: + self.file_pbar.update() + continue + + if self.rank == 0: + self.task_pbar = tqdm.tqdm(total=len(agi_question_list), desc=file, leave=False) + for idx, item in enumerate(agi_question_list): if item['passage']: question = item['passage'] + '\n' + item['question'] @@ -100,6 +121,9 @@ class AGIEvalExam(DatasetEval): instructions = [] corrects = [] + if self.task_pbar is not None: + self.task_pbar.update() + if rank == 0: logger.info("%s acc = %d/%d=%e", subject_name, acc_n, len(agi_question_list), check_divisible_by_zero(acc_n, len(agi_question_list))) @@ -108,6 +132,13 @@ class AGIEvalExam(DatasetEval): answer_result[subject_name] = subject_result score_datas.append( [subject_name, len(agi_question_list), check_divisible_by_zero(acc_n, len(agi_question_list))]) + + if self.task_pbar is not None: + self.task_pbar.close() + + if self.file_pbar is not None: + self.file_pbar.update() + if rank == 0: logger.info("AGIEval acc = %d/%d=%e", total_acc_n, total_n, check_divisible_by_zero(total_acc_n, total_n)) score_datas.append(["total", total_n, check_divisible_by_zero(total_acc_n, total_n)]) diff --git a/modellink/tasks/evaluation/eval_impl/bbh_eval.py b/modellink/tasks/evaluation/eval_impl/bbh_eval.py index 9ab8eefd..10262192 100644 --- a/modellink/tasks/evaluation/eval_impl/bbh_eval.py +++ b/modellink/tasks/evaluation/eval_impl/bbh_eval.py @@ -15,9 +15,11 @@ import os import logging import json +import re import pandas as pd import tqdm +from torch import distributed as dist from .template import BBH_TEMPLATE_DIR from ..eval_api.dataset_eval import DatasetEval from ..eval_api.chat import Chat @@ -32,6 +34,9 @@ class BBHEval(DatasetEval): self.test_dir = test_dir self.instruction_template = instruction_template self.batch_size = batch_size + self.rank = dist.get_rank() + self.file_pbar = None + self.task_pbar = None def eval(self, chat: Chat) -> (dict, pd.DataFrame): answer_result = {} @@ -40,24 +45,39 @@ class BBHEval(DatasetEval): score_datas = [] sample_n = 0 rank = None + with open(BBH_TEMPLATE_DIR, encoding='utf-8') as f: bbh_template = json.load(f) - for file in tqdm.tqdm(os.listdir(self.test_dir)): + + if self.rank == 0: + self.file_pbar = tqdm.tqdm(total=len(os.listdir(self.test_dir)), desc="total") + + for file in os.listdir(self.test_dir): file_path = os.path.join(self.test_dir, file) with open(file_path, encoding='utf-8') as f: bbh_dataset = json.load(f) - subject_name = file[0: -5] + subject_name = re.sub(r'(?:_test|_val|_dev)?\.\w+$', "", file) subject_result = {} sample_n += len(bbh_dataset['examples']) acc_n = 0 sorted_dataset = sorted(bbh_dataset['examples'], key=lambda x: len(x['input'])) instructions = [] targets = [] + + if subject_name not in bbh_template: + logging.error(f"missing '{subject_name}' instruction_template in {BBH_TEMPLATE_DIR}") + if self.file_pbar is not None: + self.file_pbar.update() + continue + + if self.rank == 0: + self.task_pbar = tqdm.tqdm(total=len(sorted_dataset), desc=file, leave=False) + for idx, item in enumerate(sorted_dataset): instruction = self.instruction_template.format(fewshot_template=bbh_template[subject_name], question=item['input']) instructions.append(instruction) - targets.append(item['target']) + targets.append(item['target'].lstrip('(').rstrip(')')) if len(instructions) == self.batch_size or len(bbh_dataset['examples']) == idx + 1: chat_results, rank = chat.chat(instruction=instructions, history=[]) @@ -76,6 +96,9 @@ class BBHEval(DatasetEval): instructions = [] targets = [] + if self.task_pbar is not None: + self.task_pbar.update() + if rank == 0: logging.info(f"{subject_name} acc = {acc_n}/{len(bbh_dataset['examples'])}=" f"{check_divisible_by_zero(acc_n, len(bbh_dataset['examples']))}") @@ -84,6 +107,13 @@ class BBHEval(DatasetEval): answer_result[subject_name] = subject_result score_datas.append([subject_name, len(bbh_dataset['examples']), check_divisible_by_zero(acc_n, len(bbh_dataset['examples']))]) + + if self.task_pbar is not None: + self.task_pbar.close() + + if self.file_pbar is not None: + self.file_pbar.update() + if rank == 0: logger.info(f"bbh acc = {total_acc_n}/{total_n}={check_divisible_by_zero(total_acc_n, total_n)}") score_datas.append(["total", total_n, check_divisible_by_zero(total_acc_n, total_n)]) diff --git a/modellink/tasks/evaluation/eval_impl/boolq_eval.py b/modellink/tasks/evaluation/eval_impl/boolq_eval.py index c81fd599..6136edb8 100644 --- a/modellink/tasks/evaluation/eval_impl/boolq_eval.py +++ b/modellink/tasks/evaluation/eval_impl/boolq_eval.py @@ -19,6 +19,7 @@ import json import pandas as pd import tqdm +from torch import distributed as dist from ..eval_api.dataset_eval import DatasetEval from ..eval_api.chat import Chat from ....error_utils import check_divisible_by_zero @@ -33,6 +34,9 @@ class BoolqEval(DatasetEval): self.test_dir = test_dir self.instruction_template = instruction_template self.batch_size = batch_size + self.rank = dist.get_rank() + self.file_pbar = None + self.task_pbar = None def eval(self, chat: Chat) -> (dict, pd.DataFrame): answer_result = {} @@ -40,7 +44,11 @@ class BoolqEval(DatasetEval): total_acc_n = 0 total_n = 0 rank = None - for file in tqdm.tqdm(os.listdir(self.test_dir)): + + if self.rank == 0: + self.file_pbar = tqdm.tqdm(total=len(os.listdir(self.test_dir)), desc="total") + + for file in os.listdir(self.test_dir): file_path = os.path.join(self.test_dir, file) with open(file_path, encoding='utf-8') as f: boolq_question_list = [] @@ -50,6 +58,10 @@ class BoolqEval(DatasetEval): acc_n = 0 instructions = [] targets = [] + + if self.rank == 0: + self.task_pbar = tqdm.tqdm(total=len(boolq_question_list), desc=file, leave=False) + for index, item in enumerate(boolq_question_list): instruction = self.instruction_template.format(passage=item['passage'], question=item['question']) instructions.append(instruction) @@ -74,11 +86,21 @@ class BoolqEval(DatasetEval): instructions = [] targets = [] + if self.task_pbar is not None: + self.task_pbar.update() + if rank == 0: total_n += len(boolq_question_list) total_acc_n += acc_n answer_result['Boolq_dataset'] = subject_result score_datas.append(['Boolq_dataset', len(boolq_question_list), acc_n / len(boolq_question_list)]) + + if self.task_pbar is not None: + self.task_pbar.close() + + if self.file_pbar is not None: + self.file_pbar.update() + if rank == 0: logger.info(f"boolq acc = {total_acc_n}/{total_n}={check_divisible_by_zero(total_acc_n, total_n)}") score_datas.append(["total", total_n, total_acc_n / total_n]) diff --git a/modellink/tasks/evaluation/eval_impl/ceval_exam.py b/modellink/tasks/evaluation/eval_impl/ceval_exam.py index 2c3a2821..e4ed6168 100644 --- a/modellink/tasks/evaluation/eval_impl/ceval_exam.py +++ b/modellink/tasks/evaluation/eval_impl/ceval_exam.py @@ -15,9 +15,11 @@ import os import logging import json +import re import pandas as pd import tqdm +from torch import distributed as dist from .template import CEVAL_TEMPLATE_DIR from ..eval_api.dataset_eval import DatasetEval from ..eval_api.chat import Chat @@ -33,6 +35,9 @@ class CEvalExam(DatasetEval): self.test_dir = test_dir self.instruction_template = instruction_template self.batch_size = batch_size + self.rank = dist.get_rank() + self.file_pbar = None + self.task_pbar = None def eval(self, chat: Chat) -> (dict, pd.DataFrame): answer_result = {} @@ -41,17 +46,32 @@ class CEvalExam(DatasetEval): score_datas = [] sample_n = 0 rank = None + with open(CEVAL_TEMPLATE_DIR, encoding='utf-8') as f: ceval_few_shot_template = json.load(f) - for file in tqdm.tqdm(os.listdir(self.test_dir)): + + if self.rank == 0: + self.file_pbar = tqdm.tqdm(total=len(os.listdir(self.test_dir)), desc="total") + + for file in os.listdir(self.test_dir): file_path = os.path.join(self.test_dir, file) data_df = pd.read_csv(file_path) - subject_name = file[0: -8] + subject_name = re.sub(r'(?:_test|_val|_dev)?\.\w+$', "", file) subject_result = {} sample_n += len(data_df) acc_n = 0 instructions = [] answers = [] + + if subject_name not in ceval_few_shot_template: + logging.error(f"missing '{subject_name}' instruction_template in {CEVAL_TEMPLATE_DIR}") + if self.file_pbar is not None: + self.file_pbar.update() + continue + + if self.rank == 0: + self.task_pbar = tqdm.tqdm(total=len(data_df), desc=file, leave=False) + for idx, row in data_df.iterrows(): test_question = f"{row['question']}\nA. {row['A']}\nB. {row['B']}\nC. {row['C']}\nD. {row['D']}" instruction = self.instruction_template.format(fewshot_template=ceval_few_shot_template[subject_name], @@ -76,11 +96,21 @@ class CEvalExam(DatasetEval): instructions = [] answers = [] + if self.task_pbar is not None: + self.task_pbar.update() + if rank == 0: total_n += len(data_df) total_acc_n += acc_n answer_result[subject_name] = subject_result score_datas.append([subject_name, len(data_df), acc_n / len(data_df)]) + + if self.task_pbar is not None: + self.task_pbar.close() + + if self.file_pbar is not None: + self.file_pbar.update() + if rank == 0: logger.info(f"ceval acc = {total_acc_n}/{total_n}={check_divisible_by_zero(total_acc_n, total_n)}") score_datas.append(["total", total_n, total_acc_n / total_n]) diff --git a/modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_templatejson b/modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_template.json similarity index 55% rename from modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_templatejson rename to modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_template.json index 588ac254..e7319456 100644 --- a/modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_templatejson +++ b/modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_template.json @@ -1,25 +1,25 @@ { "boolean_expressions": "Evaluate the result of a random Boolean expression.\n\nQ: not ( ( not not True ) ) is\nA: False\n\nQ: True and False and not True and True is\nA: False\n\nQ: not not ( not ( False ) ) is\nA: True\n\n", "causal_judgement": "Answer questions about causal attribution.\n\nQ: How would a typical person answer each of the following questions about causation?\nFrank T., had an ongoing dispute with his neighbor over a stretch of land and one day decided to shoot his neighbor in the body. Frank T. had no experience with guns, his hand slipped on the barrel of the gun, and the shot went wild. Nonetheless, the bullet bounced off a large boulder several feet away and hit the neighbor's body, causing significant injury. Did Frank T. intentionally shoot his neighbor in the body?\nOptions:\n- Yes\n- No\nA: No\n\nQ: How would a typical person answer each of the following questions about causation?\nSuzy and Billy are working on a project that is very important for our nation's security. The boss tells them both: Be sure that you are here at exactly 9 am. It is absolutely essential that you arrive at that time.Both Billy and Suzy arrive at 9 am. As it happens, there was a motion detector installed in the room where they arrived. The motion detector was set up to be triggered if at least one person appeared in the room at the same time. So the motion detector went off. Did Billy cause the motion detector to go off?\nOptions:\n- Yes\n- No\nA: Yes\n\nQ: How would a typical person answer each of the following questions about causation?\nGeorge and his sister Lena reunite at their parents' house for Thanksgiving. Whereas George just got into medical school, Lena is unhappy in her marriage and recently lost her job. Over the course of the day, George and Lena get into a number of heated arguments. Later in the afternoon they play a game of darts. They split the first two games, and the third game is close until the end. Who will win comes down to George's last shot. If he hits a high point region, he wins; if he hits a low point region, Lena wins. George thinks of the difficult time Lena is having, and he really wants to let her win. He aims the dart at the low point region. He sets up his shot and the dart lands in the low point region. After his shot, Lena wins the game and is very happy. Did George hit the low point region intentionally?\nOptions:\n- Yes\n- No\nA: Yes\n\n", - "date_understanding": "Infer the date from context.\n\nQ: Today is Christmas Eve of 1937. What is the date 10 days ago in MM/DD/YYYY?\nOptions:\n(A) 12/14/2026\n(B) 12/14/1950\n(C) 12/14/2007\n(D) 12/14/1937\n(E) 07/14/1938\n(F) 12/14/1988\nA: (D)\n\nQ: Tomorrow is 11/12/2019. What is the date one year ago from today in MM/DD/YYYY?\nOptions:\n(A) 09/04/2018\n(B) 11/11/2018\n(C) 08/25/2018\n(D) 11/02/2018\n(E) 11/04/2018\nA: (B)\n\nQ: Jane and John married on Jan 2, 1958. It is their 5-year anniversary today. What is the date tomorrow in MM/DD/YYYY?\nOptions:\n(A) 01/11/1961\n(B) 01/03/1961\n(C) 01/18/1961\n(D) 10/14/1960\n(E) 01/03/1982\n(F) 12/03/1960\nA: (B)\n\n", - "disambiguation_qa": "Clarify the meaning of sentences with ambiguous pronouns.\n\nQ: In the following sentences, explain the antecedent of the pronoun (which thing the pronoun refers to), or state that it is ambiguous.\nSentence: The chief told the counselor that they took the day off.\nOptions:\n(A) The chief took the day off\n(B) The counselor took the day off\n(C) Ambiguous\nA: (A)\n\nQ: In the following sentences, explain the antecedent of the pronoun (which thing the pronoun refers to), or state that it is ambiguous.\nSentence: The manager sent a message to the secretary, but he didn't reply yet.\nOptions:\n(A) The secretary didn't reply yet\n(B) The manager didn't reply yet\n(C) Ambiguous\nA: (A)\n\nQ: In the following sentences, explain the antecedent of the pronoun (which thing the pronoun refers to), or state that it is ambiguous.\nSentence: Bailey will plan to meet the director at his office\nOptions:\n(A) It will be Bailey's office\n(B) It will be the director's office\n(C) Ambiguous\nA: (C)\n\n", + "date_understanding": "Infer the date from context.\n\nQ: Today is Christmas Eve of 1937. What is the date 10 days ago in MM/DD/YYYY?\nOptions:\n(A) 12/14/2026\n(B) 12/14/1950\n(C) 12/14/2007\n(D) 12/14/1937\n(E) 07/14/1938\n(F) 12/14/1988\nA: D\n\nQ: Tomorrow is 11/12/2019. What is the date one year ago from today in MM/DD/YYYY?\nOptions:\n(A) 09/04/2018\n(B) 11/11/2018\n(C) 08/25/2018\n(D) 11/02/2018\n(E) 11/04/2018\nA: B\n\nQ: Jane and John married on Jan 2, 1958. It is their 5-year anniversary today. What is the date tomorrow in MM/DD/YYYY?\nOptions:\n(A) 01/11/1961\n(B) 01/03/1961\n(C) 01/18/1961\n(D) 10/14/1960\n(E) 01/03/1982\n(F) 12/03/1960\nA: B\n\n", + "disambiguation_qa": "Clarify the meaning of sentences with ambiguous pronouns.\n\nQ: In the following sentences, explain the antecedent of the pronoun (which thing the pronoun refers to), or state that it is ambiguous.\nSentence: The chief told the counselor that they took the day off.\nOptions:\n(A) The chief took the day off\n(B) The counselor took the day off\n(C) Ambiguous\nA: A\n\nQ: In the following sentences, explain the antecedent of the pronoun (which thing the pronoun refers to), or state that it is ambiguous.\nSentence: The manager sent a message to the secretary, but he didn't reply yet.\nOptions:\n(A) The secretary didn't reply yet\n(B) The manager didn't reply yet\n(C) Ambiguous\nA: A\n\nQ: In the following sentences, explain the antecedent of the pronoun (which thing the pronoun refers to), or state that it is ambiguous.\nSentence: Bailey will plan to meet the director at his office\nOptions:\n(A) It will be Bailey's office\n(B) It will be the director's office\n(C) Ambiguous\nA: C\n\n", "dyck_languages": "Correctly close a Dyck-n word.\n\nQ: Complete the rest of the sequence, making sure that the parentheses are closed properly. Input: [ { [\nA: ] } ]\n\nQ: Complete the rest of the sequence, making sure that the parentheses are closed properly. Input: < > ( ( [ [ ( { } ) [ < > ] ]\nA: ] ) )\n\nQ: Complete the rest of the sequence, making sure that the parentheses are closed properly. Input: < [ < [ { < [ ] < { } > > } ] > { { ( ) } { < [ < > ] > }\nA: } ] >\n\n", "formal_fallacies": "Distinguish deductively valid arguments from formal fallacies.\n\nQ: It is not always easy to see who is related to whom -- and in which ways. The following argument pertains to this question: To begin with, Lesley is a close friend of Fernando. Moreover, being a close friend of Fernando or a schoolmate of Lowell is sufficient for being a great-grandfather of Leroy. It follows that Lesley is a great-grandfather of Leroy.\nIs the argument, given the explicitly stated premises, deductively valid or invalid?\nOptions:\n- valid\n- invalid\nA: valid\n\nQ: It is not always easy to see who is related to whom -- and in which ways. The following argument pertains to this question: Whoever is not a great-grandfather of Clyde is a stepbrother of Brian. Being an ancestor of Dana is sufficient for not being a great-grandfather of Clyde. We may conclude: Everyone who is an ancestor of Dana is a stepbrother of Brian, too.\nIs the argument, given the explicitly stated premises, deductively valid or invalid?\nOptions:\n- valid\n- invalid\nA: valid\n\nQ: It is not always easy to grasp who is consuming which products. The following argument pertains to this question: Every infrequent user of Paul Mitchell shampoo is either a rare consumer of Nioxin shampoo or a loyal buyer of Caress soap, or both. No regular consumer of Lush soap is a rare consumer of Nioxin shampoo and, in the same time, a loyal buyer of Caress soap. It follows that whoever is an infrequent user of Paul Mitchell shampoo is not a regular consumer of Lush soap.\nIs the argument, given the explicitly stated premises, deductively valid or invalid?\nOptions:\n- valid\n- invalid\nA: invalid\n\n", - "geometric_shapes": "Name geometric shapes from their SVG paths.\n\nQ: This SVG path element draws a\nOptions:\n(A) circle\n(B) heptagon\n(C) hexagon\n(D) kite\n(E) line\n(F) octagon\n(G) pentagon\n(H) rectangle\n(I) sector\n(J) triangle\nA: (F)\n\nQ: This SVG path element draws a\nOptions:\n(A) circle\n(B) heptagon\n(C) hexagon\n(D) kite\n(E) line\n(F) octagon\n(G) pentagon\n(H) rectangle\n(I) sector\n(J) triangle\nA: (G)\n\nQ: This SVG path element draws a\nOptions:\n(A) circle\n(B) heptagon\n(C) hexagon\n(D) kite\n(E) line\n(F) octagon\n(G) pentagon\n(H) rectangle\n(I) sector\n(J) triangle\nA: (D)\n\n", - "hyperbaton": "Order adjectives correctly in English sentences.\n\nQ: Which sentence has the correct adjective order:\nOptions:\n(A) rubber terrible ship\n(B) terrible rubber ship\nA: (B)\n\nQ: Which sentence has the correct adjective order:\nOptions:\n(A) repulsive small Brazilian exercise ship\n(B) Brazilian repulsive exercise small ship\nA: (A)\n\nQ: Which sentence has the correct adjective order:\nOptions:\n(A) blue gold wonderful square shoe\n(B) wonderful square blue gold shoe\nA: (B)\n\n", - "logical_deduction": "A logical deduction task which requires deducing the order of a sequence of objects.\n\nQ: The following paragraphs each describe a set of three objects arranged in a fixed order. The statements are logically consistent within each paragraph. In a golf tournament, there were three golfers: Amy, Eli, and Eve. Eve finished above Amy. Eli finished below Amy.\nOptions:\n(A) Amy finished last\n(B) Eli finished last\n(C) Eve finished last\nA: (B)\n\nQ: The following paragraphs each describe a set of three objects arranged in a fixed order. The statements are logically consistent within each paragraph. On a shelf, there are three books: a white book, a green book, and an orange book. The green book is to the right of the white book. The orange book is the rightmost.\nOptions:\n(A) The white book is the leftmost\n(B) The green book is the leftmost\n(C) The orange book is the leftmost\nA: (A)\n\nQ: The following paragraphs each describe a set of three objects arranged in a fixed order. The statements are logically consistent within each paragraph. On a shelf, there are three books: a red book, a gray book, and a white book. The white book is to the left of the gray book. The red book is the second from the left.\nOptions:\n(A) The red book is the leftmost\n(B) The gray book is the leftmost\n(C) The white book is the leftmost\nA: (C)\n\n", - "movie_recommendation": "Recommend movies similar to the given list of movies.\n\nQ: Find a movie similar to Star Wars Episode IV - A New Hope, Indiana Jones and the Last Crusade, Star Wars Episode V - The Empire Strikes Back, The Big Lebowski:\nOptions:\n(A) Tetsuo\n(B) the Ironman\n(C) The Princess Bride\n(D) The Barkley Marathons The Race That Eats Its Young\n(E) Bug\nA: (C)\n\nQ: Find a movie similar to Twister, The Silence of the Lambs, Independence Day, Braveheart:\nOptions:\n(A) They Shoot Horses\n(B) Don't They\n(C) Forrest Gump\n(D) The Salton Sea\n(E) Extreme Days\nA: (C)\n\nQ: Find a movie similar to Minority Report, Total Recall, Inside Out, Forrest Gump:\nOptions:\n(A) Phenomena\n(B) Lilting\n(C) Catwoman\n(D) Edge of Tomorrow\nA: (D)\n\n", + "geometric_shapes": "Name geometric shapes from their SVG paths.\n\nQ: This SVG path element draws a\nOptions:\n(A) circle\n(B) heptagon\n(C) hexagon\n(D) kite\n(E) line\n(F) octagon\n(G) pentagon\n(H) rectangle\n(I) sector\n(J) triangle\nA: F\n\nQ: This SVG path element draws a\nOptions:\n(A) circle\n(B) heptagon\n(C) hexagon\n(D) kite\n(E) line\n(F) octagon\n(G) pentagon\n(H) rectangle\n(I) sector\n(J) triangle\nA: G\n\nQ: This SVG path element draws a\nOptions:\n(A) circle\n(B) heptagon\n(C) hexagon\n(D) kite\n(E) line\n(F) octagon\n(G) pentagon\n(H) rectangle\n(I) sector\n(J) triangle\nA: D\n\n", + "hyperbaton": "Order adjectives correctly in English sentences.\n\nQ: Which sentence has the correct adjective order:\nOptions:\n(A) rubber terrible ship\n(B) terrible rubber ship\nA: B\n\nQ: Which sentence has the correct adjective order:\nOptions:\n(A) repulsive small Brazilian exercise ship\n(B) Brazilian repulsive exercise small ship\nA: A\n\nQ: Which sentence has the correct adjective order:\nOptions:\n(A) blue gold wonderful square shoe\n(B) wonderful square blue gold shoe\nA: B\n\n", + "logical_deduction": "A logical deduction task which requires deducing the order of a sequence of objects.\n\nQ: The following paragraphs each describe a set of three objects arranged in a fixed order. The statements are logically consistent within each paragraph. In a golf tournament, there were three golfers: Amy, Eli, and Eve. Eve finished above Amy. Eli finished below Amy.\nOptions:\n(A) Amy finished last\n(B) Eli finished last\n(C) Eve finished last\nA: B\n\nQ: The following paragraphs each describe a set of three objects arranged in a fixed order. The statements are logically consistent within each paragraph. On a shelf, there are three books: a white book, a green book, and an orange book. The green book is to the right of the white book. The orange book is the rightmost.\nOptions:\n(A) The white book is the leftmost\n(B) The green book is the leftmost\n(C) The orange book is the leftmost\nA: A\n\nQ: The following paragraphs each describe a set of three objects arranged in a fixed order. The statements are logically consistent within each paragraph. On a shelf, there are three books: a red book, a gray book, and a white book. The white book is to the left of the gray book. The red book is the second from the left.\nOptions:\n(A) The red book is the leftmost\n(B) The gray book is the leftmost\n(C) The white book is the leftmost\nA: C\n\n", + "movie_recommendation": "Recommend movies similar to the given list of movies.\n\nQ: Find a movie similar to Star Wars Episode IV - A New Hope, Indiana Jones and the Last Crusade, Star Wars Episode V - The Empire Strikes Back, The Big Lebowski:\nOptions:\n(A) Tetsuo\n(B) the Ironman\n(C) The Princess Bride\n(D) The Barkley Marathons The Race That Eats Its Young\n(E) Bug\nA: C\n\nQ: Find a movie similar to Twister, The Silence of the Lambs, Independence Day, Braveheart:\nOptions:\n(A) They Shoot Horses\n(B) Don't They\n(C) Forrest Gump\n(D) The Salton Sea\n(E) Extreme Days\nA: C\n\nQ: Find a movie similar to Minority Report, Total Recall, Inside Out, Forrest Gump:\nOptions:\n(A) Phenomena\n(B) Lilting\n(C) Catwoman\n(D) Edge of Tomorrow\nA: D\n\n", "multistep_arithmetic_two": "Solve multi-step arithmetic problems.\n\nQ: ((-5 + 9 * -4 - 0) * (4 + -7 + 0 * -5)) =\nA: 123\n\nQ: ((-9 * 7 * 7 * -9) + (4 * -9 - 8 - -4)) =\nA: 3929\n\nQ: ((-3 + 5 * 8 * -4) - (9 - 8 * -7 + -9)) =\nA: -219\n\n", "navigate": "Given a series of navigation instructions, determine whether one would end up back at the starting point.\n\nQ: If you follow these instructions, do you return to the starting point? Turn left. Turn around. Turn left. Take 7 steps. Take 2 steps. Take 4 steps. Take 8 steps.\nOptions:\n- Yes\n- No\nA: No\n\nQ: If you follow these instructions, do you return to the starting point? Turn around. Take 1 step. Take 6 steps. Turn around. Take 6 steps. Take 9 steps. Take 1 step.\nOptions:\n- Yes\n- No\nA: No\n\nQ: If you follow these instructions, do you return to the starting point? Always face forward. Take 2 steps right. Take 9 steps left. Take 7 steps right.\nOptions:\n- Yes\n- No\nA: Yes\n\n", "object_counting": "Questions that involve enumerating objects and asking the model to count them.\n\nQ: I have a blackberry, a clarinet, a nectarine, a plum, a strawberry, a banana, a flute, an orange, and a violin. How many fruits do I have?\nA: 6\n\nQ: I have an orange, a raspberry, two peaches, a blackberry, an apple, a grape, a nectarine, and three plums. How many fruits do I have?\nA: 11\n\nQ: I have a lettuce head, a head of broccoli, an onion, a stalk of celery, two carrots, a garlic, and a yam. How many vegetables do I have?\nA: 8\n\n", - "penguins_in_a_table": "Answer questions about a table of penguins and their attributes.\n\nQ: Here is a table where the first line is a header and each subsequent line is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. We now add a penguin to the table:\nJames, 12, 90, 12\nHow many penguins are less than 8 years old?\nOptions:\n(A) 1\n(B) 2\n(C) 3\n(D) 4\n(E) 5\nA: (B)\n\nQ: Here is a table where the first line is a header and each subsequent line is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. Which is the youngest penguin?\nOptions:\n(A) Louis\n(B) Bernard\n(C) Vincent\n(D) Gwen\n(E) James\nA: (B)\n\nQ: Here is a table where the first line is a header and each subsequent line is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. What is the name of the second penguin sorted by alphabetic order?\nOptions:\n(A) Louis\n(B) Bernard\n(C) Vincent\n(D) Gwen\n(E) James\nA: (D)\n\n", - "reasoning_about_colored_objects": "Answer extremely simple questions about the colors of objects on a surface.\n\nQ: On the nightstand, there is a red pencil, a purple mug, a burgundy keychain, a fuchsia teddy bear, a black plate, and a blue stress ball. What color is the stress ball?\nOptions:\n(A) red\n(B) orange\n(C) yellow\n(D) green\n(E) blue\n(F) brown\n(G) magenta\n(H) fuchsia\n(I) mauve\n(J) teal\n(K) turquoise\n(L) burgundy\n(M) silver\n(N) gold\n(O) black\n(P) grey\n(Q) purple\n(R) pink\nA: (E)\n\nQ: On the table, you see a bunch of objects arranged in a row: a purple paperclip, a pink stress ball, a brown keychain, a green scrunchiephone charger, a mauve fidget spinner, and a burgundy pen. What is the color of the object directly to the right of the stress ball?\nOptions:\n(A) red\n(B) orange\n(C) yellow\n(D) green\n(E) blue\n(F) brown\n(G) magenta\n(H) fuchsia\n(I) mauve\n(J) teal\n(K) turquoise\n(L) burgundy\n(M) silver\n(N) gold\n(O) black\n(P) grey\n(Q) purple\n(R) pink\nA: (F)\n\nQ: On the nightstand, you see the following items arranged in a row: a teal plate, a burgundy keychain, a yellow scrunchiephone charger, an orange mug, a pink notebook, and a grey cup. How many non-orange items do you see to the left of the teal item?\nOptions:\n(A) zero\n(B) one\n(C) two\n(D) three\n(E) four\n(F) five\n(G) six\nA: (A)\n\n", - "ruin_names": "Select the humorous edit that 'ruins' the input movie or musical artist name.\n\nQ: Which of the following is a humorous edit of this artist or movie name: 'whitesnake'?\nOptions:\n(A) whitesnape\n(B) whitesnapke\n(C) whitesnuake\n(D) mwhitesnake\nA: (A)\n\nQ: Which of the following is a humorous edit of this artist or movie name: 'one of our dinosaurs is missing'?\nOptions:\n(A) ofne of our dinosaurs is missing\n(B) one af our dinosaurs is missing\n(C) one of our dinosaurs is pissing\n(D) one of our dinosaur is missing\nA: (C)\n\nQ: Which of the following is a humorous edit of this artist or movie name: 'counting crows'?\nOptions:\n(A) countingy crows\n(B) counting cows\n(C) courting crows\n(D) coutnting crows\nA: (B)\n\n", - "salient_translation_error_detection": "Detect the type of error in an English translation of a German source sentence.\n\nQ: The following translations from German to English contain a particular error. That error will be one of the following types: Named Entities: An entity (names, places, locations, etc.) is changed to a different entity. Numerical Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are changed. Negation or Antonyms: Introduce or remove a negation or change comparatives to their antonyms. Facts: Trivial factual errors not pertaining to the above classes are introduced in the translations. Dropped Content: A significant clause in the translation is removed. Please identify that error. Source: In der Liste der Baudenkmale in Lenzen (Elbe) sind alle Baudenkmale der brandenburgischen Stadt Lenzen (Elbe) und ihrer Ortsteile aufgelistet.\nTranslation: In the list of architectural monuments in Lenzen all architectural monuments of the Brandenburg city of Lenzen and its districts are listed.\nThe translation contains an error pertaining to\nOptions:\n(A) Modifiers or Adjectives\n(B) Numerical Values\n(C) Negation or Antonyms\n(D) Named Entities\n(E) Dropped Content\n(F) Facts\nA: (D)\n\nQ: The following translations from German to English contain a particular error. That error will be one of the following types: Named Entities: An entity (names, places, locations, etc.) is changed to a different entity. Numerical Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are changed. Negation or Antonyms: Introduce or remove a negation or change comparatives to their antonyms. Facts: Trivial factual errors not pertaining to the above classes are introduced in the translations. Dropped Content: A significant clause in the translation is removed. Please identify that error. Source: Auf dieser Seite sind die Baudenkm\u00e4ler der oberbayerischen Gro\u00dfen Kreisstadt Landsberg am Lech zusammengestellt.\nTranslation: On this page are compiled the architectural monuments of the town of Landsberg am Lech.\nThe translation contains an error pertaining to\nOptions:\n(A) Modifiers or Adjectives\n(B) Numerical Values\n(C) Negation or Antonyms\n(D) Named Entities\n(E) Dropped Content\n(F) Facts\nA: (E)\n\nQ: The following translations from German to English contain a particular error. That error will be one of the following types: Named Entities: An entity (names, places, locations, etc.) is changed to a different entity. Numerical Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are changed. Negation or Antonyms: Introduce or remove a negation or change comparatives to their antonyms. Facts: Trivial factual errors not pertaining to the above classes are introduced in the translations. Dropped Content: A significant clause in the translation is removed. Please identify that error. Source: \u0141eba ist eine Kleinstadt und ein Badeort im Powiat L\u0119borski der polnischen Woiwodschaft Pommern.\nTranslation: Eba is not a small town and seaside resort in the Powiat L\u00e9borski county of the Pomeranian Voivodeship of Poland.\nThe translation contains an error pertaining to\nOptions:\n(A) Modifiers or Adjectives\n(B) Numerical Values\n(C) Negation or Antonyms\n(D) Named Entities\n(E) Dropped Content\n(F) Facts\nA: (C)\n\n", - "snarks": "Determine which of two sentences is sarcastic.\n\nQ: Which statement is sarcastic?\nOptions:\n(A) Yes, because having interests and actively researching them is a huge waste\n(B) Yes, because having interests and actively researching them is a huge deal\nA: (A)\n\nQ: Which statement is sarcastic?\nOptions:\n(A) No one is going to disagree with you on this. Avoiding ad hominem attacks really help your case\n(B) No one is going to disagree with you on this. Ad hominem attacks really help your case\nA: (B)\n\nQ: Which statement is sarcastic?\nOptions:\n(A) Consistency in the league's punishments? What do you think this is supposed to be, politics?\n(B) Consistency in the league's punishments? What do you think this is supposed to be, moral?\nA: (A)\n\n", + "penguins_in_a_table": "Answer questions about a table of penguins and their attributes.\n\nQ: Here is a table where the first line is a header and each subsequent line is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. We now add a penguin to the table:\nJames, 12, 90, 12\nHow many penguins are less than 8 years old?\nOptions:\n(A) 1\n(B) 2\n(C) 3\n(D) 4\n(E) 5\nA: B\n\nQ: Here is a table where the first line is a header and each subsequent line is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. Which is the youngest penguin?\nOptions:\n(A) Louis\n(B) Bernard\n(C) Vincent\n(D) Gwen\n(E) James\nA: B\n\nQ: Here is a table where the first line is a header and each subsequent line is a penguin: name, age, height (cm), weight (kg) Louis, 7, 50, 11 Bernard, 5, 80, 13 Vincent, 9, 60, 11 Gwen, 8, 70, 15 For example: the age of Louis is 7, the weight of Gwen is 15 kg, the height of Bernard is 80 cm. What is the name of the second penguin sorted by alphabetic order?\nOptions:\n(A) Louis\n(B) Bernard\n(C) Vincent\n(D) Gwen\n(E) James\nA: D\n\n", + "reasoning_about_colored_objects": "Answer extremely simple questions about the colors of objects on a surface.\n\nQ: On the nightstand, there is a red pencil, a purple mug, a burgundy keychain, a fuchsia teddy bear, a black plate, and a blue stress ball. What color is the stress ball?\nOptions:\n(A) red\n(B) orange\n(C) yellow\n(D) green\n(E) blue\n(F) brown\n(G) magenta\n(H) fuchsia\n(I) mauve\n(J) teal\n(K) turquoise\n(L) burgundy\n(M) silver\n(N) gold\n(O) black\n(P) grey\n(Q) purple\n(R) pink\nA: E\n\nQ: On the table, you see a bunch of objects arranged in a row: a purple paperclip, a pink stress ball, a brown keychain, a green scrunchiephone charger, a mauve fidget spinner, and a burgundy pen. What is the color of the object directly to the right of the stress ball?\nOptions:\n(A) red\n(B) orange\n(C) yellow\n(D) green\n(E) blue\n(F) brown\n(G) magenta\n(H) fuchsia\n(I) mauve\n(J) teal\n(K) turquoise\n(L) burgundy\n(M) silver\n(N) gold\n(O) black\n(P) grey\n(Q) purple\n(R) pink\nA: F\n\nQ: On the nightstand, you see the following items arranged in a row: a teal plate, a burgundy keychain, a yellow scrunchiephone charger, an orange mug, a pink notebook, and a grey cup. How many non-orange items do you see to the left of the teal item?\nOptions:\n(A) zero\n(B) one\n(C) two\n(D) three\n(E) four\n(F) five\n(G) six\nA: A\n\n", + "ruin_names": "Select the humorous edit that 'ruins' the input movie or musical artist name.\n\nQ: Which of the following is a humorous edit of this artist or movie name: 'whitesnake'?\nOptions:\n(A) whitesnape\n(B) whitesnapke\n(C) whitesnuake\n(D) mwhitesnake\nA: A\n\nQ: Which of the following is a humorous edit of this artist or movie name: 'one of our dinosaurs is missing'?\nOptions:\n(A) ofne of our dinosaurs is missing\n(B) one af our dinosaurs is missing\n(C) one of our dinosaurs is pissing\n(D) one of our dinosaur is missing\nA: C\n\nQ: Which of the following is a humorous edit of this artist or movie name: 'counting crows'?\nOptions:\n(A) countingy crows\n(B) counting cows\n(C) courting crows\n(D) coutnting crows\nA: B\n\n", + "salient_translation_error_detection": "Detect the type of error in an English translation of a German source sentence.\n\nQ: The following translations from German to English contain a particular error. That error will be one of the following types: Named Entities: An entity (names, places, locations, etc.) is changed to a different entity. Numerical Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are changed. Negation or Antonyms: Introduce or remove a negation or change comparatives to their antonyms. Facts: Trivial factual errors not pertaining to the above classes are introduced in the translations. Dropped Content: A significant clause in the translation is removed. Please identify that error. Source: In der Liste der Baudenkmale in Lenzen (Elbe) sind alle Baudenkmale der brandenburgischen Stadt Lenzen (Elbe) und ihrer Ortsteile aufgelistet.\nTranslation: In the list of architectural monuments in Lenzen all architectural monuments of the Brandenburg city of Lenzen and its districts are listed.\nThe translation contains an error pertaining to\nOptions:\n(A) Modifiers or Adjectives\n(B) Numerical Values\n(C) Negation or Antonyms\n(D) Named Entities\n(E) Dropped Content\n(F) Facts\nA: D\n\nQ: The following translations from German to English contain a particular error. That error will be one of the following types: Named Entities: An entity (names, places, locations, etc.) is changed to a different entity. Numerical Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are changed. Negation or Antonyms: Introduce or remove a negation or change comparatives to their antonyms. Facts: Trivial factual errors not pertaining to the above classes are introduced in the translations. Dropped Content: A significant clause in the translation is removed. Please identify that error. Source: Auf dieser Seite sind die Baudenkm\u00e4ler der oberbayerischen Gro\u00dfen Kreisstadt Landsberg am Lech zusammengestellt.\nTranslation: On this page are compiled the architectural monuments of the town of Landsberg am Lech.\nThe translation contains an error pertaining to\nOptions:\n(A) Modifiers or Adjectives\n(B) Numerical Values\n(C) Negation or Antonyms\n(D) Named Entities\n(E) Dropped Content\n(F) Facts\nA: E\n\nQ: The following translations from German to English contain a particular error. That error will be one of the following types: Named Entities: An entity (names, places, locations, etc.) is changed to a different entity. Numerical Values: Numerical values (ordinals or cardinals), dates, and/or units are changed. Modifiers or Adjectives: The modifiers and adjectives pertaining to a noun are changed. Negation or Antonyms: Introduce or remove a negation or change comparatives to their antonyms. Facts: Trivial factual errors not pertaining to the above classes are introduced in the translations. Dropped Content: A significant clause in the translation is removed. Please identify that error. Source: \u0141eba ist eine Kleinstadt und ein Badeort im Powiat L\u0119borski der polnischen Woiwodschaft Pommern.\nTranslation: Eba is not a small town and seaside resort in the Powiat L\u00e9borski county of the Pomeranian Voivodeship of Poland.\nThe translation contains an error pertaining to\nOptions:\n(A) Modifiers or Adjectives\n(B) Numerical Values\n(C) Negation or Antonyms\n(D) Named Entities\n(E) Dropped Content\n(F) Facts\nA: C\n\n", + "snarks": "Determine which of two sentences is sarcastic.\n\nQ: Which statement is sarcastic?\nOptions:\n(A) Yes, because having interests and actively researching them is a huge waste\n(B) Yes, because having interests and actively researching them is a huge deal\nA: A\n\nQ: Which statement is sarcastic?\nOptions:\n(A) No one is going to disagree with you on this. Avoiding ad hominem attacks really help your case\n(B) No one is going to disagree with you on this. Ad hominem attacks really help your case\nA: B\n\nQ: Which statement is sarcastic?\nOptions:\n(A) Consistency in the league's punishments? What do you think this is supposed to be, politics?\n(B) Consistency in the league's punishments? What do you think this is supposed to be, moral?\nA: A\n\n", "sports_understanding": "Determine whether an artificially constructed sentence relating to sports is plausible or not.\n\nQ: Is the following sentence plausible? Bam Adebayo scored a reverse layup in the Western Conference Finals.\nA: yes\n\nQ: Is the following sentence plausible? Santi Cazorla scored a touchdown.\nA: no\n\nQ: Is the following sentence plausible? DeMar DeRozan was called for the goal tend.\nA: yes\n\n", - "temporal_sequences": "Task description: Answer questions about which times certain events could have occurred.\n\nQ: Today, Emily went to the museum. Between what times could they have gone?\nWe know that:\nEmily woke up at 1pm.\nElizabeth saw Emily reading at the library from 2pm to 4pm.\nJessica saw Emily watching a movie at the theater from 4pm to 5pm.\nLeslie saw Emily waiting at the airport from 5pm to 6pm.\nWilliam saw Emily buying clothes at the mall from 6pm to 7pm.\nThe museum was closed after 7pm.\nBetween what times could Emily have gone to the museum?\nOptions:\n(A) 1pm to 2pm\n(B) 6pm to 7pm\n(C) 5pm to 6pm\n(D) 2pm to 4pm\nA: (A)\n\nQ: Today, Elizabeth went to the amusement park. Between what times could they have gone?\nWe know that:\nElizabeth woke up at 7am.\nDavid saw Elizabeth fixing their computer at the electronic store from 1pm to 2pm.\nSarah saw Elizabeth playing tennis at the tennis court from 2pm to 3pm.\nSusan saw Elizabeth walking towards the Statue of Liberty from 3pm to 6pm.\nAndrew saw Elizabeth taking photos near the Eiffel Tower from 6pm to 9pm.\nEmily saw Elizabeth getting a coffee at the cafe from 9pm to 10pm.\nThe amusement park was closed after 10pm.\nBetween what times could Elizabeth have gone to the amusement park?\nOptions:\n(A) 7am to 1pm\n(B) 9pm to 10pm\n(C) 1pm to 2pm\n(D) 3pm to 6pm\nA: (A)\n\nQ: Today, Tiffany went to the beach. Between what times could they have gone?\nWe know that:\nTiffany woke up at 5am.\nBetty saw Tiffany getting a coffee at the cafe from 5am to 6am.\nJessica saw Tiffany working at the office from 6am to 9am.\nJohn saw Tiffany stretching at a yoga studio from 9am to 12pm.\nSean saw Tiffany sitting on a rooftop from 12pm to 2pm.\nSarah saw Tiffany playing tennis at the tennis court from 2pm to 3pm.\nThe beach was closed after 4pm.\nBetween what times could Tiffany have gone to the beach?\nOptions:\n(A) 9am to 12pm\n(B) 12pm to 2pm\n(C) 5am to 6am\n(D) 3pm to 4pm\nA: (D)\n\n", - "tracking_shuffled_objects": "A task requiring determining the final positions of a set of objects given their initial positions and a description of a sequence of swaps.\n\nQ: Alice, Bob, and Claire are playing a game. At the start of the game, they are each holding a ball: Alice has a yellow ball, Bob has a blue ball, and Claire has a pink ball.\nAs the game progresses, pairs of players trade balls. First, Claire and Alice swap balls. Then, Alice and Bob swap balls. Finally, Claire and Bob swap balls. At the end of the game, Bob has the\nOptions:\n(A) yellow ball\n(B) blue ball\n(C) pink ball\nA: (A)\n\nQ: Alice, Bob, and Claire are playing a game. At the start of the game, they are each holding a ball: Alice has a white ball, Bob has a purple ball, and Claire has a pink ball.\nAs the game progresses, pairs of players trade balls. First, Bob and Alice swap balls. Then, Bob and Claire swap balls. Finally, Bob and Alice swap balls. At the end of the game, Alice has the\nOptions:\n(A) white ball\n(B) purple ball\n(C) pink ball\nA: (C)\n\nQ: Alice, Bob, and Claire are dancers at a square dance. At the start of a song, they each have a partner: Alice is dancing with Lola, Bob is dancing with Rodrigo, and Claire is dancing with Patrick.\nThroughout the song, the dancers often trade partners. First, Alice and Bob switch partners. Then, Claire and Bob switch partners. Finally, Bob and Alice switch partners. At the end of thehg sy dance, Alice is dancing with\nOptions:\n(A) Lola\n(B) Rodrigo\n(C) Patrick\nA: (C)\n\n", + "temporal_sequences": "Task description: Answer questions about which times certain events could have occurred.\n\nQ: Today, Emily went to the museum. Between what times could they have gone?\nWe know that:\nEmily woke up at 1pm.\nElizabeth saw Emily reading at the library from 2pm to 4pm.\nJessica saw Emily watching a movie at the theater from 4pm to 5pm.\nLeslie saw Emily waiting at the airport from 5pm to 6pm.\nWilliam saw Emily buying clothes at the mall from 6pm to 7pm.\nThe museum was closed after 7pm.\nBetween what times could Emily have gone to the museum?\nOptions:\n(A) 1pm to 2pm\n(B) 6pm to 7pm\n(C) 5pm to 6pm\n(D) 2pm to 4pm\nA: A\n\nQ: Today, Elizabeth went to the amusement park. Between what times could they have gone?\nWe know that:\nElizabeth woke up at 7am.\nDavid saw Elizabeth fixing their computer at the electronic store from 1pm to 2pm.\nSarah saw Elizabeth playing tennis at the tennis court from 2pm to 3pm.\nSusan saw Elizabeth walking towards the Statue of Liberty from 3pm to 6pm.\nAndrew saw Elizabeth taking photos near the Eiffel Tower from 6pm to 9pm.\nEmily saw Elizabeth getting a coffee at the cafe from 9pm to 10pm.\nThe amusement park was closed after 10pm.\nBetween what times could Elizabeth have gone to the amusement park?\nOptions:\n(A) 7am to 1pm\n(B) 9pm to 10pm\n(C) 1pm to 2pm\n(D) 3pm to 6pm\nA: A\n\nQ: Today, Tiffany went to the beach. Between what times could they have gone?\nWe know that:\nTiffany woke up at 5am.\nBetty saw Tiffany getting a coffee at the cafe from 5am to 6am.\nJessica saw Tiffany working at the office from 6am to 9am.\nJohn saw Tiffany stretching at a yoga studio from 9am to 12pm.\nSean saw Tiffany sitting on a rooftop from 12pm to 2pm.\nSarah saw Tiffany playing tennis at the tennis court from 2pm to 3pm.\nThe beach was closed after 4pm.\nBetween what times could Tiffany have gone to the beach?\nOptions:\n(A) 9am to 12pm\n(B) 12pm to 2pm\n(C) 5am to 6am\n(D) 3pm to 4pm\nA: D\n\n", + "tracking_shuffled_objects": "A task requiring determining the final positions of a set of objects given their initial positions and a description of a sequence of swaps.\n\nQ: Alice, Bob, and Claire are playing a game. At the start of the game, they are each holding a ball: Alice has a yellow ball, Bob has a blue ball, and Claire has a pink ball.\nAs the game progresses, pairs of players trade balls. First, Claire and Alice swap balls. Then, Alice and Bob swap balls. Finally, Claire and Bob swap balls. At the end of the game, Bob has the\nOptions:\n(A) yellow ball\n(B) blue ball\n(C) pink ball\nA: A\n\nQ: Alice, Bob, and Claire are playing a game. At the start of the game, they are each holding a ball: Alice has a white ball, Bob has a purple ball, and Claire has a pink ball.\nAs the game progresses, pairs of players trade balls. First, Bob and Alice swap balls. Then, Bob and Claire swap balls. Finally, Bob and Alice swap balls. At the end of the game, Alice has the\nOptions:\n(A) white ball\n(B) purple ball\n(C) pink ball\nA: C\n\nQ: Alice, Bob, and Claire are dancers at a square dance. At the start of a song, they each have a partner: Alice is dancing with Lola, Bob is dancing with Rodrigo, and Claire is dancing with Patrick.\nThroughout the song, the dancers often trade partners. First, Alice and Bob switch partners. Then, Claire and Bob switch partners. Finally, Bob and Alice switch partners. At the end of thehg sy dance, Alice is dancing with\nOptions:\n(A) Lola\n(B) Rodrigo\n(C) Patrick\nA: C\n\n", "web_of_lies": "Evaluate a random boolean function expressed as a word problem.\n\nQ: Question: Fidel tells the truth. Jerry says Fidel tells the truth. Vina says Jerry tells the truth. Millicent says Vina lies. Raymond says Millicent lies. Does Raymond tell the truth?\nA: Yes\n\nQ: Question: Kristian lies. Millie says Kristian lies. Maybelle says Millie tells the truth. Fidel says Maybelle lies. Leda says Fidel lies. Does Leda tell the truth?\nA: Yes\n\nQ: Question: Kristian tells the truth. Michaela says Kristian lies. Raymond says Michaela tells the truth. Osvaldo says Raymond tells the truth. Jamey says Osvaldo tells the truth. Does Jamey tell the truth?\nA: No\n\n", "word_sorting": "Sort a list of words.\n\nQ: Sort the following words alphabetically: List: oven costume counterpart\nA: costume counterpart oven\n\nQ: Sort the following words alphabetically: List: hypochlorite ponderosa phone credulity\nA: credulity hypochlorite phone ponderosa\n\nQ: Sort the following words alphabetically: List: newt arson parthia seismography mugho aspect census\nA: arson aspect census mugho newt parthia seismography\n\n" } \ No newline at end of file diff --git a/modellink/tasks/evaluation/eval_impl/gsm8k_eval.py b/modellink/tasks/evaluation/eval_impl/gsm8k_eval.py index 1a9d825c..ebc46d89 100644 --- a/modellink/tasks/evaluation/eval_impl/gsm8k_eval.py +++ b/modellink/tasks/evaluation/eval_impl/gsm8k_eval.py @@ -20,6 +20,7 @@ import json import pandas as pd import tqdm +from torch import distributed as dist from .template import GSM8K_TEMPLATE_DIR from ..eval_api.dataset_eval import DatasetEval from ..eval_api.chat import Chat @@ -36,6 +37,9 @@ class Gsm8kEval(DatasetEval): self.instruction_template = instruction_template self.output_template = output_template self.batch_size = batch_size + self.rank = dist.get_rank() + self.file_pbar = None + self.task_pbar = None def eval(self, chat: Chat) -> (dict, pd.DataFrame): final_result = {} @@ -43,9 +47,14 @@ class Gsm8kEval(DatasetEval): total_acc_n = 0 total_n = 0 rank = None + with open(GSM8K_TEMPLATE_DIR, encoding='utf-8') as f: gsm8k_few_shot_template = json.load(f) - for file in tqdm.tqdm(os.listdir(self.test_dir)): + + if self.rank == 0: + self.file_pbar = tqdm.tqdm(total=len(os.listdir(self.test_dir)), desc="total") + + for file in os.listdir(self.test_dir): file_path = os.path.join(self.test_dir, file) with open(file_path, encoding='utf-8') as f: gsm8k_list = [] @@ -55,6 +64,10 @@ class Gsm8kEval(DatasetEval): acc_n = 0 instructions = [] answers = [] + + if self.rank == 0: + self.task_pbar = tqdm.tqdm(total=len(gsm8k_list), desc=file, leave=False) + for index, item in enumerate(gsm8k_list): instruction = self.instruction_template.format(fewshot_template=gsm8k_few_shot_template['few_shot'], question=item['question']) @@ -88,11 +101,21 @@ class Gsm8kEval(DatasetEval): instructions = [] answers = [] + if self.task_pbar is not None: + self.task_pbar.update() + if rank == 0: total_n += len(gsm8k_list) total_acc_n += acc_n final_result['Gsm8k_dataset'] = subject_result score_datas.append(['Gsm8k_dataset', len(gsm8k_list), acc_n / len(gsm8k_list)]) + + if self.task_pbar is not None: + self.task_pbar.close() + + if self.file_pbar is not None: + self.file_pbar.update() + if rank == 0: logger.info(f"gsm8k acc = {total_acc_n}/{total_n}={check_divisible_by_zero(total_acc_n, total_n)}") score_datas.append(["total", total_n, total_acc_n / total_n]) diff --git a/modellink/tasks/evaluation/eval_impl/human_eval.py b/modellink/tasks/evaluation/eval_impl/human_eval.py index 0a1ec80a..6fd34159 100644 --- a/modellink/tasks/evaluation/eval_impl/human_eval.py +++ b/modellink/tasks/evaluation/eval_impl/human_eval.py @@ -21,7 +21,9 @@ import sys import subprocess from typing import Iterable, Dict import pandas as pd +import tqdm +from torch import distributed as dist from .template import CODE_TEST_LOG_DIR from ..eval_api.dataset_eval import DatasetEval from ..eval_api.chat import Chat @@ -85,6 +87,9 @@ class HumanEval(DatasetEval): else: self.instruction_template = "The definition and function description of the python function are as follows. " \ "Please complete the implementation of the python function.\n{prompt}" + self.rank = dist.get_rank() + self.file_pbar = None + self.task_pbar = None def read_problems(self) -> Dict[str, Dict]: return {task["task_id"]: task for task in self.stream_jsonl(self.test_dir)} @@ -93,6 +98,10 @@ class HumanEval(DatasetEval): """ Parses each jsonl line and yields it as a dictionary """ + + if self.rank == 0: + self.file_pbar = tqdm.tqdm(total=len(os.listdir(self.test_dir)), desc="total") + for file in os.listdir(test_dir): test_code_path = os.path.join(self.test_dir, file) with open(test_code_path, 'r') as fp: @@ -100,11 +109,18 @@ class HumanEval(DatasetEval): if any(not x.isspace() for x in line): yield json.loads(line) + if self.file_pbar is not None: + self.file_pbar.update() + def eval(self, chat: Chat) -> (dict, pd.DataFrame): problems = self.read_problems() success_n = 0 rank = None answer_result = {} + + if self.rank == 0: + self.task_pbar = tqdm.tqdm(total=len(problems), leave=False) + for idx, (task_id, task) in enumerate(problems.items()): instruction = self.instruction_template.format(prompt=task['prompt']) chat_result, rank = chat.beam_search_chat(instruction=instruction, history=[]) @@ -132,6 +148,13 @@ class HumanEval(DatasetEval): logger.info("%s failed. %s", task_id, e) finally: pass + + if self.task_pbar is not None: + self.task_pbar.update() + + if self.task_pbar is not None: + self.task_pbar.close() + if rank == 0: logger.info("acc = %s", {check_divisible_by_zero(success_n, len(problems))}) return answer_result, None diff --git a/modellink/tasks/evaluation/eval_impl/mmlu_eval.py b/modellink/tasks/evaluation/eval_impl/mmlu_eval.py index aa2d85ab..0fb3976b 100644 --- a/modellink/tasks/evaluation/eval_impl/mmlu_eval.py +++ b/modellink/tasks/evaluation/eval_impl/mmlu_eval.py @@ -20,6 +20,7 @@ import json import pandas as pd import tqdm +from torch import distributed as dist from .template import MMLU_TEMPLATE_DIR from ..eval_api.dataset_eval import DatasetEval from ..eval_api.chat import Chat @@ -38,6 +39,9 @@ class MmluEval(DatasetEval): self.instruction_template = instruction_template self.output_template = [output_template1, output_template2] self.batch_size = batch_size + self.rank = dist.get_rank() + self.file_pbar = None + self.task_pbar = None def eval(self, chat: Chat) -> (dict, pd.DataFrame): answer_result = {} @@ -47,15 +51,29 @@ class MmluEval(DatasetEval): rank = None with open(MMLU_TEMPLATE_DIR, encoding='utf-8') as f: mmlu_few_shot_template = json.load(f) - for file in tqdm.tqdm(os.listdir(self.test_dir)): + + if self.rank == 0: + self.file_pbar = tqdm.tqdm(total=len(os.listdir(self.test_dir)), desc="total") + + for file in os.listdir(self.test_dir): file_path = os.path.join(self.test_dir, file) data_df = pd.read_csv(file_path, names=['question', 'A', 'B', 'C', 'D', 'answer']) - subject_name = file[0: -9] # 文件命名规则是 {subject}_test.csv + subject_name = re.sub(r'(?:_test|_val|_dev)?\.\w+$', "", file) # 文件命名规则类似 {subject}_test.csv subject = subject_name.replace("_", " ") subject_result = {} acc_n = 0 instructions = [] corrects = [] + + if subject_name not in mmlu_few_shot_template: + logging.error(f"missing '{subject_name}' instruction_template in {MMLU_TEMPLATE_DIR}") + if self.file_pbar is not None: + self.file_pbar.update() + continue + + if self.rank == 0: + self.task_pbar = tqdm.tqdm(total=len(data_df), desc=file, leave=False) + for idx, row in data_df.iterrows(): test_question = f"{row['question']}\nA. {row['A']}\nB. {row['B']}\nC. {row['C']}\nD. {row['D']}" instruction = self.instruction_template.format(few_shot_examples=mmlu_few_shot_template[subject_name], @@ -97,11 +115,21 @@ class MmluEval(DatasetEval): instructions = [] corrects = [] + if self.task_pbar is not None: + self.task_pbar.update() + if rank == 0: total_n += len(data_df) total_acc_n += acc_n answer_result[subject_name] = subject_result score_datas.append([subject_name, len(data_df), acc_n / len(data_df)]) + + if self.task_pbar is not None: + self.task_pbar.close() + + if self.file_pbar is not None: + self.file_pbar.update() + if rank == 0: logger.info(f"mmlu acc = {total_acc_n}/{total_n}={check_divisible_by_zero(total_acc_n, total_n)}") score_datas.append(["total", total_n, total_acc_n / total_n]) diff --git a/modellink/tasks/evaluation/eval_impl/template.py b/modellink/tasks/evaluation/eval_impl/template.py index 488fcb01..6ea1b076 100644 --- a/modellink/tasks/evaluation/eval_impl/template.py +++ b/modellink/tasks/evaluation/eval_impl/template.py @@ -17,5 +17,5 @@ GSM8K_TEMPLATE_DIR = 'modellink/tasks/evaluation/eval_impl/fewshot_template/gsm8 MMLU_TEMPLATE_DIR = 'modellink/tasks/evaluation/eval_impl/fewshot_template/mmlu_5shot_template.json' CEVAL_TEMPLATE_DIR = 'modellink/tasks/evaluation/eval_impl/fewshot_template/ceval_5shot_template.json' AGIEVAL_TEMPLATE_DIR = 'modellink/tasks/evaluation/eval_impl/fewshot_template/AGI_fewshot.json' -BBH_TEMPLATE_DIR = 'modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_templatejson' +BBH_TEMPLATE_DIR = 'modellink/tasks/evaluation/eval_impl/fewshot_template/bbh_template.json' CODE_TEST_LOG_DIR = 'modellink/tasks/evaluation/codecheck_log'