Published
-
How LLM Training, Fine-Tuning, RAG, and Agents Differ

Photo by Bernd 📷 Dittrich on Unsplash
How LLM Training, Fine-Tuning, RAG, and Agents Differ
1. Executive Summary
The most common mistake in LLM discussions is to treat pretraining, fine-tuning, prompting, RAG, tool use, and agents as if they were all the same kind of improvement. In reality, pretraining and fine-tuning change model weights, prompting and RAG change runtime context, tool use expands what the model can do in the outside world, and agents add a control loop that can plan, act, and verify across multiple steps. 出典: OpenAI fine-tuning guide, OpenAI function calling guide, Building effective agents, and MCP specification support this framing.
In practice, the fastest way to choose is to ask what you are trying to change. If you want stable wording or format, start with prompting and then consider fine-tuning. If you want answers grounded in current company documents or frequently changing facts, use RAG. If the system must read from or write to external systems, add tools. If the job requires several steps, retries, or branching decisions, use an agent. MCP sits in the integration layer, not the learning layer, so it helps standardize tool and data connections rather than alter model behavior. 出典: Effective context engineering for AI agents and MCP specification both point to runtime system design rather than model training as the relevant layer here.
Three rules cover most decisions.
- Techniques that change weights are broad but expensive and slow to update.
- Techniques that change runtime context are cheaper and faster, but depend heavily on input quality and retrieval quality.
- Techniques that add external actions can automate real work, but they require permissions, logging, and blast-radius control.
flowchart TD
Q["What changes?"] --> W["Weights"]
Q --> C["Context"]
Q --> A["External actions"]
Q --> L["Control loop"]
W --> P["Pretraining / fine-tuning"]
C --> R["Prompting / RAG"]
A --> T["Tools / MCP"]
L --> G["Agents"]
This diagram separates the options by layer. Once you touch weights, you usually need retraining to change behavior again. Once you rely on runtime context, you can change behavior immediately, but the change is only as strong as the input you provide. Once you add tools and agents, the design problem shifts from intelligence alone to safe execution.
2. The Layers
Pretraining builds broad generalization on top of a massive corpus. Fine-tuning adds task-specific examples, style rules, labels, or policy constraints on top of that base. Prompting is the instruction you give at runtime without changing the model. RAG retrieves external documents and injects them into context so the model can answer with fresher or domain-specific information. Tool use lets the model call calculators, search systems, databases, and business APIs. Agents wrap those capabilities in a plan-act-check loop. 出典: RAG paper, OpenAI fine-tuning guide, OpenAI function calling guide, and Building effective agents are the main references behind this distinction.
The practical comparison looks like this.
| Technique | What it changes | Update frequency | Cost level | Best for | Main risk |
|---|---|---|---|---|---|
| Pretraining | Model weights | Low | Very high | Broad capability building | Data, compute, and time are all heavy |
| Fine-tuning | Model weights | Medium | High | Format, classification, tone, policy | Weak for new facts |
| Prompting | Runtime context | Very high | Low | Fast instruction shaping | Brittle when long or complex |
| RAG | Retrieved context | High | Medium | Fresh documents and grounded answers | Retrieval quality and document quality matter |
| Tool use | External actions | High | Medium to high | Calculation, lookup, writes, execution | Permissions and failure handling matter |
| Agents | Control loop | High | Medium to high | Multi-step work with retries and branching | Error chains and runaway behavior |
This is a structural comparison, not a vendor price sheet. Real costs vary by model, token volume, document volume, execution count, and compliance requirements. Even so, the ordering is usually stable: changing weights is the most expensive route, and changing context or actions is usually the cheapest way to iterate.
3. How to Choose
The first question is whether the problem is really about knowledge or about procedure. If the problem is knowledge, RAG is the strongest default when the source material changes often or when you need citations. If the problem is procedure, start with prompting; if the same failure keeps recurring, consider fine-tuning. 出典: OpenAI fine-tuning guide and RAG paper fit neatly into this division of labor.
The second question is whether the system must merely read external systems or also write to them. Read-only use cases often stop at search, database lookup, or file retrieval. Write access demands approval, diff review, rollback, and logging. That is where the difference between tool use and agents becomes important. A single API call is a tool use case. A sequence that can replan, retry, and verify is an agent use case. 出典: OpenAI function calling guide and Building effective agents are useful for understanding this boundary.
The rule of thumb is simple.
- If you only need better wording or structure, start with prompting.
- If you need the same behavior at scale, consider fine-tuning.
- If you need current facts or internal documents, use RAG.
- If you need external calculation, lookup, or writeback, add tools.
- If the work involves multiple steps and possible retries, use an agent.
- If the number of connectors keeps growing, use MCP to normalize the interface.
This ordering is an inference from public information, not an official universal roadmap. In real systems, the common pattern is to combine them: prompt plus RAG, fine-tuning plus RAG, or tools plus agents.
flowchart LR
A["Stable format"] --> B["Prompting / fine-tuning"]
C["Fresh knowledge"] --> D["RAG"]
E["External action"] --> F["Tools"]
G["Multi-step work"] --> H["Agents"]
4. MCP and External Tooling
MCP is a protocol for connecting context, tools, and resources to LLM applications in a standardized way. The key point is that MCP does not add knowledge to the model. It standardizes how connections are exposed. In practice, that makes it easier to plug documents, APIs, developer tools, and operations tools into different clients without rebuilding every integration from scratch. 出典: MCP specification defines MCP as an open standard for connecting context, tools, and resources to LLM apps.
So MCP is not a substitute for RAG or tool use. It is closer to a wiring layer that helps those capabilities travel across assistants and environments. Once you reach this layer, authorization, logging, and reversibility matter more than the model name.
5. Risks and Limits
First, RAG does not guarantee correctness. If the retrieved document is wrong, the answer can still be wrong. If the right document is not retrieved, the answer can still miss the mark. RAG makes grounded answers easier, but it does not automatically produce truth. 出典: RAG paper and Effective context engineering for AI agents both make retrieval quality and context design a prerequisite.
Second, fine-tuning is not a substitute for freshness. If facts change often, retraining is a slow way to keep up. It is usually better to keep changing facts outside the model and use the model for stable behavior.
Third, the more useful tools and agents become, the larger the blast radius of mistakes. A wrong write operation, overuse of an API, a permission leak, prompt injection, or an unexpected retry can do more harm than a plain wrong answer. That is why the NIST AI RMF treats AI risk management as an ongoing Govern / Map / Measure / Manage process. 出典: NIST AI RMF frames AI risk management as a continuous process rather than a one-time checklist.
Fourth, agents are not the answer to everything. Predictable jobs often belong in workflows, and only the exploratory or retry-heavy parts belong in an agent loop. That is a design choice aimed at lowering failure rates, not a style preference. 出典: Building effective agents distinguishes workflows for predictable tasks from agents for tasks that require flexible exploration.
6. Recommended Sequence
The least risky rollout path, inferred from public information, is this:
- Try prompting first.
- Add RAG when external knowledge matters.
- Consider fine-tuning when a format or classification pattern repeats at scale.
- Add tools when the system has to affect the outside world.
- Move to agents when multi-step automation becomes necessary.
- Standardize the connectors with MCP once integrations start to proliferate.
The value of this sequence is that it avoids jumping straight to expensive retraining or high-risk autonomy. Fine-tuning and agents are not goals in themselves. They are tools you use only when the quality target, update frequency, audit needs, and operational permissions justify them.
7. References
LLMの学習・微調整・RAG・エージェントの使い分け
1. エグゼクティブサマリー
LLMの議論で最も混同されやすいのは、事前学習、ファインチューニング、プロンプト、RAG、ツール利用、エージェントを同じ種類の「改善策」と見なすことである。実際には、事前学習とファインチューニングはモデルの重みを変え、プロンプトとRAGは実行時の文脈を変え、ツール利用は外部操作を増やし、エージェントはそれらを複数手順で回す制御ループを加える。 出典: OpenAI fine-tuning guide, OpenAI function calling guide, Building effective agents, MCP specification に基づく整理である。
実務の判断は、まず「何を変えたいか」を分けると速い。出力の書式や口調を安定させたいなら、まずプロンプトを試し、必要ならファインチューニングを検討する。社内文書や最新情報を根拠付きで返したいならRAGが向く。外部システムに書き込みたいならツール利用が必要になる。複数ステップを自律的に進めたいならエージェントが候補になる。MCPはこのうち学習方法ではなく、外部ツールやデータ接続を標準化するための層に位置する。 出典: Effective context engineering for AI agents と MCP specification を踏まえると、プロンプトと接続の設計は実行時システムの一部として扱うのが妥当である。
要点は三つである。
- 重みを変える技術は、広く効くが高コストで、更新が遅い。
- 文脈を変える技術は、安くて速いが、入力品質と検索品質に強く依存する。
- 外部操作を増やす技術は、業務を自動化できる一方、権限、監査、失敗時の損害管理が必要になる。
flowchart TD
Q["何を変えるか"] --> W["重み"]
Q --> C["文脈"]
Q --> A["外部操作"]
Q --> L["制御ループ"]
W --> P["事前学習 / 微調整"]
C --> R["プロンプト / RAG"]
A --> T["ツール / MCP"]
L --> G["エージェント"]
この図は、各技術を「どのレイヤーを触るか」で分けている。重みを触ると振る舞いの傾向は変わるが、再学習が要る。文脈を触ると即時に挙動を変えられるが、長期的な固定化は弱い。ツールとエージェントはモデルの賢さよりも、どこまで安全に実行させるかが設計の中心になる。
2. レイヤーの切り分け
事前学習は、巨大なコーパスで広い一般化能力を作る工程である。ファインチューニングは、その土台に対して、特定のタスク、書式、分類基準、用語集、応答方針を追加学習する工程である。プロンプトは、学習済みモデルに与える実行時指示であり、モデル自体は変えない。RAGは、検索で外部文書を拾って文脈に差し込む設計であり、知識の置き場をモデル内部から外部へずらす。ツール利用は、計算機、検索、DB、業務APIなどを呼べるようにする。エージェントは、それらを計画・実行・検証のループにまとめる。 出典: RAG paper, OpenAI fine-tuning guide, OpenAI function calling guide, Building effective agents を参照した。
比較すると、こうなる。
| 技術 | 何を変えるか | 更新頻度 | コスト感 | 得意な用途 | 主な注意点 |
|---|---|---|---|---|---|
| 事前学習 | モデルの重み | 低い | 非常に高い | 汎用能力の獲得 | データ、計算資源、期間が重い |
| ファインチューニング | モデルの重み | 中 | 高い | 書式、分類、口調、業務ルールの固定 | 新しい事実の追随には弱い |
| プロンプト | 実行時文脈 | 非常に高い | 低い | すぐ試したい指示調整 | 長く複雑になると壊れやすい |
| RAG | 検索結果と実行時文脈 | 高い | 中 | 最新文書、社内ナレッジ、根拠提示 | 検索精度と文書品質に依存 |
| ツール利用 | 外部操作 | 高い | 中〜高 | 計算、照会、書き込み、実行 | 権限と失敗時の被害管理が必要 |
| エージェント | 制御ループ | 高い | 中〜高 | 複数手順、再試行、探索 | 誤りの連鎖と暴走を抑える設計が要る |
この表は厳密な市場価格表ではなく、構造比較である。実際の費用はベンダー、モデル、トークン量、文書量、実行回数、監査要件で大きく変わる。ただし、重みを変えるほど高コストで、文脈と操作を変えるほど低コストかつ即時に試せる、という序列はほぼ崩れない。
3. 使い分けの判断基準
まず確認すべきなのは、その問題が「知識の問題」か「手順の問題」かである。知識の問題ならRAGが有力で、特に更新頻度が高い社内文書や、根拠を提示したい回答に向く。手順の問題なら、まずプロンプトで十分かを見て、繰り返し同じ失敗をするならファインチューニングを検討する。 出典: OpenAI fine-tuning guide と RAG paper の役割分担を踏まえた判断である。
次に確認するのは、外部システムを「読むだけ」か「書き込む」かである。読むだけなら検索、DB照会、ファイル参照で足りることが多い。書き込むなら、承認、差分確認、ロールバック、監査ログが必要になる。ここでツール利用とエージェントの差が出る。単発のAPI呼び出しならツール利用で足りる。再計画、再試行、検証が必要ならエージェントの用途である。 出典: OpenAI function calling guide と Building effective agents は、この境界を理解するのに有用である。
判断の目安は次の通りである。
- 出力の書式を変えたいだけなら、まずプロンプト。
- 同じ出力形式を大量に安定供給したいなら、ファインチューニング。
- 最新情報や社内文書を答えに混ぜたいなら、RAG。
- 外部計算、検索、更新、送信が必要なら、ツール利用。
- 途中で計画変更や再試行が必要なら、エージェント。
- 接続先が増えて運用が辛いなら、MCPでインターフェースを揃える。
この順番は公表情報からの推定である。実際には、プロンプト + RAG、ファインチューニング + RAG、ツール + エージェントのような組み合わせが多い。単独で完結する技術は少なく、たいていはレイヤーの重ね合わせになる。
flowchart LR
A["安定した書式"] --> B["プロンプト / 微調整"]
C["最新知識"] --> D["RAG"]
E["外部操作"] --> F["ツール"]
G["複数手順"] --> H["エージェント"]
4. MCP と外部ツール連携
MCPは、LLMが使う外部ツールやデータ接続を、個別実装ではなく共通プロトコルで扱うための仕組みである。ここで重要なのは、MCPがモデルの知識を増やすわけではない点である。MCPが変えるのは接続の標準化であり、接続設計では「どのLLMクライアントでも同じ種類の文脈・ツールを接続しやすくする」ことに価値がある。 出典: MCP specification は、MCP を context, tools, resources を LLM アプリに接続するためのオープン標準として定義している。
その意味で、MCPはRAGやツール利用の上位互換ではない。むしろ、RAG用の文書ソース、社内API、開発ツール、運用ツールを、同じ接続方式で提供するための配線層に近い。モデルの選択よりも、権限、認証、ログ、取り消し可能性をどう設計するかが重要になる。
5. リスク・限界
第一に、RAGは正しさを保証しない。検索で拾う文書が誤っていれば、回答も誤る。逆に、文書が正しくても、検索で拾えなければ使えない。したがって、RAGは「根拠付き回答を作りやすくする」技術であって、「真実を自動保証する」技術ではない。 出典: RAG paper と Effective context engineering for AI agents によると、検索品質と文脈設計が性能の前提になる。
第二に、ファインチューニングは最新性の代替ではない。頻繁に変わる事実を埋め込む用途では、再学習の遅さがそのまま欠点になる。更新頻度が高い知識は外部に置き、モデルは振る舞いの安定化に使う方がよい。
第三に、ツール利用とエージェントは、便利になるほど損害半径も広がる。誤った書き込み、過剰なAPI利用、権限漏れ、プロンプト注入、想定外の再試行は、モデル単体の誤答よりも被害が大きい。NISTのAI RMFのように、評価、監視、是正を継続プロセスとして回す前提が要る。 出典: NIST AI RMF は、AIリスク管理を継続的な Govern / Map / Measure / Manage の活動として扱っている。
第四に、エージェントは万能ではない。予測可能な仕事はworkflowで十分なことが多く、探索や再試行が本当に必要な部分だけをagentに任せる方が安定する。これは設計上の好みではなく、失敗率を下げるための分業である。 出典: Building effective agents は、予測可能なタスクには workflow、柔軟な探索が必要なタスクには agent が向くと整理している。
6. 推奨方針
公表情報からの推定として、実務では次の順で導入するのが最も無理が少ない。
- まずプロンプトで試す。
- 次にRAGで外部知識を足す。
- 反復する書式や分類があるならファインチューニングを検討する。
- システムが外部世界に作用するならツールを追加する。
- 複数手順の自動化が必要になった時点でエージェント化する。
- 接続先が増えたらMCPで配線を標準化する。
この順序の利点は、最初から高コストな再学習や高リスクな自律化に飛ばずに済むことだ。逆に言えば、ファインチューニングやエージェントは「使うこと自体」が目的ではない。必要な品質、更新頻度、監査要件、運用権限に照らして、最も安いレイヤーから積み上げるのが合理的である。