Lesson 11 of 11 · 5 min
30 Interview Q&As
Q1: What does RAG stand for and what problem does it solve?
Retrieval-Augmented Generation. Solves knowledge cutoff and hallucination by retrieving relevant documents at query time and feeding them as LLM context.
Q2: What are the two phases of a RAG pipeline?
Offline indexing (embed and store documents) and online querying (embed question, retrieve chunks, generate answer).
Q3: What is a vector embedding?
A dense numerical representation of text in high-dimensional space where semantically similar texts have similar vectors (small cosine distance).
Q4: What is FAISS?
Facebook AI Similarity Search — an efficient library for finding nearest neighbours in large sets of vectors. Supports exact and approximate search.
Q5: What is ChromaDB?
An open-source, embeddable vector database that stores embeddings with metadata and supports semantic similarity search.
Q6: What is the role of chunk overlap?
Prevents answers from being split across chunk boundaries. Typically 10–15% of chunk size.
Q7: What is cosine similarity?
Measures the angle between two vectors. Value ranges from -1 to 1. Two identical texts → cosine similarity = 1.
Q8: What is LangChain?
A framework for building LLM applications that chains together document loaders, text splitters, embeddings, vector stores, and LLMs into pipelines.
Q9: What is the difference between dense and sparse retrieval?
Dense: embedding similarity (captures meaning). Sparse: keyword/TF-IDF matching (captures exact terms). Hybrid combines both.
Q10: What is MMR (Maximal Marginal Relevance)?
Retrieval strategy that balances relevance to query with diversity among retrieved chunks, reducing redundancy.
Q11: When would you choose RAG over fine-tuning?
RAG: when data changes frequently, you need source citations, or cost is a constraint. Fine-tuning: when adapting style/format, not knowledge.
Q12: What chunk size is typically recommended?
500–1000 tokens with 10–15% overlap. Depends on document structure and LLM context window.
Q13: What is a vector database?
Specialized database optimized for storing, indexing, and querying high-dimensional vectors. Examples: FAISS, ChromaDB, Pinecone, Weaviate.
Q14: What is RetrievalQA in LangChain?
A chain that combines a retriever and an LLM: retrieves relevant documents for a query, then passes them as context to the LLM to generate an answer.
Q15: What is the 'stuff' chain type vs 'map_reduce'?
Stuff: concatenates all retrieved docs and sends to LLM in one call (simpler, limited by context window). Map-reduce: processes each doc separately, then combines (handles long docs).
Q16: How do you evaluate RAG quality?
Use RAGAS metrics: context recall, context precision, faithfulness, answer relevance. Also evaluate retrieval and generation separately.
Q17: What is the sentence-transformers library?
A Python library providing pre-trained models for generating sentence/paragraph embeddings. Model 'all-MiniLM-L6-v2' is fast and general-purpose.
Q18: What causes hallucination in LLMs and how does RAG mitigate it?
LLMs generate plausible-sounding text even without factual basis. RAG grounds answers in retrieved documents, reducing but not eliminating hallucination.
Q19: What is a document loader in LangChain?
A component that reads and parses documents from various sources (PDF, web, CSV, database) into a standard Document format for processing.
Q20: What is RecursiveCharacterTextSplitter?
LangChain splitter that recursively tries to split on paragraphs, sentences, words — preserving semantic coherence better than fixed-size splitting.
Q21: What is k in retrieval (search_kwargs={"k": 3})?
The number of most similar chunks to retrieve for each query. Too low misses relevant context; too high overwhelms LLM with noise.
Q22: What embedding model would you use for medical RAG?
Domain-specific: 'pritamdeka/S-PubMedBert-MS-MARCO' or similar. General models underperform on specialized vocabulary.
Q23: What is Pinecone?
A managed, cloud-based vector database. Handles scaling, persistence, and updates without infrastructure management.
Q24: What is the difference between L2 distance and cosine similarity for vector search?
L2 (Euclidean): measures absolute distance. Cosine: measures angle (direction), ignoring magnitude. Cosine is generally preferred for text embeddings.
Q25: What is a RetrievalQA chain with source_documents=True?
Returns both the generated answer and the source chunks that were used to generate it — essential for citation and auditability.
Q26: What is context window stuffing?
A problem where too many retrieved chunks exceed the LLM's context window (e.g., 4K tokens for older models). Solved by map-reduce or limiting k.
Q27: What is hybrid search in RAG?
Combining semantic (vector) search and keyword (BM25) search, then merging results using reciprocal rank fusion or weighted scoring.
Q28: What is a metadata filter in vector search?
Filtering retrieved documents by metadata (e.g., date, author, department) before similarity ranking — reduces irrelevant results.
Q29: What are the limitations of RAG?
- Retrieval can fail if question is ambiguous. 2. Long-range reasoning across many documents is hard. 3. Latency from retrieval step. 4. Quality bounded by document quality.
Q30: How would you improve a RAG system with poor answer quality?
Check retrieval first (are correct chunks being found?). Then: improve chunking, try better embedding model, increase k, add re-ranking, improve prompt template.
