Feedough Logo

What Is RAG in AI? How It Works, Benefits and RAG vs Fine-Tuning

By Aashish Pahwa

12 min read

[Reader Disclosure]Our content is reader-supported. This means we may earn a commission if you click on some of our links.

RAG stands for retrieval-augmented generation. It means the AI first looks up the most relevant passages in your documents, then answers from them, instead of answering only from what it learned in training.

A model only knows its training data. That data stops at a cutoff date and never included your company’s files, so on questions about your business it guesses. RAG hands it the right page at the moment you ask.

We ran a test on 2 December 2026 to see how much that matters. With no documents, gpt-4.1-mini got 43 of 60 answers wrong about a made-up tea company, Kettle & Pine. With the documents in play, pasted or found by RAG, the two models we tested got 240 of 240 right.

You will see how RAG works, what it fixes, what our test showed, how it compares with fine-tuning, which one to use, where it fails, and a prompt to try in ChatGPT with your own file.

How RAG Works

RAG adds one look-up step before the AI writes its answer. The name breaks into three parts: retrieval is finding the right passages, augmented means adding them to your question, and generation is the model writing the reply from them.

A typical RAG system runs five steps:

  1. Split your documents into small chunks. A chunk is one paragraph or a few.
  2. Turn each chunk into an embedding.
  3. Turn the question into an embedding too, then find the chunks whose embeddings sit closest to it.
  4. Give those few chunks to the model along with the question.
  5. Let the model write the answer from those chunks, and point to where it found each fact.

An embedding is a list of numbers that captures what a piece of text means, so texts about similar things get similar numbers even when they share no words. A customer who writes “my box arrived crushed” still lands on the paragraph about damaged boxes, and a support assistant then answers from it.

The name comes from the 2020 paper that named RAG, by Patrick Lewis and colleagues at Facebook AI Research, UCL and NYU, first submitted on 22 May 2020. It paired a trained model (what it had memorised) with a searchable index of Wikipedia (what it could look up), and gave more specific and factual answers than the model on its own.

Most chatbots and business apps that let you upload files or connect a knowledge base run some version of this look-up step behind the scenes.

The same step shows up inside AI agents, which can search documents as one of their tools.

Benefits of RAG

That look-up step pays off in five concrete ways:

  • Answers from your own, current documents. Company policies, product specs and last week’s notes never made it into any model’s training data, and that data always stops at a cutoff date. For a closer look at what a model learned, see how ChatGPT works.
  • Fewer made-up answers. In a 2021 study by Facebook AI Research, human judges found that a chatbot without retrieval invented facts in 68.2% of its replies. The best retrieval-augmented version did it in 7.9%.
  • Updates without retraining. Change your refund policy this morning and the next answer uses the new text. You swap a document, not a whole training run.
  • Answers that show their sources. The reply comes from specific chunks, so the app can cite the handbook section or page behind each fact. You can check where it came from.
  • Costs less than retraining. OpenAI’s API pricing puts its file search tool, its ready-made RAG, at $2.50 per 1,000 searches plus $0.10 per GB of storage a day, with the first 1 GB free. Fine-tuning gpt-4.1-mini is listed at $5.00 per million training tokens before you ask a single question, and the same page now says fine-tuning is closed to new users.

RAG vs Pasting the Whole Document vs No Documents: What We Found

Price lists tell you what a technique costs. They do not tell you what it buys. So we ran the comparison ourselves.

We ran this test through the OpenAI API on 2 December 2026 with gpt-4.1-mini and gpt-5.4-mini. We wrote a 15-paragraph support handbook for a made-up tea subscription company, Kettle & Pine, with 20 facts no model could know: the founder, the prices, the shipping day, the refund window and more. Each model answered 20 customer questions three times in each of three ways: with no documents, with the whole handbook pasted into the prompt, and with RAG, where the 15 paragraphs were turned into embeddings and only the 3 closest to each question were passed to the model. We also asked 4 questions the handbook does not answer, then changed 3 facts and asked again. A script checked every answer against the handbook.

Method
Correct (of 120)
Wrong (of 120)
Input tokens per question (about)
Changed facts right (of 18)
No documents
19
52
60
0
Whole handbook pasted
120
0
560
18
RAG (3 closest of 15 paragraphs)
120
0
170
18
Chart of Feedough's RAG test on a made-up tea company handbook: no documents got 19 of 120 answers right and 52 confidently wrong, while the whole handbook pasted and RAG each got 120 of 120, with RAG using about 170 input tokens per question against 562
Our RAG test: no documents vs the whole handbook pasted vs RAG on the same 20 questions. Tap to enlarge.

The other 49 no-document answers were “I don’t know” (46 from gpt-5.4-mini, 3 from gpt-4.1-mini), and gpt-4.1-mini’s 14 correct ones were lucky guesses that matched common defaults such as 30-day returns and no phone line.

