Part 1: Understanding RAG, where it fails, and how to evaluate Retrieval
By Dr. Ashish Bamania
Published: 2026-11-01
URL: https://www.intoai.pub/p/how-to-evaluate-your-rag-pipeline
Retrieval-Augmented Generation (RAG) is one of the most widely used techniques in modern AI systems.
It lets LLMs access up-to-date and trustworthy information by connecting them to external knowledge sources. This ensures the LLM's responses are based on verifiable sources rather than only its internal knowledge.
Here’s what each term in RAG means:
-
Retrieval: obtaining relevant information from a knowledge base/ private datasets
-
Augmentation: adding the retrieved information to the LLM’s context window
-
Generation: the LLM generating a response based on the given query and relevant information added to the context window
RAG visualized (Image from author’s book ‘LLMs In 100 Images’)
Despite its popularity in AI systems, it is not well evaluated in production, which can cause LLMs and agents to fail in unintended ways. In this lesson, we will learn how to evaluate your RAG pipeline effectively.
🥳 We just hit 10K views on the Into AI YouTube channel! If you haven’t yet, please subscribe to the channel where I share interesting and super-valuable videos all week! 🎥
What are the steps in RAG?
RAG involves the following five steps:
-
Indexing: This step involves:
-
Loading a set of documents that we intend to retrieve information from
-
Splitting them into chunks (Chunking)
-
Converting the chunks to document embeddings using an embedding model
-
Storing these embeddings in a vector database. This is the knowledge base.
-
Retrieval: This step involves:
-
Converting the user query into a query embedding using the same embedding model that was used during indexing
-
Searching the vector database for the chunks whose embeddings are most similar to the query embedding. This is measured by cosine similarity/ dot product.
-
Returning the top-K chunks most similar to the query embedding
-
Re-ranking: This step uses a Re-ranker, which is a cross-encoder model that reads the query and each candidate together and scores how well they match.
Retrieval is fast but less accurate: it quickly searches the vector database and returns a large number of candidate chunks. Re-ranking, on the other hand, is much more accurate but slower: it scores the retrieved candidates and passes only the best few to the LLM.
-
Augmentation: This step involves combining the user query and the selected chunks in a single prompt and passing it to an LLM.
-
Generation: This step involves the LLM generating an answer based on the augmented prompt.
Where can a RAG pipeline fail?
A RAG pipeline can fail in many different ways, and it is important to isolate what’s failing so that you can fix it appropriately. Here are the main ways:

