utils.py 606 Bytes
Newer Older
1
from lm_eval.utils import weighted_f1_score
2
3
4


def doc_to_text(doc):
Lintang Sutawika's avatar
Lintang Sutawika committed
5
    output = """Please identify whether the premise entails or contradicts the hypothesis in the following premise
6
    and hypothesis. The answer should be exact entailment, contradiction, or neutral.
Lintang Sutawika's avatar
Lintang Sutawika committed
7

8
9
    Premise: {premise}
    Hypothesis: {hypothesis}
Lintang Sutawika's avatar
Lintang Sutawika committed
10

11
12
    Is it entailment, contradiction, or neutral?"""

Lintang Sutawika's avatar
Lintang Sutawika committed
13
    text = output.format(premise=doc["premise"], hypothesis=doc["hypothesis"])
14
15
16
17
    return text


def doc_to_target(doc):
Lintang Sutawika's avatar
Lintang Sutawika committed
18
    replacements = {0: "entailment", 1: "neutral", 2: "contradiction"}
19
    return replacements[doc["label"]]