__init__.py 17.4 KB
Newer Older
&'s avatar
& committed
1
from pprint import pprint
2
from typing import List, Union
&'s avatar
& committed
3

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

Jason Phang's avatar
Jason Phang committed
7
8
from . import superglue
from . import glue
Leo Gao's avatar
Leo Gao committed
9
from . import arc
thefazzer's avatar
thefazzer committed
10
from . import coqa
Leo Gao's avatar
Leo Gao committed
11
from . import race
Leo Gao's avatar
Leo Gao committed
12
from . import webqs
Leo Gao's avatar
Leo Gao committed
13
from . import anli
14
from . import wsc273
Charles Foster's avatar
Charles Foster committed
15
from . import winogrande
Charles Foster's avatar
Charles Foster committed
16
from . import quac
Charles Foster's avatar
Charles Foster committed
17
from . import hellaswag
jon-tow's avatar
jon-tow committed
18
from . import swag
Charles Foster's avatar
Charles Foster committed
19
from . import openbookqa
Charles Foster's avatar
Charles Foster committed
20
from . import squad
21
from . import naturalqs
22
from . import sat
23
from . import arithmetic
Leo Gao's avatar
Leo Gao committed
24
from . import lambada
Leo Gao's avatar
Leo Gao committed
25
from . import piqa
Jonathan Tow's avatar
Jonathan Tow committed
26
from . import prost
Jonathan Tow's avatar
Jonathan Tow committed
27
from . import mc_taco
28
from . import triviaqa
jeffhsu3's avatar
jeffhsu3 committed
29
from . import pubmedqa
30
from . import sciq
31
from . import qasper
32
from . import qa4mre
&'s avatar
& committed
33
from . import translation
34
35
from . import headqa
from . import mathqa
Leo Gao's avatar
Leo Gao committed
36
from . import hendrycks_ethics
Jon Tow's avatar
Jon Tow committed
37
from . import drop
38
from . import unscramble
39
from . import logiqa
Andy Zou's avatar
Andy Zou committed
40
from . import hendrycks_test
Leo Gao's avatar
Leo Gao committed
41
from . import hendrycks_math
42
from . import cbt
43
from . import lambada_cloze
Jason Phang's avatar
Jason Phang committed
44
from . import pile
Leo Gao's avatar
Leo Gao committed
45
from . import wikitext
sdtblck's avatar
sdtblck committed
46
from . import lambada_multilingual
Jonathan Tow's avatar
Jonathan Tow committed
47
from . import mutual
48
from . import truthfulqa
Igor Ostrovsky's avatar
Igor Ostrovsky committed
49
from . import blimp
rokosbasilisk's avatar
rokosbasilisk committed
50
from . import asdiv
Jonathan Tow's avatar
Jonathan Tow committed
51
from . import gsm8k
Jonathan Tow's avatar
Jonathan Tow committed
52
from . import storycloze
53
from . import kobest
54
from . import nsmc
Taekyoon's avatar
Taekyoon committed
55
from . import klue
56
from . import ko_translation
Taekyoon's avatar
Taekyoon committed
57
from . import korquad
ingyuseong's avatar
ingyuseong committed
58
from . import korunsmile
ingyuseong's avatar
ingyuseong committed
59
from . import kohatespeech
Tom Hartvigsen's avatar
Tom Hartvigsen committed
60
from . import toxigen
Aflah's avatar
Aflah committed
61
from . import crowspairs
62
from . import json
63
from . import xcopa
64
from . import bigbench
65
66
67
68
69
from . import xstorycloze
from . import xwinograd
from . import pawsx
from . import xnli
from . import mgsm
Taekyoon's avatar
Taekyoon committed
70

&'s avatar
& committed
71
72
73
74
########################################
# Translation tasks
########################################

75

&'s avatar
& committed
76
77
# 6 total
gpt3_translation_benchmarks = {
Fabrizio Milo's avatar
Fabrizio Milo committed
78
79
    "wmt14": ["en-fr", "fr-en"],  # French
    "wmt16": ["en-ro", "ro-en", "de-en", "en-de"],  # German, Romanian
&'s avatar
& committed
80
81
82
83
84
85
}

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

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


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

