0Pricing
Prompt Engineering & LLM Optimization for Developers · Lektion

Halluzinationen erkennen und abmildern

Halluzinationen sind selbstbewusst formulierte, aber falsche LLM-Ausgaben. Lernen Sie, warum sie entstehen, wie Sie sie erkennen und mit welchen konkreten Techniken Sie sie in der Produktion reduzieren

Halluzinationen erkennen und abmildern ist eine kostenlose Prompt Engineering & LLM Optimization for Developers-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Prompt Engineering & LLM Optimization for Developers-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Prompt Engineering & LLM Optimization for Developers-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

What is a Hallucination?

A hallucination is when an LLM produces text that is fluent and confident but factually wrong or unsupported by any source.

Because the output looks authoritative, hallucinations are dangerous in user-facing apps.

Why They Happen

LLMs predict the most likely next token, not the truth. With no grounding, they fill gaps with plausible-sounding inventions.

  • Missing knowledge in training data
  • Ambiguous or leading prompts
  • Pressure to always answer

Types of Hallucination

Two broad categories:

  • Factual: wrong dates, fake citations, invented APIs
  • Faithfulness: answer contradicts the provided context (common in RAG)

Grounding with Context

The strongest defense is grounding: give the model trusted source text and instruct it to answer only from that text.

Answer ONLY using the context below.
If the answer is not in the context, say "I do not know".

Context:
{retrieved_docs}

Forcing Citations

Ask the model to cite which passage supports each claim. Unsupported sentences become easy to spot and verify.

For each sentence, add a [doc_id] citation.
Do not make claims you cannot cite.

Lowering Temperature

Higher temperature increases creativity — and invention. For factual tasks, set a low temperature so the model stays close to high-probability, well-grounded tokens.

const res = await client.chat.completions.create({
  model: "gpt-4o-mini",
  temperature: 0,
  messages
});

Self-Consistency Checks

Generate the answer several times. If the model gives different facts each run, the claim is likely a hallucination. Agreement is a weak but useful signal of reliability.

LLM-as-a-Judge Verification

Use a second model call to check whether the answer is supported by the context. The judge returns a faithfulness verdict you can act on.

Does the ANSWER follow only from the CONTEXT?
Reply: SUPPORTED, PARTIAL, or UNSUPPORTED.

Programmatic Validation

When outputs are structured, validate them. A cited URL should resolve, a quoted number should match the source, a JSON field should match a schema.

function validateCitation(cit, docs) {
  return docs.some(d => d.id === cit.doc_id);
}

Letting the Model Abstain

Give the model permission to say I do not know. Removing the pressure to always answer measurably reduces fabricated content.

Human Review for High Stakes

For medical, legal, or financial outputs, route low-confidence or uncited answers to a human before showing them to users. Automation plus oversight beats either alone.

Quick Check

Test your understanding.

Recap

You learned to fight hallucinations: ground answers in trusted context, force citations, lower temperature, use self-consistency and LLM-as-a-judge checks, validate outputs programmatically, allow abstention, and add human review for high-stakes cases.

Häufig gestellte Fragen

Ist die Lektion „Halluzinationen erkennen und abmildern“ kostenlos?

Ja — der vollständige Text von „Halluzinationen erkennen und abmildern“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Prompt Engineering & LLM Optimization for Developers-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Prompt Engineering & LLM Optimization for Developers-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Halluzinationen erkennen und abmildern“?

Halluzinationen sind selbstbewusst formulierte, aber falsche LLM-Ausgaben. Lernen Sie, warum sie entstehen, wie Sie sie erkennen und mit welchen konkreten Techniken Sie sie in der Produktion reduzier… Du übst Prompt Engineering & LLM Optimization for Developers mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Prompt Engineering & LLM Optimization for Developers zu starten?

Keine Vorkenntnisse erforderlich. Prompt Engineering & LLM Optimization for Developers auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Halluzinationen erkennen und abmildern“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Prompt Engineering & LLM Optimization for Developers-Lektion Code schreiben und ausführen?

Ja. Jede Prompt Engineering & LLM Optimization for Developers-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. LLM-Evaluationsmetriken und Benchmarks
  2. Feedbacksysteme mit Human-in-the-Loop
  3. Prompt Injection und Best Practices für Sicherheit
  4. Halluzinationen erkennen und abmildern
← Zurück zu Prompt Engineering & LLM Optimization for Developers