The three levers
When a base model does not do what you want, you have three levers — and choosing among prompting, RAG, and fine-tuning is the most consequential design decision in the whole project. Prompting changes the instructions you send. RAG — retrieval-augmented generation — feeds the model relevant facts at request time. Fine-tuning changes the model's weights with further training. They are not rivals; mature products often use all three. The mistake is reaching for the heaviest lever first.
A pipeline where a user query retrieves documents that are added to the prompt before the model generates an answer.
A decision framework
Work from cheap-and-fast to expensive-and-slow, and stop as soon as the task is solved well enough.
- Start with a strong prompt and the best general model. Surprisingly often, this is the whole answer.
- If failures come from missing or stale facts, add RAG: chunk your documents, embed them into a vector store, retrieve the top matches, and inject them into the prompt.
- If the task is multi-step or branches, decompose it with prompt chaining before you reach for anything heavier.
- Only fine-tune when prompting plus RAG plateau: you need a consistent house style, a rigid output format, lower per-call cost, or a smaller model to match a big one on your narrow task.
Human preferences train a reward model that then guides policy tuning of the language model.
Orchestration: gluing the steps together
Once an app has more than one model call — retrieve, then answer; classify, then route; plan, then act — you need orchestration. An orchestration framework manages the control flow: it sequences calls, passes state between them, wires in retrieval and tools, handles retries, and gives you tracing across the whole chain. You can hand-roll this, and for simple apps you should; frameworks earn their keep when the graph of steps gets branchy, when you want swappable components, or when you need observability out of the box.
A loop of reason, act, and observe steps driving a multi-step LLM application.
Common composition patterns
Orchestrated apps tend to take a few shapes. A chain runs fixed steps in order. A router uses a cheap classification call to pick which branch (or which model) handles a request. A map-reduce splits a huge document, summarizes the pieces in parallel, then merges them. And an agent hands control to the model itself: it decides which tool to call next, loops, and stops when done. Chains and routers are predictable and easy to evaluate; agents are powerful but harder to make reliable — which is exactly why the last guide in this track treats agentic products as the frontier.