ingyuseong's avatar
ingyuseong committed
100
# task 레지스트리에 클래스 추가 
Jason Phang's avatar
Jason Phang committed
101
TASK_REGISTRY = {
Jason Phang's avatar
multirc  
Jason Phang committed
102
    # GLUE
Jason Phang's avatar
Jason Phang committed
103
104
    "cola": glue.CoLA,
    "mnli": glue.MNLI,
Jason Phang's avatar
Jason Phang committed
105
    "mnli_mismatched": glue.MNLIMismatched,
Jason Phang's avatar
Jason Phang committed
106
107
108
109
    "mrpc": glue.MRPC,
    "rte": glue.RTE,
    "qnli": glue.QNLI,
    "qqp": glue.QQP,
Fabrizio Milo's avatar
Fabrizio Milo committed
110
    # "stsb": glue.STSB, # not implemented yet
Jason Phang's avatar
Jason Phang committed
111
112
    "sst": glue.SST,
    "wnli": glue.WNLI,
Jason Phang's avatar
multirc  
Jason Phang committed
113
    # SuperGLUE
Jason Phang's avatar
Jason Phang committed
114
    "boolq": superglue.BoolQ,
thefazzer's avatar
thefazzer committed
115
    "cb": superglue.CommitmentBank,
Jason Phang's avatar
Jason Phang committed
116
    "copa": superglue.Copa,
Jason Phang's avatar
multirc  
Jason Phang committed
117
    "multirc": superglue.MultiRC,
Jason Phang's avatar
Jason Phang committed
118
    "record": superglue.ReCoRD,
Jason Phang's avatar
Jason Phang committed
119
    "wic": superglue.WordsInContext,
Jason Phang's avatar
wsc  
Jason Phang committed
120
    "wsc": superglue.SGWinogradSchemaChallenge,
Jason Phang's avatar
multirc  
Jason Phang committed
121
    # Order by benchmark/genre?
thefazzer's avatar
thefazzer committed
122
    "coqa": coqa.CoQA,
Jon Tow's avatar
Jon Tow committed
123
    "drop": drop.DROP,
jon-tow's avatar
jon-tow committed
124
125
126
127
    "lambada_openai": lambada.LambadaOpenAI,
    "lambada_standard": lambada.LambadaStandard,
    "lambada_openai_cloze": lambada_cloze.LambadaOpenAICloze,
    "lambada_standard_cloze": lambada_cloze.LambadaStandardCloze,
128
    # multilingual lambada
sdtblck's avatar
sdtblck committed
129
    **lambada_multilingual.construct_tasks(),
Leo Gao's avatar
Leo Gao committed
130
    "wikitext": wikitext.WikiText,
Leo Gao's avatar
Leo Gao committed
131
132
    # "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
133
    "piqa": piqa.PiQA,
Jonathan Tow's avatar
Jonathan Tow committed
134
    "prost": prost.PROST,
Jonathan Tow's avatar
Jonathan Tow committed
135
    "mc_taco": mc_taco.MCTACO,
136
    # Science related
Fabrizio Milo's avatar
Fabrizio Milo committed
137
138
    "pubmedqa": pubmedqa.Pubmed_QA,
    "sciq": sciq.SciQ,
139
    "qasper": qasper.QASPER,
Fabrizio Milo's avatar
Fabrizio Milo committed
140
141
142
    "qa4mre_2011": qa4mre.QA4MRE_2011,
    "qa4mre_2012": qa4mre.QA4MRE_2012,
    "qa4mre_2013": qa4mre.QA4MRE_2013,
Leo Gao's avatar
Leo Gao committed
143
    "triviaqa": triviaqa.TriviaQA,
Jonathan Tow's avatar
Jonathan Tow committed
144
145
    "arc_easy": arc.ARCEasy,
    "arc_challenge": arc.ARCChallenge,
146
    # "quac": quac.QuAC, # not implemented yet
147
    "logiqa": logiqa.LogiQA,
Leo Gao's avatar
Leo Gao committed
148
    "hellaswag": hellaswag.HellaSwag,
jon-tow's avatar
jon-tow committed
149
    "swag": swag.SWAG,
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
Fabrizio Milo's avatar
Fabrizio Milo 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,
Leo Gao's avatar
Leo Gao committed
164
165
166
167
168
169
    "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,
Fabrizio Milo's avatar
Fabrizio Milo committed
170
171
    "truthfulqa_mc": truthfulqa.TruthfulQAMultipleChoice,
    "truthfulqa_gen": truthfulqa.TruthfulQAGeneration,
Jonathan Tow's avatar
Jonathan Tow committed
172
173
174
    # dialogue
    "mutual": mutual.MuTual,
    "mutual_plus": mutual.MuTualPlus,
Eric Tang's avatar
Eric Tang committed
175
    # math
Leo Gao's avatar
Leo Gao committed
176
177
178
179
180
181
182
    "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
183
    "math_asdiv": asdiv.Asdiv,
Jonathan Tow's avatar
Jonathan Tow committed
184
    "gsm8k": gsm8k.GradeSchoolMath8K,
185
186
187
188
189
190
191
192
193
194
195
    # 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
196
197
    # TODO Perhaps make these groups of tasks
    #   e.g. anli, arithmetic, openai_translations, harness_translations
Andy Zou's avatar
Andy Zou committed
198
    # hendrycksTest (57 tasks)
Andy Zou's avatar
Andy Zou committed
199
    **hendrycks_test.create_all_tasks(),
&'s avatar
...  
& committed
200
    # e.g. wmt14-fr-en
&'s avatar
& committed
201
202
203
    **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
204
    # Word Scrambling and Manipulation Tasks
205
206
207
208
209
    "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
210
    # Pile
Leo Gao's avatar
Leo Gao committed
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
    "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
233
234
235
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
    # 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,
Tom Hartvigsen's avatar
Tom Hartvigsen committed
301
    "toxigen": toxigen.ToxiGen,
Aflah's avatar
Aflah committed
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
    "crows_pairs_english": crowspairs.CrowsPairsEnglish,
    "crows_pairs_english_race_color": crowspairs.CrowsPairsEnglishRaceColor,
    "crows_pairs_english_socioeconomic": crowspairs.CrowsPairsEnglishSocioeconomic,
    "crows_pairs_english_gender": crowspairs.CrowsPairsEnglishGender,
    "crows_pairs_english_age": crowspairs.CrowsPairsEnglishAge,
    "crows_pairs_english_religion": crowspairs.CrowsPairsEnglishReligion,
    "crows_pairs_english_disability": crowspairs.CrowsPairsEnglishDisability,
    "crows_pairs_english_sexual_orientation": crowspairs.CrowsPairsEnglishSexualOrientation,
    "crows_pairs_english_nationality": crowspairs.CrowsPairsEnglishNationality,
    "crows_pairs_english_physical_appearance": crowspairs.CrowsPairsEnglishPhysicalAppearance,
    "crows_pairs_english_autre": crowspairs.CrowsPairsEnglishAutre,
    "crows_pairs_french": crowspairs.CrowsPairsFrench,
    "crows_pairs_french_race_color": crowspairs.CrowsPairsFrenchRaceColor,
    "crows_pairs_french_socioeconomic": crowspairs.CrowsPairsFrenchSocioeconomic,
    "crows_pairs_french_gender": crowspairs.CrowsPairsFrenchGender,
    "crows_pairs_french_age": crowspairs.CrowsPairsFrenchAge,
    "crows_pairs_french_religion": crowspairs.CrowsPairsFrenchReligion,
    "crows_pairs_french_disability": crowspairs.CrowsPairsFrenchDisability,
    "crows_pairs_french_sexual_orientation": crowspairs.CrowsPairsFrenchSexualOrientation,
    "crows_pairs_french_nationality": crowspairs.CrowsPairsFrenchNationality,
    "crows_pairs_french_physical_appearance": crowspairs.CrowsPairsFrenchPhysicalAppearance,
    "crows_pairs_french_autre": crowspairs.CrowsPairsFrenchAutre,
Jonathan Tow's avatar
Jonathan Tow committed
324
325
326
327
    # Requires manual download of data.
    # "storycloze_2016": storycloze.StoryCloze2016,
    # "storycloze_2018": storycloze.StoryCloze2018,
    # "sat": sat.SATAnalogies,
328
    "klue_sts": klue.STS,
329
    "klue_ynat": klue.YNAT,
ingyuseong's avatar
ingyuseong committed
330
    "klue_nli": klue.NLI,
331
    "nsmc": nsmc.NSMC,    
332
    "korquad": korquad.Korquad,
333
334
335
336
    "kobest_boolq": kobest.BoolQ,
    "kobest_copa": kobest.COPA,
    "kobest_wic": kobest.WiC,
    "kobest_hellaswag": kobest.HellaSwag,
337
338
    "kobest_sentineg": kobest.SentiNeg,
    "ko_en_translation": ko_translation.KoEnTranslation,
ingyuseong's avatar
ingyuseong committed
339
    "en_ko_translation": ko_translation.EnKoTranslation,
ingyuseong's avatar
ingyuseong committed
340
    "korunsmile": korunsmile.KorUnSmile,
ingyuseong's avatar
ingyuseong committed
341
342
    "kohatespeech":kohatespeech.HateSpeech,
    "kohatespeech_gen_bias":kohatespeech.GenderBias,
bzantium's avatar
bzantium committed
343
    "kohatespeech_apeach":kohatespeech.Apeach,
344
    **xcopa.construct_tasks(),
345
    **bigbench.create_all_tasks(),
346
347
348
349
350
    **xstorycloze.create_all_tasks(),
    **xwinograd.create_all_tasks(),
    **pawsx.construct_tasks(),
    **xnli.construct_tasks(),
    **mgsm.construct_tasks(),
Jason Phang's avatar
Jason Phang committed
351
}
Jason Phang's avatar
gpt3  
Jason Phang committed
352

