-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpromptv2.py
More file actions
64 lines (54 loc) · 2.25 KB
/
promptv2.py
File metadata and controls
64 lines (54 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class Promptconfig:
def __init__(self, incontext_prompt, belief_prompt, negation_prompt, question_prompt, nli_prompt):
self.incontext_prefix = incontext_prompt
self.belief_prefix = belief_prompt
self.negation_prefix = negation_prompt
self.question_prefix = question_prompt
self.nli_prefix = nli_prompt
def create_E_T_prompt(self, sentence):
generation_prefix = self.incontext_prefix
question = sentence[:-1] + "?"
return f"{generation_prefix}" \
f"Q: {question} This statement is true, because\n" \
f"A:"
def create_E_F_prompt(self, sentence):
generation_prefix = self.incontext_prefix
question = sentence[:-1] + "?"
return f"{generation_prefix}s" \
f"Q: {question} This statement is false, because\n" \
f"A:"
def create_negation_prompt(self, sentence):
return f"{self.negation_prefix}" \
f"Q: {sentence}\n"\
f"A:"
def create_new_negation_prompt(self,sentence):
return f"{self.negation_prefix}" \
f"Q: {sentence}\n"\
f"A:"
def create_belief_prompt(self, sentence):
belief_prefix = self.belief_prefix
question = sentence[:-1] + "?"
return f"{belief_prefix}" \
f"Q: {question}\n" \
f"A:"
def create_Q_prompt(self, question):
question = question[:-1] + "."
return f"{self.question_prefix}" \
f"Q: {question}\n" \
f"A: This statement is true."
def create_Q_tilde_prompt(self, question):
question = question[:-1] + "."
return f"{self.negation_prefix}" \
f"Q: {question}\n" \
f"A:"
def create_new_Q_tilde_prompt(self, question):
question = question[:-1] + "."
return f"{self.negation_prefix}" \
f"Q: {question}\n" \
f"A:"
def create_nli_prompt(self, premise, hypothesis):
return f"{self.nli_prefix}" \
f"Premise: {premise}\n" \
f"Hypothesis: {hypothesis}\n" \
f"Options: entailment, contradiction, neutral.\n" \
f"A:"