Retrieval-augmented generation: architecture that holds up in production
A working retrieval pipeline is straightforward. Making it reliable enough to trust with business questions is where the engineering is.
Inference costs scale with usage in ways that surprise teams. A few architectural decisions control most of the bill.
Track cost per request, per user and per resolved task from the first day. An aggregate monthly figure tells you the bill; the unit cost tells you whether the system is economic.
Log token counts alongside outcomes so the relationship between cost and value is visible rather than inferred.
Not every request needs the largest model. A smaller model handles routine cases well, with escalation to a larger one when confidence is low or the task is complex.
Sending large amounts of context on every request is the most common cause of unexpected cost. Better retrieval that sends five relevant passages instead of fifty reduces cost and usually improves quality.
Trim conversation history deliberately rather than accumulating it indefinitely.
Rate limits per user, spending alerts and a hard cap prevent a loop or an unusual usage pattern turning into a large invoice.
Build these in at the start. They are simple then, and they are written under pressure after an incident otherwise.
Cost surprises usually come from usage patterns nobody modelled. Before committing to a design, estimate tokens per request for each request type and multiply by realistic volume, including the retries and failures that will happen.
Model a pessimistic case as well: what if usage is five times the estimate, or if users write much longer inputs than expected? Knowing the ceiling informs whether limits are needed and where.
Revisit the model against actuals after a month in production. The gap between estimate and reality is usually instructive and worth feeding into the next design.
It can be at sustained high volume, and it moves cost from per-token pricing to infrastructure and operations. Below substantial usage, hosted endpoints are usually cheaper in total.
For identical or near-identical queries, yes, and it is very effective for support-style workloads where the same questions recur.
Measure token usage per request type in a pilot, multiply by expected volume, and add margin. Retrieval systems are more predictable than open-ended conversation.
Keep reading
A working retrieval pipeline is straightforward. Making it reliable enough to trust with business questions is where the engineering is.
Connecting a language model to your documents is the straightforward part. The reliability work is everything after that, and it looks nothing like the demonstration.
Without an evaluation set, every change to a language model system is argued on anecdote. Building one is the highest-value early task.