Agenda
• Why RAG?
•Understanding Embeddings
• Vector Databases (FAISS / Qdrant)
• Hybrid Retrieval (BM25 + Embeddings)
• Building a Context-Aware QA System (Live
Demo)
• Wrap-up & Q&A
3.
The Problem —Why RAG?
• LLMs can hallucinate and lack access to private
or up-to-date data.
• RAG provides external knowledge at query
time to ground responses.
• Useful for internal knowledge bases,
document Q&A, support systems.
4.
What is Retrieval-AugmentedGeneration
(RAG)?
• Combines a retriever (search over documents)
with a generator (LLM).
• Retriever finds relevant context; generator
uses it to answer.
• Reduces hallucination and increases
relevance.
5.
RAG Architecture Overview
•Input Query -> Embedding Generation ->
Vector Search -> Retrieved Docs -> LLM
Response
• Chunking, embedding model selection, vector
DB choice are key decisions.
• Return source documents to increase
explainability.
Keyword Search vsSemantic Search
• Keyword (BM25/TF-IDF): exact word
matching, fast, precise for keywords.
• Semantic (Embeddings): finds meaning,
catches paraphrases and synonyms.
• Hybrid retrieval combines both for better
results.
8.
Vector Databases (FAISS/ Qdrant / Pinecone)
• Store and retrieve high-dimensional
embeddings efficiently.
• FAISS: local, efficient; Qdrant: cloud-ready
with metadata search.
• Choose based on scale, latency, and
deployment preferences.
9.
Hybrid Retrieval (BM25+ Embeddings)
• Combine keyword and semantic scores to
balance precision and recall.
• Tools: LangChain, Haystack, LlamaIndex
provide hybrid retriever patterns.
• Weight the retrievers according to your data
characteristics.
10.
End-to-End RAG Pipeline
•1. Data collection & preprocessing
• 2. Chunk documents and create embeddings
• 3. Store embeddings in vector DB
• 4. Retrieve top-k context for queries
• 5. Pass context to LLM and generate answer
(with sources)
11.
Live Demo Plan— Mini RAG QA (Azure
OpenAI + FAISS)
• Sample corpus of short docs (3-6 paragraphs).
• Generate embeddings with sentence-
transformers (all-MiniLM-L6-v2).
• Store embeddings in FAISS local index.
• Use Azure OpenAI (Chat Completions) to
answer with retrieved context.
• Show outputs and source documents.
Common Challenges &Tuning
• Chunk size and overlap influence retrieval
accuracy.
• Embedding model choice affects semantic
quality.
• Keeping the vector DB updated (vector drift)
and scaling latency.