Without documents gpt-4.1-mini put the company in Seattle instead of Halifax and priced the Brew plan at $24 instead of $29. On the look-up side, RAG found the right paragraph in its top 3 in 138 of 138 look-ups, and re-embedding the 3 changed paragraphs took 0.28 seconds.

One answer shows what guessing looks like. The handbook has no Earl Grey, and it has no caffeine figures at all:

gpt-4.1-mini, no documents
Q: How much caffeine is in your Earl Grey?
A: Our Earl Grey tea contains approximately 40-70 mg of caffeine per 8 oz cup.

Now the refund window, after we changed it from 30 days to 45 days and re-embedded the changed paragraphs:

gpt-4.1-mini, RAG
Q: How long do I have to return unopened tea?
A: You have 45 days from delivery to return unopened tea for a full refund.

On the 4 questions the handbook does not answer, gpt-5.4-mini said it did not know all 12 times in every setup. gpt-4.1-mini invented an answer 9 of 12 times with no documents, 6 of 12 with the whole handbook and 3 of 12 with RAG.

What This Means

  • With a small document, just paste it. Pasting the whole handbook was as accurate as RAG on all 20 questions the handbook answers. You do not need a look-up system for 15 paragraphs.
  • RAG matched it at about a third of the input tokens, around 170 versus 560 per question. And it keeps working when the documents are far too big to paste.
  • RAG picks up changes in seconds. Re-embed the changed paragraph and the next answer is right. No retraining, no waiting.
  • The model matters for questions your documents cannot answer. The newer gpt-5.4-mini admitted not knowing far more often than gpt-4.1-mini.

One small made-up handbook, two small OpenAI models, 3 runs each, answers checked by a script. Real document sets are bigger and messier, so treat this as a demonstration, not a benchmark. Section 07 covers how RAG fails on real data.

RAG vs Fine-Tuning

Fine-tuning is the other way people try to teach a model new knowledge. It means training the model further on your own examples until its weights change. Those weights are the numbers inside the model that store what it learned. RAG never touches them. It hands the model the right pages at question time.

That difference decides the job. Fine-tuning changes how a model writes. RAG changes what it can read. A support bot that must always sound like your brand is a fine-tuning job. A price list that changes every month is a RAG job.

 
RAG
Fine-tuning
What it changes
What the model reads for each question
The model’s weights
Best for
Facts, documents, anything that changes
Tone, format, a narrow repeated task
Updating
Edit or add a document, live in seconds
Collect new examples and train again
Cost and effort
Search and storage fees; a few hours to set up with ready tools
A training run, pricier calls to the custom model, and hundreds of good examples
Risk of made-up answers
Lower, and answers can be checked against sources
Still guesses on facts it did not learn well, with no source to check

A Microsoft study comparing the two shows the knowledge gap. The team asked about facts newer than the model’s training. Mistral 7B scored 0.481 on its own, 0.504 after fine-tuning and 0.875 with RAG. Those are Mistral 7B scores on their current-events questions, and the authors found that models struggle to learn new factual information through unsupervised fine-tuning.

We planned to add a third method to our own test: fine-tune gpt-4.1-mini on question-and-answer pairs about the Kettle & Pine handbook, then score it like the rest. On 2 December 2026 OpenAI refused the training job for our account, and the same refusal came for gpt-4.1-nano and gpt-4o-mini.

POST /v1/fine_tuning/jobs, 403 training_not_available
"OpenAI is winding down the fine-tuning platform and your organization is no longer able to create new fine-tuning training jobs."

That refusal applied to our account. The wider timeline sits on OpenAI’s deprecations page. Organisations that had never run a fine-tuning job lost the option on 7 May 2026, and from 15 December 2026 no organisation can create new self-serve fine-tuning jobs. Fine-tuned models you already built keep running until their base model is retired.

For most teams building on OpenAI, that makes RAG, or simply pasting the document, the practical default for adding knowledge.

Which Should You Use? A Simple Ladder

Start at step 1 and only climb when the step below stops working.

  1. Write a better prompt. Give the model the task, the context and the format you want, as covered in how to write a good prompt. OpenAI’s fine-tuning guide says the prompt engineering process may be all you need.
  2. Paste the document. For one or a few small files, paste or attach them. A founder with a one-page pricing sheet needs nothing more, and pasting was as accurate as RAG on the answerable questions in our test. Anthropic puts the limit at about 200,000 tokens, roughly 500 pages. Under that, send the whole knowledge base in the prompt.
  3. Use a file or project feature, or RAG. Many documents, frequent changes, or files too big to paste? Upload them to a file or project feature in your chat app. A support team with hundreds of help articles is at this step, and a developer can set up RAG for it.
  4. Fine-tune only for style or format at scale. Think thousands of product descriptions in one fixed format, or the same tone every single time. OpenAI lists fine-tuning’s best uses as a set format, fixing instructions the model ignores, tone and style, and training a smaller, cheaper model for one task. For outside information, its advice is to put it in the prompt.

