Architecture
RAG, Tool Use, or Fine-Tuning? Choosing the Right Approach
Start with the behavior the system needs, then choose the smallest architecture that supports it.
These approaches change different things
RAG, tool use, and fine-tuning are often presented as competing ways to “give a model knowledge.” That framing hides the more useful distinction: each changes a different part of the system.
Retrieval-augmented generation (RAG) changes the context available for a request. A retrieval system finds relevant source material at runtime and supplies it to the model.
Tool use lets the model request information or actions through functions defined by the application. The application executes the function and returns the result; the model does not.
Fine-tuning changes model behavior using a training dataset. It can improve consistency on a task or style, but it is not normally the best mechanism for frequently changing private facts.
The right question is therefore not “Which one is best?” It is “What behavior is missing, and which layer should provide it?”
Choose RAG when the answer depends on source material
RAG is a strong candidate when users need answers or search over documents, policies, records, or other knowledge that changes independently of the base model. It can support citations and allow source updates without retraining.
A production retrieval system includes ingestion, parsing, chunking, metadata, synchronization, access control, query transformation, retrieval, ranking, context assembly, generation, and evaluation. Vector search may be useful, but it is not mandatory for every corpus or query. Keyword and hybrid methods can outperform a purely semantic approach for identifiers, exact terms, or structured filters.
Google Cloud’s generative AI application guidance describes RAG as retrieving relevant information and adding it to a model prompt for grounding. Grounding helps; it does not prove that every generated sentence is supported. Evaluate retrieval and answer quality separately.
Use RAG when:
- facts change or are private;
- source provenance matters;
- access differs by user;
- the corpus can be indexed and synchronized;
- the task is primarily finding, comparing, or explaining evidence.
Choose tool use when the system needs live state or action
A tool is appropriate when the model needs information that belongs behind an application API, or when it must propose an operation: check inventory, calculate a quote, open a case, schedule work, or update a permitted field.
The model should return structured arguments. The application validates them, checks permissions, performs the call, and returns a bounded result. Current Google Cloud function-calling documentation explains this separation and recommends clear function descriptions, strongly typed parameters, a limited relevant tool set, and user validation before consequential calls.
Use tool calling when:
- the result depends on current application state;
- an API already owns the truth;
- a calculation should remain deterministic;
- the system must take or prepare an action;
- authorization and audit belong at an application boundary.
Retrieval and tools can coexist. A support assistant might retrieve policy context, then call a permitted account tool after the user confirms an action.
Choose fine-tuning when the behavior needs to change consistently
Fine-tuning can help when prompt and context design still produce inconsistent task behavior and the team can assemble representative, high-quality examples. Candidates include specialized classification, recurring structured transformations, domain-specific language patterns, or improved function selection for a stable tool set.
Google Cloud documents supervised tuning for function-calling behavior, which illustrates the actual distinction: tuning can improve how the model selects and structures calls; the live result still comes from the function.
Fine-tuning carries operational work. Training data must be created and reviewed. New models or requirements may need retesting or retuning. Poor examples can encode poor behavior. Evaluation needs a held-out set that measures the target task rather than similarity to the training data.
Use fine-tuning when:
- a stable behavior must become more consistent;
- enough representative examples exist;
- prompt and retrieval changes do not solve the failure;
- the expected gain justifies training and maintenance;
- current factual knowledge is not the primary requirement.
A simple decision sequence
- Define the missing behavior. Is the system missing facts, an external capability, or consistent task performance?
- Use the smallest intervention. Improve instructions and application context before adding infrastructure.
- Retrieve changing evidence. Use RAG when source material should remain current and inspectable.
- Call authoritative systems. Use tools for live state, calculations, and actions.
- Tune persistent behavior. Fine-tune only after the task and evaluation are stable enough to prove the change.
This order is a CodeCradle recommendation, not a universal rule. Some latency, privacy, deployment, or scale constraints may justify a different design.
Combinations are normal, but complexity is not free
A product may retrieve policy context, call an account tool, and use a tuned model for classification. That can be a sound system. It also creates more failure boundaries: stale indexes, missing permissions, tool errors, model regressions, and coordination logic.
Add each mechanism because a measured behavior requires it. Keep evaluation examples tagged by failure layer so the team knows whether to adjust retrieval, tool design, instructions, model choice, or training data.
Sources and further reading
- Google Cloud: Develop a generative AI application
- Google Cloud: Function calling
- Google Cloud: Tune function calling
See RAG & Enterprise Knowledge Systems for retrieval work and AI Agents & Agentic Automation for controlled tools and actions.