Basic RAG retrieves once and answers. Newer patterns let the system reason about its own retrieval.
Patterns
| Pattern | Idea | Useful for |
|---|---|---|
| GraphRAG (Edge et al. 2024) | Build a graph of entities and their relations, with summaries of related groups | Global questions such as "what are the main themes across all audit reports", which single chunks cannot answer |
| Corrective RAG (Yan et al. 2024) | A small evaluator grades the retrieved passages, and if they look weak the system rewrites the query or searches elsewhere | Questions where the first retrieval is often poor |
| Self-RAG (Asai et al. 2023) | The model decides when to retrieve and critiques its own answer | Questions that may not need retrieval at all |
| Agentic RAG | Retrieval becomes one tool inside a plan, act and observe loop | Multi-step questions, see Agentic AI |
Remembering tip
GraphRAG sees the big picture, Corrective RAG checks the sources, Self-RAG asks itself whether to look up, and Agentic RAG puts retrieval in a loop.
Code
Corrective RAG as a simple loop: grade the retrieval, and rewrite the query if the grade is weak.
def corrective_search(query, grade, rewrite, k=5, min_grade=0.5):
"""grade(query, chunk_ids) -> score in [0, 1], rewrite(query) -> new query (for example from an LLM)."""
ids = hybrid_search(query, k=k)
if grade(query, ids) < min_grade: # retrieval looks weak
new_query = rewrite(query) # ask the LLM to rewrite the question
ids = hybrid_search(new_query, k=k)
return idsNotes:
gradecan be a small model or an LLM judge that scores how relevant the passages are- this is a sketch of the idea, so a real system also needs a limit on the number of retries
These patterns are used in production systems like the one in Bank Compliance Assistant.