{"slug": "rag-vs-fine-tuning-which-fixes-your-llm-problem", "title": "RAG vs Fine-Tuning: Which Fixes Your LLM Problem?", "summary": "A developer tested whether retrieval or fine-tuning fixes a model's wrong answers, running llama3.2 (3B) on Ollama 0.40.16 against 12 invented documents about a fictional deploy platform. With no context the model got 0 of 10 questions right and fabricated answers; with the top 3 keyword-retrieved passages in the prompt it got 10 of 10, matching the score from pasting all 12 documents. The writeup notes that OpenAI's fine-tuning platform is closed to new users and existing users can create training jobs only until January 6, 2027, making retrieval the default path on hosted models.", "body_md": "Originally published on [DevToolHub](https://devtoolhub.com/rag-vs-fine-tuning/).\n\nRAG vs fine-tuning comes down to one question: what is wrong with the model's answers? If it lacks facts, such as your docs or last week's changes, use RAG. If it knows enough but answers in the wrong format or tone, fine-tune. I tested the first case locally: a 3B model got 0 of 10 questions right about an invented runbook, then 10 of 10 once the right passages were in the prompt.\n\nOne 2026 detail changes the usual advice. OpenAI's own docs say its fine-tuning platform is winding down. It is closed to new users, and existing users can create training jobs only until January 6, 2027. On hosted models, retrieval is now the default path.\n\n**In this guide:**\n\n- Decide between RAG and fine-tuning from the symptom, not the hype\n- See what a small local test showed, including a retrieval miss\n- Check what is still available for fine-tuning in 2026\n- Pick an approach with four plain rules\n\nRAG changes what the model sees at question time. A retriever finds relevant passages and the pipeline adds them to the prompt. Fine-tuning changes the model's weights with training examples, so it behaves differently on every request. RAG fixes missing or stale knowledge. Fine-tuning fixes consistent behavior: format, tone, labels.\n\n| Symptom | Pick | Why | \n|---|---|---|\n| Model invents answers about your private docs | RAG | The facts must be in the prompt | \n| Facts change weekly | RAG | Update the index, not the model | \n| Output must follow one strict format | Fine-tuning | Examples teach the shape | \n| Classification with fixed labels | Fine-tuning | Many examples beat a long prompt | \n| Both missing facts and strict format | Both | RAG for facts, tuning for shape | \n\nIf you need the basics first, read [what RAG is](https://devtoolhub.com/what-is-rag/) and [what an LLM is](https://devtoolhub.com/what-is-an-llm/).\n\nI tested the RAG half. The model was `llama3.2` (3B) on Ollama 0.40.16, run with temperature 0 and a fixed seed. The knowledge was 12 short invented documents about a fictional deploy platform: a rollback window, a staging cluster name, a secrets rotation job, and so on. I asked 10 questions and counted an answer as correct if it contained the expected string.\n\n| Mode | Correct | \n|---|---|\n| No context | 0 of 10 | \n| Top 3 retrieved passages in the prompt | 10 of 10 | \n| All 12 documents in the prompt | 10 of 10 | \n\nWithout context the model did not just say \"I don't know\". Instead, it made things up. It named Alembic as the tool that runs schema migrations, answered \"HOLIDAY\" for the freeze code word, and called the build dashboard the \"Build Health Index (BHI)\". For secrets rotation it said secrets \"don't actually rotate\".\n\nThe retriever was plain keyword scoring, not embeddings. So the whole test stays small enough to read:\n\n``` python\ndef score(q,d):\n    dt=tok(d); c=collections.Counter(dt); s=0\n    for t in set(tok(q)):\n        if t in c: s+=(1+math.log(c[t]))*math.log(1+len(DOCS)/df[t])\n    return s\ndef retrieve(q,k=3):\n    return [d for _,d in sorted(DOCS,key=lambda x:-score(q,x[1]))[:k]]\n```\n\nThe prompt was `Answer in one short sentence using only this context.`, then the passages, then the question. That is the whole pipeline.\n\n**Tip:** With 12 short documents, pasting everything worked as well as retrieval. If your knowledge fits in the context window, skip the retriever and paste it.\n\nIn RAG, the failure moves from the model to the retriever. For example, I reworded four questions so they shared fewer words with the documents. Three still pulled the right passage and got correct answers. One did not.\n\nThen I asked, \"When can nobody push to prod over the winter break?\" The retriever returned the wrong passages, and the model answered that nobody can push \"when the secrets rotation job `vault-spin` is running\". That sentence was fluent, confident and wrong. The correct passage, the December 18 to January 4 freeze, was never in the prompt. That is why it failed.\n\nAn embedding model would likely catch that paraphrase, but embeddings miss too, and I did not test them. Either way, the takeaway holds: log which passages were retrieved for every question, and grade retrieval separately from the final answer.\n\n**Warning:** A RAG answer that cites the wrong passage looks the same as a correct one. Without retrieval logs you cannot tell them apart.\n\nFine-tuning wins when the problem is behavior, because examples teach a pattern. OpenAI's [supervised fine-tuning guide](https://developers.openai.com/api/docs/guides/supervised-fine-tuning) lists four best-fit tasks: classification, nuanced translation, generating content in a specific format, and correcting instruction-following failures. It also says to start with 50 well-crafted examples, with a minimum of 10.\n\nIts [model optimization guide](https://developers.openai.com/api/docs/guides/model-optimization) adds a cost angle. Fine-tuning lets you use more examples than fit in a prompt and use shorter prompts, which lowers token cost and latency. Before you train, try a few correct examples inside the prompt, as the same guide suggests.\n\nHowever, fine-tuning is the weaker tool for new facts. The paper [Fine-Tuning or Retrieval?](https://arxiv.org/abs/2312.05934) compared both for knowledge injection. Its authors report that RAG outperformed unsupervised fine-tuning for existing knowledge and for entirely new knowledge. But that study covers one training style, so treat it as a strong hint, not a law. I did not reproduce it.\n\nOn open-weight models, fine-tuning is cheaper than it used to be, because only a few weights train. Hugging Face's [PEFT library](https://huggingface.co/docs/peft/index) trains only a small number of extra parameters, which its docs say brings large models within reach of consumer hardware. The [train-your-own-local-model walkthrough](https://devtoolhub.com/train-local-ai-model/) covers the practical side.\n\n**Note:** As of November 20, 2026, OpenAI's fine-tuning docs say the platform is closed to new users and that existing users can create training jobs until January 6, 2027. Fine-tuned models stay available for inference until their base models are deprecated. The supported models listed on the page are the `gpt-4.1` family. Check the page again before you plan around it.\n\nFollow these four rules in order. Then stop at the first one that matches.\n\nAlso, agents that call tools sit on top of either choice. See [AI agents explained](https://devtoolhub.com/ai-agents-explained/) for where retrieval fits in an agent loop.\n\nI did not run a fine-tune, so the fine-tuning claims above come from OpenAI's docs, the Hugging Face docs and one paper, not from my own training run. I also did not use embeddings or a vector database, I tested one small model with 12 short documents, and I graded by substring match. A larger corpus, a bigger model or a hosted API could change the numbers. Because the runbook is invented, no model could have seen it in training. That is why the no-context score was zero.\n\n**Q: Is RAG better than fine-tuning?**\n\nA: For adding facts, usually yes. RAG keeps knowledge outside the model, so you can update it without training. One paper found RAG beat unsupervised fine-tuning for both existing and new knowledge. For output format and tone, fine-tuning is the better tool.\n\n**Q: Can you use RAG and fine-tuning together?**\n\nA: Yes. Use RAG to supply current facts and a fine-tuned model to answer in a fixed format. Build the RAG part first, since it is quicker to test and change.\n\n**Q: Does fine-tuning teach a model new facts?**\n\nA: Not reliably. OpenAI's guide lists formats, classification and instruction-following fixes as best uses, and the comparison paper found retrieval stronger for new knowledge. Use fine-tuning for behavior and RAG for facts.\n\n**Q: Can I still fine-tune an OpenAI model?**\n\nA: Only on an existing account, and only for a limited time. As of November 20, 2026, OpenAI's docs say the platform is closed to new users and that eligible existing customers can create training jobs until January 6, 2027.\n\n**Quick Summary:**\n\nFor the RAG vs fine-tuning choice, start with RAG, log your retrieved passages, and fine-tune only when the output shape is the problem.", "url": "https://wpnews.pro/news/rag-vs-fine-tuning-which-fixes-your-llm-problem", "canonical_source": "https://dev.to/amareswer/rag-vs-fine-tuning-which-fixes-your-llm-problem-2ld1", "published_at": "2026-11-23 14:11:00+00:00", "updated_at": "2026-11-23 14:13:46.916835+00:00", "lang": "en", "topics": ["large-language-models", "ai-tools", "ai-products"], "entities": ["OpenAI", "Ollama", "llama3.2", "DevToolHub"], "also_reported_by": [], "takeaway": "A 3B llama3.2 model scored 0 of 10 on questions about invented docs without context but 10 of 10 with the top 3 keyword-retrieved passages, and pasting all 12 documents matched retrieval, so skip the retriever when your knowledge fits the context window.", "recommendation": {"advice": "Paste your full knowledge base into the prompt when it fits the context window, and test retrieval with reworded queries, since a keyword retriever missed one of four paraphrased questions and produced a confident wrong answer.", "playbook": "rag-retrieval", "playbook_url": "https://wpnews.pro/playbooks/rag-retrieval"}, "alternates": {"html": "https://wpnews.pro/news/rag-vs-fine-tuning-which-fixes-your-llm-problem", "markdown": "https://wpnews.pro/news/rag-vs-fine-tuning-which-fixes-your-llm-problem.md", "text": "https://wpnews.pro/news/rag-vs-fine-tuning-which-fixes-your-llm-problem.txt", "jsonld": "https://wpnews.pro/news/rag-vs-fine-tuning-which-fixes-your-llm-problem.jsonld"}}