File size: 11,694 Bytes
27411b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
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

from typing import Literal

AGG_SCORE_METRICS_TYPE = Literal["agg_score_metrics", "agg_score_metrics_prob_raw", "agg_score_metrics_acc"]

agg_score_metrics_dict_prob = {
    "ar": [
        'custom|alghafa:mcq_exams_test_ar|0/prob_norm_token',
        'custom|alghafa:meta_ar_msa|0/prob_norm',
        'custom|alghafa:multiple_choice_grounded_statement_soqal_task|0/prob_norm_token',
        'custom|arabic_mmlu_native:_average|0/prob_norm_pmi',
        'custom|arc_easy_ar|0/prob_norm_token',
        'custom|hellaswag-ar|0/prob_norm_token',
        'custom|mlqa-ar|0/qa_ar_f1',
        'custom|piqa_ar|0/prob_norm_token',
        'custom|race_ar|0/prob_norm_token',
        'custom|sciq_ar|0/prob_norm_token',
        'custom|tydiqa-ar|0/qa_ar_f1',
        'custom|x-codah-ar|0/prob_norm_token',
        'custom|x-csqa-ar|0/prob_norm_pmi',
        'custom|xnli-2.0-bool-v2-ar|0/prob',
        'custom|arcd|0/qa_ar_f1',
        'custom|xstory_cloze-ar|0/prob_norm_token'
    ],
    "fr": [
        'custom|belebele-fr|0/prob_norm_token',
        'custom|fquadv2|0/qa_fr_f1',
        'custom|french-hellaswag|0/prob_norm_token',
        'custom|mintaka-fr|0/qa_fr_f1',
        'custom|meta_mmlu-fr:_average|0/prob_norm_pmi',
        'custom|x-codah-fr|0/prob_norm_token',
        'custom|x-csqa-fr|0/prob_norm_pmi',
        'custom|xnli-2.0-bool-v2-fr|0/prob',
        'custom|arc-fr|0/prob_norm_pmi'
    ],
    "hi": [
        'custom|belebele-hi|0/prob_norm_token',
        'custom|hellaswag-hi|0/prob_norm_token',
        'custom|hi-arc:easy|0/arc_norm_token',
        'custom|indicqa.hi|0/qa_hi_f1',
        'custom|meta_mmlu-hi:_average|0/prob_norm_pmi',
        'custom|x-codah-hi|0/prob_norm_token',
        'custom|x-csqa-hi|0/prob_norm_pmi',
        'custom|xcopa-hi|0/prob_norm_token',
        'custom|indicnxnli-hi-bool-v2-hi|0/prob_norm_token',
        'custom|xstory_cloze-hi|0/prob_norm_token'
    ],
    "ru": [
        'custom|arc-ru|0/prob_norm_pmi',
        'custom|belebele-ru|0/prob_norm_token',
        'custom|hellaswag-ru|0/prob_norm_token',
        'custom|parus|0/prob_norm_token',
        'custom|rummlu:_average|0/prob_norm_pmi',
        'custom|ruopenbookqa|0/prob_norm_token',
        'custom|tydiqa-ru|0/qa_ru_f1',
        'custom|x-codah-ru|0/prob_norm_token',
        'custom|x-csqa-ru|0/prob_norm_pmi',
        'custom|xnli-2.0-bool-v2-ru|0/prob',
        'custom|sber_squad|0/qa_ru_f1',
        'custom|xstory_cloze-ru|0/prob_norm_token',
        'custom|xquad-ru|0/qa_ru_f1'
    ],
    "sw": [
        'custom|belebele-sw|0/prob_norm_token',
        'custom|arc-sw:easy|0/prob_norm_token',
        'custom|kenswquad|0/qa_sw_f1',
        'custom|tydiqa-sw|0/qa_sw_f1',
        'custom|m3exam-sw|0/prob_norm_token',
        'custom|x-csqa-sw|0/prob_norm_pmi',
        'custom|xcopa-sw|0/prob_norm_token',
        'custom|xnli-2.0-bool-v2-sw|0/prob_norm',
        'custom|xstory_cloze-sw|0/prob_norm_token'
    ],
    "te": [
        'custom|belebele-te|0/prob_norm_token',
        'custom|custom_hellaswag-te|0/prob_norm_token',
        'custom|indicqa.te|0/qa_te_f1',
        'custom|mmlu-te:_average|0/prob_norm_token',
        'custom|indicnxnli-te-bool-v2-te|0/prob_norm_token',
        'custom|xcopa-te|0/prob_norm_token',
        'custom|xstory_cloze-te|0/prob_norm_token'
    ],
    "th": [
        'custom|belebele-th|0/prob_norm_token',
        'custom|m3exam-th|0/prob_norm_token',
        'custom|meta_mmlu-th:_average|0/prob_norm_pmi',
        'custom|xnli-2.0-bool-v2-th|0/prob',
        'custom|custom_hellaswag-th|0/prob_norm_token',
        'custom|thaiqa|0/qa_th_f1',
        'custom|xquad-th|0/qa_th_f1',
    ],
    "tr": [
        'custom|arc-v2-tr|0/prob_norm',
        'custom|belebele-tr|0/prob_norm',
        'custom|exams-tr:_average|0/prob_norm',
        'custom|hellaswag-tr|0/prob_norm',
        'custom|mmlu-tr:_average|0/prob_norm_pmi',
        'custom|tqduad2|0/qa_tr_f1',
        'custom|xcopa-tr|0/prob_norm',
        'custom|xnli-2.0-bool-v2-tr|0/prob',
        'custom|xquad-tr|0/qa_tr_f1'
    ],
    "zh": [
        'custom|agieval_NEW_LINE:_average|0/prob_norm_pmi',
        'custom|belebele-zh|0/prob_norm_token',
        'custom|c3|0/prob_norm_token',
        'custom|ceval_NEW_LINE:_average|0/prob_norm_token',
        'custom|cmmlu:_average|0/prob_norm_token',
        'custom|cmrc|0/qa_zh_f1',
        'custom|hellaswag-zh|0/prob_norm_token',
        'custom|m3exam-zh|0/prob_norm_token',
        'custom|mlqa-zh|0/qa_zh_f1',
        'custom|x-codah-zh|0/prob_norm_token',
        'custom|x-csqa-zh|0/prob_norm_pmi',
        'custom|xcopa-zh|0/prob_norm_token',
        'custom|ocnli-bool-v2-zh|0/prob',
        'custom|chinese-squad|0/qa_zh_f1',
        'custom|xstory_cloze-zh|0/prob_norm_token',
        'custom|xwinograd-zh|0/prob_norm_token'
    ]
}


