RAG is one of the most important patterns in practical AI engineering. It allows an LLM to answer questions using information retrieved from external knowledge sources, such as PDFs, websites, databases, manuals, and internal company documents.
Why do we need RAG? A general-purpose LLM may not know your company's latest employee policy, product catalogue, internal documentation, or private business data. RAG retrieves relevant information at query time and supplies it to the model as context.
Understand the RAG pipeline
1
IngestLoad PDFs, web pages, databases
2
ChunkSplit content into useful passages
3
EmbedConvert passages into vectors
4
IndexStore vectors and metadata
5
RetrieveFind relevant passages
6
AugmentBuild a grounded model prompt
7
GenerateGenerate an answer from context
8
EvaluateCheck relevance and correctness
Document ingestionPDF parsing, Word documents, HTML, web pages, CSV, OCR and data extraction.
Chunking strategiesFixed-size, overlapping, recursive, semantic and structure-aware chunking. Understand chunk size and overlap trade-offs.
Embedding modelsText embeddings, vector dimensions, similarity metrics, indexing, and selecting models for a retrieval task.
Vector databasesCollections, metadata, similarity search, filtering, indexing and persistence.
Retrieval strategiesSemantic search, keyword search, hybrid retrieval, query rewriting, metadata filters and reranking.
RAG evaluationRetrieval precision, recall, context relevance, groundedness, answer relevance, citation quality and failure analysis.
Real-world example: College policy chatbot
Upload admission rules, fee policies, scholarship documents and examination guidelines. A student asks, "What is the minimum attendance required to appear in the examination?" The system retrieves the relevant policy section and asks the LLM to answer using that section, ideally with a citation to the source document.
Another example: E-commerce assistant
Index product descriptions, specifications, return policies and support articles. A user asks, "Which laptop has 16 GB RAM and is suitable for programming under ₹70,000?" Retrieval finds matching product records; the model organizes the results into a useful response.
Recommended tools
LangChainLlamaIndexChromaFAISSPineconeQdrantWeaviatePostgreSQL + pgvector
Milestone: Build a document-based chatbot that ingests multiple files, retrieves relevant passages, generates grounded answers, and displays source references.