Sub topic 11
Comparing cost, latency, freshness, and control
This chapter compares prompting, retrieval-augmented generation (RAG), and fine-tuning on four dimensions: cost, latency, freshness, and control. It assumes you can call a chat-style API, read Python, and know what embeddings and a context window are. Earlier chapters covered how each approach works. Here you will learn what each one costs you in practice, so that the decision framework in the next chapter has real numbers to work with.
Why compare on these four dimensions
No approach wins on every dimension. Each one moves a cost from one place to another. Prompting spends tokens on every request. RAG spends engineering effort and a retrieval step on every request. Fine-tuning spends effort and money up front, then asks you to maintain a custom model.
The four dimensions used here are:
- Cost: money and engineering time, both one-off and per request.
- Latency: the time between sending a request and receiving the full answer.
- Freshness: how quickly a change in the real world can show up in the model's answers.
- Control: how reliably you can shape the format, tone, and content of the output, and how easy it is to inspect or undo that shaping.
The table gives the usual pattern. Treat it as a starting point, because your workload can shift any cell.
| Dimension | Prompting | RAG | Fine-tuning |
|---|---|---|---|
| Up-front cost | Very low | Medium (index, pipeline) | High (data, training, evaluation) |
| Per-request cost | Grows with prompt length | Grows with retrieved context plus retrieval | Often lower, since prompts get shorter |
| Latency | Baseline | Baseline plus retrieval and a longer prompt | Baseline or lower |
| Freshness | Only what you paste in | Minutes, once the index is updated | Frozen until you retrain |
| Control of style and format | Good, but not guaranteed | Same as prompting | Strongest |
| Control of facts and sources | Weak | Strong, with citations possible | Weak |
| Ease of rollback | Trivial | Easy | Needs model versioning |
Cost
Prompting
Prompting has almost no setup cost. You edit text and run your evaluation set. The ongoing cost is tokens. Instructions and few-shot examples are sent with every request, so a prompt with 1,500 tokens of examples pays for those tokens on every call.
RAG
RAG adds several cost sources:
- An embedding model, used once per chunk at indexing time and once per query.
- A vector store, which you host or pay for.
- Retrieved passages, which enlarge every prompt.
- Engineering time for chunking, ranking, and keeping the index in sync with the source documents.
The retrieved context is often the largest part of the bill. Retrieving five chunks of 400 tokens adds about 2,000 input tokens to each request.
Fine-tuning
Fine-tuning has the highest up-front cost. You pay for training data curation, which is mostly human time, plus the training run and a new evaluation cycle. After that, per-request cost can drop. A tuned model has learned the format and style, so you can remove long instructions and examples from the prompt.
Two points are easy to miss. First, many providers charge a higher per-token price for tuned models than for the base model, which can cancel the savings from shorter prompts. Second, every time the base model is retired or you retrain, you pay again.
A break-even calculation
You can estimate whether fine-tuning pays off by comparing the saved prompt tokens against the up-front cost. The code below uses made-up prices. Replace them with your provider's current rates.
def breakeven_requests(
upfront_cost,
tokens_saved_per_request,
base_price_per_1k,
tuned_price_per_1k,
tuned_tokens_per_request,
):
"""Return how many requests until fine-tuning costs less than prompting.
The prompted request costs base_price_per_1k for
(tuned_tokens_per_request + tokens_saved_per_request) tokens.
The tuned request costs tuned_price_per_1k for tuned_tokens_per_request tokens.
"""
prompted = (tuned_tokens_per_request + tokens_saved_per_request) / 1000 * base_price_per_1k
tuned = tuned_tokens_per_request / 1000 * tuned_price_per_1k
saving = prompted - tuned
if saving <= 0:
return None # fine-tuning never pays back on token cost alone
return upfront_cost / saving
n = breakeven_requests(
upfront_cost=2000.0,
tokens_saved_per_request=1500,
base_price_per_1k=0.0005,
tuned_price_per_1k=0.0012,
tuned_tokens_per_request=300,
)
print(round(n) if n else "never")With these numbers the function returns None, which prints never. The tuned model's higher price per token outweighs the 1,500 saved tokens. This is a realistic result for small workloads, and it shows why the calculation is worth running before you commit.
Latency
Latency has three sources: the work done before the model call, the time the model takes to read the prompt, and the time it takes to generate the output. Longer prompts increase the second source. Longer outputs increase the third.
- Prompting has only model time. A long few-shot prompt slows the first token slightly.
- RAG adds an embedding call for the query, a vector search, and possibly a reranking step. These often add tens to a few hundred milliseconds. The longer prompt adds a little more.
- Fine-tuning adds nothing before the call. Shorter prompts can make requests slightly faster. Some hosted tuned models have a slower cold start, so measure on your provider.
Measure latency at the 95th percentile (p95) as well as the average. A retrieval step that is usually fast but occasionally slow shows up in p95.
The diagram shows where time is spent in a RAG request compared with a plain prompt.
For a plain prompt, only the last two arrows exist. For a fine-tuned model, the same two arrows remain, usually with a shorter prompt.
Reducing latency
- Run retrieval and any independent work in parallel.
- Lower
k, the number of retrieved chunks, if your evaluation shows the extra chunks do not help. - Cache embeddings for frequent queries.
- Cap output length. Generation time grows with every output token.
Freshness
Freshness describes how long a fact stays wrong after the real world changes.
- Prompting can only use facts you place in the prompt. Anything newer than the model's training cutoff is unknown unless you supply it.
- RAG is the strongest option. Update or add a document, re-embed it, and the next query can use it. Delay is the time your indexing job takes.
- Fine-tuning is the weakest. Facts learned during tuning are frozen until the next run. They are also stored unreliably, because tuning on facts rarely makes recall dependable and can encourage confident wrong answers.
This is why the diagnosis step from earlier chapters matters. Missing or changing facts point to RAG. A stable behavior points to tuning.
Freshness has its own failure modes
RAG is only as fresh as its pipeline. Three common problems are:
- The indexing job fails silently, and the index goes stale while answers look normal.
- Old and new versions of a document both sit in the index, and the model sees conflicting passages.
- Deleted documents stay in the index, so the system keeps quoting content that should be gone.
Store a source identifier and a last-updated timestamp with every chunk. That lets you filter old versions, delete by source, and monitor how old your newest chunk is.
Control
Control has two parts that are easy to confuse: control over how the answer is written, and control over what the answer says.
Control over form
Fine-tuning gives the strongest control over form. A model trained on hundreds of examples of your house style will follow it with less prompting and fewer slips. Prompting with few-shot examples gets close for simple formats. RAG adds no control over form.
Control over content
RAG gives the strongest control over content. You can see which passages were retrieved, restrict the model to them, and show citations. When an answer is wrong, you can inspect the retrieved context and decide whether retrieval or generation failed. A fine-tuned model offers no such trace, since its knowledge is spread across its weights.
Other control concerns
- Access control: with RAG you can filter retrieved chunks by the user's permissions before they reach the prompt. You cannot do that with knowledge baked into a tuned model. Anyone who can call the model can potentially extract what it learned.
- Auditability: a prompt and a retrieved passage can be logged and reviewed. Model weights cannot.
- Reversibility: a prompt change rolls back in seconds. A tuned model rolls back only if you kept the previous version and your application can switch to it.
Putting the trade-offs to work
A quick way to compare options is to score each on the dimensions that matter for your workload. The snippet below weights the dimensions and ranks the approaches. The scores are illustrative judgments from the table above, on a scale of 1 (poor) to 5 (strong). Higher is always better, so a high cost score means low cost.
SCORES = {
"prompting": {"cost": 5, "latency": 4, "freshness": 2, "control": 3},
"rag": {"cost": 3, "latency": 3, "freshness": 5, "control": 4},
"fine-tuning": {"cost": 2, "latency": 5, "freshness": 1, "control": 4},
}
def rank(weights):
totals = {}
for approach, scores in SCORES.items():
totals[approach] = sum(scores[dim] * w for dim, w in weights.items())
return sorted(totals.items(), key=lambda item: item[1], reverse=True)
# A support bot whose facts change weekly: freshness matters most.
print(rank({"cost": 1, "latency": 1, "freshness": 3, "control": 2}))Running this ranks RAG first for the weekly-changing workload. Change the weights toward latency and control and fine-tuning rises. The weights are a way to make your priorities explicit, and they do not replace measurement. Always confirm the ranking with your evaluation set.
Common mistakes when comparing
- Comparing a tuned model to a weak prompt. Improve the prompt first, or the tuning looks better than it is.
- Counting only token price and ignoring engineering and maintenance time.
- Measuring average latency only and missing slow retrieval at p95.
- Expecting fine-tuning to keep facts current.
- Expecting RAG to change tone or format. It supplies facts, not behavior.
- Skipping a cost estimate for retrieved context, which is often the biggest line item.
Exercise
A legal team wants a model that answers questions about contract clauses that change monthly, and every answer must cite its source. Their prompts already produce the right tone. Which approach fits best on freshness and control, and why would fine-tuning be a poor main choice?
Show answer
RAG fits best. The clauses change monthly, so the facts must be updatable by re-indexing, which RAG allows within minutes and fine-tuning does not. RAG also gives control over content: the retrieved passages can be shown as citations and inspected when an answer is wrong. Fine-tuning would freeze the clauses at training time, store them unreliably in the weights, give no source trace, and need retraining after each change. Tone is already handled by the prompt, so tuning adds little.
Exercise
Using the break-even function, you change tokenssavedper_request to 8000 and keep the other values. Does fine-tuning now pay back, and how many requests does it need (rounded)?
Show answer
Yes. The prompted cost is (300 + 8000) / 1000 0.0005 = 0.00415. The tuned cost is 300 / 1000 0.0012 = 0.00036. The saving per request is 0.00379. Dividing 2000 by 0.00379 gives about 527,704 requests. Below that volume, prompting is cheaper overall.
Exercise
Name two ways a RAG system can return outdated answers even though the source documents have been updated, and one metadata field that helps you detect each problem.
Show answer
First, the indexing job fails silently, so the index is stale. A last-updated timestamp lets you monitor the age of the newest chunk. Second, old and new versions of a document both remain in the index. A source identifier lets you delete or replace all chunks from the old version.