Skip to content

    LLM Hallucinations & Evaluation

    AI · Advanced

    Definition

    Hallucinations are confident but false LLM outputs; evaluation measures accuracy, grounding and safety.

    Reliable AI products must detect and reduce hallucinations.

    Diagram

    question→ answer→ compare truth

    Flowchart

    Build test setRun modelScore vs referencesCheck grounding in sourcesIterate prompts/RAG

    Example: Exact-match score

    pred = ['Paris', 'Delhi', 'Rome']
    gold = ['Paris', 'Mumbai', 'Rome']
    print(round(sum(p == g for p, g in zip(pred, gold)) / 3, 3))

    Output: 0.667

    Key points

    • RAG and citations reduce hallucinations
    • Lower temperature gives more consistent answers

    Interview questions

    Why do LLMs hallucinate?

    They predict likely text, not verified facts.

    More AI topics