mirror of
https://github.com/dair-ai/Prompt-Engineering-Guide
synced 2024-11-18 03:25:39 +00:00
94 lines
6.1 KiB
Plaintext
94 lines
6.1 KiB
Plaintext
# Identifizieren von Halluzination in LLM-Antworten
|
||
|
||
import { Tabs, Tab } from 'nextra/components';
|
||
import { Callout } from 'nextra/components';
|
||
|
||
## Hintergrund
|
||
|
||
Der folgende Prompt testet die Fähigkeit eines LLMs, Halluzinationen im Kontext von [geschlossenen Frage-Antwort-Systemen](/question-answering/closed-domain) zu identifizieren. Bubeck et al. (2023) legen nahe, dass LLMs wie GPT-4 genutzt werden können, um Halluzinationen zu erkennen.
|
||
|
||
<Callout type="warning" emoji="⚠️">
|
||
Beachten Sie, dass aufgrund der herausfordernden Natur der Aufgabe
|
||
LLMs wahrscheinlich halluzinieren werden, wenn sie kein Wissen oder
|
||
keinen Kontext zur Frage haben.
|
||
</Callout>
|
||
|
||
Der Prompt wurde leicht modifiziert, um Indikatoren einzuschließen, die zeigen, welchen Abschnitten des Prompts welche Informationen entsprechen.
|
||
|
||
## Prompt
|
||
|
||
```markdown
|
||
Patientenfakten:
|
||
|
||
- 20-jährige weibliche Person
|
||
- mit einer Vorgeschichte von Anorexia nervosa und Depression
|
||
- Blutdruck 100/50, Puls 50, Größe 5’5’’
|
||
- von ihrem Ernährungsberater überwiesen, aber leugnet ihre Krankheit
|
||
- berichtet, gut zu essen, ist jedoch stark untergewichtig
|
||
|
||
Frage: Bitte schreibe die obenstehenden Daten in eine medizinische Notiz um, unter ausschließlicher Verwendung der oben genannten Informationen.
|
||
|
||
GPT-4-Antwort: 20-jährige Patientin mit einer Vorgeschichte von Anorexia nervosa und Depression wurde von ihrem Ernährungsberater zur Bewertung und Behandlung ihrer Essstörung überwiesen. Sie leugnet jegliche Probleme mit ihren Essgewohnheiten oder ihrem Körperbild und behauptet, normal zu essen. Jedoch ist sie für ihre Größe (BMI 16,6) stark untergewichtig und weist Anzeichen von Mangelernährung auf, wie niedrigen Blutdruck (100/50) und Bradykardie (Puls 50). Zudem berichtet sie, sich depressiv und hoffnungslos zu fühlen. Sie ist gefährdet für ernsthafte medizinische Komplikationen, wie Herzrhythmusstörungen, Elektrolytungleichgewichte, Osteoporose und Unfruchtbarkeit. Sie benötigt dringend psychiatrische und medizinische Intervention, um ihre Anorexia nervosa und Depression zu adressieren.
|
||
|
||
Bitte lesen Sie die obige medizinische Notiz und überprüfen Sie, dass jede Behauptung genau in den Patientenfakten enthalten ist. Melden Sie jegliche Informationen, die nicht in der Liste der Patientenfakten enthalten sind.
|
||
```
|
||
|
||
## Code / API
|
||
|
||
<Tabs items={['GPT-4 (OpenAI)', 'Mixtral MoE 8x7B Instruct (Fireworks)']}>
|
||
<Tab>
|
||
|
||
```python
|
||
from openai import OpenAI
|
||
client = OpenAI()
|
||
|
||
response = client.chat.completions.create(
|
||
model="gpt-4",
|
||
messages=[
|
||
{
|
||
"role": "user",
|
||
"content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list."
|
||
}
|
||
],
|
||
temperature=1,
|
||
max_tokens=250,
|
||
top_p=1,
|
||
frequency_penalty=0,
|
||
presence_penalty=0
|
||
)
|
||
```
|
||
</Tab>
|
||
|
||
<Tab>
|
||
```python
|
||
import fireworks.client
|
||
fireworks.client.api_key = "<FIREWORKS_API_KEY>"
|
||
completion = fireworks.client.ChatCompletion.create(
|
||
model="accounts/fireworks/models/mixtral-8x7b-instruct",
|
||
messages=[
|
||
{
|
||
"role": "user",
|
||
"content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list.",
|
||
}
|
||
],
|
||
stop=["<|im_start|>","<|im_end|>","<|endoftext|>"],
|
||
stream=True,
|
||
n=1,
|
||
top_p=1,
|
||
top_k=40,
|
||
presence_penalty=0,
|
||
frequency_penalty=0,
|
||
prompt_truncate_len=1024,
|
||
context_length_exceeded_behavior="truncate",
|
||
temperature=0.9,
|
||
max_tokens=4000
|
||
)
|
||
```
|
||
</Tab>
|
||
|
||
</Tabs>
|
||
|
||
## Referenz
|
||
|
||
- [Sparks of Artificial General Intelligence: Early experiments with GPT-4](https://arxiv.org/abs/2303.12712) (13. April 2023)
|