utils.py 772 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from lm_eval.api.filter import Filter
from lm_eval.api.registry import register_filter

alpha = ['A', 'B', 'C']
out_dic = {"ايجابي": 1, "سلبي": 0, "ماكينش إحساس": 2}

def doc_to_text(doc):
    return doc["messages"][0]["content"].replace('-سلبي', 'A. سلبي').replace('-ايجابي', 'B. ايجابي').replace('-ماكينش إحساس', 'C. ماكينش إحساس\nThe answer should be strictly one letter of the following: A, B, C.')#.replace('شنو هو الإحساس ديال هاد الجملة؟', 'شنو هو الإحساس ديال هاد الجملة؟')

def doc_to_choice_3(doc):
    return alpha

def doc_to_choice_2(doc):
    return alpha[:2]

def doc_to_target(doc):
    return alpha[out_dic[doc["messages"][1]["content"]]]