Short answer: RAG (retrieval-augmented generation) is a way to make an AI model answer from your own information: when a question comes in, the software searches your documents or database for the most relevant passages, adds them to the prompt, and the model writes its answer from that material, ideally citing it. It's how chatbots answer from a company's manuals, policies, or past jobs without retraining a model. If your material is small, under about 500 pages by Anthropic's guidance, you can often skip RAG and include all of it in the prompt. We Build Custom Software builds RAG systems when a business's documents are too large or change too often for that.
Key facts
- Stands for: retrieval-augmented generation. The term comes from a 2020 research paper by Patrick Lewis and colleagues.
- How it works: search your content for the passages relevant to a question, put them in the prompt, and have the model answer from them.
- Why it's used: models don't know your business, and retraining a model on your documents is slow, costly, and hard to keep current.
- When you can skip it: Anthropic says a knowledge base under 200,000 tokens (about 500 pages) can often go straight into the prompt, with prompt caching to keep it fast and affordable.
- Built-in options: as of November 2026, OpenAI's API offers a hosted file search tool, and Claude Projects switch to a retrieval mode on paid plans when project knowledge nears the limit.
- Security: OWASP's 2025 Top 10 for LLM applications includes vector and embedding weaknesses, such as one user's documents leaking into another user's answers.
What does RAG mean in AI?
RAG means the AI retrieves information before it generates an answer. A language model on its own only knows what was in its training data, which doesn't include your price rules, your warranty terms, or last week's job notes. RAG adds a lookup step: your software finds the right pieces of your own content and hands them to the model along with the question, with an instruction to answer from that material.
The idea was named in a 2020 paper, "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks," which combined a language model with a searchable index of documents and found the answers were more specific and factual than the model alone. Today the same pattern underlies most "chat with your documents" products.
How does RAG work, step by step?
- Prepare your content. Documents, web pages, manuals, and records are split into passages ("chunks") of a few paragraphs each.
- Index it. Each chunk gets an embedding: a list of numbers that represents its meaning, so passages about "refunds" and "money back" land near each other. These go into a vector database (a database built to search by meaning). Good systems also keep a keyword index, because exact terms like part numbers matter.
- Search at question time. When someone asks a question, the system finds the most relevant chunks, by meaning and by keyword.
- Check permissions. Your code removes anything this user isn't allowed to see.
- Answer. The model gets the question plus the retrieved passages and instructions such as "answer only from these sources, cite them, and say so if the answer isn't here."
- Show sources. The answer links to the documents it came from, so a person can check.
OpenAI's hosted file search tool, for example, stores your files in vector stores and combines meaning-based and keyword search for you. Custom systems do the same with a database you control, such as PostgreSQL with a vector extension.
Do you need RAG, or can you just give the AI all your documents?
If your material is small, give it all to the AI. Anthropic's guidance is that a knowledge base under 200,000 tokens, roughly 500 pages, can simply be included in the prompt, and prompt caching (reusing the same long prompt across requests at lower cost) keeps that practical. That covers a lot of small businesses: a service list, policies, a price rule sheet, and an FAQ often fit easily.
You need RAG when:
- your content is larger than that, such as years of job records, a big product catalog, or a library of manuals
- it changes often and must be current (inventory, order status, schedules)
- different users should see different documents
- you want answers to point to the exact source passage
How we handle this
We start by looking at what the AI needs to know and how big and how fresh that material is. If it fits in the prompt, we keep it simple. If it doesn't, we build retrieval over your documents or database with permission checks in code, and we test it against real questions from your business before anyone relies on it. You work with the person building it throughout.
Why does RAG still give wrong answers sometimes?
Most RAG failures are retrieval failures: the right passage wasn't found, so the model answered from the wrong one or from its general knowledge. Common causes and fixes:
- Chunks lose context. A passage that says "the fee is waived after 30 days" means nothing without knowing which fee. Anthropic's "contextual retrieval" approach adds a short description of where each chunk came from before indexing it.
- Outdated or conflicting documents. If two versions of a policy are indexed, the AI may quote the old one. Clean up sources and keep one current version.
- Exact terms missed. Meaning-based search alone can miss part numbers and codes; combine it with keyword search.
- The model fills gaps. Instruct it to say when the sources don't contain the answer, and test that it does.
- Leaks between users. If permissions aren't enforced in code before retrieval, one customer could get another's information. OWASP lists this class of problem among its top LLM risks.
Questions
What's the difference between RAG and fine-tuning?
RAG gives the model your information at question time; fine-tuning further trains a model on examples to change its behavior or style. For answering from business documents, RAG is usually the better fit because you can update a document and the next answer reflects it, and you can see which source was used. Fine-tuning is better suited to teaching a consistent format or tone.
Does a small business need RAG?
Often not at first. If everything the AI needs fits in a few hundred pages, you can include it directly in the prompt or use a Claude Project or custom GPT with uploaded files. RAG becomes worth building when your content is large, changes often, or needs per-user permissions.
Does RAG send all my documents to the AI company?
No. Only the passages retrieved for each question go to the model with that request; the full library stays in your own database or storage, unless you use a hosted tool like OpenAI's file search, which stores the files with OpenAI. Use business API terms, which as of November 2026 exclude your data from training by default at OpenAI, Anthropic, and Google.