From 1bcace31f1e67625627066d8ed6ae1e581ff96ed Mon Sep 17 00:00:00 2001 From: Shayne Longpre Date: Fri, 10 Mar 2023 17:16:52 -0500 Subject: [PATCH] fixes to input inversion tagging --- flan/v2/few_shot.py | 1 - flan/v2/task_configs.py | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flan/v2/few_shot.py b/flan/v2/few_shot.py index 9b8fdcd..c7dc47f 100644 --- a/flan/v2/few_shot.py +++ b/flan/v2/few_shot.py @@ -106,7 +106,6 @@ def add_delimiter_after_x(ex): eval_preprocessors=single_ex_preprocessors, train_split='train', train_feature_keys=('inputs', 'targets', '_template_idx'), - # '_template_type', '_task_source', '_task_name'), ) # These are the preprocessors we run *after* we have formed few-shot examples. # Note that we re-introduce the tokenization steps here. diff --git a/flan/v2/task_configs.py b/flan/v2/task_configs.py index 857c276..335fb7b 100644 --- a/flan/v2/task_configs.py +++ b/flan/v2/task_configs.py @@ -16,6 +16,7 @@ import functools import os +import copy from flan.v2 import constants from flan.v2 import constants_niv2 @@ -97,7 +98,7 @@ def _process_lambada(example): ) # '_input_inversion' will get mapped to an inverted template cot_ii_tname = f"{cot_type}_input_inversion_{dataset_name}" - COT_II_TASK_CONFIGS[cot_ii_tname] = COT_TASK_CONFIGS[f"{cot_type}_{dataset_name}"] + COT_II_TASK_CONFIGS[cot_ii_tname] = copy.deepcopy(COT_TASK_CONFIGS[f"{cot_type}_{dataset_name}"]) cot_ii_prep_fn = functools.partial(prep.add_source_info, task_name=f"{cot_type}_{dataset_name}_ii", task_source="CoT") COT_II_TASK_CONFIGS[cot_ii_tname].preprocessors = COT_II_TASK_CONFIGS[cot_ii_tname].preprocessors[:-1] + [cot_ii_prep_fn] @@ -133,10 +134,10 @@ def _process_lambada(example): ) # '_input_inversion' will get mapped to an inverted template wd_ii_tname = "wiki_dialog_input_inversion" -DIALOG_II_TASK_CONFIGS[wd_ii_tname] = DIALOG_TASK_CONFIGS["wiki_dialog"] -wikidialog_prep_fn = functools.partial(prep.add_source_info, +DIALOG_II_TASK_CONFIGS[wd_ii_tname] = copy.deepcopy(DIALOG_TASK_CONFIGS["wiki_dialog"]) +wikidialog_ii_prep_fn = functools.partial(prep.add_source_info, task_name=f"wiki_dialog_ii", task_source="Dialog") -DIALOG_II_TASK_CONFIGS[wd_ii_tname].preprocessors = DIALOG_II_TASK_CONFIGS[wd_ii_tname].preprocessors[:-1] + [wikidialog_prep_fn] +DIALOG_II_TASK_CONFIGS[wd_ii_tname].preprocessors = DIALOG_II_TASK_CONFIGS[wd_ii_tname].preprocessors[:-1] + [wikidialog_ii_prep_fn] # ================================== QReCC ==================================== @@ -150,10 +151,10 @@ def _process_lambada(example): ) # '_input_inversion' will get mapped to an inverted template qrecc_ii_tname = "qrecc_input_inversion" -DIALOG_II_TASK_CONFIGS[qrecc_ii_tname] = DIALOG_TASK_CONFIGS["qrecc"] -wikidialog_prep_fn = functools.partial(prep.add_source_info, +DIALOG_II_TASK_CONFIGS[qrecc_ii_tname] = copy.deepcopy(DIALOG_TASK_CONFIGS["qrecc"]) +qrecc_ii_prep_fn = functools.partial(prep.add_source_info, task_name=f"qrecc_ii", task_source="Dialog") -DIALOG_II_TASK_CONFIGS[qrecc_ii_tname].preprocessors = DIALOG_II_TASK_CONFIGS[qrecc_ii_tname].preprocessors[:-1] + [qrecc_prep_fn] +DIALOG_II_TASK_CONFIGS[qrecc_ii_tname].preprocessors = DIALOG_II_TASK_CONFIGS[qrecc_ii_tname].preprocessors[:-1] + [qrecc_ii_prep_fn] # ========================= T0 (P3) Training Sets =========================== for task_name in constants_t0.T0_TRAIN_TASK_SPLITS: