Table of Contents
A production AI system succeeds when it meets a real user need reliably, safely, and at an acceptable total cost—not when its model wins one benchmark. The hard decisions involve ownership, maintainability, data, latency, adaptation, and the consequences of failure.
Before choosing an architecture, define a task-specific evaluation set and operating targets: output quality, unacceptable failure types, p95 latency, availability, cost per completed task, review rate, and recovery time. Without this baseline, “build versus buy” and “fine-tune versus prompt” become opinions instead of engineering decisions.
1. Build, buy, or combine both?
Teams rarely choose only between a vendor API and a model trained from scratch. Practical options include a hosted API, a managed cloud endpoint, an open-weight model on rented infrastructure, an on-premises deployment, or a router that uses several providers.

| Question | Hosted or managed service may fit when… | Self-hosting may fit when… |
|---|---|---|
| Time to first release | The team needs a fast pilot and a small operations burden | The serving platform and deployment skills already exist |
| Data and control | Provider terms, region, retention, and security meet requirements | Workload needs tighter residency, isolation, weights, or runtime control |
| Workload | Demand is uncertain or bursty | Demand is measurable, sustained, and suitable for owned capacity |
| Model changes | The team values quick access to vendor improvements | The team needs a stable model version and controls its upgrade schedule |
| Operations | Rate limits, observability, and support are sufficient | The team can own capacity planning, patching, safety, monitoring, and incidents |
Model total cost of ownership with real traffic. Include input and output volume, retries, tool calls, embedding and retrieval, peak concurrency, idle capacity, accelerators, storage, network egress, engineers on call, evaluation, security review, and migrations. There is no universal request count at which self-hosting becomes cheaper.
Keep the first decision reversible. Put provider-specific calls behind a small internal interface, log model and prompt versions, and store evaluation inputs in a portable format. A pilot can start with a managed service without making every application component depend on one vendor.
2. Accuracy versus maintainability
The simplest system that meets the task's error budget is usually the strongest production baseline. A small improvement in an offline metric may not justify an extra model, agent, retriever, reranker, feature pipeline, or orchestration framework.

The classic Google paper Hidden Technical Debt in Machine Learning Systems describes risks such as entanglement, hidden feedback loops, undeclared consumers, data dependencies, and configuration debt. The warning applies strongly to LLM applications: the model call may be a small part of a much larger production system.
Before adding complexity, require an ablation test:
- Measure the current baseline on representative cases.
- Add one component.
- Measure quality, latency, cost, and new failure modes.
- Test degraded conditions: timeout, empty retrieval, malformed tool output, provider outage, and rate limiting.
- Keep the component only if the gain is material and operable.
Design an explicit fallback. A retrieval system may fall back to “insufficient evidence,” a large model to a smaller model, or an autonomous action to a human approval queue. Use feature flags, shadow traffic, canary rollout, and versioned configuration so the team can reverse a bad release.
3. More data versus better data
Collecting more examples helps only when they represent the task and are labeled consistently. A large dataset with duplicated records, leaked targets, conflicting annotations, obsolete policy, or missing edge cases can make evaluation look better while production behavior gets worse.

