Skip to content

Commit

Permalink
Update template.py (#1096)
Browse files Browse the repository at this point in the history
* Update template.py

* Update hallucination.md

* Update hallucination.md
  • Loading branch information
jverre authored Jan 21, 2025
1 parent 7b59c2c commit 8a665a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ The template uses a few-shot prompting technique to detect hallucinations. The t
Guidelines:
1. The OUTPUT must not introduce new information beyond what's provided in the CONTEXT.
2. The OUTPUT must not contradict any information given in the CONTEXT.
3. Ignore the INPUT when evaluating faithfulness; it's provided for context only.
4. Consider partial hallucinations where some information is correct but other parts are not.
5. Pay close attention to the subject of statements. Ensure that attributes, actions, or dates are correctly associated with the right entities (e.g., a person vs. a TV show they star in).
6. Be vigilant for subtle misattributions or conflations of information, even if the date or other details are correct.
7. Check that the OUTPUT doesn't oversimplify or generalize information in a way that changes its meaning or accuracy.
3. The OUTPUT should not contradict well-established facts or general knowledge.
4. Ignore the INPUT when evaluating faithfulness; it's provided for context only.
5. Consider partial hallucinations where some information is correct but other parts are not.
6. Pay close attention to the subject of statements. Ensure that attributes, actions, or dates are correctly associated with the right entities (e.g., a person vs. a TV show they star in).
7. Be vigilant for subtle misattributions or conflations of information, even if the date or other details are correct.
8. Check that the OUTPUT doesn't oversimplify or generalize information in a way that changes its meaning or accuracy.
Verdict options:
- "{FACTUAL_VERDICT}": The OUTPUT is entirely faithful to the CONTEXT.
- "{HALLUCINATION_VERDICT}": The OUTPUT contains hallucinations or unfaithful information.
Analyze the text thoroughly and assign a hallucination score between 0 and 1, where:
- 0.0: The OUTPUT is entirely faithful to the CONTEXT
- 1.0: The OUTPUT is entirely unfaithful to the CONTEXT
{examples_str}
Expand All @@ -71,13 +72,10 @@ CONTEXT:
OUTPUT:
{output}
Provide your verdict in JSON format:
It is crucial that you provide your answer in the following JSON format:
{{
"{VERDICT_KEY}": <your verdict>,
"{REASON_KEY}": [
<list your reasoning as bullet points>
]
"score": <your score between 0.0 and 1.0>,
"reason": ["reason 1", "reason 2"]
}}
Reasons amount is not restricted. Output must be JSON format only.
```

with `HALLUCINATION_VERDICT` being `hallucinated`, `FACTUAL_VERDICT` being `factual`, `VERDICT_KEY` being `verdict`, and `REASON_KEY` being `reason`.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class FewShotExampleHallucination(TypedDict):
Guidelines:
1. The OUTPUT must not introduce new information beyond what's provided in the CONTEXT.
2. The OUTPUT must not contradict any information given in the CONTEXT.
2. The OUTPUT should not contradict well-established facts or general knowledge.
3. Ignore the INPUT when evaluating faithfulness; it's provided for context only.
4. Consider partial hallucinations where some information is correct but other parts are not.
5. Pay close attention to the subject of statements. Ensure that attributes, actions, or dates are correctly associated with the right entities (e.g., a person vs. a TV show they star in).
6. Be vigilant for subtle misattributions or conflations of information, even if the date or other details are correct.
7. Check that the OUTPUT doesn't oversimplify or generalize information in a way that changes its meaning or accuracy.
3. The OUTPUT should not contradict well-established facts or general knowledge.
4. Ignore the INPUT when evaluating faithfulness; it's provided for context only.
5. Consider partial hallucinations where some information is correct but other parts are not.
6. Pay close attention to the subject of statements. Ensure that attributes, actions, or dates are correctly associated with the right entities (e.g., a person vs. a TV show they star in).
7. Be vigilant for subtle misattributions or conflations of information, even if the date or other details are correct.
8. Check that the OUTPUT doesn't oversimplify or generalize information in a way that changes its meaning or accuracy.
Analyze the text thoroughly and assign a hallucination score between 0 and 1, where:
- 0.0: The OUTPUT is entirely faithful to the CONTEXT
Expand Down

0 comments on commit 8a665a7

Please sign in to comment.