PreviewYou're previewing CTO AI Forge. Sign in to use it.Sign in
← All lessons
L0 · AI basics for technology leaders8 min read

Giving models your knowledge: context, retrieval (RAG) and fine-tuning

A model trained on public data does not know your codebase, your APIs, your runbooks or last week's incident. There are three ways to give it that knowledge.

1. Put it in the prompt (context)

The simplest approach: include the relevant files, docs or examples directly in the request. Coding tools do this automatically with open files and nearby code. It works until the knowledge you need is too large or too scattered to send every time.

2. Retrieval-augmented generation (RAG)

RAG searches your own sources first — code, docs, tickets, wikis — and adds the best matches to the prompt. The idea was set out in a 2020 research paper by Lewis and colleagues, who combined a model's built-in knowledge with a searchable document index. In engineering, RAG powers "ask the codebase" chat, documentation assistants and incident tools that pull similar past incidents.

RAG quality depends on search quality: how documents are split, indexed, ranked and kept fresh. A RAG system over stale wiki pages confidently returns stale answers.

3. Fine-tuning

Fine-tuning continues training a model on your examples so it learns a style, format or narrow task (for example your code conventions, or classifying alerts). It changes the model itself, which means data preparation, training runs, evaluation, hosting or vendor fine-tuning fees, and redoing the work when you want a newer base model.

Which to choose

  • Facts that change (docs, code, tickets): retrieval.
  • Behaviour, format or a narrow repeated task where prompting falls short: consider fine-tuning.
  • Start with prompting and retrieval; fine-tune only when evaluations show a gap that cheaper methods can't close.

Research supports this order for knowledge: a 2023 study comparing the two for injecting knowledge found retrieval consistently beat unsupervised fine-tuning, for both existing and new knowledge.

What this means for the CTO

For a CTO this is a platform decision more than a model decision. Retrieval needs clean, permissioned, well-indexed sources — code search, docs, tickets — and someone who owns their freshness. Fine-tuning needs ML skills, evaluation sets and a plan for model upgrades.

When a team proposes fine-tuning, ask what retrieval and better prompting achieved first, and what the evaluation results were. Most engineering knowledge problems are search and documentation problems in disguise.

Practically, that means funding the unglamorous parts: code search, up-to-date docs and clean ticket data. They help humans and AI alike.

Diagram

Giving models your knowledge: context, retrieval (RAG) and fine-tuning

Real example

Researchers from Microsoft (Ovadia, Brief, Mishaeli and Elisha, 2023) compared unsupervised fine-tuning with retrieval-augmented generation for adding knowledge to LLMs and found that "RAG consistently outperforms it, both for existing knowledge encountered during training and entirely new knowledge"; they also noted LLMs struggle to learn new facts through fine-tuning alone. Source: Ovadia, Brief, Mishaeli & Elisha — Fine-Tuning or Retrieval? Comparing Knowledge Injection in LLMs (arXiv 2312.05934, 2023) ↗

Use it

Quick check · 3 questions

  1. 1.Your engineers want an assistant that answers questions about internal APIs that change every sprint. What is usually the best first approach?

  2. 2.What does RAG quality depend on most?

  3. 3.When is fine-tuning most worth considering?

0 of 3 answered

Sources

Last reviewed 2026-10-01.