preprocess_medqa.py 362 Bytes
Newer Older
Tanishq Abraham's avatar
Tanishq Abraham committed
1
def doc_to_text(doc) -> str:
2
3
4
5
6
7
    option_choices = {
        "A": doc["ending0"],
        "B": doc["ending1"],
        "C": doc["ending2"],
        "D": doc["ending3"],
    }
Tanishq Abraham's avatar
Tanishq Abraham committed
8
9
10
11
12
13
    answers = "".join((f"{k}. {v}\n") for k, v in option_choices.items())
    return f"Question: {doc['sent1']}\n{answers}Answer:"


def doc_to_target(doc) -> int:
    return doc["label"]