---
title: "RAG and vector search"
description: "Retrieval augmented generation explained: RAG pipelines, chunking, embeddings, vector databases and reranking, and when to choose RAG or fine-tuning."
type: "topic-hub"
canonical_url: "https://theaiengineering.com/topics/rag"
markdown_url: "https://theaiengineering.com/topics/rag.md"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
keywords: ["retrieval augmented generation","what is rag","rag vs fine tuning","vector database for rag","embeddings","agentic rag"]
citation: "The AI Engineering Editors. \"RAG and vector search.\" The AI Engineering. https://theaiengineering.com/topics/rag"
---

# RAG and vector search

Grounding model output in your own data: pipelines, vector search and trade-offs.

Retrieval augmented generation (RAG) supplies a model with relevant documents at query time so its answers can draw on information it was never trained on. A RAG system is a pipeline: ingestion, chunking, embedding, indexing, retrieval, reranking and generation, and each stage can fail on its own.

The guides here explain the pipeline end to end, compare RAG with fine-tuning, and point to the vector databases and evaluation methods teams use in production.

## RAG and vector search guides

- [Chunking strategies for RAG: how to choose, tune, and evaluate them](https://theaiengineering.com/articles/chunking-strategies-for-rag): Chunking strategies for RAG compared: fixed-size, recursive, document-aware, semantic, parent-child, and late chunking, with tested Python and an eval method.
- [RAG vs fine-tuning: how to choose for your LLM application](https://theaiengineering.com/articles/rag-vs-fine-tuning): RAG vs fine-tuning: RAG adds knowledge at query time, while fine-tuning changes model behavior. Compare freshness, cost, latency, data needs, LoRA, and hybrids.
- [What is retrieval-augmented generation (RAG)? How RAG works](https://theaiengineering.com/articles/what-is-rag): Retrieval-augmented generation (RAG) grounds LLM answers in your documents. Learn the RAG pipeline, hybrid search, agentic RAG, evaluation, and failure modes.

## Key terms

- [Agentic RAG](https://theaiengineering.com/glossary/agentic-rag): Agentic RAG is a retrieval-augmented generation design in which an AI agent treats retrieval as a tool, deciding when to search, what query to send, which source to use, and whether to search again.
- [Approximate nearest neighbor search](https://theaiengineering.com/glossary/approximate-nearest-neighbor): Approximate nearest neighbor (ANN) search is a family of indexing methods that find vectors close to a query vector without comparing it to every stored vector, accepting that some true nearest neighbors are missed.
- [BM25](https://theaiengineering.com/glossary/bm25): BM25 is a keyword ranking function that scores a document against a query using how often each query term appears, how rare the term is across the corpus, and how long the document is.
- [Chunking](https://theaiengineering.com/glossary/chunking): Chunking is the step in a retrieval pipeline that splits documents into smaller passages, called chunks, so each one can be embedded, indexed, and retrieved on its own.
- [Contextual retrieval](https://theaiengineering.com/glossary/contextual-retrieval): Contextual retrieval is a RAG indexing technique in which a language model writes a short note situating each chunk within its source document, and the note is prepended before embedding and BM25 indexing.
- [Cosine similarity](https://theaiengineering.com/glossary/cosine-similarity): Cosine similarity is a measure of how closely two vectors point in the same direction, computed as their dot product divided by the product of their lengths, with values from -1 to 1.
- [Embeddings](https://theaiengineering.com/glossary/embeddings): Embeddings are fixed-length vectors of numbers that represent data such as text or images so that items with similar meaning sit close together, which lets software compare meaning with arithmetic.
- [Hybrid search](https://theaiengineering.com/glossary/hybrid-search): Hybrid search is a retrieval method that runs keyword search, typically BM25, and vector similarity search on the same query and merges the two ranked lists into one result set.
- [Late chunking](https://theaiengineering.com/glossary/late-chunking): Late chunking is an embedding technique that runs a long-context embedding model over a whole document first, then splits the token embeddings at chunk boundaries and averages each span into one chunk vector.
- [Recall@k](https://theaiengineering.com/glossary/recall-at-k): Recall@k is a retrieval metric that measures the fraction of a query's relevant documents that appear in the top k results, averaged over a set of test queries.
- [Reranking](https://theaiengineering.com/glossary/reranking): Reranking is a second retrieval stage that rescores an initial list of candidate documents with a more accurate but slower model, usually a cross-encoder, and keeps only the most relevant ones.
- [Retrieval-augmented generation (RAG)](https://theaiengineering.com/glossary/retrieval-augmented-generation): Retrieval-augmented generation (RAG) is a technique that retrieves relevant passages from an external knowledge source at query time and adds them to a language model's prompt so the answer is grounded in that data.
- [Vector database](https://theaiengineering.com/glossary/vector-database): A vector database is a database built to store embedding vectors and quickly return the vectors most similar to a query vector, usually with approximate nearest neighbor indexes such as HNSW.

## Tools and platforms

- [Vector databases](https://theaiengineering.com/platforms/vector-databases): 29 platforms. A vector database stores embeddings, the numeric vectors that represent text, images, or other data, and returns the entries closest to a query vector using approximate nearest neighbor indexes.
- [Embedding and reranking models](https://theaiengineering.com/platforms/embedding-reranking): 23 platforms. An embedding model converts text, images, or other content into vectors so that items with similar meaning sit close together, and a reranker scores a query against each candidate passage to reorder the results a retriever returns.
- [Document parsing and data ingestion](https://theaiengineering.com/platforms/data-ingestion): 28 platforms. Data ingestion tools turn PDFs, Office files, scans, images, and web pages into clean text, Markdown, or structured JSON that a RAG pipeline can chunk, embed, and cite.

## Cite this page

The AI Engineering Editors. "RAG and vector search." The AI Engineering. https://theaiengineering.com/topics/rag

- Title: RAG and vector search
- Author: The AI Engineering Editors
- Publisher: The AI Engineering
- URL: https://theaiengineering.com/topics/rag
- Markdown: https://theaiengineering.com/topics/rag.md