You can also combine the two. In Microsoft’s agriculture study, fine-tuning raised accuracy by over 6 percentage points, and RAG added about 5 more on top. Yet the study in the section above found that adding fine-tuning to RAG did not beat RAG alone on brand-new facts. So start with RAG.

Where RAG Goes Wrong

Starting with RAG is the right default, but the look-up step is no guarantee. Five things go wrong:

  • Retrieval brings back the wrong passages. If the search step misses the right chunk, the model answers from the wrong page and still sounds sure of itself. Anthropic’s contextual retrieval tests measured standard retrieval missing the right chunk 5.7% of the time. Adding a short note of context to each chunk cut that to 3.7%, and pairing it with keyword search (BM25) cut it to 2.9%, and an extra reranking step that re-sorts the results cut it to 1.9%. That last figure is a 67% cut, and it needs the reranking step. These are retrieval failures, not hallucinations.
  • Chunks can cut a fact in half. The price sits in one chunk and its conditions in the next, so the model sees half the rule and fills in the rest. Keep related sentences in the same chunk.
  • Old documents stay in the index. If last year’s refund policy is still embedded, the model may quote it as current. Remove or label old versions when a file changes.
  • The model still fills gaps. With RAG in play, gpt-4.1-mini still answered 3 of 12 unanswerable runs with a confident guess, each time saying the company does not sell tea kettles when the handbook never says so. Paid tools do it too. A Stanford study of legal AI tools found Lexis+ AI and Ask Practical Law AI gave incorrect information more than 17% of the time, and Westlaw AI-Assisted Research more than 34%.
  • Your documents leave your walls. They go to the model provider and sit in a search index. Keep passwords, customers’ personal data and confidential files out unless your company’s AI policy allows them.

Check any answer that matters against the source it cites.

Try It: Ask ChatGPT About Your Own Document

You can get grounded answers like these in ChatGPT today, with no code and no setup. Grab a document you already have: a company handbook, a policy, a report.

Feedough's ChatGPT Prompt Generator writing a prompt that answers questions only from an attached company handbook and says when the answer is not in it
Feedough’s ChatGPT Prompt Generator writing a prompt that answers only from your document.
  1. Open a new chat and attach the document with the attach (+) button.
  2. Paste the prompt below, then replace the question with your own.
  3. Check the answer against the section it names. Then ask one question you know the document does not answer, to see whether it admits it.
Answer my question using only the document I attached.
- Name the section or heading your answer comes from.
- When you give a number, date or price, quote the exact sentence.
- If the answer is not in the document, reply "Not in the document" and stop. Do not guess.

My question: [your question]

This is RAG done by hand. You supply the document and tell the model to stay inside it.

You can build prompts like this for other tasks with Feedough’s ChatGPT prompt generator.

Just leave anything private out, as the section above covers.

RAG: Quick Answers

What does RAG stand for in AI?

RAG stands for retrieval-augmented generation. The model retrieves the passages most relevant to your question, adds them to the prompt, and generates its answer from them. The name came from a 2020 Facebook AI Research paper.

What is RAG in simple terms?

Treat it like an open-book exam. A model on its own answers from memory and often guesses. With RAG, the AI looks up the right page first, then answers from what that page says.

What is the difference between RAG and fine-tuning?

RAG hands the model your documents at question time and never touches the model itself. Fine-tuning trains the model further, so its weights change. RAG suits facts and fine-tuning suits style and format, as the RAG vs Fine-Tuning section above shows.

Is RAG better than fine-tuning?

For adding knowledge, usually yes. In Menlo Ventures’ 2024 survey of 600 US IT decision-makers, RAG was the most-used design pattern at 51% adoption, up from 31% a year earlier, while only 9% of production models were fine-tuned. For tone or format, fine-tuning can still win.

Can you use RAG and fine-tuning together?

Yes. One Microsoft study found the gains stacked. But when you need brand-new facts, start with RAG and add fine-tuning only if you also need a fixed style.

The Bottom Line

One rule to keep: RAG makes the AI answer from your documents instead of guessing. For one small file, paste it into the chat. For many files or facts that change, use RAG. Fine-tune only to fix tone or format, not to teach facts.

The next lessons in Feedough’s free prompt engineering course build on this one.

Aashish Pahwa

Aashish Pahwa

Aashish Pahwa is the founder of Feedough and Koso, an AI agency that builds custom AI systems for companies. He has trained more than 50,000 people to use AI, teaches AI to over 180,000 followers on Instagram (@okaashish), and has spoken at WordCamp Mumbai and DevFest Noida. Feedough’s work has been cited by Harvard Business School and Al Jazeera.

Read Feedough’s editorial standards

Put this to work.

Free Feedough tools for the next step.

  1. Chatgpt Prompt GeneratorGenerate effective ChatGPT prompts
  2. 15000+ Chatgpt Prompts15,000+ ready-to-use AI prompts
  3. AI Prompt GeneratorCreate powerful AI prompts instantly
See all free tools