QA
Beginner LevelAI, LLMs, Embeddings & MCP

What causes LLM Hallucinations and how do you mitigate un-grounded responses?

❓ Interview Prompt: Explain why LLMs hallucinate false information, data distribution gaps, and operational techniques to reduce hallucinations.

An LLM Hallucination occurs when a model generates text that sounds authoritative and grammatically correct, but is factually inaccurate, ungrounded, or contradictory.

Root Causes:

1
Probabilistic Autoregression: Models predict the most likely next word, not factual truth.
2
Out-of-Date / Out-of-Domain Training Data: Gaps in pre-training corpora cause models to extrapolate plausible fabrications.

Effective Mitigation Strategies:

•
Retrieval-Augmented Generation (RAG): Force the model to quote directly from retrieved ground truth documents.
•
Lower Temperature: Reduce temperature to 0.0 for factual tasks.
•
System Instructions: Instruct the model: "If the answer cannot be found in the provided context, state 'I do not know'".

Code Implementation Example

typescript
const antiHallucinationSystemPrompt = "You are a strict technical assistant.\n" +
"Rules:\n" +
"1. Answer questions ONLY using the provided facts in the Context section.\n" +
"2. If the context does not contain the answer, reply EXACTLY with: 'Information not found in context.'\n" +
"3. Do NOT use outside knowledge or make assumptions.";
💡Anti-hallucination system prompt enforcing strict context grounding.
🎯 Interview Key Takeaway

Mitigate hallucinations by using RAG, setting temperature to 0.0, and instructing models to refuse ungrounded questions.

#Hallucination#RAG#Prompting#Beginner
Back to all AI, LLMs, Embeddings & MCP Questions→

More AI, LLMs, Embeddings & MCP Interview Questions

Beginner LevelAI, LLMs, Embeddings & MCP

What are Vector Embeddings and Cosine Similarity in AI Semantic Search?

Beginner LevelAI, LLMs, Embeddings & MCP

What is the Model Context Protocol (MCP) and how does it connect LLMs to external tools?

Beginner LevelAI, LLMs, Embeddings & MCP

What is Retrieval-Augmented Generation (RAG) and how does it prevent LLM hallucinations?