def transform_for_prob_raw(metric: str):
    # The pmi can't be used for unormalized probabilities
    # Secondly the acc_norm_token is better in terms of monotonicity for this evaluation metric
    splitted_metric = metric.split("/")
    
    # If it's generative metric we don't do anything
    if not "prob" in splitted_metric[-1]:
        return metric
    return "/".join(splitted_metric[:-1] + ["prob_raw_norm_token"])



    
agg_score_metrics_dict_prob_raw = {
    lang: [transform_for_prob_raw(metric) for metric in metrics]
    for lang, metrics in agg_score_metrics_dict_prob.items()
}

agg_score_metrics_dict_acc = {
    lang: [metric.replace("/prob", "/acc") for metric in metrics]
    for lang, metrics in agg_score_metrics_dict_prob.items()
}

agg_score_metrics_dict_both = {
    lang: agg_score_metrics_dict_prob[lang] + agg_score_metrics_dict_acc[lang]
    for lang in agg_score_metrics_dict_prob.keys()
}


agg_score_metrics = {
    "prob": agg_score_metrics_dict_prob,
    "prob_raw": agg_score_metrics_dict_prob_raw,
    "acc": agg_score_metrics_dict_acc,
    "both": agg_score_metrics_dict_both
}

# Allow to override default groupping behaviour for aggregate tasks
# The key is the task name and value is the list of tasks to use for the average
custom_task_aggregate_groups = {
    'custom|agieval_NEW_LINE': [
        'gaokao-biology', 'gaokao-chemistry', 'gaokao-chinese', 'gaokao-geography',
        'gaokao-history', 'gaokao-physics', 'jec-qa-ca',
        'jec-qa-kd', 'logiqa-zh'
    ]
}

