Velamuvi AIAcademy

Lesson 2 of 16 · Foundations

RAG vs Fine-Tuning

RAG vs fine-tuning: what each changes, cost, freshness, sources and effort, a rule of thumb (RAG for knowledge, fine-tuning for behaviour) and when to combine.

  • 6 min read
  • Intermediate
  • Reviewed
In this lesson you will learn
  • Explain what RAG changes and what fine-tuning changes
  • Compare them on freshness, sources, cost and effort
  • Choose the right approach for a given need
  • Estimate the extra token cost that RAG adds

Two ways to make a model fit your needs

RAG leaves the model untouched and changes what it reads for each question. Fine-tuning changes the model itself. That one difference explains most of the trade-offs.

RAGFine-tuning
What changesThe prompt: relevant passages are addedThe model's weights
Best forKnowledge: facts, documents, dataBehaviour: tone, format, style, narrow skills
Updating factsEdit a document; works immediatelyRetrain the model
Showing sourcesYes, you know which passages were usedNo; knowledge is blended into the weights
Upfront effortAn ingestion pipeline and a search indexA training dataset (often hundreds to thousands of good examples), training runs
Cost per questionExtra input tokens for the passagesOften lower (shorter prompts), but training costs extra
Access controlFilter what each user's search can seeHard: everything trained in is available to everyone

A useful rule of thumb: RAG for knowledge, fine-tuning for behaviour. Fine-tuning is a poor way to teach facts: the model may blend or half-remember them, it can't show where an answer came from, and every change needs new training.

The cost of RAG, in tokens

Every retrieved passage becomes input tokens that you pay for and that take time to process. A quick estimate helps you choose how many chunks to send:

Try it yourselfPython
# What does RAG add to each request? Retrieved text = extra input tokens.
# The prices below are made-up round numbers: look up your provider's real prices.
price_per_million_input = 1.00      # dollars per 1 million input tokens (example)
chunks_per_question = 5
tokens_per_chunk = 300
questions_per_month = 100_000

extra_tokens = chunks_per_question * tokens_per_chunk * questions_per_month
extra_cost = extra_tokens / 1_000_000 * price_per_million_input

print(f"Extra input tokens per question: {chunks_per_question * tokens_per_chunk:,}")
print(f"Extra input tokens per month:    {extra_tokens:,}")
print(f"Extra cost per month:            ${extra_cost:,.2f}")

Change chunks_per_question to 3 or tokens_per_chunk to 500 and watch the cost move. Retrieving well (fewer, better chunks) saves money as well as improving answers.

Choosing, with examples

Before either, always try better prompting: clear instructions and a few examples solve many “the model doesn't do what we want” problems at no extra cost.

Common mistakes

Practice exercise

Decide which approach fits each need. Fresh facts and citations point one way; tone and style point the other.

Your solutionPython
needs = {
    "answers must use documents that change every week": "RAG",
    "replies must always follow our brand's tone and format": "?",
    "answers must cite the policy they came from": "?",
    "a small, cheap model must write in our house style without long instructions": "?",
}

# Replace each "?" with "RAG" or "fine-tuning":
# RAG adds knowledge (and sources); fine-tuning changes behaviour and style.
for need, choice in needs.items():
    print(f"{choice}: {need}")
Knowledge check

Your product prices change every week and answers must show where each price came from. Which approach fits best?

Summary

  • RAG changes what the model reads; fine-tuning changes the model's weights.
  • Rule of thumb: RAG for knowledge, fine-tuning for behaviour (style, format, narrow skills).
  • RAG gives fresh facts, sources and per-user access control; it costs extra input tokens per question.
  • Try better prompting first, and combine approaches when a project needs both.

Next: the parts of a RAG system and how they connect.

Finished reading? Tick it off to track your progress.