Jason Phang's avatar
Jason Phang committed
353
ALL_TASKS = sorted(list(TASK_REGISTRY))
Jason Phang's avatar
Jason Phang committed
354

355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
_EXAMPLE_JSON_PATH = "split:key:/absolute/path/to/data.json"


def add_json_task(task_name):
    """Add a JSON perplexity task if the given task name matches the
    JSON task specification.

    See `json.JsonPerplexity`.
    """
    if not task_name.startswith("json"):
        return

    def create_json_task():
        splits = task_name.split("=", 1)
        if len(splits) != 2 or not splits[1]:
            raise ValueError(
                "json tasks need a path argument pointing to the local "
                "dataset, specified like this: json="
                + _EXAMPLE_JSON_PATH
                + ' (if there are no splits, use "train")'
            )

        json_path = splits[1]
        if json_path == _EXAMPLE_JSON_PATH:
            raise ValueError(
                "please do not copy the example path directly, but substitute "
                "it with a path to your local dataset"
            )
        return lambda: json.JsonPerplexity(json_path)

    TASK_REGISTRY[task_name] = create_json_task()

Jason Phang's avatar
Jason Phang committed
387

Jason Phang's avatar
cleanup  
Jason Phang committed
388
def get_task(task_name):
&'s avatar
& committed
389
    try:
