Every serious AI application hits the same wall in its first week: the model does not know your data. Not your product catalog, not your documentation, not what your team decided last Tuesday. Its knowledge is broad, public, and frozen at a training cutoff. Getting *your* knowledge in front of it at the right moment is arguably the central engineering problem of building with AI, and there are exactly three families of solution.

Option one: just put it in the context

The embarrassingly effective baseline. If your entire knowledge base — the policy manual, the product docs, the codebase file — fits comfortably in the model's context window, send it along with the question and be done. No infrastructure, no retrieval bugs, perfect 'recall' because nothing was left out. Modern context windows hold books' worth of text, and teams routinely over-engineer past this option without checking whether it suffices. The costs that eventually force you off it: token spend on every call (partially blunted by prompt caching, which providers offer for exactly this repeated-context pattern), and degraded attention as truly enormous contexts strain the model's focus. But 'we outgrew context stuffing' is a milestone, not a starting requirement.

Option two: retrieval — RAG

Retrieval-augmented generation is the standard answer once the knowledge outgrows the window: store your documents in searchable form, and at question time fetch only the most relevant pieces to include in the prompt. The conceptual overview lives in [RAG explained](/guides/rag-explained/); this is the builder's view, and the builder's view is mostly about the details the diagram omits:

  • Chunking is a real decision. Documents get split into pieces for search, and where you split determines what can be found. Split mid-thought and retrieval returns fragments; chunk by structure — sections, headings, natural units — and keep enough overlap or metadata that a hit carries its context with it.
  • Search quality is hybrid. Semantic search via embeddings — numeric representations where similar meanings land near each other — finds conceptual matches; classic keyword search finds exact part numbers, error codes, and names that embeddings blur. Production systems overwhelmingly use both, because users ask both kinds of question.
  • Retrieval is where RAG fails. When a RAG system gives a wrong answer, the cause is usually not the model — it is that the right passage never made it into the prompt. Which means debugging RAG is debugging search: log what was retrieved for each question, and when an answer disappoints, look at the passages before blaming the generation.
  • Tell the model to stay grounded. The system prompt should instruct: answer from the provided passages, and say so when they do not contain the answer. Grounding plus an honest 'not found' path is what turns retrieval into trustworthy answers — and it gives you something [testable](/build/evals-and-testing/).

The storage layer matters less than the blogosphere implies. Purpose-built vector databases exist and are excellent at scale, but the extensions in ordinary databases handle an enormous range of real applications. Start with whatever you already operate.

Option three: fine-tuning — probably not, and here is the test

Fine-tuning — additional training on your examples — has a persistent gravitational pull on newcomers, because it sounds like the serious version. The decision test that holds up: fine-tuning teaches behavior; context teaches facts. A consistent format, a house style or tone, a specialized transformation — behavior, fine-tuning territory. Knowing your prices, your policies, your customer history — facts, and facts change, which means retraining forever versus updating a document store. Most applications that think they need fine-tuning need retrieval plus a well-specified [system prompt](/build/prompting-for-programs/). The full comparison lives in [fine-tuning vs RAG vs prompting](/guides/fine-tuning-vs-rag-vs-prompting/).

Choosing without agonizing

The decision usually makes itself if asked in order. Does the knowledge fit the context window at acceptable cost? Stuff it and ship. Does it exceed the window, or change constantly, or need per-user access control? Retrieval. Is the gap about *how the model behaves* rather than *what it knows*? That, and mostly only that, is fine-tuning's lane. And the combinations are normal — a fine-tuned tone with retrieved facts, retrieval over documents with a stuffed-context FAQ. These are ingredients, not competing religions.

One closing habit from teams that do this well: keep the source of truth in documents humans maintain, and treat the AI plumbing as a view over it. When the answer is wrong, you fix a document, not a pipeline — and the same documents keep serving humans, search, and [agents](/build/building-agents/) alike.