4.4.15 · HinglishAlignment, Prompting & RAG

Hallucination mitigation

1,943 words9 min readRead in English

4.4.15 · AI-ML › Alignment, Prompting & RAG


Hallucination KYA hoti hai?

Do flavors jo aapko alag karne chahiye:

Type Fails against Example Main fix
Factuality real-world truth "The capital of Australia is Sydney" Retrieval (RAG), better data
Faithfulness the given context Doc kehta hai 2019; model kehta hai 2021 Grounding + citations

LLMs hallucinate KYUN karte hain?


Isse KAISE measure karein (taaki reduce kar sakein)

Hum model ko claims ke classifier ke roop mein treat karte hain {supported, unsupported} mein.

Figure — Hallucination mitigation

Mitigation toolbox (80/20 impact ke order mein)

1. Retrieval-Augmented Generation (RAG)

Retrieved passages ko prompt mein inject karo aur instruct karo: "Answer sirf context use karke do; agar present nahi hai, toh kaho ki pata nahi." Yeh ek factuality task ko ek faithfulness task mein convert karta hai, jo enforce aur audit karna kaafi aasaan hai (citations ke through). Dekho RAG pipeline.

2. Citations / quote-then-answer force karo

[source] tags require karo. Ungrounded claims visibly uncited ho jaati hain → filter karna easy.

3. Factual tasks ke liye temperature kam karo

decoding ko near-greedy bana deta hai, low-probability invented tokens kaat deta hai.

4. Self-consistency

answers sample karo; majority answer rakho. Hallucinations aksar samples mein unstable hoti hain, truths stable hoti hain.

5. Self-check / chain-of-verification (CoVe)

Model draft karta hai → verification questions generate karta hai → unhe independently answer karta hai → revise karta hai. Independence isse rok deti hai ki woh sirf apni galti ko re-justify na kare.

6. Calibrated abstention

Model ko train/prompt karo ki jab evidence missing ho toh "I don't know" output kare; upar wale risk–coverage curve se threshold set karo.


Worked examples


Common mistakes (Steel-man → Fix)


Active recall

Recall Quick self-test (chhupaao, phir jawab do)
  • Factuality aur faithfulness hallucination mein kya difference hai?
  • LLMs mein high confidence correct hone ki guarantee kyun nahi deta?
  • Abstention threshold badhane se risk aur coverage par kya effect padta hai?
  • Answers ko atomic claims mein kyun decompose karte hain?
Recall Feynman: ek 12-saal ke bacche ko samjhao

Ek bahut tez storyteller ki imagine karo jo kabhi stuck nahi dikhna chahta. Kuch bhi pucho aur woh turant ek smooth answer deta hai — jab woh actually jaanta bhi nahi, toh woh sirf kuch aisa bana deta hai jo sahi lagta hai. Woh bana hua hissa ek "hallucination" hai. Isko rokne ke liye hum teen cheezein karte hain: (1) pehle isko answer book de do (retrieval) aur kaho "sirf yahi use karo"; (2) isse apne sources dikhwao taaki hum invented bits pakad sakein; (3) isko "I'm not sure" kehne do guess karne ki jagah. Hum usi question ko kai baar bhi poochte hain — sahi answer same rehta hai, bana hua answer baar baar badalta hai, toh hum fake pakad lete hain.


Flashcards

LLM hallucination kya hoti hai?
Ek fluent, confident output jo factually galat hai ya given context se unsupported hai, kyunki model true tokens ki jagah likely tokens predict karta hai.
Factuality vs faithfulness hallucination?
Factuality real-world truth ko contradict karta hai; faithfulness provided source/context ko contradict karta hai.
N atomic claims ke saath C supported ke liye hallucination rate ka formula?
(N − C)/N.
Self-consistency hallucinations kyun reduce karta hai?
Sahi facts samples mein stable hoti hain jabki fabrications vary karti hain, toh majority voting unstable galat answers filter kar deta hai.
Abstention threshold τ badhane ka effect?
Coverage kam hoti hai (kum jawab diye) aur selective risk kam hoti hai (jawab diye gaye mein kum errors).
RAG hallucinations poori tarah kyun eliminate nahi karta?
Model context ko ignore/misread kar sakta hai (faithfulness failure) ya retriever galat passages fetch kar sakta hai.
Temperature=0 akela insufficient kyun hai?
Yeh sampling-based errors hatata hai lekin knowledge-gap errors nahi — yeh confidently single most likely galat answer return karta hai.
Chain-of-Verification (CoVe) ki core idea?
Draft → verification questions generate karo → unhe independently answer karo → revise karo, taaki model apni galti ko re-justify na kare.
Scoring ke liye answers ko atomic claims mein kyun decompose karte hain?
Taaki ek false claim true ones mein chup na jaaye; aapko ek granular faithfulness fraction milta hai (FActScore).
Selective risk ki definition?
Error rate sirf un questions par calculate kiya gaya jinhe model ne answer karna choose kiya (confidence ≥ τ).

Connections

  • RAG pipeline — primary grounding mechanism
  • Prompt engineering — "sirf context se answer do / I don't know kaho"
  • RLHF and alignment — models over-confident kyun ho jaate hain aur abstention train kaise karein
  • Model calibration — raw confidence ko trustworthy uncertainty mein kaise badlein
  • Chain-of-thought reasoning — reasoning + verification steps
  • Evaluation metrics for LLMs — FActScore, risk–coverage curves

Concept Map

not a

always outputs

when ungrounded

type 1

type 2

fixed by

fixed by

caused by

measured by

decomposed via

reduced by

trade-off

LLM next-token predictor

Truth database

Plausible-sounding text

Hallucination

Factuality error vs world

Faithfulness error vs context

Retrieval RAG

Grounding + citations

Objective mismatch, gaps, no IDK, decoding

HallucinationRate = N-C over N

FActScore atomic claims

Abstention above threshold tau

Risk vs Coverage