RAG · Guide
RAG (Retrieval-Augmented Generation): A Complete Guide
Ground an LLM in your own documents — embeddings, vector search, chunking, reranking, evaluation.
Retrieval-Augmented Generation (RAG) grounds a language model in your own documents by retrieving the most relevant passages at query time and passing them to the model as context, instead of relying on its trained-in memory. This guide covers embeddings, vector search, chunking strategies, hybrid retrieval and reranking, RAG evaluation, and building a RAG chatbot end to end.
Generate your own lesson →What you'll learn
- RAG Chunking Strategies Explained
- What Are Vector Embeddings?
- What Is RAG? (Retrieval-Augmented Generation)
- Build a RAG Chatbot in Python
- Building RAG with LlamaIndex
- Chunking Strategies for RAG
- Embeddings and Vector Search
- Evaluating RAG: Faithfulness and Relevance
- Fine-Tuning vs RAG vs Prompting
- GraphRAG: Retrieval over Knowledge Graphs
- How Vector Databases Work
- Hybrid Retrieval and Reciprocal Rank Fusion
- pgvector: Vector Search in Postgres for RAG
- Reranking for Better RAG Answers
- Semantic Search with Embeddings
- Vector Databases Compared
- RAG vs Fine-Tuning: When to Use Each
- Pinecone Vector Database: Complete Tutorial
- Qdrant Vector Database Guide
Lessons in this guide (19)
RAG Chunking Strategies Explained
Chunking is the step in a retrieval-augmented generation (RAG) pipeline that splits large documents into smaller passages before they are embedded and stored in a vector database. Good chunking keeps each passage semantically self-contained
What Are Vector Embeddings?
A vector embedding is a list of numbers that represents the meaning of a piece of data — a word, sentence, image, or document — as a point in space. An embedding model places similar meanings close together, so 'dog' and 'puppy' land near e
What Is RAG? (Retrieval-Augmented Generation)
Retrieval-Augmented Generation (RAG) is a technique that makes a large language model answer from your own documents instead of only its training data. Before answering, the system retrieves the most relevant text — usually by embedding sim
Build a RAG Chatbot in Python
A retrieval-augmented generation (RAG) chatbot answers questions from your own documents by retrieving relevant passages and feeding them to a large language model. You build one in Python in five steps: load documents, split them into chun
Building RAG with LlamaIndex
LlamaIndex is a data framework built for retrieval-augmented generation, giving you first-class pieces for the whole pipeline: loaders that ingest documents, an index that chunks and embeds them, a retriever that fetches relevant nodes, and
Chunking Strategies for RAG
Chunking splits documents into passages before they are embedded for retrieval-augmented generation, and the strategy you choose is one of the highest-impact decisions in a RAG pipeline. Beyond fixed-size and recursive splitting, production
Embeddings and Vector Search
Embeddings and vector search are the retrieval building block behind most AI search and RAG systems. An embedding model turns each piece of text into a vector that captures its meaning; vector search then finds the stored vectors closest to
Evaluating RAG: Faithfulness and Relevance
Evaluating a retrieval-augmented generation (RAG) system means grading its two halves separately: retrieval and generation. Retrieval is measured by whether the right passages were fetched (context precision and recall). Generation is measu
Fine-Tuning vs RAG vs Prompting
Fine-tuning, retrieval-augmented generation (RAG), and prompting are three ways to adapt a large language model to your task. Prompting changes only the instructions you send; RAG injects relevant external data into the prompt at query time
GraphRAG: Retrieval over Knowledge Graphs
GraphRAG is a retrieval-augmented generation approach that builds a knowledge graph of entities and their relationships from your documents, then retrieves over that structure instead of, or alongside, plain vector search. Because it can tr
How Vector Databases Work
A vector database is a database built to store and search high-dimensional vectors — the numeric embeddings that represent the meaning of text, images, or audio. Instead of matching exact keywords, a vector database finds the items whose em
Hybrid Retrieval and Reciprocal Rank Fusion
Hybrid retrieval combines keyword search and semantic (vector) search so a retrieval-augmented generation system gets both exact-term precision and meaning-based recall. Because the two methods produce scores on different scales, results ar
pgvector: Vector Search in Postgres for RAG
pgvector is an open-source extension that adds a vector data type and similarity search to PostgreSQL, letting you store embeddings and run nearest-neighbor queries in the database you already run. For retrieval-augmented generation, it mea
Reranking for Better RAG Answers
Reranking is a second retrieval stage that reorders an initial set of candidate passages by true relevance to the query before they go to the model. The first stage (vector or keyword search) is fast but coarse; a reranker — usually a cross
Semantic Search with Embeddings
Semantic search is a search technique that ranks results by meaning rather than exact keyword matches. It converts both the query and every document into embeddings — numeric vectors from a model — and returns the documents whose vectors si
Vector Databases Compared
Vector databases store embeddings and run similarity search for retrieval-augmented generation, and the main options differ less in core search than in how you run and scale them. Pinecone is fully managed; Weaviate, Qdrant, and Milvus are
RAG vs Fine-Tuning: When to Use Each
Choose Retrieval-Augmented Generation when you need fresh, citable facts from external documents; choose fine-tuning when you need to reshape a model's default style, format, or domain vocabulary.
Pinecone Vector Database: Complete Tutorial
Build and deploy a vector search application with Pinecone by mastering index creation, embedding ingestion, similarity querying, metadata filtering, and RAG pipeline integration.
Qdrant Vector Database Guide
Qdrant is a purpose-built vector database that stores embeddings as points inside collections and retrieves the nearest neighbors fast — with payload filtering, multiple index types, and a clean API that fits directly into RAG and semantic
Frequently asked questions
What is RAG?
RAG stands for Retrieval-Augmented Generation. It fetches relevant chunks from your document store and feeds them to the LLM as context so answers are grounded in your data and can be cited — without retraining the model.
RAG vs fine-tuning — when do I use each?
Use RAG when the knowledge is large, changing, or must be cited (docs, policies). Use fine-tuning to change the model's behavior or format, not to add fresh facts. They're often combined.
How does vector search work?
Each chunk and the query are encoded into vectors by an embedding model; the store returns the chunks whose vectors are nearest to the query's (cosine similarity). Hybrid search adds keyword matching to catch exact terms.