Retrieval-Augmented Generation (RAG)
Also known as: RAG, retrieval-augmented LLM, grounded generation, Erişim Destekli Metin Üretimi (RAG)
Retrieval-Augmented Generation (RAG) is a natural-language-processing pipeline introduced by Lewis et al. in 2020 that strengthens a large language model (LLM) with evidence fetched at inference time from an external knowledge base. Instead of relying solely on what a model memorised during training, RAG first retrieves the most relevant passages from a document index and then hands those passages to the LLM as context, grounding the generated answer in verifiable, up-to-date information. The approach reduces hallucination and allows domain-specific or time-sensitive knowledge to be injected without retraining the model.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
+1 more
When to use it
RAG fits when you need an LLM to answer questions about a private, domain-specific, or rapidly changing corpus that the model was not trained on. It is particularly suitable for question answering over large document collections, enterprise knowledge bases, legal or medical literature, and any scenario where hallucination must be contained and answers must be traceable to source passages. A vector knowledge base and access to an embedding model and an LLM are necessary prerequisites. If the knowledge base is very small (fewer than roughly ten documents), simpler retrieval strategies may suffice. RAG does not apply when there is no document collection to retrieve from.
Strengths & limitations
- Reduces hallucination by grounding answers in retrieved evidence rather than model memory alone.
- Allows domain-specific or up-to-date knowledge to be incorporated without retraining or fine-tuning the LLM.
- Provides answer traceability: retrieved passages can be surfaced as citations, making outputs auditable.
- The knowledge base can be updated independently of the model, keeping answers current as documents change.
- Retrieval quality is a bottleneck: if the right passages are not returned, the LLM cannot compensate.
- Building and maintaining a vector index adds infrastructure overhead — embedding models, a vector database, and synchronisation pipelines are required.
- The LLM can still ignore or misinterpret retrieved passages, especially when the context window is saturated with irrelevant chunks.
- Evaluation is more complex than standard classification: faithfulness, context relevance, and answer relevance must each be measured separately.
Frequently asked
How is RAG different from fine-tuning an LLM?
Fine-tuning bakes knowledge into the model weights during an additional training pass; the knowledge is implicit and cannot be easily updated. RAG keeps knowledge external in a vector database and retrieves it at inference time, making the knowledge base straightforward to update, expand, or audit without touching the model. Fine-tuning is better for adapting the model's style or task format; RAG is better for keeping factual content current and traceable.
What is the role of the embedding model in RAG?
The embedding model converts both documents and queries into dense vectors in a shared semantic space so that similar meanings map to nearby vectors. The quality of retrieval — and therefore the quality of the final answer — depends heavily on how well the embedding model captures the semantics of the target domain. A generic embedding model may underperform on specialised corpora; domain-adapted models should be preferred when available.
How do I evaluate whether my RAG pipeline is working well?
Evaluation should cover three dimensions: context relevance (did retrieval return the right passages?), faithfulness (does the generated answer agree with the retrieved passages?), and answer relevance (does the answer address the question?). Frameworks such as RAGAS operationalise these metrics automatically. Human annotation of a sample of query-answer pairs provides a reliable ground truth.
How many documents does RAG need to be useful?
There is no strict minimum, but RAG becomes most valuable when the knowledge base is large enough that a general LLM would not have reliable coverage — typically at least tens of documents with meaningful content. For very small corpora (fewer than ten documents), direct prompting with the full text may be simpler. As the collection grows into thousands or millions of documents, RAG's structured retrieval becomes essential.
Sources
- Lewis, P. et al. (2020). Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks. Advances in Neural Information Processing Systems (NeurIPS), 33, 9459-9474. DOI: 10.48550/arXiv.2005.11401 ↗
- Gao, Y. et al. (2023). Retrieval-Augmented Generation for Large Language Models: A Survey. arXiv preprint. DOI: 10.48550/arXiv.2312.10997 ↗
How to cite this page
ScholarGate. (2026, June 1). Retrieval-Augmented Generation (RAG). ScholarGate. https://scholargate.app/en/text-mining/retrieval-augmented-generation
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- BERT EmbeddingsText mining↔ compare
- BERT Fine-TuningDeep learning↔ compare
- Knowledge Graph ConstructionText mining↔ compare
- Question AnsweringText mining↔ compare
- Self-AttentionDeep learning↔ compare
- Text SummarizationText mining↔ compare
- TransformerDeep learning↔ compare