Video summary
Advanced RAG: How Corrective RAG (CRAG) Solves Traditional RAG Problems | CampusX
Main summary
Key takeaways
Summary
The video explains Corrective Retrieval-Augmented Generation (CRAG), an approach that checks whether retrieved documents are useful before an LLM relies on them. The presenter first demonstrates how traditional RAG can produce unsupported answers, then builds a CRAG-style workflow step by step.
1. Traditional RAG and its weakness
A traditional RAG system has three main stages:
- Retrieval: Convert the user’s query into a vector and search a vector database for similar document chunks.
- Augmentation: Add the retrieved chunks to the query as context.
- Generation: Ask the LLM to answer using that context.
The problem is that the LLM may trust retrieved documents blindly. If the documents are irrelevant or incomplete, the system may still produce an answer—either by forcing an answer from poor context or by relying on the LLM’s internal knowledge. This can lead to unsupported or hallucinated answers.
In the demonstration, a vector database containing machine-learning and deep-learning books returns relevant material for a bias–variance question. But for a question about transformers, it retrieves unrelated material. The LLM nevertheless gives a plausible answer, apparently drawing on its internal knowledge rather than the retrieved documents. In a business setting, such as answering a question about a company leave policy, an unsupported answer could have serious consequences.
2. CRAG’s core idea
CRAG adds a retrieval evaluator between retrieval and generation. The evaluator judges how well each retrieved document supports the query, then routes the query according to retrieval quality:
- Correct retrieval: Refine relevant documents, then generate an answer.
- Incorrect retrieval: Search an external source, such as the web, and generate from the resulting information.
- Ambiguous retrieval: Combine useful retrieved material with web results, refine the combined context, and generate.
The key principle is that a system should not assume retrieved documents are reliable just because a search returned them.
3. Knowledge refinement
Retrieved chunks can contain useful information mixed with unrelated text, particularly because chunk boundaries do not necessarily align with topic boundaries. CRAG cleans this context through a knowledge-refinement process:
- Decomposition: Break each retrieved document into sentence-level or short sentence-group “strips.”
- Filtration: Compare each strip with the query and keep only strips that directly help answer it.
- Recomposition: Join the retained strips into a refined context for generation.
The paper reportedly uses a fine-tuned Google T5-Large model for evaluation and filtering. In the walkthrough, the presenter uses an OpenAI chat model instead because the fine-tuned model was not available to him.
4. Retrieval evaluation and routing
In the walkthrough, an LLM scores each retrieved document for relevance and provides a reason for its score. Thresholds are then used to classify retrieval quality:
- Correct: At least one document exceeds the upper threshold.
- Incorrect: No document exceeds the lower threshold.
- Ambiguous: Neither condition applies. Some useful material exists, but no document is strong enough to count as clearly sufficient.
The code uses example thresholds of 3 and 7, which the presenter notes can be tuned. The subtitles contain a scale inconsistency: the scoring prompt is described as using a 0–1 score, while the examples and thresholds use a 0–10-style scale. The intended method is to score relevance and compare the scores with lower and upper thresholds.
Only documents scoring above the lower threshold are used for generation, even when the overall retrieval is classified as correct.
5. Web search and query rewriting
When retrieval is incorrect, CRAG searches the web rather than returning an unsupported answer. Web results are refined before use:
- Send the query to a web-search tool.
- Convert the returned results into document objects.
- Decompose and filter those documents.
- Generate an answer from the refined external context.
The video also adds an optional query-rewriting step before web search. An LLM rewrites the user’s query into a clearer, search-engine-friendly version, adding useful constraints—for example, a recent time period when the query asks for current information. The rewritten query is then sent to Tavily.
For ambiguous retrieval, the system keeps useful internal documents and combines them with refined web results. The presenter implements ambiguous and incorrect retrieval using the same general route: both proceed to web search, while the refinement step determines which contexts to use.
6. Implementation walkthrough
The example system is built incrementally in a graph-based workflow:
- It loads three books: Hands-On Machine Learning, Deep Learning, and Pattern Recognition.
- It splits the documents with a Recursive Character Text Splitter, using a chunk size of 900 and an overlap of 150.
- It creates embeddings, stores them in a vector database, and retrieves the top four chunks for a query.
- It develops the graph in stages: traditional retrieval and generation, knowledge refinement, retrieval evaluation, web search, query rewriting, and combined handling of ambiguous results.
- The final workflow uses internal knowledge for correct retrieval, external web knowledge for incorrect retrieval, and both for ambiguous retrieval.
The broader lesson is to build RAG systems with verification and fallback processes rather than treating retrieval as automatically trustworthy.
Speakers and sources featured
- Nitesh (CampusX): Presenter and narrator; the only speaker heard in the subtitles.
- The Corrective RAG research paper: Referenced as the architecture’s source; the presenter describes it as a 2024 paper.
- Tools and models: LangGraph, a FAISS vector database, OpenAI embeddings and chat models, Google T5-Large (described as the model used in the paper), and Tavily for web search.
- Example document sources: Hands-On Machine Learning, Deep Learning, and Pattern Recognition.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.