Prompts Forms Resume Reports ★ Saved ★ Saved★ + Submit a tool
Techniques

RAG (Retrieval-Augmented Generation)

About 1600 characters Updated Nov 30, 2026 32 views AI wiki

RAG (Retrieval-Augmented Generation) is the mainstream solution to the problems of large models "not knowing the latest news" and "making up facts". The idea is direct: look up the material first, then answer.

Why RAG Is Needed

Large models have two hard flaws:

  • Knowledge cutoff: training data has a cutoff date, so the model does not know yesterday's news
  • Hallucination: when it does not know, it confidently makes things up

RAG's approach is to store all available material in a vector database, retrieve the most relevant passages at question time, and place them in the prompt so the model answers based on that content.

The Full Pipeline

  1. Document chunking: split long documents into small chunks of a few hundred words
  2. Embedding: convert each chunk into a vector with an embedding model and store it in a vector database
  3. Retrieval: convert the user's question into a vector and find the most similar Top-K chunks in the database
  4. Reranking: use a rerank model to reorder the candidate chunks once more and refine them
  5. Generation: pass the matched content and the question to the large model to produce the final answer

Key Technical Points

  • Chunking strategy: chunks that are too small lose context; chunks that are too large introduce noise. A common practice is to split on semantic boundaries and add sliding-window overlap
  • Hybrid retrieval: combining vector retrieval (semantic similarity) with keyword retrieval (BM25) usually outperforms either alone
  • Reranking: recall 50 candidates in the first stage, then rerank them down to the top 5 in the second, which markedly improves precision

Typical Applications

Enterprise knowledge base Q&A, customer service bots, legal clause lookup, medical literature assistants, and code repository Q&A.

Limitations

RAG cannot teach a model new capabilities; it can only supply new knowledge. If retrieval quality is poor, answer quality collapses with it.