utils.py 857 Bytes
Newer Older
1
2
3
from lm_eval.api.filter import Filter
from lm_eval.api.registry import register_filter

4
5

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

8

9
def doc_to_text(doc):
10
11
12
13
14
15
16
17
18
19
    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('شنو هو الإحساس ديال هاد الجملة؟', 'شنو هو الإحساس ديال هاد الجملة؟')

20
21
22
23

def doc_to_choice_3(doc):
    return alpha

24

25
26
27
def doc_to_choice_2(doc):
    return alpha[:2]

28

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