RAG (Retrieval Augmented Generation) interview questions & answers
133+ real RAG (Retrieval Augmented Generation) interview questions with model answers, plus free lessons to learn the concepts. Prepare in English & Hinglish, then practise with an AI mock interview.
11 topics · 133+ questions
Hirenix kaise padhata hai
Ek chapter. 90 minute.
Interview ke liye taiyaar.
Har concept ek real-world problem se — jaisa production code mein aata hai, waisa. Ratna nahi padta, samajh aa jaata hai. Har question ka model answer diya hai: interviewer ko exactly kya bolna hai, aur kyun. Phir usi chapter ka AI mock interview.
- 📖Concept, 5 min meinJargon nahi — seedhi baat
- 🛠️Real-world problemJaisa production code mein aata hai
- 💬Model answerInterview mein kya bolna hai
- 🧠FlashcardsRevision 10 min mein
- 🤖AI mock interviewFollow-up bhi poochta hai
- 📊Weak topicsKahan phans rahe ho, pata chale

Farq content ka nahi, filter ka hai — sirf wahi jo production mein actually use hota hai aur interview mein actually poocha jaata hai. Kitaabi topics jo industry mein kahin nahi chalte, wo yahan nahi milenge.
What you’ll learn
- ●RAG kya hai?
- ●RAG vs fine-tuning
- Document loadersFree account
- Text splitting aur chunkingFree account
- Retrieval strategiesFree account
- Re-rankingFree account
- RAG evaluationFree account
- Advanced RAG techniquesFree account
- Conversational RAGFree account
- RecapFree account
- ●Project: AI Document Q&A Bot
RAG kya hai?
LLM ko ek brilliant student samajh jisne closed-book exam diya hai — internet ke bade dher se train hua hai ek cutoff date tak, aur uske baad training ruk gayi. Usse bahut saari general baatein pata hain, par usne tera company ka HR manual, tere private PDFs, ya training ke baad hui koi bhi cheez kabhi nahi dekhi. Us knowledge ke bahar kuch poocho toh ya toh bolega "mujhe nahi pata", ya usse bhi bura — confidently kuch bana ke bol dega (hallucination).
RAG me, model ne jo yaad kiya hai sirf usi pe depend karne ke bajaye, tu usse ek open-book exam deta hai: jawab dene se pehle, tu TERE documents se relevant pages nikaal ke sawaal ke saath model ko de deta hai. RAG ka matlab hai Retrieve → Augment → Generate: apne data se relevant chunks retrieve karo, unse prompt ko augment (badhao) karo, fir LLM ko us context ke basis pe grounded answer generate karne do. Model ke weights kabhi nahi badalte — tu sirf prompt me kya jaa raha hai wo badal raha hai.
RAG ke do alag phases hote hain. Indexing (offline, ek baar, ya jab bhi documents change hon): documents load karo → chunks me split karo → har chunk embed karo (Ch3) → vectors ko vector DB me store karo (Ch3 — ChromaDB/Pinecone/pgvector). Query (online, har question pe): user ke question ko embed karo → vector DB se top-k nearest chunks retrieve karo → un chunks + question ko context bana ke prompt banao → LLM final answer generate karta hai.
Sirf retrieval hallucination rokne ke liye kaafi nahi hai — tujhe ek grounding prompt bhi chahiye. Ye ek system instruction hai jo model ko bolta hai: "Sirf neeche diye context se answer do. Agar context me answer nahi hai, toh bolo ki tumhare paas ye information nahi hai — guess mat karo." Isko citations ke saath jodo: batao ki answer kis chunk se aaya, taaki user (ya interviewer) usse verify kar sake. Ye grounding + citation combo hi RAG ka anti-hallucination core hai, aur yahi RAG ke answer ko ek confident guess se better, trustworthy banata hai.
🌍 Real-world example: Ek plain LLM se poocho "meri company ki annual leave policy kya hai?" toh wo ek generic number guess karega ya bolega usse pata nahi. Actual HR policy text ko context ke roop me grounding prompt ke saath do, toh wo sahi se "24 days" bolega — aur ye bhi bata dega ki ye exactly kis document se aaya.
💡 RAG = Retrieval Augmented Generation — apne data se relevant text retrieve karke prompt me daal do, taaki LLM un facts se answer de jo usne kabhi train nahi kiye the.
💡 Indexing phase = one-time (ya jab bhi data change ho) kaam jisme documents ko searchable vectors me prepare karte hain — chunk, embed, store.
💡 Query phase = har question ke liye ka kaam — question embed karna, matching chunks retrieve karna, aur LLM se unke basis pe answer maangna.
💡 Grounding prompt = ek instruction jo LLM ko sirf diye gaye context se answer karne tak limit karta hai, aur jab answer wahan na ho toh admit karne ko kehta hai — hallucination ke against sabse bada defence.
💡 Citations = user ko batana ki answer ka har hissa kis source chunk/document se aaya, taaki answer verify ho sake.
Standard definition (interview me bolo): RAG (Retrieval Augmented Generation) is a technique where relevant text is retrieved from an external knowledge source and inserted into the LLM's prompt as context before generation, so the model answers using up-to-date or private data it was never trained on, without changing the model's weights.
from openai import OpenAI
import chromadb
client = OpenAI()
chroma = chromadb.PersistentClient(path="./rag_db")
collection = chroma.get_or_create_collection("company_docs")
# ============================
# INDEXING PHASE (run once)
# ============================
documents = [
"Annual leave policy: Every employee gets 24 days of annual leave per year.",
"Sick leave: Employees are entitled to 12 days of sick leave annually.",
"Work from home: WFH is allowed 2 days per week with manager approval.",
]
collection.add(documents=documents, ids=[f"doc_{i}" for i in range(len(documents))])
# ============================
# QUERY PHASE (run per question)
# ============================
def ask(question):
# RETRIEVE: nearest chunks from Ch3's vector search
results = collection.query(query_texts=[question], n_results=2)
chunks = results["documents"][0]
# AUGMENT: grounding prompt + citations
context = "\n".join(f"[{i+1}] {c}" for i, c in enumerate(chunks))
prompt = f"""Answer ONLY using the context below. If the answer is not in
the context, say "I don't have this information in the documents."
Cite the source number(s) you used, like [1].
Context:
{context}
Question: {question}
Answer:"""
# GENERATE: grounded answer
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],
temperature=0,
)
return response.choices[0].message.content
print(ask("How many annual leaves do I get?"))
print(ask("What is the CEO's name?"))RAG vs fine-tuning
LLM ko ek naye employee ki tarah socho. Unhe better banane ke do bilkul alag tareeke hain: unhe ek reference folder de do jise wo har sawaal se pehle palat sake, ya unhe ek training course pe bhej do jo unke sochne aur bolne ka tareeka hi badal de. RAG wo reference folder hai. Fine-tuning wo training course hai.
Gen AI me, RAG (Retrieval Augmented Generation, Ch4) query time pe tere documents se relevant text nikaal ke prompt me paste kar deta hai — model ke weights kabhi change nahi hote, sirf wo kya padhta hai wo change hota hai. Fine-tuning iska ulta karta hai: tu model ke weights ko hazaaron labelled examples pe retrain karta hai taaki uska underlying behaviour permanently change ho jaaye — answer time pe extra documents ki zaroorat nahi.
Decision framework simple hai jab tu EK sawaal poochta hai: problem missing knowledge hai, ya galat behaviour?
- Missing knowledge ("model ko humari refund policy / aaj ki price list / ye naya law nahi pata") -> RAG. Facts jo baar-baar change hote hain, jinhe source tak trace karna zaroori hai, aur jinke liye har document change pe retrain nahi karna chahiye.
- Galat behaviour ("model ko facts pata hain lekin humare exact tone / JSON schema / medical-report format / rare domain jargon me reply nahi karta") -> fine-tuning. Style, structure, aur consistency jo akela prompt har baar lock karne me struggle karta hai.
🌍 Real-world example: Ek hospital chatbot ko (a) ISI hafte ki bed-availability sheet se answer dena hai — ye RAG hai, kyunki data daily change hota hai aur har answer source ke against check-able hona chahiye — aur (b) hamesha ek strict clinical-note format me reply karna hai jo hospital ki compliance team ne approve kiya hai — ye fine-tuning ka candidate hai, kyunki har answer ka shape identical hona chahiye, sirf facts nahi.
💡 Knowledge vs behaviour = sabse important lens: RAG facts ko context me inject karta hai; fine-tuning ek skill/style ko weights me bake karta hai. 💡 Grounding / citations = RAG ek fact exactly kis chunk/document se aaya ye point kar sakta hai; fine-tuned model nahi kar sakta — ek baar fact weights me bake ho jaaye toh koi "source" cite karne ke liye bacha nahi rehta. 💡 Update speed = RAG document re-index karte hi update ho jaata hai (minutes); fine-tuning ko ek fact bhi change karne ke liye naya labelled dataset aur retraining run chahiye (hours se days).
Standard definition (interview me bolo): RAG changes what the model reads (retrieved context injected into the prompt, weights untouched) to add or refresh knowledge cheaply and with citations; fine-tuning changes what the model is (weights retrained on labelled examples) to change behaviour, tone, or output format permanently — the two solve different problems and are often combined, and most real systems should start with a well-prompted RAG pipeline before ever considering fine-tuning.
Comparison table
| Dimension | RAG | Fine-tuning |
|---|---|---|
| Fixes | Missing/changing knowledge | Galat behaviour, tone, format |
| Cost | Kam — embedding + vector DB | Zyada — GPU training + MLOps |
| Update speed | Minutes (document re-index) | Hours se days (retrain) |
| Citations / traceability | Haan — exact source chunk cite kar sakte ho | Nahi — facts weights me bake ho jaate hain |
| Data chahiye | Tumhare existing documents | Sainkdo-hazaaron labelled examples |
| Naye/changing facts handle karta hai | Haan, natively | Kharab — har baar retrain chahiye |
| Consistent style/format lock karta hai | Weak — prompt discipline pe depend karta hai | Strong — model ka default ban jaata hai |
| Hallucination risk | Kam (retrieved text me grounded) | Base model jitna hi, jab tak RAG bhi na add ho |
Jab dono me se kuch bhi na use karo
Agar model ko already facts pata hain AUR wo already sahi style me output deta hai, toh shayad tumhe sirf behtar prompting chahiye — ek clearer system prompt, kuch few-shot examples, ya ek strict output-format instruction. RAG ya fine-tuning try karne se pehle ek achhe se likhe prompt ko try karo; ye sabse sasta lever hai aur aksar 80% "model wo nahi kar raha jo main chahta hoon" cases solve kar deta hai.
Jab dono ko combine karo
Bohot saare production systems dono use karte hain: model ko chhote se example-set pe fine-tune karo taaki wo hamesha tumhare exact tone/format/domain jargon me reply kare, AUR RAG use karo taaki wo hamesha fresh, citable facts se answer de. Fine-tuning kaise handle karta hai; RAG kya handle karta hai.
One-line interview answer: "Start with RAG; fine-tune only when prompting + RAG can't get you the behaviour you need — and even then the two are often combined, not either/or."
Project: AI Document Q&A Bot
Kya bana rahe hain: Ek real AI Document Q&A Bot — koi bhi PDF upload karo, plain English mein uske baare mein sawaal poochho, grounded answers milte hain neeche exact source snippets ke saath. Ye wahi project hai jismein is chapter ke saare RAG interview questions (chunking, embeddings, retrieval, grounding, citations) ek saath aate hain. Tech stack: Streamlit (UI) + pypdf (text extraction) + ChromaDB (vector store, Ch3 se) + OpenAI (embeddings + chat).
Step 0 — Poora pipeline, end to end (pehle padho)
User PDF upload karta hai
-> pypdf raw text extract karta hai
-> text splitter use chunk karta hai (size 500, overlap 100)
-> OpenAI har chunk ko embed karta hai
-> ChromaDB vectors store karta hai
-> user ek sawaal type karta hai
-> sawaal embed hota hai
-> ChromaDB top-5 nearest chunks return karta hai
-> chunks + sawaal ek grounding prompt mein jaate hain
-> LLM sirf us context se answer deta hai
-> answer + source snippets user ko dikhte hain
Neeche har step us chain ka ek link hai — notice karo har step agle ko kya hand karta hai.
Step 1 — Uploaded PDF se text extract karo
from pypdf import PdfReader
def load_pdf(file):
reader = PdfReader(file)
text = ""
for page in reader.pages:
text += page.extract_text() + "\n"
return text
Ho ye raha hai: PdfReader(file) uploaded PDF ko open karta hai (Streamlit tumhe seedha ek file-like object deta hai — pehle disk pe save karne ki zaroorat nahi). reader.pages page objects ki list hai; .extract_text() har ek se plain text nikaalta hai. Hum har page ko ek lambe text string mein jod dete hain, beech mein \n daal ke taaki page boundaries pe do words merge na ho jaayein. Step 2 ko hand hota hai: raw document text ka ek bada string.
🌍 Real-world example: ye bilkul wahi hai jo ek company ke policy-document search tool HR handbook ke saath karta hai, ya legal-tech tool contract ke saath karta hai — jo PDF koi padhna nahi chahta, use searchable text bana dena.
Step 2 — Text ko chunk karo (size 500, overlap 100)
from langchain.text_splitter import RecursiveCharacterTextSplitter
def create_chunks(text):
splitter = RecursiveCharacterTextSplitter(
chunk_size=500, chunk_overlap=100
)
return splitter.split_text(text)
Ho ye raha hai: poore PDF ke liye ek hi embedding kisi specific sawaal ka jawab dene ke liye bahut vague hota, isliye hum ~500-character pieces mein split karte hain. chunk_overlap=100 ka matlab hai har chunk pichhle chunk ke last 100 characters repeat karta hai — to koi sentence jo chunk boundary pe aadha kat jaata hai, wo kam se kam ek chunk mein poora rehta hai. Step 3 ko hand hota hai: chunk strings ki ek Python list, jaise ["chunk 0 text...", "chunk 1 text...", ...].
💡 Chunk overlap = wo safety margin jo kisi fact ko chunk boundary pe chupke se lost hone se rokta hai.
Step 3 — Embed karo aur ChromaDB mein store karo
import chromadb
chroma = chromadb.PersistentClient(path="./vectordb")
def store_documents(chunks, collection_name="docs"):
collection = chroma.get_or_create_collection(collection_name)
collection.add(
documents=chunks,
ids=[f"chunk_{i}" for i in range(len(chunks))]
)
return collection
Ho ye raha hai (Ch3 recap, ek line): tumhe already pata hai ChromaDB text ko embeddings mein badalta hai aur similarity search ke liye vectors store karta hai. PersistentClient(path=...) DB ko disk pe save karta hai taaki wo runs ke beech survive kare (sirf memory mein nahi). collection.add(documents=chunks, ...) — plain text pass karo aur Chroma ka default embedding function har chunk ko tumhare liye embed karke vector + original text + ek id store kar deta hai. Step 4 ko hand hota hai: disk pe baitha ek searchable collection, queries ke liye ready.
Step 4 — Ek sawaal ke liye top-5 chunks retrieve karo
def ask_question(question, collection_name="docs"):
collection = chroma.get_collection(collection_name)
results = collection.query(query_texts=[question], n_results=5)
context = "\n---\n".join(results["documents"][0])
Ho ye raha hai: collection.query(query_texts=[question], n_results=5) sawaal ko usi tarah embed karta hai jaise chunks embed hue the, fir un 5 chunks ko return karta hai jinke vectors sabse kareeb hain (cosine similarity, Ch3 se). results["documents"][0] un 5 chunk strings ki list hai; unhe "\n---\n" se jod ke ek context block banta hai jo LLM padh sake. Step 5 ko hand hota hai: ek context string jismein PDF ke 5 sabse relevant slices hain.
Step 5 — Grounding prompt (anti-hallucination core)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": f"""Answer based ONLY on this context.
If not found, say "Not in the documents."
Context:
{context}"""},
{"role": "user", "content": question}
],
temperature=0
)
Ho ye raha hai: ye poore project ki sabse important line hai. system message model ko hard-instruct karta hai: sirf hamara retrieve kiya context use karo, aur jab answer wahaan na ho to admit karo — ye hi cheez LLM ko confidently apni general training knowledge se cheezein bana lene (hallucinate karne) se rokti hai, jo ki tumhare document se alag hoti. temperature=0 answer ko jitna ho sake deterministic/factual banata hai, creative nahi. Step 6 ko hand hota hai: ek response object jiska .choices[0].message.content grounded answer text hai.
🌍 Real-world example: ye exact pattern — pehle retrieve, fir "only from context" instruct karo — har real internal-docs chatbot (Notion AI, company ka HR bot, legal contract assistant) isi tarah non-existent policy invent karne se bachta hai.
Step 6 — Answer WITH source snippets return karo
return {
"answer": response.choices[0].message.content,
"sources": results["documents"][0][:3]
}
Ho ye raha hai: hum sirf answer text return nahi karte — hum wo top 3 raw chunks bhi return karte hain jo answer generate karne mein use hue. Yahi cheez ek black-box answer ko ek trustworthy, citable answer mein badalti hai: user "Sources" expand kar sakta hai aur apni aankhon se dekh sakta hai ki bot apna answer PDF ki kaunsi lines pe base kar raha hai. Step 7 ko hand hota hai: ek dict {answer, sources} jise frontend seedha render kar deta hai.
💡 Source citation = wo exact retrieve kiya gaya text dikhana jahaan se ek claim aayi, taaki user (ya interviewer) verify kar sake ki answer hallucinated nahi hai.
Step 7 — Streamlit UI se wire karo
import streamlit as st
from rag_engine import load_pdf, create_chunks, store_documents, ask_question
st.title("AI Document Q&A Bot")
uploaded_file = st.file_uploader("Upload PDF", type="pdf")
if uploaded_file:
with st.spinner("Processing..."):
text = load_pdf(uploaded_file)
chunks = create_chunks(text)
store_documents(chunks)
st.success(f"Processed! {len(chunks)} chunks created.")
question = st.text_input("Ask a question about your document:")
if question:
result = ask_question(question)
st.write("### Answer:")
st.write(result["answer"])
with st.expander("Sources"):
for i, source in enumerate(result["sources"]):
st.write(f"**Source {i+1}:** {source[:200]}...")
Ho ye raha hai — poori wiring, traced: st.file_uploader tumhe wahi file object deta hai jo Step 1 consume karta hai. Upload karte hi Steps 1-3 trigger hote hain (load_pdf -> create_chunks -> store_documents) ek spinner ke andar, to ChromaDB ek baar, upfront populate ho jaata hai. st.text_input sawaal capture karta hai; har sawaal Steps 4-6 trigger karta hai (ask_question = retrieve + grounding prompt + sources) fresh. Answer aur expandable source list chain ka aakhri link hain — ek backend pipeline ko kuch aisa banate hain jo ek non-technical user actually use aur trust kar sake.
Bonus features (resume/recruiter differentiators)
Base bot prove karta hai ki tum RAG end-to-end wire kar sakte ho. Ye chaar cheezein tumhe har doosre "maine RAG chatbot banaya" resume line se alag karti hain:
- Multi-file upload — kai PDFs accept karo, har chunk ke metadata ko uski source filename se tag karo, taaki citations bataayein ki answer kaunse document se aaya, sirf kaunsa chunk nahi.
- Chat history — pichhle Q&A turns store karo aur recent turns ko prompt mein pass karo, follow-ups handle karne ke liye jaise "aur page 3 pe?" (ye
conversational-raghai, agla topic — query ko standalone question mein rewrite karna). - Cohere re-ranking — pehle wide retrieve karo (jaise top 20) fir cross-encoder se re-rank karke best 5 tak laao prompt banane se pehle, tricky sawaalon pe kaafi better answer quality ke liye.
- Token usage tracking — har call ka
response.usagelog karo taaki tum real cost/latency numbers dikha sako — exactly wo cheez jo ek production team ko matter karti hai, aur ek badhiya interview talking point ("maine apne RAG pipeline ka token spend X% optimize kiya").
Recruiter is project mein kya dekhta hai
- RAG implementation — 2025-26 job postings mein sabse hot applied-AI skill.
- Ek real document processing pipeline — extraction, chunking, embedding, storage, sab wired together.
- Vector database usage — ChromaDB production-shaped code mein, koi toy example nahi.
- Grounding + source attribution — proof ki tum hallucination risk aur uska mitigation samajhte ho, yahi cheez ek junior "maine API call ki" project ko senior-shaped project se alag karti hai.
- Ek working, demoable UI — recruiters wo projects yaad rakhte hain jo wo 30 second mein click through kar sakein; resume mein ek Streamlit link ek GitHub repo se zyada value ka hai jo wo clone nahi karenge.
Standard definition (interview me bolo): The AI Document Q&A Bot is a retrieval-augmented generation application that extracts text from an uploaded PDF, splits it into overlapping chunks, embeds and stores the chunks in a vector database, retrieves the most relevant chunks for a user's question, and generates an answer using a grounding prompt that restricts the LLM to the retrieved context — returning both the answer and the source snippets it was built from.
import chromadb
from openai import OpenAI
from pypdf import PdfReader
from langchain.text_splitter import RecursiveCharacterTextSplitter
client = OpenAI()
chroma = chromadb.PersistentClient(path="./vectordb")
def load_pdf(file):
reader = PdfReader(file)
text = ""
for page in reader.pages:
text += page.extract_text() + "\n"
return text
def create_chunks(text):
splitter = RecursiveCharacterTextSplitter(
chunk_size=500, chunk_overlap=100
)
return splitter.split_text(text)
def store_documents(chunks, collection_name="docs"):
collection = chroma.get_or_create_collection(collection_name)
collection.add(
documents=chunks,
ids=[f"chunk_{i}" for i in range(len(chunks))]
)
return collection
def ask_question(question, collection_name="docs"):
collection = chroma.get_collection(collection_name)
results = collection.query(query_texts=[question], n_results=5)
context = "\n---\n".join(results["documents"][0])
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": f"""Answer based ONLY on this context.
If not found, say "Not in the documents."
Context:
{context}"""},
{"role": "user", "content": question}
],
temperature=0
)
return {
"answer": response.choices[0].message.content,
"sources": results["documents"][0][:3]
}RAG (Retrieval Augmented Generation)interview questions & answers
10 sample questions below — 133+ in the full bank inside.
Conversational RAG ke context me 'standalone question' ka matlab kya hai?
Standalone question woh hoti hai jo apne aap bina kisi pichli conversation context ke samajh aaye. Isme sab information hoti hai jis se retriever accurately search kar sake, jaisse 'What is the sick leave policy?' 'And sick leave?' ke bajaye.
In simple terms: Standalone = self-contained. Agar koi stranger sirf ek question read kare zero background ke saath, samajh aa jaaye. 'And sick leave?' fail hai kyunki stranger ko nahi pata 'and' leave ki baat karne ke liye. 'What is the sick leave policy?' kaam karti hai kyunki poora hai: subject, verb, context — sab ek sentence me.
Plain RAG follow-up questions jaaise 'And sick leave?' handle kyu nahi kar sakta?
Plain RAG query ke exact words ke basis pe retrieve karta hai. Jab tum 'And sick leave?' poochte ho, retriever un literal words ko search karta hai aur usse context nahi hota ki tum leave policy ke baare me puch rahe ho — isliye weak ya irrelevant chunks retrieve hote hain.
In simple terms: Retriever ko librarian samjho jo zero memory ke saath kaam kare. Agar tum bolo 'Mujhe 1930s ki books chahiye' lekin author name mat bolo, librarian ko pata hi nahi ki Agatha Christie ka matlab hai. Example: vector DB me ['and', 'sick', 'leave'] se search karne se medical days wale results aate hain, leave policy nahi.
Conversational RAG me query rewriting (ya query condensation) kya hoti hai?
Query rewriting ek LLM use karke context-dependent follow-up question ko chat history ke base pe ek standalone, self-contained question me convert karta hai. Jaise 'And sick leave?' 'What is the sick leave policy?' ban jaata hai taaki retrieval actually relevant chunks search kar sake.
In simple terms: Imagine librarian ko context yaad dilaane me tum help kar rahe ho. Tum bolo 'Us author se, 1930s wali koi hai?' — toh ek helper usse rewrite karke bolta hai 'Agatha Christie ki jo 1930s ki books hain, kaun-kaun si hain?' librarian search kare usse pehle. Code: `rewritten_q = llm.rewrite(user_follow_up, chat_history)` fir `results = db.search(rewritten_q)`.
Conversational RAG me bounded history kya hoti hai, aur usse kyu use kiya jaata hai?
Bounded history matlab sirf last N turns (jaise last 6 messages) ke chat ko rakhna, puri conversation nahi. Isko use isliye kiya jaata hai taaki token cost aur latency predictable rahe conversation badhne ke saath — har turn pe poori chat LLM ko nahi bhejni padti.
In simple terms: Short-term memory samjho hamesha ke liye recording karne ke bajaye. Agar tumhara 2-hour ka chat hai, agle question ka jawab dene ke liye poori replay nahi karni — bas last kuch exchanges dekh lo. Code: `chat_history[-MAX_HISTORY_TURNS:]` jisme `MAX_HISTORY_TURNS = 6` matlab sirf last 6 messages LLM ko bhejte hain.
HyDE ka matlab kya aur ye kya karta hai?
HyDE ka matlab Hypothetical Document Embeddings. User ke raw question ko embed karne ki jagah, tum ek LLM se sawaal ka hypothetical (fake) answer generate karte ho, us fake answer ko embed karte ho, aur usse vector database search karte ho. Phir fake answer phenk dete ho aur real documents retrieve karte ho.
In simple terms: Ek chhota sawaal 'What is Python?' embedding space me document paragraph jaisa nahi dikhta, par paragraph-style answer 'Python is a high-level language...' dikhta hai. Isliye HyDE ek fake answer banata hai taaki search embedding actual documents jaisa lag jaye. Example: question='Tell me about leave policy', HyDE fake_answer banata hai 'Our company offers 24 days annual leave and 5 days sick leave...', fake answer embed hota hai, aur real policy chunks retrieve hote hain jo un details ko contain karte hain.
Agentic RAG kya hota hai?
Agentic RAG me LLM khud decide karta hai ki search kare, alag query se dobara search kare, ya seedha answer de de, ek fixed one-shot retrieve-then-answer pipeline karne ki jagah. Model ek agent ban jaata hai jo baari-baari soch aur action le sakta hai.
In simple terms: Fixed pipeline ki jagah: (1) query embed karo, (2) chunks retrieve karo, (3) answer do — agentic RAG me LLM tera sawaal dekh ke decide karta hai: 'Mujhe documents chahiye' ya 'Mujhe pehle se pata hai' ya 'Mera pehla search fail hua, alag sawaal se dobara karo.' Example: sawaal 'Kaunn X ko found kiya aur usse pehle kya kiya?' — agentic RAG pehle search kare, dekhe ki pre-founding history nahi mila, phir 'background before X founder' se dobara search kare, aur dono results combine kare.
Contextual compression RAG me kya hota hai?
Contextual compression ek post-retrieval step hai jahan ek LLM har retrieved chunk padhta hai aur irrelevant sentences hata deta hai, sirf wo hisse chhod ke jo user ke sawaal ka answer dete hain. Isse token count kam hota hai aur noise bhi kam hota hai final prompt se pehle.
In simple terms: Socho ek retrieved chunk me ye hai: 'Founded 2010, offices in 5 countries, leave policy is 24 days, revenue up 50%.' Contextual compression yeh padhta hai aur sirf 'leave policy is 24 days' nikal ke deta hai agar sawaal leave ke baare me tha. Ye ek filter jaisa hai jo LLM ko na chahne wale sentences remove kar deta hai. Example Python me: ek LLM call har chunk ko wrap karte hai aur sirf relevant subset return karta hai final grounded prompt banane se pehle.
RAG me parent-child (small-to-big) chunking kya hoti hai?
Parent-child chunking documents ko do sizes me kaat deti hai: chhote child chunks precise vector search matching ke liye, aur bade parent chunks LLM ko reasoning dene ke liye. Tum small chunk embedding use karke search karte ho par full parent chunk context ke roop me return karte ho.
In simple terms: Socho ek kitaab ke chapter dhundne jaisa — tum ek chhoti table-of-contents entry search karte ho jo chapter mil jaaye, par phir full chapter reader ko dete ho, sirf entry nahi. Example: ek document ko chhote chunks me kaat diya ("Python is dynamically typed", "Variables are created on assignment"), har ek embed aur index hota hai, par ek match ho jaaye to uska full parent chunk (pura "Data Types" section) LLM ko return karte ho.
HyDE raw user question embed karne se behtar kyun kaam karta hai?
Embedding models mostly document-jaisi text pe train hote hain. Ek chhota sawaal aur paragraph-style document embedding space me bahut alag dikhte hain, par hypothetical answer (jo document jaisa padhe) real document embeddings ke zyada kareeb hota hai, isliye retrieval zyada accurate hota hai.
In simple terms: User jo 'Python?' poochta hai, uska embedding ek Wikipedia paragraph 'Python is a high-level dynamically-typed language...' se bahut alag hota hai. Par HyDE ka fake answer 'Python is a programming language used for data science...' wo Wikipedia chunk jaisa zyada dikhta hai kyunki dono document-jaisa hain. Socho 'How tall?' vs. 'I need someone about 180cm tall for this role' — doosra job posting jaisa zyada lagta hai aur better match hota hai.
Conversational RAG me chunks retrieve karte waqt original follow-up use karte ho ya rewritten question use karte ho?
Rewritten standalone question se chunks retrieve karte ho. Par user ko rewritten version kabhi nahi dikhta — final answer original question aur natural conversation history se generate hota hai, taaki chat readable rahe.
In simple terms: Do alag audiences, do alag jobs: retriever (machine jise memory nahi) ko rewritten question milta hai taaki wo chunks find kar sake. User (human jo normal chat pasand karte hain) ko natural back-and-forth dikhta hai. Code: `results = db.search(standalone_q)` lekin `answer = llm.answer(original_q, chat_history)`.
123+ more RAG (Retrieval Augmented Generation) questions inside
Create a free account to read the full question bank, learn every topic, and practise with an AI mock interview.
Unlock all questions — freeReady to practise RAG (Retrieval Augmented Generation)?
Unlock every topic free, then face an AI interviewer that asks follow-ups and grades your answers.