__init__.py 16.2 KB
Newer Older
cjlovering's avatar
cjlovering committed
1
from promptsource.templates import DatasetTemplates
&'s avatar
& committed
2
from pprint import pprint
3
from typing import List, Union
&'s avatar
& committed
4

&'s avatar
& committed
5
import sacrebleu
6
import lm_eval.base
&'s avatar
& committed
7

Jan-Christoph Kalo's avatar
Jan-Christoph Kalo committed
8

Jason Phang's avatar
Jason Phang committed
9
10
from . import superglue
from . import glue
Leo Gao's avatar
Leo Gao committed
11
from . import arc
thefazzer's avatar
thefazzer committed
12
from . import coqa
Leo Gao's avatar
Leo Gao committed
13
from . import race
Leo Gao's avatar
Leo Gao committed
14
from . import webqs
Leo Gao's avatar
Leo Gao committed
15
from . import anli
16
from . import wsc273
Charles Foster's avatar
Charles Foster committed
17
from . import winogrande
Charles Foster's avatar
Charles Foster committed
18
from . import quac
Charles Foster's avatar
Charles Foster committed
19
from . import hellaswag
Charles Foster's avatar
Charles Foster committed
20
from . import openbookqa
Charles Foster's avatar
Charles Foster committed
21
from . import squad
22
from . import naturalqs
23
from . import sat
24
from . import arithmetic
Leo Gao's avatar
Leo Gao committed
25
from . import lambada
Jon Tow's avatar
Jon Tow committed
26
from . import race
Leo Gao's avatar
Leo Gao committed
27
from . import piqa
Jonathan Tow's avatar
Jonathan Tow committed
28
from . import prost
Jonathan Tow's avatar
Jonathan Tow committed
29
from . import mc_taco
30
from . import triviaqa
jeffhsu3's avatar
jeffhsu3 committed
31
from . import pubmedqa
32
from . import sciq
33
from . import webqs
34
from . import qasper
35
from . import qa4mre
&'s avatar
& committed
36
from . import translation
37
38
from . import headqa
from . import mathqa
Leo Gao's avatar
Leo Gao committed
39
from . import hendrycks_ethics
Jon Tow's avatar
Jon Tow committed
40
from . import drop
41
from . import unscramble
42
from . import logiqa
Andy Zou's avatar
Andy Zou committed
43
from . import hendrycks_test
Leo Gao's avatar
Leo Gao committed
44
from . import hendrycks_math
45
from . import cbt
46
from . import lambada_cloze
Jason Phang's avatar
Jason Phang committed
47
from . import pile
Leo Gao's avatar
Leo Gao committed
48
from . import wikitext
sdtblck's avatar
sdtblck committed
49
from . import lambada_multilingual
Jonathan Tow's avatar
Jonathan Tow committed
50
from . import mutual
51
from . import truthfulqa
Igor Ostrovsky's avatar
Igor Ostrovsky committed
52
from . import blimp
rokosbasilisk's avatar
rokosbasilisk committed
53
from . import asdiv
Jonathan Tow's avatar
Jonathan Tow committed
54
from . import gsm8k
Jonathan Tow's avatar
Jonathan Tow committed
55
from . import storycloze
56
from . import hans
jordiclive's avatar
webnlg  
jordiclive committed
57
from . import gem_webnlg
KhalidAlt's avatar
KhalidAlt committed
58
from . import lama
cjlovering's avatar
cjlovering committed
59
# from . import e2e_nlg_cleaned
ken's avatar
ken committed
60
from . import gem_xsum
Shashi456's avatar
Shashi456 committed
61
from . import gem_mlsum
tomlimi's avatar
tomlimi committed
62
from . import wino_bias
63
from . import e2e_nlg_cleaned
jordiclive's avatar
jordiclive committed
64
from . import gem_asset_turk
KhalidAlt's avatar
KhalidAlt committed
65
from . import lama
Jason Phang's avatar
gpt3  
Jason Phang committed
66

&'s avatar
& committed
67
68
69
70
71
72
########################################
# Translation tasks
########################################

