MODULE 5 · LESSON 21 · 12 MIN
Build vs. Buy: Foundation Models, Fine-Tuning, or RAG?
By Siten Sanghvi · Published · Updated
Name the gap before you choose a tool. If the model lacks information, supply it in the request (retrieval is one way). If it answers in the wrong shape, fix the prompt first and fine-tune only if tests still show a gap. If it is not capable enough, try a stronger model. If the problem is cost, delay, privacy or control, look at where the model runs. A prompt-only baseline on your own test cases shows which gap you have. Pre-training from scratch is out of reach for almost every team: Epoch AI estimated GPT-4's final run at about $40 million in hardware and energy alone (BT-L07).
"Build vs. buy" is two choices. Where does the model run? A hosted API, a managed cloud platform, or an open-weight model you host (BT-L16). How do you adapt it? Prompting, retrieval, or fine-tuning. They combine freely. OpenAI's accuracy guide calls them levers that solve different things, not a ladder: one supplies context (what the model knows when it answers), the other changes behavior (format, tone, reasoning). Vendor facts are dated 2026-11-11.
The levers in plain terms
- Prompting: change the instructions and examples sent with each request.
- Retrieval-augmented generation (RAG): look up passages when a question arrives and add them to the request. The weights stay the same (BT-L13).
- Fine-tuning: continue training on your own examples, which changes the weights (BT-L07). LoRA trains small add-on matrices while the original weights stay frozen (paper: 10,000 times fewer trainable parameters than fully tuning GPT-3 175B).
- Open-weight model: one whose trained weights you can download and run. That is not automatically "open source": OSI's definition also requires training-data information and code.
Step 1: name the gap
| What you see | Gap | Try first |
|---|---|---|
| Wrong or outdated facts about your products or policies | Knowledge | Put the current text in the request: paste it, include the whole document if it fits (Anthropic's 2024 advice: under about 200,000 tokens, if budget allows), or retrieve passages |
| Right content, wrong shape: format, tone, labels | Behavior | Clearer instructions and examples; a schema-constrained output setting if offered (OpenAI's enforces a JSON Schema, but your code still checks business rules); fine-tune if held-out tests still fail and your provider offers tuning for your model |
| Mistakes on hard reasoning cases | Capability | A stronger model, compared on your cases |
| Bill or delay too high at volume | Efficiency | Smaller model, shorter prompts, caching (BT-L16); for one narrow task, a fine-tuned small model |
| Documents cannot go to a third party, or you need control | Hosting | Change where the model runs, then rerun your test set: start from the same lever, but a different model can change what you need |
OpenAI's fine-tuning guide suggests writing evals before prompts. Collect real questions with known good answers (BT-L19 covers sizing), grade each criterion separately, run a prompt-only baseline and read the failures.
EXHIBIT 21 / BUILDBUY
Explore the mechanismChange the right layer.
Separate what the system needs from where the model runs.
Missing or changing facts
Hosting changes who operates the stack and handles data. Compare outcomes on your own cases.
Inspect the example data and reasoning
| Element | What to notice |
|---|---|
| First thing to try | Supply current evidence. Model weights stay unchanged; test that the right passage is found and used. |
| Where it runs | Prompts go to the provider under its terms. |
Decision aid, not a universal ranking. Deployment and adaptation are different axes and can be combined.
Read the mechanism without interacting
- Baseline
- Test the simplest hosted or local baseline against your task first.
- Context
- Supply current evidence when missing information is the issue; retrieval is one way to do it.
- Adaptation
- Fine-tuning can change learned behavior; it is not a guaranteed factual database.
For a changing handbook, test supplied passages. For repeated output errors, compare prompt changes before a fine-tuning experiment.
Try explaining it: What evidence would justify adding retrieval or fine-tuning to your baseline?
What studies show about adding facts
- Ovadia et al. (Microsoft) tested three 7-billion-parameter models on Wikipedia-based multiple-choice questions, including events after their training cutoffs. On the post-cutoff current-events questions one model scored 48% unaided, 88% with retrieved passages, 50% after fine-tuning on the text and 59% after fine-tuning on ten paraphrases of each passage. On those questions fine-tuning plus retrieval did not beat retrieval alone for any model; on the older subject-area questions it sometimes did. Each current-events question matched one source passage, which authors say suited retrieval.
- Gekhman et al. (paper) fine-tuned one model on closed-book questions. Facts it did not already know were learned slowly and, once fitted, raised its tendency to hallucinate. It concludes models mostly acquire facts in pre-training.
- Soudani and Kanoulas (study) tested twelve models on rarely seen facts. Retrieval beat fine-tuning by a large margin.
Scope: small to mid-sized models, question answering, mostly Wikipedia-style text; only Ovadia and Soudani tested retrieval; no full cost, delay or upkeep comparison. They do not show that fine-tuning never adds facts (Ovadia et al. saw some gains) or that retrieval always works (BT-L13 covers its failures). They support starting with retrieval when facts are missing.
Fine-tuning's stronger record is narrow tasks. In LoRA Land, a fine-tuning vendor's study of 310 LoRA models (10 base models, 31 tasks), 4-bit tuned models beat GPT-4 by 10 points on average and reached near 90% on narrow classification tasks, while GPT-4 led on 6 of 31, mainly broader ones such as Python coding and MMLU. All models got simple zero- or one-shot prompts, so read it as a reason to pilot a small tuned model on one narrow task, not as proof it beats a large model at open-ended reasoning.
What fine-tuning costs beyond training
- Examples. Starting points are small: OpenAI recommends 50 well-crafted examples (minimum 10) and says the right number varies; Google's tuning guide says 100 or more works best, lists hundreds to thousands as typical, and puts quality over quantity. LoRA Land fixed a 40,000-example budget per model.
- Your data leaves. On a vendor platform, training data goes to the vendor. OpenAI's data table lists fine-tuning jobs as not used to train OpenAI's models, with 30 days of abuse-monitoring retention and job data kept until deleted.
- Safety can shift. Qi et al. found that fine-tuning, even on benign data, degraded safety behavior in their 2023 tests of GPT-3.5 Turbo and Llama-2-7b-Chat.
- It goes stale. Tuned weights reflect their training data; changes arrive only by retraining.
RAG has upkeep too
Answers change when the text changes, but "instant" depends on your pipeline. In Azure AI Search the shortest indexer schedule interval is 5 minutes, and OpenAI's file search says to wait until a file's status is completed. Someone must own the index and its tests.
Where it runs, and what you can take with you
Hosting changes who operates the model and where prompts go, not whether it knows your facts. Retrieved passages are part of each request, so a hosted model's provider receives them too (BT-L13). BT-L16 compares options and cost; BT-L24 covers vendors and open versus closed models.
Hosted and managed models have lifetimes the vendor sets. On its own platform Anthropic gives at least 60 days' notice before retiring a public model. OpenAI is winding down its fine-tuning platform: closed to new users, open to eligible existing customers for new jobs until 2027-01-06, with tuned models served only until their base shuts down (gpt-4.1 and gpt-4.1-mini on 2027-01-14). On Bedrock (models launched since 2026-09-07), a Legacy base model takes no new fine-tuning jobs, and requests fail after end of life.
What stays yours: prompts, test set, source documents, training examples. What does not travel: an adapter is trained against particular frozen base weights, so a new base usually means training again (Trans-LoRA makes the same point).
Open-weight models swap vendor notice for your own operations. You choose when to change models, and you run the servers and security (BT-L16). Licenses differ: the Qwen2.5-7B-Instruct model card lists Apache 2.0; the Llama 3.1 Community License adds an acceptable-use policy, attribution and naming conditions, and a license request above 700 million monthly active users. Read the license of your exact version.
Plan for exit. NIST's AI RMF says third-party AI may be opaque and calls for contingency processes; the UK NCSC's guidelines say to be ready to fail over for mission-critical systems. This course's practice: keep a second model tested, not deployed, so switching has a measured cost. BT-L22 covers the policies and vendor checks around these choices.
Worked example: an IT service-desk assistant (illustrative)
Inputs. The assistant answers staff policy questions from a wiki that changes monthly and returns a JSON ticket. The wiki is internal but not regulated, and policy allows the provider's API terms (assumed). Test set: 40 de-identified past questions, two criteria graded separately. The scores are invented.
| Variant | Answer matches current policy | Valid JSON |
|---|---|---|
| A. Prompt only | 14 of 40 | 31 of 40 |
| B. A plus retrieved wiki passages | 33 of 40 | 31 of 40 |
| C. B plus schema-constrained output | 33 of 40 | 40 of 40 |
Decision. Variant C on a hosted API, with no fine-tuning. Retrieval moved the knowledge criterion and left format alone; the schema setting moved format. Seven misses remain; check retrieval versus generation (BT-L19).
What would change it:
- Format failures survive the schema: try fine-tuning on correct tickets.
- Volume. Each request has 1,200 instruction and example tokens, 1,800 retrieved-passage tokens, a 100-token question and 150 output tokens. At a hypothetical $1 per million input and $4 per million output tokens, that costs $0.0037. If a tuned model no longer needed the 1,200 instruction tokens, it costs $0.0025, saving $0.0012. Against a hypothetical $8,000 a year to build, evaluate and retrain (10 engineer-days at $800), break-even is about 555,556 requests a month. At 200,000 a month the saving is $240 ($2,880 a year): not yet. At 800,000 it is $960 ($11,520 a year): worth a test. This assumes equal quality and per-token price; caching can cheapen the repeated 1,200 tokens (BT-L16).
- Documents cannot leave, or the provider retires the model: rerun the test set on a managed, self-hosted or replacement model, keeping C's choices.
Try it: write a decision record
Take one real use case. Collect 20 to 40 de-identified questions (BT-L19 covers sizing), grade a prompt-only baseline, then write five lines. Gap: which row, with the failing cases. Evidence: the scores. Choice: the lever, where it runs and why. Exit: what you keep and how you would switch. Revisit when: a number or event, such as volume, a retirement notice or a failed criterion.
The takeaway
Name the gap, then test the cheapest lever for it. In the studies cited, retrieval beat fine-tuning at adding facts, and fine-tuning's stronger record is narrow tasks. Vendors set model lifetimes, so keep your data, tests and an exit plan.
Related lessons
- RAG: Retrieval-Augmented Generation Explained covers how retrieval works and fails.
- AI Infrastructure: APIs, Hosting, and Cost Models covers hosting, pricing, caching and data handling.
- Evaluating AI Outputs: How to Know If Your System Is Working covers test sets and baselines.
Up next
AI Governance, Compliance, and Enterprise Policy: how organizations govern AI use: policy, vendor assessment and compliance.
VISUAL FIELDNOTES / 21
Keep the big picture.
A one-page visual companion. Save it, print it, or explain it to someone else.
View the full-size sheet ↗Change the right layer.
Separate what the system needs from where the model runs.
One US Letter page · Vector artwork · Fits A4 when printed to fit
Read the key points as text
- Baseline
- Test the simplest hosted or local baseline against your task first.
- Context
- Supply current evidence when missing information is the issue; retrieval is one way to do it.
- Adaptation
- Fine-tuning can change learned behavior; it is not a guaranteed factual database.
Remember: Test the simplest hosted or local baseline against your task first.
Try it: For a changing handbook, test supplied passages. For repeated output errors, compare prompt changes before a fine-tuning experiment.
Recall: What evidence would justify adding retrieval or fine-tuning to your baseline?
OPTIONAL CHECK
Check your understanding.
The optional check requires JavaScript. You can continue reading the lesson.
A service-desk helper writes well-formatted answers but quotes last year's VPN rules. What is the sensible first move?
A classifier's facts are right, but it sometimes returns free text instead of the required JSON. What is a sensible order of attempts?
Which statement about studies comparing fine-tuning with retrieval for new facts is accurate?
A vendor demo says retrieval gives instant knowledge updates. What is the best correction for your own system?
A tuned model saves $0.0012 a request and costs a hypothetical $8,000 a year to build, evaluate and retrain. At 200,000 requests a month, what is the best conclusion?
A provider announces it will retire the base model your fine-tuned model was trained on. What is the best preparation?
One open-weight model card lists Apache 2.0; another model uses a custom community license. What should you do?
A fine-tuning vendor reports its small tuned models beat GPT-4 by 10 points on average across 31 tasks. How should you use this?
A team wants to start fine-tuning next week and has no test set. What should happen first?
Policy bars sending internal documents to a third-party API, and a colleague says fine-tuning solves this. What is the best response?
Quiz complete
YOUR LEARNING
Keep your place.
Your progress is saved on this device.