390
        add_json_task(task_name)
&'s avatar
& committed
391
        return TASK_REGISTRY[task_name]
392
    except KeyError:
&'s avatar
& committed
393
394
395
        print("Available tasks:")
        pprint(TASK_REGISTRY)
        raise KeyError(f"Missing task {task_name}")
Jason Phang's avatar
cleanup  
Jason Phang committed
396
397


398
399
400
401
def get_task_name_from_object(task_object):
    for name, class_ in TASK_REGISTRY.items():
        if class_ is task_object:
            return name
402

403
    # this gives a mechanism for non-registered tasks to have a custom name anyways when reporting
Fabrizio Milo's avatar
Fabrizio Milo committed
404
405
406
407
408
    return (
        task_object.EVAL_HARNESS_NAME
        if hasattr(task_object, "EVAL_HARNESS_NAME")
        else type(task_object).__name__
    )
409
410
411


def get_task_dict(task_name_list: List[Union[str, lm_eval.base.Task]]):
412
    task_name_dict = {
Jason Phang's avatar
cleanup  
Jason Phang committed
413
        task_name: get_task(task_name)()
Fabrizio Milo's avatar
Fabrizio Milo committed
414
415
        for task_name in task_name_list
        if isinstance(task_name, str)
416
417
    }
    task_name_from_object_dict = {
418
        get_task_name_from_object(task_object): task_object
Fabrizio Milo's avatar
Fabrizio Milo committed
419
420
        for task_object in task_name_list
        if not isinstance(task_object, str)
Jason Phang's avatar
cleanup  
Jason Phang committed
421
    }
422
423
    assert set(task_name_dict.keys()).isdisjoint(set(task_name_from_object_dict.keys()))
    return {**task_name_dict, **task_name_from_object_dict}