# 6 total
gpt3_translation_benchmarks = {
cjlovering's avatar
cjlovering committed
73
74
    "wmt14": ["en-fr", "fr-en"],  # French
    "wmt16": ["en-ro", "ro-en", "de-en", "en-de"],  # German, Romanian
&'s avatar
& committed
75
76
77
78
79
80
81
}


# 28 total
selected_translation_benchmarks = {
    **gpt3_translation_benchmarks,
    "wmt20": sacrebleu.get_langpairs_for_testset("wmt20"),
cjlovering's avatar
cjlovering committed
82
    "iwslt17": ["en-ar", "ar-en"],  # Arabic
&'s avatar
& committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
}

# 319 total
all_translation_benchmarks = {
    ts: sacrebleu.get_langpairs_for_testset(ts)
    for ts in sacrebleu.get_available_testsets()
}


########################################
# All tasks
########################################


Jason Phang's avatar
Jason Phang committed
97
TASK_REGISTRY = {
Jason Phang's avatar
multirc  
Jason Phang committed
98
    # GLUE
Jason Phang's avatar
Jason Phang committed
99
100
    "cola": glue.CoLA,
    "mnli": glue.MNLI,
Jason Phang's avatar
Jason Phang committed
101
    "mnli_mismatched": glue.MNLIMismatched,
Jason Phang's avatar
Jason Phang committed
102
103
104
105
    "mrpc": glue.MRPC,
    "rte": glue.RTE,
    "qnli": glue.QNLI,
    "qqp": glue.QQP,
cjlovering's avatar
cjlovering committed
106
    # "stsb": glue.STSB, # not implemented yet
Jason Phang's avatar
Jason Phang committed
107
108
    "sst": glue.SST,
    "wnli": glue.WNLI,
Jason Phang's avatar
multirc  
Jason Phang committed
109
    # SuperGLUE
Jason Phang's avatar
Jason Phang committed
110
    "boolq": superglue.BoolQ,
thefazzer's avatar
thefazzer committed
111
    "cb": superglue.CommitmentBank,
Jason Phang's avatar
Jason Phang committed
112
    "copa": superglue.Copa,
Jason Phang's avatar
multirc  
Jason Phang committed
113
    "multirc": superglue.MultiRC,
Jason Phang's avatar
Jason Phang committed
114
    "record": superglue.ReCoRD,
Jason Phang's avatar
Jason Phang committed
115
    "wic": superglue.WordsInContext,
Jason Phang's avatar
wsc  
Jason Phang committed
116
    "wsc": superglue.SGWinogradSchemaChallenge,
Jason Phang's avatar
multirc  
Jason Phang committed
117
    # Order by benchmark/genre?
thefazzer's avatar
thefazzer committed
118
    "coqa": coqa.CoQA,
Jon Tow's avatar
Jon Tow committed
119
    "drop": drop.DROP,
Leo Gao's avatar
Leo Gao committed
120
    "lambada": lambada.LAMBADA,
121
    "lambada_cloze": lambada_cloze.LAMBADA_cloze,
jordiclive's avatar
jordiclive committed
122
    **gem_webnlg.construct_tasks(),
123
    # multilingual lambada
jordiclive's avatar
jordiclive committed
124
    **gem_asset_turk.construct_tasks(),
sdtblck's avatar
sdtblck committed
125
    **lambada_multilingual.construct_tasks(),
Leo Gao's avatar
Leo Gao committed
126
    "wikitext": wikitext.WikiText,
Leo Gao's avatar
Leo Gao committed
127
128
    # "cbt-cn": cbt.CBTCN, # disabled pending context length fix
    # "cbt-ne": cbt.CBTNE, # disabled pending context length fix
Leo Gao's avatar
Leo Gao committed
129
    "piqa": piqa.PiQA,
Jonathan Tow's avatar
Jonathan Tow committed
130
    "prost": prost.PROST,
Jonathan Tow's avatar
Jonathan Tow committed
131
    "mc_taco": mc_taco.MCTACO,
132
    # Science related
cjlovering's avatar
cjlovering committed
133
134
    "pubmedqa": pubmedqa.Pubmed_QA,
    "sciq": sciq.SciQ,
135
    "e2e_nlg_cleaned": e2e_nlg_cleaned.E2E_NLG_Cleaned,
136
    "qasper": qasper.QASPER,
cjlovering's avatar
cjlovering committed
137
138
139
    "qa4mre_2011": qa4mre.QA4MRE_2011,
    "qa4mre_2012": qa4mre.QA4MRE_2012,
    "qa4mre_2013": qa4mre.QA4MRE_2013,
Leo Gao's avatar
Leo Gao committed
140
    "triviaqa": triviaqa.TriviaQA,
Jonathan Tow's avatar
Jonathan Tow committed
141
142
    "arc_easy": arc.ARCEasy,
    "arc_challenge": arc.ARCChallenge,
143
    # "quac": quac.QuAC, # not implemented yet
KhalidAlt's avatar
KhalidAlt committed
144
145
146
147
    "lama_trex": lama.Trex,
    "lama_squad": lama.Squad,
    "lama_google_re": lama.google_re,
    "lama_concptnet": lama.Conceptnet,
148
    "logiqa": logiqa.LogiQA,
Leo Gao's avatar
Leo Gao committed
149
    "hellaswag": hellaswag.HellaSwag,
Jon Tow's avatar
Jon Tow committed
150
    "openbookqa": openbookqa.OpenBookQA,
Leo Gao's avatar
Leo Gao committed
151
    "squad2": squad.SQuAD2,
Jon Tow's avatar
Jon Tow committed
152
    "race": race.RACE,
153
    # "naturalqs": naturalqs.NaturalQs, # not implemented yet
cjlovering's avatar
cjlovering committed
154
    "headqa": headqa.HeadQAEsDeprecated,  # for backwards compat - headqa used to default to es
155
156
    "headqa_es": headqa.HeadQAEs,
    "headqa_en": headqa.HeadQAEn,
157
    "mathqa": mathqa.MathQA,
158
    "webqs": webqs.WebQs,
159
    "wsc273": wsc273.WinogradSchemaChallenge273,
160
    "winogrande": winogrande.Winogrande,
Jonathan Tow's avatar
Jonathan Tow committed
161
162
163
    "anli_r1": anli.ANLIRound1,
    "anli_r2": anli.ANLIRound2,
    "anli_r3": anli.ANLIRound3,
164
    "hans": hans.HANS,
Leo Gao's avatar
Leo Gao committed
165
166
167
168
169
170
    "ethics_cm": hendrycks_ethics.EthicsCM,
    "ethics_deontology": hendrycks_ethics.EthicsDeontology,
    "ethics_justice": hendrycks_ethics.EthicsJustice,
    "ethics_utilitarianism_original": hendrycks_ethics.EthicsUtilitarianismOriginal,
    "ethics_utilitarianism": hendrycks_ethics.EthicsUtilitarianism,
    "ethics_virtue": hendrycks_ethics.EthicsVirtue,
KhalidAlt's avatar
KhalidAlt committed
171
172
    #"tydiqa_primary" : TyDiQA.Primary, not implemented yet
    #"tydiqa_secondary" : TyDiQA.Secondary, not implemented yet
cjlovering's avatar
cjlovering committed
173
174
    "truthfulqa_mc": truthfulqa.TruthfulQAMultipleChoice,
    "truthfulqa_gen": truthfulqa.TruthfulQAGeneration,
Jonathan Tow's avatar
Jonathan Tow committed
175
176
177
    # dialogue
    "mutual": mutual.MuTual,
    "mutual_plus": mutual.MuTualPlus,
Eric Tang's avatar
Eric Tang committed
178
    # math
Leo Gao's avatar
Leo Gao committed
179
180
181
182
183
184
185
    "math_algebra": hendrycks_math.MathAlgebra,
    "math_counting_and_prob": hendrycks_math.MathCountingAndProbability,
    "math_geometry": hendrycks_math.MathGeometry,
    "math_intermediate_algebra": hendrycks_math.MathIntermediateAlgebra,
    "math_num_theory": hendrycks_math.MathNumberTheory,
    "math_prealgebra": hendrycks_math.MathPrealgebra,
    "math_precalc": hendrycks_math.MathPrecalculus,
rokosbasilisk's avatar
rokosbasilisk committed
186
    "math_asdiv": asdiv.Asdiv,
Jonathan Tow's avatar
Jonathan Tow committed
187
    "gsm8k": gsm8k.GradeSchoolMath8K,
188
189
190
191
192
193
194
195
196
197
198
    # arithmetic
    "arithmetic_2da": arithmetic.Arithmetic2DPlus,
    "arithmetic_2ds": arithmetic.Arithmetic2DMinus,
    "arithmetic_3da": arithmetic.Arithmetic3DPlus,
    "arithmetic_3ds": arithmetic.Arithmetic3DMinus,
    "arithmetic_4da": arithmetic.Arithmetic4DPlus,
    "arithmetic_4ds": arithmetic.Arithmetic4DMinus,
    "arithmetic_5da": arithmetic.Arithmetic5DPlus,
    "arithmetic_5ds": arithmetic.Arithmetic5DMinus,
    "arithmetic_2dm": arithmetic.Arithmetic2DMultiplication,
    "arithmetic_1dc": arithmetic.Arithmetic1DComposite,
&'s avatar
& committed
199
200
    # TODO Perhaps make these groups of tasks
    #   e.g. anli, arithmetic, openai_translations, harness_translations
Andy Zou's avatar
Andy Zou committed
201
    # hendrycksTest (57 tasks)
Andy Zou's avatar
Andy Zou committed
202
    **hendrycks_test.create_all_tasks(),
&'s avatar
...  
& committed
203
    # e.g. wmt14-fr-en
&'s avatar
& committed
204
205
206
    **translation.create_tasks_from_benchmarks(gpt3_translation_benchmarks),
    # chef's selection, mostly wmt20
    **translation.create_tasks_from_benchmarks(selected_translation_benchmarks),
Jon Tow's avatar
Jon Tow committed
207
    # Word Scrambling and Manipulation Tasks
208
209
210
211
212
    "anagrams1": unscramble.Anagrams1,
    "anagrams2": unscramble.Anagrams2,
    "cycle_letters": unscramble.CycleLetters,
    "random_insertion": unscramble.RandomInsertion,
    "reversed_words": unscramble.ReversedWords,
Jason Phang's avatar
Jason Phang committed
213
    # Pile
Leo Gao's avatar
Leo Gao committed
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
    "pile_arxiv": pile.PileArxiv,
    "pile_books3": pile.PileBooks3,
    "pile_bookcorpus2": pile.PileBookCorpus2,
    "pile_dm-mathematics": pile.PileDmMathematics,
    "pile_enron": pile.PileEnron,
    "pile_europarl": pile.PileEuroparl,
    "pile_freelaw": pile.PileFreeLaw,
    "pile_github": pile.PileGithub,
    "pile_gutenberg": pile.PileGutenberg,
    "pile_hackernews": pile.PileHackernews,
    "pile_nih-exporter": pile.PileNIHExporter,
    "pile_opensubtitles": pile.PileOpenSubtitles,
    "pile_openwebtext2": pile.PileOpenWebText2,
    "pile_philpapers": pile.PilePhilPapers,
    "pile_pile-cc": pile.PilePileCc,
    "pile_pubmed-abstracts": pile.PilePubmedAbstracts,
    "pile_pubmed-central": pile.PilePubmedCentral,
    "pile_stackexchange": pile.PileStackExchange,
    "pile_uspto": pile.PileUspto,
    "pile_ubuntu-irc": pile.PileUbuntuIrc,
    "pile_wikipedia": pile.PileWikipedia,
    "pile_youtubesubtitles": pile.PileYoutubeSubtitles,
Igor Ostrovsky's avatar
Igor Ostrovsky committed
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
    # BLiMP
    "blimp_adjunct_island": blimp.BlimpAdjunctIsland,
    "blimp_anaphor_gender_agreement": blimp.BlimpAnaphorGenderAgreement,
    "blimp_anaphor_number_agreement": blimp.BlimpAnaphorNumberAgreement,
    "blimp_animate_subject_passive": blimp.BlimpAnimateSubjectPassive,
    "blimp_animate_subject_trans": blimp.BlimpAnimateSubjectTrans,
    "blimp_causative": blimp.BlimpCausative,
    "blimp_complex_NP_island": blimp.BlimpComplex_NPIsland,
    "blimp_coordinate_structure_constraint_complex_left_branch": blimp.BlimpCoordinateStructureConstraintComplexLeftBranch,
    "blimp_coordinate_structure_constraint_object_extraction": blimp.BlimpCoordinateStructureConstraintObjectExtraction,
    "blimp_determiner_noun_agreement_1": blimp.BlimpDeterminerNounAgreement_1,
    "blimp_determiner_noun_agreement_2": blimp.BlimpDeterminerNounAgreement_2,
    "blimp_determiner_noun_agreement_irregular_1": blimp.BlimpDeterminerNounAgreementIrregular_1,
    "blimp_determiner_noun_agreement_irregular_2": blimp.BlimpDeterminerNounAgreementIrregular_2,
    "blimp_determiner_noun_agreement_with_adj_2": blimp.BlimpDeterminerNounAgreementWithAdj_2,
    "blimp_determiner_noun_agreement_with_adj_irregular_1": blimp.BlimpDeterminerNounAgreementWithAdjIrregular_1,
    "blimp_determiner_noun_agreement_with_adj_irregular_2": blimp.BlimpDeterminerNounAgreementWithAdjIrregular_2,
    "blimp_determiner_noun_agreement_with_adjective_1": blimp.BlimpDeterminerNounAgreementWithAdjective_1,
    "blimp_distractor_agreement_relational_noun": blimp.BlimpDistractorAgreementRelationalNoun,
    "blimp_distractor_agreement_relative_clause": blimp.BlimpDistractorAgreementRelativeClause,
    "blimp_drop_argument": blimp.BlimpDropArgument,
    "blimp_ellipsis_n_bar_1": blimp.BlimpEllipsisNBar_1,
    "blimp_ellipsis_n_bar_2": blimp.BlimpEllipsisNBar_2,
    "blimp_existential_there_object_raising": blimp.BlimpExistentialThereObjectRaising,
    "blimp_existential_there_quantifiers_1": blimp.BlimpExistentialThereQuantifiers_1,
    "blimp_existential_there_quantifiers_2": blimp.BlimpExistentialThereQuantifiers_2,
    "blimp_existential_there_subject_raising": blimp.BlimpExistentialThereSubjectRaising,
    "blimp_expletive_it_object_raising": blimp.BlimpExpletiveItObjectRaising,
    "blimp_inchoative": blimp.BlimpInchoative,
    "blimp_intransitive": blimp.BlimpIntransitive,
    "blimp_irregular_past_participle_adjectives": blimp.BlimpIrregularPastParticipleAdjectives,
    "blimp_irregular_past_participle_verbs": blimp.BlimpIrregularPastParticipleVerbs,
    "blimp_irregular_plural_subject_verb_agreement_1": blimp.BlimpIrregularPluralSubjectVerbAgreement_1,
    "blimp_irregular_plural_subject_verb_agreement_2": blimp.BlimpIrregularPluralSubjectVerbAgreement_2,
    "blimp_left_branch_island_echo_question": blimp.BlimpLeftBranchIslandEchoQuestion,
    "blimp_left_branch_island_simple_question": blimp.BlimpLeftBranchIslandSimpleQuestion,
    "blimp_matrix_question_npi_licensor_present": blimp.BlimpMatrixQuestionNpiLicensorPresent,
    "blimp_npi_present_1": blimp.BlimpNpiPresent_1,
    "blimp_npi_present_2": blimp.BlimpNpiPresent_2,
    "blimp_only_npi_licensor_present": blimp.BlimpOnlyNpiLicensorPresent,
    "blimp_only_npi_scope": blimp.BlimpOnlyNpiScope,
    "blimp_passive_1": blimp.BlimpPassive_1,
    "blimp_passive_2": blimp.BlimpPassive_2,
    "blimp_principle_A_c_command": blimp.BlimpPrinciple_ACCommand,
    "blimp_principle_A_case_1": blimp.BlimpPrinciple_ACase_1,
    "blimp_principle_A_case_2": blimp.BlimpPrinciple_ACase_2,
    "blimp_principle_A_domain_1": blimp.BlimpPrinciple_ADomain_1,
    "blimp_principle_A_domain_2": blimp.BlimpPrinciple_ADomain_2,
    "blimp_principle_A_domain_3": blimp.BlimpPrinciple_ADomain_3,
    "blimp_principle_A_reconstruction": blimp.BlimpPrinciple_AReconstruction,
    "blimp_regular_plural_subject_verb_agreement_1": blimp.BlimpRegularPluralSubjectVerbAgreement_1,
    "blimp_regular_plural_subject_verb_agreement_2": blimp.BlimpRegularPluralSubjectVerbAgreement_2,
    "blimp_sentential_negation_npi_licensor_present": blimp.BlimpSententialNegationNpiLicensorPresent,
    "blimp_sentential_negation_npi_scope": blimp.BlimpSententialNegationNpiScope,
    "blimp_sentential_subject_island": blimp.BlimpSententialSubjectIsland,
    "blimp_superlative_quantifiers_1": blimp.BlimpSuperlativeQuantifiers_1,
    "blimp_superlative_quantifiers_2": blimp.BlimpSuperlativeQuantifiers_2,
    "blimp_tough_vs_raising_1": blimp.BlimpToughVsRaising_1,
    "blimp_tough_vs_raising_2": blimp.BlimpToughVsRaising_2,
    "blimp_transitive": blimp.BlimpTransitive,
    "blimp_wh_island": blimp.BlimpWhIsland,
    "blimp_wh_questions_object_gap": blimp.BlimpWhQuestionsObjectGap,
    "blimp_wh_questions_subject_gap": blimp.BlimpWhQuestionsSubjectGap,
    "blimp_wh_questions_subject_gap_long_distance": blimp.BlimpWhQuestionsSubjectGapLongDistance,
    "blimp_wh_vs_that_no_gap": blimp.BlimpWhVsThatNoGap,
    "blimp_wh_vs_that_no_gap_long_distance": blimp.BlimpWhVsThatNoGapLongDistance,
    "blimp_wh_vs_that_with_gap": blimp.BlimpWhVsThatWithGap,
    "blimp_wh_vs_that_with_gap_long_distance": blimp.BlimpWhVsThatWithGapLongDistance,
Shashi456's avatar
Shashi456 committed
304
305
    
    #GEM/mlsum
306
307
    "mlsum_es":gem_mlsum.GEMMLSUMEs,
    "mlsum_de":gem_mlsum.GEMMLSUMDe,
Shashi456's avatar
Shashi456 committed
308
309
310
    "mlsum_es_covid_challenge_set":gem_mlsum.GEMMLSUMEsChallgeTestCovid,
    "mlsum_de_covid_challenge_set":gem_mlsum.GEMMLSUMDeChallgeTestCovid,

Jonathan Tow's avatar
Jonathan Tow committed
311
312
313
314
    # Requires manual download of data.
    # "storycloze_2016": storycloze.StoryCloze2016,
    # "storycloze_2018": storycloze.StoryCloze2018,
    # "sat": sat.SATAnalogies,
ken's avatar
ken committed
315
316
317
318
319
320
321
322
323

    #GEM/xum
    "gem_xsum": gem_xsum.GEMXSUM,
    "gem_xsum_challenge_sample": gem_xsum.GEMXSUMChallgeSample,
    "gem_xsum_challenge_test_backtranslation": gem_xsum.GEMXSUMChallgeTestBacktranslation,
    "gem_xsum_challenge_test_bfp_02": gem_xsum.GEMXSUMChallgeTestBFP02,
    "gem_xsum_challenge_test_bfp_05": gem_xsum.GEMXSUMChallgeTestBFP05,
    "gem_xsum_challenge_test_nopunc": gem_xsum.GEMXSUMChallgeTestNopunc,
    "gem_xsum_challenge_test_covid": gem_xsum.GEMXSUMChallgeTestCovid,
Jan-Christoph Kalo's avatar
Jan-Christoph Kalo committed
324
325

   #LAMA
KhalidAlt's avatar
KhalidAlt committed
326
327
328
329
330
    "lama-trex": lama.Trex,
    "lama-squad": lama.Squad,
    "lama-google_re": lama.google_re,
    "lama-concptnet": lama.Conceptnet,
    "bigscience-lama":lama.BigScienceLAMA,
tomlimi's avatar
tomlimi committed
331
332
333
334
335
    # WinoBias
    "wino_bias_type1_pro": wino_bias.WinoBiasType1Pro,
    "wino_bias_type1_anti": wino_bias.WinoBiasType1Anti,
    "wino_bias_type2_pro": wino_bias.WinoBiasType2Pro,
    "wino_bias_type2_anti": wino_bias.WinoBiasType2Anti,
Jason Phang's avatar
Jason Phang committed
336
}
Jason Phang's avatar
gpt3  
Jason Phang committed
337
338


