In LLM 106, we looked at fine-tuning and adaptation. That gave us a way to change model behavior when prompting, retrieval, and tools are not enough. Now we move from model behavior to system behavior.
An LLM prototype can be a notebook, a prompt, and a few examples. A deployed LLM system is different. It has users, latency expectations, costs, logs, privacy constraints, model updates, failures, and maintenance work. This post focuses on the practical side: model choice, inference cost, serving, caching, monitoring, privacy, and operational reliability.
1. Deployment Is a System Problem
The model is only one component. A deployed LLM application usually includes prompts, retrieval, tools, routing, user interface, logging, monitoring, safety checks, access control, and evaluation.
Task, context, and expectations.
Prompting, routing, and policies.
RAG, files, databases, and tools.
Inference, generation, and scoring.
Quality, cost, latency, and risk.
The core deployment question is not “Can the model answer this once?” It is “Can the system answer this reliably, affordably, and safely for real users?”
Practical framing: deployment turns model quality into service quality. Service quality includes latency, cost, privacy, observability, uptime, and user trust.
2. Choosing a Model
Model choice is a tradeoff. Larger models often perform better on difficult reasoning and broad knowledge tasks, but they cost more and are slower. Smaller models can be cheaper, faster, easier to host, and good enough for narrow workflows.
Better for complex reasoning, broad tasks, and messy language.
Better for speed, cost, classification, extraction, and constrained tasks.
Send easy tasks to cheaper models and hard tasks to stronger models.
For many applications, the best system uses more than one model. A small model might classify intent, a retrieval system might gather evidence, and a stronger model might synthesize the final answer.
Important model-choice questions:
- What task must the model perform?
- Does it need tool use or structured output?
- How much context does it need?
- What is the acceptable latency?
- What is the cost per successful task, not just cost per token?
- Can data leave your environment?
- How will you evaluate regressions after model changes?
For example, a hurricane-season planning assistant that processes confidential municipal evacuation routes might require an open-weight model hosted on-premises to satisfy data governance requirements.
3. Open vs Closed Models
Not all models are accessed the same way. Closed models (e.g., GPT-4, Claude) are accessed through APIs. You send your data to the provider’s servers and receive completions back. Open-weight models (e.g., Llama, Mistral, Gemma) publish their weights so you can download them and run inference on your own infrastructure.
This distinction affects cost structure, data privacy, customization options, and long-term reliability.
Easiest way to start. No infrastructure to manage. The provider handles updates, scaling, and hardware.
But: your data leaves your environment, pricing can change without notice, and you depend on the provider's availability and policies. If the provider deprecates a model version, your system may break.
Full control over data, hosting, and customization. You can fine-tune freely and run inference in air-gapped environments.
But: you manage infrastructure, compute costs, security patches, and model updates yourself. Operational complexity is higher.
When local matters: for research involving sensitive data, IRB constraints, or reproducibility requirements, the ability to run models locally can be a decisive factor. If your evaluation must be exactly reproducible six months from now, relying on a versioned local model is more reliable than depending on a provider's API endpoint.
4. Latency: Time to First Token and Time to Done
LLM latency has two parts. Time to first token is how long the user waits before seeing the answer begin. Time to completion is how long the full answer takes.
Long prompts increase prefill time. Long answers increase decoding time. Tool calls, retrieval, reranking, and safety checks add their own latency.
Illustrative only. The shape changes with model size, context length, hardware, batching, and output length.
Useful latency techniques include:
- streaming tokens to the user;
- reducing prompt size;
- retrieving fewer but better chunks;
- caching repeated prompts or retrieval results;
- using smaller models for simple tasks;
- batching requests when throughput matters;
- limiting output length;
- using faster decoding or serving systems.
- Dao et al. (2022), "FlashAttention": important for memory-efficient and IO-aware attention computation.
- Chen et al. (2023), "Accelerating Large Language Model Decoding with Speculative Sampling": explains draft-and-verify decoding as a way to reduce generation latency.
5. Cost Is More Than Tokens
Token cost matters, but it is not the whole bill. A deployed system may pay for model calls, embedding calls, vector databases, rerankers, tool execution, storage, monitoring, human review, and engineering maintenance.
Think in terms of cost per successful task:
A cheap model that fails often can be more expensive than a stronger model that succeeds with fewer retries. A long prompt that avoids one tool call may still cost more than a short prompt with a deterministic tool.
If a transportation planning office uses an LLM assistant to process 200 evacuation scenario reports per season, the cost-per-task calculation should include the full pipeline: document retrieval, reranking, generation, and human review of each output.
Deployment habit: measure cost, latency, and quality together. Optimizing only one usually makes the other two worse.
6. Serving and the KV Cache
During generation, transformer models store key-value representations for previous tokens. This KV cache avoids recomputing the entire history at every step. It is essential for efficient decoding, but it can use a lot of memory.
Serving systems care about:
- how many requests can run at once;
- how long each request is;
- how much KV cache memory is needed;
- whether requests can be batched;
- whether shared prefixes can reuse computation;
- how to schedule work under load.
GPU memory fragments.
Long requests block shorter ones.
Throughput suffers under load.
Memory is reused more carefully.
Batching becomes more practical.
Serving cost can improve.
- Kwon et al. (2023), "Efficient Memory Management for Large Language Model Serving with PagedAttention": introduces PagedAttention and vLLM for high-throughput LLM serving.
- Shazeer (2019), "Fast Transformer Decoding: One Write-Head is All You Need": an important reference for multi-query attention and faster decoding.
7. Quantization and Compression
Quantization reduces the precision used to store or compute with model weights. The goal is to reduce memory and sometimes increase speed while keeping quality acceptable.
This is especially important when deploying models on limited hardware. But quantization is a tradeoff. Lower precision can reduce quality, affect rare tasks, or interact badly with certain model architectures.
Common high-quality inference precision.
Often useful for memory reduction with manageable quality impact.
Very memory efficient, but needs careful evaluation.
Always evaluate the quantized model on your actual task. A quantized model may look fine on casual chat but fail on structured extraction, citations, math, or domain-specific wording.
- Dettmers et al. (2022), "LLM.int8()": studies 8-bit matrix multiplication for large transformer inference.
- Frantar et al. (2022), "GPTQ": a widely cited post-training quantization method for generative transformer models.
- Xiao et al. (2022), "SmoothQuant": an important post-training quantization approach for large language models.
8. Caching
Caching can reduce cost and latency, but only when used carefully.
Useful cache targets include:
- embeddings for documents;
- retrieval results for repeated queries;
- reranking results;
- prompt prefixes;
- tool outputs;
- final answers for deterministic or low-risk tasks.
Caching is less safe when answers depend on user permissions, current data, or private context. If two users ask the same question but have different document access, they should not automatically receive the same cached answer.
Cache rule: cache stable computations, not sensitive decisions. Include permissions, source versions, and prompt versions in cache keys when they affect the answer.
9. Monitoring Quality in Production
You cannot manually inspect every output. You need monitoring signals.
Track:
- latency;
- cost;
- token counts;
- retry rate;
- tool-call failure rate;
- retrieval hit rate;
- citation coverage;
- user corrections;
- escalation rate;
- refusal rate;
- human review findings.
Latency, errors, uptime, throughput.
Answer quality, grounding, refusals, drift.
Task success, corrections, trust, adoption.
Monitoring should connect back to evaluation. If your evaluation says citation quality matters, production monitoring should track citation failures. If your agent has tools, monitor tool calls and not only final text.
10. Privacy, Logging, and Data Boundaries
LLM systems often touch sensitive data: documents, prompts, user messages, tool outputs, identifiers, and metadata. Deployment requires explicit data boundaries.
Questions to answer before launch:
- What data is sent to the model provider?
- What is logged?
- How long are logs retained?
- Can logs contain private documents or personal information?
- Who can inspect traces?
- Are retrieved documents filtered by user permissions?
- Can users request deletion or correction?
- Are prompts and outputs used for future training?
Log every prompt and retrieved document by default.
Log only what is needed, redact sensitive data, and separate debugging from production retention.
Privacy is not a layer you add at the end. It affects model choice, hosting choice, retrieval permissions, logging, monitoring, and review workflows.
11. Rollouts and Regression Testing
LLM systems should be rolled out like software systems, not like one-off demos.
Use:
- staging environments;
- fixed evaluation sets;
- canary releases;
- prompt and model versioning;
- rollback plans;
- human review for high-risk outputs;
- monitoring dashboards;
- incident notes when failures occur.
Model version: recorded Prompt version: recorded RAG index version: recorded Tool permissions: reviewed Evaluation set: passed Latency budget: passed Cost budget: passed Rollback plan: ready Monitoring: enabled
The boring versioning details matter. If quality gets worse, you need to know whether the model changed, the prompt changed, the retriever changed, the documents changed, or user behavior changed.
12. A Practical Deployment Checklist
Before shipping an LLM feature, I would check:
- Task definition: What workflow does this support?
- Model choice: Why this model, and what is the fallback?
- Prompt versioning: Can you reproduce a prior output?
- Context design: What enters the prompt, and why?
- Cost controls: Are there token, retry, and tool-call budgets?
- Latency controls: Is streaming, caching, or routing needed?
- Privacy rules: What data is sent, stored, redacted, or blocked?
- Evaluation: What local tests must pass before release?
- Monitoring: What signals show quality, risk, and cost?
- Rollback: How do you revert a bad model, prompt, or index update?
Deployment is where LLM work becomes engineering. A good system is not just impressive on a prompt. It is observable, bounded, affordable, testable, and useful under real conditions.
- A planning agency wants to deploy an LLM assistant that summarizes confidential infrastructure inspection reports. Should they use a closed API model or an open-weight model? List three factors that would influence this decision.
- Your LLM system has a latency budget of 3 seconds per response. The current pipeline takes 1.2s for retrieval, 0.5s for reranking, and 2.8s for generation. Which component would you optimize first, and what technique from this post would you try?
- After a model provider updates their API model, your evaluation scores drop by 8%. Your prompts and RAG pipeline have not changed. Using the regression testing section, describe how you would diagnose and respond to this.
In the next post, we can look at safety and responsible use: bias, privacy, misuse, transparency, uncertainty, and human oversight.