def is_agg_score_col(col: str, agg_score_type: AGG_SCORE_METRICS_TYPE, lang: str):
    metric_name = col
    if agg_score_type == "agg_score_metrics_prob_raw":
        return metric_name in agg_score_metrics_dict_prob_raw.get(lang, [])
    elif agg_score_type == "agg_score_metrics_acc":
        return metric_name in agg_score_metrics_dict_acc.get(lang, [])
    
    return agg_score_metrics_dict_prob.get(lang, [])


# agg_score_metrics = {
#     "ar": [
#         'custom|alghafa:mcq_exams_test_ar|0/acc_norm_token',
#         'custom|alghafa:meta_ar_msa|0/acc_norm',
#         'custom|alghafa:multiple_choice_grounded_statement_soqal_task|0/acc_norm_token',
#         'custom|arabic_mmlu_native:_average|0/acc_norm_pmi',
#         'custom|arc_easy_ar|0/acc_norm_token',
#         'custom|hellaswag-ar|0/acc_norm_token',
#         'custom|mlqa-ar|0/qa_ar_f1',
#         'custom|piqa_ar|0/acc_norm_token',
#         'custom|race_ar|0/acc_norm_token',
#         'custom|sciq_ar|0/acc_norm_token',
#         'custom|tydiqa-ar|0/qa_ar_f1',
#         'custom|x-codah-ar|0/acc_norm_token',
#         'custom|x-csqa-ar|0/acc_norm_pmi',
#         'custom|xnli-2.0-bool-v2-ar|0/acc',
#         'custom|arcd|0/qa_ar_f1',
#         'custom|xstory_cloze-ar|0/acc_norm_token'
#     ],
#     "fr": [
#         'custom|belebele-fr|0/acc_norm_token',
#         'custom|fquadv2|0/qa_fr_f1',
#         'custom|french-hellaswag|0/acc_norm_token',
#         'custom|mintaka-fr|0/qa_fr_f1',
#         'custom|meta_mmlu-fr:_average|0/acc_norm_pmi',
#         'custom|pawns-v2-fr|0/acc',
#         'custom|x-codah-fr|0/acc_norm_token',
#         'custom|x-csqa-fr|0/acc_norm_pmi',
#         'custom|xnli-2.0-bool-v2-fr|0/acc',
#         'custom|arc-fr|0/acc_norm_pmi'
#     ],
#     "hi": [
#         'custom|belebele-hi|0/acc_norm_token',
#         'custom|hellaswag-hi|0/acc_norm_token',
#         'custom|hi-arc:easy|0/arc_norm_token',
#         'custom|indicqa.hi|0/qa_hi_f1',
#         'custom|meta_mmlu-hi:_average|0/acc_norm_pmi',
#         'custom|x-codah-hi|0/acc_norm_token',
#         'custom|x-csqa-hi|0/acc_norm_pmi',
#         'custom|xcopa-hi|0/acc_norm_token',
#         'custom|indicnxnli-hi-bool-v2-hi|0/acc_norm_token',
#         'custom|xstory_cloze-hi|0/acc_norm_token'
#     ],
#     "ru": [
#         'custom|arc-ru|0/acc_norm_pmi',
#         'custom|belebele-ru|0/acc_norm_token',
#         'custom|hellaswag-ru|0/acc_norm_token',
#         'custom|parus|0/acc_norm_token',
#         'custom|rummlu:_average|0/acc_norm_pmi',
#         'custom|ruopenbookqa|0/acc_norm_token',
#         'custom|tydiqa-ru|0/qa_ru_f1',
#         'custom|x-codah-ru|0/acc_norm_token',
#         'custom|x-csqa-ru|0/acc_norm_pmi',
#         'custom|xnli-2.0-bool-v2-ru|0/acc',
#         'custom|sber_squad|0/qa_ru_f1',
#         'custom|xstory_cloze-ru|0/acc_norm_token',
#         'custom|xquad-ru|0/qa_ru_f1'
#     ],
#     "sw": [
#         'custom|belebele-sw|0/acc_norm_token',
#         'custom|arc-sw:easy|0/acc_norm_token',
#         'custom|kenswquad|0/qa_sw_f1',
#         'custom|tydiqa-sw|0/qa_sw_f1',
#         'custom|m3exam-sw|0/acc_norm_token',
#         'custom|x-csqa-sw|0/acc_norm_pmi',
#         'custom|xcopa-sw|0/acc_norm_token',
#         'custom|xnli-2.0-bool-v2-sw|0/acc_norm',
#         'custom|xstory_cloze-sw|0/acc_norm_token'
#     ],
#     "te": [
#         'custom|belebele-te|0/acc_norm_token',
#         'custom|custom_hellaswag-te|0/acc_norm_token',
#         'custom|indicqa.te|0/qa_te_f1',
#         'custom|mmlu-te:_average|0/acc_norm_token',
#         'custom|indicnxnli-te-bool-v2-te|0/acc_norm_token',
#         'custom|xcopa-te|0/acc_norm_token',
#         'custom|xstory_cloze-te|0/acc_norm_token'
#     ],
#     "th": [
#         'custom|belebele-th|0/acc_norm_token',
#         'custom|m3exam-th|0/acc_norm_token',
#         'custom|meta_mmlu-th:_average|0/acc_norm_pmi',
#         'custom|xnli-2.0-bool-v2-th|0/acc',
#         'custom|custom_hellaswag-th|0/acc_norm_token',
#         'custom|thaiqa|0/qa_th_f1',
#         'custom|xquad-th|0/qa_th_f1',
#         'custom|thai-exams:tgat|0/acc_norm_token'
#     ],
#     "tr": [
#         'custom|arc-v2-tr|0/acc_norm',
#         'custom|belebele-tr|0/acc_norm',
#         'custom|exams-tr:_average|0/acc_norm',
#         'custom|hellaswag-tr|0/acc_norm',
#         'custom|mmlu-tr:_average|0/acc_norm_pmi',
#         'custom|tqduad2|0/qa_tr_f1',
#         'custom|xcopa-tr|0/acc_norm',
#         'custom|xnli-2.0-bool-v2-tr|0/acc',
#         'custom|xquad-tr|0/qa_tr_f1'
#     ],
#     "zh": [
#         'custom|agieval_NEW_LINE:_average|0/acc_norm_pmi',
#         'custom|belebele-zh|0/acc_norm_token',
#         'custom|c3|0/acc_norm_token',
#         'custom|ceval_NEW_LINE:_average|0/acc_norm_token',
#         'custom|cmmlu:_average|0/acc_norm_token',
#         'custom|cmrc|0/qa_zh_f1',
#         'custom|hellaswag-zh|0/acc_norm_token',
#         'custom|m3exam-zh|0/acc_norm_token',
#         'custom|mlqa-zh|0/qa_zh_f1',
#         'custom|x-codah-zh|0/acc_norm_token',
#         'custom|x-csqa-zh|0/acc_norm_pmi',
#         'custom|xcopa-zh|0/acc_norm_token',
#         'custom|ocnli-bool-v2-zh|0/acc',
#         'custom|chinese-squad|0/qa_zh_f1',
#         'custom|xstory_cloze-zh|0/acc_norm_token',
#         'custom|xwinograd-zh|0/acc_norm_token'
#     ]
# }