When to Fine-Tune vs. Prompt vs. RAG

Three tools for adapting LLMs to specific use cases. They solve different problems - picking the wrong one wastes months. This post gives you the decision framework.

The Three Tools and What They Solve

Prompting: Tell the model what to do through the input. Zero data required. The fastest path.

  • Best for: task framing, style/tone adjustment, structured output, adding context
  • Not for: teaching the model new factual knowledge, changing persistent behavior across sessions

RAG (Retrieval-Augmented Generation): Give the model relevant documents at query time. Requires an indexed knowledge base.

  • Best for: domain-specific knowledge, up-to-date information, grounded responses with citations
  • Not for: teaching the model new reasoning patterns or changing output style

Fine-tuning: Continue training the model on domain-specific examples. Requires labeled data (typically 100–10,000 pairs).

  • Best for: consistent output format/style, domain-specific tone, specific task patterns
  • Not for: teaching new factual knowledge (models hallucinate confidently even after fine-tuning on facts)

Decision Framework

Is the required information in the base model's training data?
  YES → Can prompting reliably elicit it?
    YES → Use prompting. Done.
    NO → Is it a style/format/behavior issue?
      YES → Fine-tune on examples.
      NO → Re-examine why prompting fails.
  NO → Does the information change frequently, or must it be sourced/cited?
    YES → Use RAG.
    NO → Is the information static and proprietary?
      YES → RAG (avoids the hallucination-from-fine-tuning risk).
      NO → Consider both RAG and fine-tuning.

When Prompting Alone Fails

Signs that prompting is insufficient:

  • The model ignores format instructions reliably (structured output consistently broken)
  • Output style deviates from what you need despite explicit instructions
  • The model requires very long system prompts (> 2000 tokens) to behave correctly, slowing inference and increasing cost
  • Response quality is inconsistent across otherwise similar inputs

Fine-tuning on a few hundred examples of correct (input, output) pairs is often the right fix for these failure modes.

When RAG Is the Right Choice

Use RAG when:

  • The knowledge base changes frequently (new documents added regularly)
  • Users need verifiable sources for trust reasons
  • The information is company-specific and was not in the base model training data
  • The knowledge base is large and cannot fit in a context window

RAG is not magic: retrieval quality gates generation quality. If the retrieval does not find the relevant document, generation fails. Invest in the retrieval pipeline.

When Fine-Tuning Is Worth It

Fine-tuning on factual information is usually a mistake - models continue to hallucinate even after fine-tuning with accurate data. Fine-tuning changes behavior, not knowledge.

Fine-tuning is worth it when:

  • You have 500+ high-quality (input, output) pairs
  • The task is well-defined and repetitive (classification, extraction, specific generation format)
  • Inference cost matters (fine-tuned smaller models can match large-model quality for specific tasks)
  • Consistent style/tone across all responses is critical

The Combination Strategy

In production, the best systems often combine all three:

  1. System prompt (prompting): Sets role, tone, constraints, and format
  2. RAG: Injects domain-specific context for each query
  3. Fine-tuned model: The model has been trained to follow instructions precisely and produce the right format reliably

Each layer solves a different problem. The system prompt frames the task; RAG provides the knowledge; fine-tuning ensures reliable execution.

Practical Data Requirements for Fine-Tuning

If you decide to fine-tune, minimum data requirements:

Task TypeMinimum Quality ExamplesNotes
Format/structure following100-500Format is consistent, so fewer examples needed
Domain-specific tone200-1000Cover the range of tone variations
Task-specific behavior500-2000More varied outputs need more coverage
Complex reasoning patterns2000+Reasoning is hard to learn from few examples

Data quality matters more than quantity. 200 carefully curated examples outperform 2000 noisy ones. Always validate examples manually before fine-tuning.

Related Posts

More posts

Fine-Tuning and Post-Training: LoRA, SFT, DPO, and Reasoning RL

What actually happens after pretraining, and when you should do any of it yourself. Parameter-efficient fine-tuning with LoRA, supervised fine-tuning data, preference optimization, and the reinforcement learning recipe behind reasoning models, with a decision framework and a project you can run on one GPU.

#fine-tuning#post-training#rl#reasoning-models#huggingface#llm

LLM Context Windows: What They Mean for System Design

Context window size shapes every architectural decision in LLM applications. This post covers how to reason about context allocation, the limits that still matter even with large windows, and the patterns that scale.

#llm#system-design#transformers

Common ML Architectures Reference: CNN, RNN, Transformer, MoE

A concise technical reference for the neural network architectures that power modern ML - what each one does, how it works, when to use it, and what to watch out for.

#cnn#reference#moe#deep-learning#rnn#transformer