Use production errors to decide what data to improve:
- Define the unit of analysis and a written labeling guide.
- Track source, consent or permitted use, time range, transformations, and dataset version.
- Separate training, validation, and test data by the boundary that prevents leakage—often user, customer, document, or time period.
- Measure agreement on ambiguous labels and resolve systematic disagreement.
- Slice results by language, document type, risk level, user group, input length, and other relevant conditions.
- Keep a small, curated regression set for every serious incident.
- Set retention and deletion rules instead of keeping every prompt indefinitely.
Do not optimize the average score alone. A small error slice can dominate harm or support cost. Prioritize examples that cover high-impact failures, changing input distributions, and cases where the current system is uncertain for a meaningful reason.
4. Batch, online, or asynchronous inference?
Start with the business freshness requirement. If a prediction can be several hours old without changing a decision, scheduled batch inference is usually easier to operate. If a user is waiting for an answer based on current input, online inference may be necessary. Many workflows fit an asynchronous queue: the user submits work, receives a job ID, and returns when processing is complete.
| Pattern | Best fit | Main engineering concern |
|---|---|---|
| Batch | Nightly scores, catalog enrichment, reporting, offline embeddings | Staleness, backfills, and partial-job recovery |
| Online request/response | Interactive assistants, moderation gates, live recommendations | Tail latency, concurrency, timeouts, and graceful degradation |
| Asynchronous queue | Document processing, media generation, long agent jobs | Idempotency, status, cancellation, retries, and duplicate work |
| Hybrid | Precompute candidates, then personalize at request time | Version consistency between offline and online components |
Do not build a low-latency service simply because real time sounds advanced. Measure the value of fresher output against the cost and operational burden. A useful architecture often precomputes expensive work in batch and reserves online inference for the small portion that depends on current context.
5. Prompting, retrieval, or fine-tuning?
These techniques solve different problems and often work together.
| Technique | Use it primarily for | It does not solve by itself |
|---|---|---|
| Prompting and structured output | Instructions, examples, workflow rules, output schema | Reliable access to missing private or current facts |
| Retrieval-augmented generation | Grounding responses in selected documents or records | Poor source quality, bad chunking, or model behavior outside retrieved evidence |
| Fine-tuning | Repeated task behavior, format, style, domain patterns, or specialized capability supported by the model | Frequently changing knowledge unless it is refreshed through another mechanism |
| Tools and deterministic code | Calculations, transactions, database updates, verified lookups | Open-ended judgment without rules or evaluation |
Begin with a prompt and an evaluation set. Add retrieval when failures come from absent or changing knowledge. Add deterministic tools when the task needs exact computation or an external action. Consider fine-tuning when a stable pattern of failures remains and you have enough high-quality examples to train and validate it.
Fine-tuning should not begin with a training job. It begins with data design, a held-out evaluation set, a baseline, privacy and licensing review, and a deployment plan. Compare the tuned model with a strong prompted baseline at the same quality, latency, and cost target.
TipsMake's overview of Python libraries for LLM applications covers tools for retrieval, agents, and evaluation. Its guide to comparing LLM families also explains why a benchmark winner is not automatically the right production model.
6. Automation versus human oversight
Set the autonomy level from the consequence of a wrong action, not from the model's apparent fluency. Consider severity, reversibility, detectability, affected people, time to intervene, and the quality of available human review.

| Control level | Example use | Required safeguard |
|---|---|---|
| Suggest only | Drafting, search assistance, analysis | User sees sources and can reject the output |
| Human approval before action | External messages, refunds, account changes | Reviewer sees input, proposed action, evidence, and policy |
| Automatic low-risk action with exceptions | Routing, tagging, reversible workflow steps | Thresholds, audit log, rollback, sampled review, exception queue |
| Full automation within a narrow boundary | Deterministic, low-impact, well-tested tasks | Rate limit, monitoring, kill switch, incident owner, periodic reevaluation |
A model confidence score is not a complete risk control. It may be poorly calibrated or fail confidently on a new distribution. Combine model signals with business rules, input validity, retrieval quality, out-of-distribution checks, transaction value, and user impact.
Human review also needs engineering. Define queue capacity, reviewer guidance, disagreement handling, escalation, latency targets, and feedback quality. If reviewers rubber-stamp outputs under time pressure, “human in the loop” is only a label.
The NIST AI Risk Management Framework provides a use-case-agnostic structure for mapping, measuring, and managing AI risks. Regulated or high-stakes deployments also need applicable legal, sector, security, and organizational requirements—not a generic assumption that review is always mandatory or always sufficient.
Use one decision record for all six trade-offs
For each choice, record the user need, alternatives, representative evaluation results, cost model, risks, owner, rollout plan, rollback trigger, and review date. Revisit the decision when traffic, prices, data, regulations, providers, or failure patterns change.
| Production signal | Example trigger to reconsider the design |
|---|---|
| Quality | A critical error slice exceeds its agreed limit |
| Latency | Tail latency misses the user-facing service target |
| Cost | Cost per successful task rises after retries and review are included |
| Operations | Incidents require expertise the team cannot staff reliably |
| Risk | A new use case makes errors less reversible or more harmful |
| Vendor or model change | Terms, behavior, availability, or support no longer meet requirements |
The best architecture is not the one with the most AI. It is the smallest system that meets the user and risk requirements, can be observed in production, and can be changed safely when the evidence shifts.
Reader Comments 0
Sign in with email or Google to join the discussion.