Jason Phang's avatar
Jason Phang committed
339
ALL_TASKS = sorted(list(TASK_REGISTRY))
Jason Phang's avatar
Jason Phang committed
340
341


Jason Phang's avatar
cleanup  
Jason Phang committed
342
def get_task(task_name):
&'s avatar
& committed
343
344
345
346
347
348
    try:
        return TASK_REGISTRY[task_name]
    except KeyError as e:
        print("Available tasks:")
        pprint(TASK_REGISTRY)
        raise KeyError(f"Missing task {task_name}")
Jason Phang's avatar
cleanup  
Jason Phang committed
349
350


351
352
353
354
def get_task_name_from_object(task_object):
    for name, class_ in TASK_REGISTRY.items():
        if class_ is task_object:
            return name
cjlovering's avatar
cjlovering committed
355

356
    # this gives a mechanism for non-registered tasks to have a custom name anyways when reporting
cjlovering's avatar
cjlovering committed
357
358
359
360
361
    return (
        task_object.EVAL_HARNESS_NAME
        if hasattr(task_object, "EVAL_HARNESS_NAME")
        else type(task_object).__name__
    )
362
363
364


def get_task_dict(task_name_list: List[Union[str, lm_eval.base.Task]]):
365
    task_name_dict = {
Jason Phang's avatar
cleanup  
Jason Phang committed
366
        task_name: get_task(task_name)()
cjlovering's avatar
cjlovering committed
367
368
        for task_name in task_name_list
        if isinstance(task_name, str)
369
370
    }
    task_name_from_object_dict = {
371
        get_task_name_from_object(task_object): task_object
cjlovering's avatar
cjlovering committed
372
373
        for task_object in task_name_list
        if not isinstance(task_object, str)
Jason Phang's avatar
cleanup  
Jason Phang committed
374
    }
