You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: deepeval/metrics/contextual_relevancy/template.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -55,12 +55,10 @@ def generate_verdicts(
55
55
# Conditional instructions based on mode
56
56
extraction_instructions=""
57
57
ifmultimodal:
58
-
extraction_instructions=textwrap.dedent(
59
-
"""
58
+
extraction_instructions=textwrap.dedent("""
60
59
If the context is textual, you should first extract the statements found in the context if the context, which are high level information found in the context, before deciding on a verdict and optionally a reason for each statement.
61
60
If the context is an image, `statement` should be a description of the image. Do not assume any information not visibly available.
62
-
"""
63
-
).strip()
61
+
""").strip()
64
62
else:
65
63
extraction_instructions="You should first extract statements found in the context, which are high level information found in the context, before deciding on a verdict and optionally a reason for each statement."
Copy file name to clipboardExpand all lines: deepeval/metrics/faithfulness/template.py
+8-16Lines changed: 8 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -93,8 +93,7 @@ def generate_verdicts(
93
93
):
94
94
example_section=""
95
95
ifmultimodal:
96
-
example_section=textwrap.dedent(
97
-
"""
96
+
example_section=textwrap.dedent("""
98
97
Example retrieval contexts: "Einstein won the Nobel Prize for his discovery of the photoelectric effect. Einstein won the Nobel Prize in 1968. Einstein is a German Scientist."
99
98
Example claims: ["Barack Obama is a caucasian male.", "Zurich is a city in London", "Einstein won the Nobel Prize for the discovery of the photoelectric effect which may have contributed to his fame.", "Einstein won the Nobel Prize in 1969 for his discovery of the photoelectric effect.", "Einstein was a German chef."]
100
99
@@ -123,11 +122,9 @@ def generate_verdicts(
123
122
]
124
123
}}
125
124
===== END OF EXAMPLE ======
126
-
"""
127
-
)
125
+
""")
128
126
129
-
format_instruction=textwrap.dedent(
130
-
"""
127
+
format_instruction=textwrap.dedent("""
131
128
Expected JSON format:
132
129
{{
133
130
"verdicts": [
@@ -144,31 +141,26 @@ def generate_verdicts(
144
141
}}
145
142
]
146
143
}}
147
-
"""
148
-
)
144
+
""")
149
145
150
146
guidelines=""
151
147
ifmultimodal:
152
-
guidelines=textwrap.dedent(
153
-
"""
148
+
guidelines=textwrap.dedent("""
154
149
The length of 'verdicts' SHOULD BE STRICTLY EQUAL to that of claims.
155
150
You DON'T have to provide a reason if the answer is 'yes'.
156
151
ONLY provide a 'no' answer if the retrieval context DIRECTLY CONTRADICTS the claims. YOU SHOULD NEVER USE YOUR PRIOR KNOWLEDGE IN YOUR JUDGEMENT.
157
152
Claims made using vague, suggestive, speculative language such as 'may have', 'possibility due to', does NOT count as a contradiction.
158
153
Claims that is not backed up due to a lack of information/is not mentioned in the retrieval contexts MUST be answered 'idk', otherwise I WILL DIE.
159
154
If there are clear contradictions or any data or images that's not mentioned in the retrieval context, just provide 'no'.
160
-
"""
161
-
)
155
+
""")
162
156
else:
163
-
guidelines=textwrap.dedent(
164
-
"""
157
+
guidelines=textwrap.dedent("""
165
158
Generate ONE verdict per claim - length of 'verdicts' MUST equal number of claims.
166
159
No 'reason' needed for 'yes' verdicts.
167
160
Only use 'no' if retrieval context DIRECTLY CONTRADICTS the claim - never use prior knowledge.
168
161
Use 'idk' for claims not backed up by context OR factually incorrect but non-contradictory - do not assume your knowledge.
169
162
Vague/speculative language in claims (e.g. 'may have', 'possibility') does NOT count as contradiction.
170
-
"""
171
-
)
163
+
""")
172
164
173
165
returntextwrap.dedent(
174
166
f"""Based on the given claims, which is a list of strings, generate a list of JSON objects to indicate whether EACH claim contradicts any facts in the retrieval context. The JSON will have 2 fields: 'verdict' and 'reason'.
Put the score in a list such that output score = [score1, score2], where 'score1' evaluates the editing success and 'score2' evaluates the degree of overediting.
0 commit comments