Prompt, RAG or fine-tuning?

These methods change different things.

What you will learn

  • Explain: instructions, knowledge and adaptation
  • Apply the idea in an example: Prompt, RAG or fine-tuning?
  • Recognize limitations and verify the exercise outcome

These methods change different things. Choose based on whether the problem concerns instructions, facts or repeated behavior.

You can follow this course without an account or programming. Examples use synthetic data and AI outcomes need checking.

How it works, step by step

Instructions, knowledge and adaptation

A prompt changes request instructions and examples. RAG changes available evidence without modifying the model. Fine-tuning adjusts parameters for repeated behaviors or tasks and needs quality data and evaluation. LoRA/PEFT trains a smaller parameter set for efficient adaptation. Distillation transfers behavior from one model to another; quantization reduces numeric precision for efficient inference, with tradeoffs. None automatically repairs wrong sources. For frequently changing rules, updating documents is usually easier to verify than retraining.

RAG accesses evidence, it does not retrain

RAG means retrieval-augmented generation: retrieval supplies relevant passages before the model answers. Ingestion prepares documents, while query execution searches the index and builds context. An embedding model represents text numerically; the response model writes the answer. Rerankers, vision, graph and router models have different roles when needed. RAG helps with private or changing information but does not guarantee truth. Use an authorized API for balances, exact inventory or permissions; an old document is not a reliable source for current state.

Define success before optimizing

Prepare representative requests and expected answers or properties. Include ordinary cases, ambiguity, missing data and tool errors. For RAG, measure evidence retrieval separately from answer correctness. Recall@k measures the share of relevant evidence found in the first k results; precision@k measures the share of returned results that are relevant. For agents, also track actions, permissions and stopping. An LLM-as-judge can speed evaluation but needs calibration against humans. Do not change prompt, model and index simultaneously if you want to understand what improved results.

The visual map

Prompt, RAG or fine-tuning? Follow the solid arrows for the main flow. Dashed blue arrows supply data or context; dashed pink arrows show feedback or returning results. Colors and shapes distinguish models, stores, decisions and outputs. Connections: Problem and success criteria → Choose next action; Task, constraints and output format → Agent / LLM; Agent / LLM → Compare against expected results; RAG knowledge → Agent / LLM; Fine-tuning (external) → Adapted model behaviour; Adapted model behaviour → Compare against expected results; Capabilities and constraints → Choose next action; Choose next action → Task, constraints and output format (Instructions); Choose next action → RAG knowledge (Knowledge); Choose next action → Fine-tuning (external) (Behaviour (external)). P07 · Relationship map Prompt, RAG or fine-tuning? Input Problem and success criteria Data Capabilities and constraints Decision / control Choose next action Data Task, constraints and output format Store / index RAG knowledge Processing Fine-tuning (external) AI model / agent Agent / LLM AI model / agent Adapted model behaviour Decision / control Compare against expected results Instructions Knowledge Behaviour (external) Main flow Data and context Feedback and return

Follow the solid arrows for the main flow. Dashed blue arrows supply data or context; dashed pink arrows show feedback or returning results. Colors and shapes distinguish models, stores, decisions and outputs. On smaller screens, scroll horizontally to follow the entire diagram.

A complete example

Overly technical tone needs clearer prompting. A new policy needs updated sources and RAG. Repeated specialist formatting may justify fine-tuning after simpler options are evaluated.

Try it yourself

  1. Choose a solution for tone, live stock, a new policy and repeated formatting.
  2. Record the input, source and expected outcome before running the experiment. Use only the fictional data in the example.
  3. Follow the diagram stages. At every step record what information is received and produced; do not confuse intermediate output with the final outcome.
  4. Repeat after removing necessary information or making the input ambiguous. Check whether the system clarifies, stops or invents an answer.
  5. Compare with the explained solution. Keep the configuration, date, result and an explanation for differences. Change one thing and retest.

An explained solution

Use prompts for requirements, RAG for documents and adaptation only with adequate data and evaluation. A successful exercise lets you show the connection between input, stages and outcome. When information is missing, a cautious answer is more useful than invented details. Compare more than style: check conditions, sources and operations too.

When it helps and what can go wrong

Fine-tuning is not a live database. Choose this approach when it improves a measured need. Keep a simple baseline and compare outcomes using identical inputs. One successful example does not establish reliability in every situation.

Check your understanding

Is fine-tuning the first choice for current stock?

No. Use an authorized live source for rapidly changing information.

Does RAG change LLM parameters?

No. It supplies request-time context; parameter changes belong to training.

What outcome should this exercise produce?

Use prompts for requirements, RAG for documents and adaptation only with adequate data and evaluation.

Words to remember

  • Fine-tuning: Adapting model parameters using task-specific examples.
  • Retrieval: Finding relevant information in accessible sources.
  • Regresie / Regression: A change that breaks a previously correct case.

Sources and your next step

To prepare: P06 — Reasoning and verification