375
376
    assert set(task_name_dict.keys()).isdisjoint(set(task_name_from_object_dict.keys()))
    return {**task_name_dict, **task_name_from_object_dict}
cjlovering's avatar
cjlovering committed
377
378
379
380
381
382
383
384
385


def get_task_dict_promptsource(task_name_list: List[str]):
    """Loads a task instance for each prompt written for that task."""
    task_name_dict = {}

    for task_name in task_name_list:
        assert isinstance(task_name, str)

jon-tow's avatar
jon-tow committed
386
387
388
        # Static version of the Task Use this to get HF dataset path / name.
        static_task_obj = get_task(task_name)
        # Create the proper task name arg for DatasetTemplates.
cjlovering's avatar
cjlovering committed
389
390
391
        sub_task = (
            f"/{static_task_obj.DATASET_NAME}" if static_task_obj.DATASET_NAME else ""
        )
jon-tow's avatar
jon-tow committed
392
393
394
        ps_task_name = f"{static_task_obj.DATASET_PATH}{sub_task}"

        task_prompts = DatasetTemplates(ps_task_name)
cjlovering's avatar
cjlovering committed
395
396
397
398
399
400
401
402
        for prompt_name in task_prompts.all_template_names:
            prompt = task_prompts[prompt_name]
            # NOTE: We choose a sep that can be easily split.
            task_name_dict[f"{task_name}+{prompt_name}"] = get_task(task_name)(
                prompt=prompt
            )

    return task_name_dict