RAG
in English: retrieval-augmented generation
A method in which artificial intelligence, before answering, retrieves the document passages relevant to the question and formulates its answer based on them.
In plain terms
Imagine two students taking an exam. One answers from memory: they know a lot, but when they don't, they sometimes confidently guess. The other can use the library: they first find the relevant pages and answer based on them. RAG turns the language model into the second student.
A language model typically relies only on what it saw during training. It does not know yesterday's news, your company's internal regulations, or your own contracts. RAG fills this gap: it retrieves relevant text passages related to your question and feeds them to the model before it answers.
This way, the answer can be fresher and more accurate, and the source can be shown. The model does not need to be retrained for this: it is enough to expand or replace the document repository.
How it works
- Preparation: documents (regulations, articles, manuals) are split into short sections and stored in a searchable format, often in a so-called vector database that can be searched by meaning.
- Search: when you ask a question, the system does not first turn to the model, but searches the store for the sections best matching your query. This often uses both semantic and traditional keyword search together.
- Expansion: it inserts the found sections next to your question, so the model receives both the question and the relevant background material at once.
- Generation: the model formulates the answer based on these texts, ideally indicating which source it used.
- Verifiability: based on the references, you can open the original document yourself and check whether it actually says what is claimed.
An everyday example
Your bank's or service provider's customer service chat does not give general answers to your question but refers to the current fee schedule and general terms and conditions. Behind the scenes, RAG is likely at work: the system first retrieved the relevant paragraphs and only then answered.
Who is affected
A common misconception
Limits and risks
- The answer is only as good as the underlying document collection: outdated, incomplete, or erroneous material produces erroneous answers.
- If the search does not find the relevant section, the model either answers incompletely or fills gaps from its own memory, and does not always indicate this.
- The existence of a citation is not proof: in important matters, open the cited source and verify that it actually contains the stated information.
- Confidential documents require special attention to permissions, otherwise the system may disclose information to someone who should not have access to it.
Similar, but not the same
- Fine-tuning – Fine-tuning continues to train the model itself, while RAG leaves the model untouched and only provides background material at the moment of answering.
- Search Engine – The search engine provides a results list that you must read through, while RAG generates a ready-made, formulated answer from the results.
- Kontextusablak – The context window is the amount of text the model can consider at once, while RAG is the method that decides what gets included.
Related concepts
Generative AI, Large language model, Information retrieval
vector database, Embedding, semantic search, Graph-based RAG
hallucination, Fine-tuning, Kontextusablak, AI-agent, Prompt
A brief history
The term was introduced by Patrick Lewis and co-authors in a 2020 study, which linked the knowledge of a language model with an external, searchable document repository (Wikipedia). It became widely known from the end of 2022, with the spread of chatbots built on large language models.
Where things stand
By the end of 2026, it will be a fundamental building block of corporate AI solutions: customer service chatbots, internal knowledge bases, and AI search engines displaying sources will all use it. The direction of development is that agents will themselves decide when, where, and how often to search.
In the news
- Analysis counts more than 1,600 court cases with fake AI citations, some sanctions in six figuresAug 18, 2026 · Jog
Also known as
RAG · retrieval-augmented generation · retrieval augmented generation · retrieval-augmented generation · retrieval-augmented generation · search-based generation · search-based text generation (retrieval-augmented generation) · RAG-rendszer
Sources
- Lewis et al.: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020, arXiv)
- Wikipedia: Retrieval-augmented generation
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.