utils_logiqa.py 687 Bytes
Newer Older
1
2
3
4
5
6
# Copied from Master
def doc_to_text(doc) -> str:
    """
    Passage: <passage>
    Question: <question>
    Choices:
Herbie Bradley's avatar
Herbie Bradley committed
7
8
9
10
    (A) <choice1>
    (B) <choice2>
    (C) <choice3>
    (D) <choice4>
11
12
13
14
15
16
    Answer:
    """
    choices = ["a", "b", "c", "d"]
    prompt = "Passage: " + doc["context"] + "\n"
    prompt += "Question: " + doc["question"] + "\nChoices:\n"
    for choice, option in zip(choices, doc["options"]):
Herbie Bradley's avatar
Herbie Bradley committed
17
        prompt += f"({choice.upper()}) {option}\n"
18
19
20
21
22
23
24
    prompt += "Answer:"
    return prompt


def doc_to_target(doc) -> int:
    choices = ["a", "b", "c", "d"]
    return choices.index(doc["label"].strip())
Herbie Bradley's avatar
Herbie Bradley committed
25
26
27
28


def doc_to_choice(doc):
    return ["(A)", "(B)", "(C)", "(D)"]