Deploying Large Language Models Locally: Model Selection, Resource Estimation, and Production Practices
Deploying a large language model locally involves far more than downloading weights and running inference. This guide walks through an engineering-oriented approach covering three core questions: how to discover and evaluate candidate models for your use case, how to assess whether your hardware can support a given model (including VRAM estimation for weights and KV cache), and how to deploy models as stable, observable, and maintainable services. It covers constraint definition, model admission criteria, quantization trade-offs, inference optimization, deployment workflows, scenario-based selection guidance, and common pitfalls to avoid.
Deploying Large Language Models Locally: Model Selection, Resource Estimation, and Production Practices
Deploying a large language model (LLM) locally is not as simple as “find a model, download it, and run it.” A solution that actually works in production must answer three questions: first, how to continuously discover and filter models suited to your business; second, how to determine whether your local hardware meets the model’s requirements; and third, how to deploy the model as a stable, observable, and maintainable service. This article presents a neutral, reusable methodology from an engineering practice perspective.
1. Define Goals and Constraints Before Asking for Model Recommendations
Before discussing “which model to recommend,” you should first clarify your deployment goals. Common goals include internal knowledge Q&A, document summarization, coding assistance, customer support augmentation, offline text processing, and multimodal understanding. These goals differ significantly in their requirements for model capability, context length, response latency, concurrency, and data compliance.
Start by listing your constraints:
- Task type: general conversation, structured extraction, summarization, translation, code generation, image-text understanding, etc.
- Data compliance: whether data can leave your internal network, whether it involves sensitive information, and whether audit logs are required.
- Hardware boundaries: available GPU VRAM, CPU memory, disk capacity, network bandwidth, and budget for expansion.
- Performance targets: time to first token, throughput, concurrency, P99 latency, and availability goals.
- Maintenance capacity: whether dedicated staff can handle model updates, quantization, inference service operations, and monitoring/alerting.
- Licensing and commercial restrictions: whether the model license permits internal use, commercial use, redistribution, or fine-tuning.
Only when these constraints are written down clearly will model selection avoid degenerating into a blind “bigger is better” comparison.
2. How to Discover and Filter Deployable Models
Model sources should prioritize auditable, version-traceable model hosting platforms, internal model artifact repositories, or official release channels. When filtering candidates, don’t rely solely on leaderboard scores—focus on the following:
- Model card: parameter count, architecture type, training data description, supported languages, context length, and recommended inference methods.
- Versions and changelogs: clear version numbers, update logs, known issues, and fix records.
- License: whether commercial use is allowed, whether attribution is required, and whether redistribution is restricted.
- Quantization support: whether common low-precision weights are provided and whether the community has mature quantization practices.
- Deployment ecosystem: whether mainstream inference frameworks support it and whether it can be easily exposed as a service API.
- Reproducible evaluation: whether you can run small-scale offline evaluations with your own business samples instead of trusting only public benchmarks.
For enterprise teams, it is advisable to maintain a “model admission list”: for each candidate model, record its source, version, license, hardware requirements, offline evaluation results, deployment method, and owner. This turns “the latest model” into “a manageable asset” and prevents maintenance chaos caused by constantly chasing new releases.
3. Hardware Resource Estimation: VRAM Is Not the Only Metric
The core constraint for local LLM deployment is usually GPU VRAM, but it is not the whole picture. VRAM primarily holds model weights, the KV cache, intermediate activations, and inference framework overhead. Without quantization, weight memory can be roughly estimated with a simple rule of thumb:
Weight memory (GB) ≈ parameter count (B) × bytes per parameterFP16/BF16: ~2 bytes per parameter, i.e., ~ parameter count (B) × 2 GBINT8: ~1 byte per parameter, i.e., ~ parameter count (B) × 1 GBINT4: ~0.5 bytes per parameter, i.e., ~ parameter count (B) × 0.5 GB
For example, a 7B model requires about 14 GB of weight memory in FP16, a 13B model about 26 GB, and a 70B model about 140 GB. Actual usage must also account for the KV cache, framework overhead, and the additional memory from batching and context length. The KV cache can be roughly understood with this general formula:
KV Cache ≈ 2 × number of layers × hidden dimension × context length × batch size × bytes per element
As a result, long contexts and high concurrency push VRAM usage up significantly. A model that “runs for a single request” is not the same as one that “stably serves multiple users.” Beyond VRAM, you should also evaluate:
- CPU memory: needed for model loading, preprocessing, postprocessing, and caching.
- Disk space: required for weight files, quantized variants, logs, and model artifacts.
- Network bandwidth: multi-GPU inference, model distribution, and remote calls can be bandwidth-limited.
- Cooling and power: sustained inference places demands on overall system stability.
- Scalability: support for multi-GPU setups, multiple instances, batching, and elastic scaling.
It is recommended to build a resource estimation table using pseudocode:
Input: parameter count B, precision, context length, batch size, concurrencyCompute weight memory = parameter count B × bytes per parameterCompute KV cache = 2 × layers × hidden dimension × context length × batch size × bytesTotal VRAM ≈ weight memory + KV cache + framework overhead + safety marginIf total VRAM > available VRAM × 0.85, reduce batch size, shorten context, or apply quantization
4. Quantization and Inference Optimization: Validate Before Going Live
Quantization is a key technique for reducing VRAM usage, with 8-bit and 4-bit being the most common options. As a rule of thumb, 8-bit weights are roughly half the size of unquantized weights, and 4-bit roughly a quarter. However, embedding layers, output layers, or other sensitive layers may be kept at higher precision, so actual usage will exceed theoretical values. After quantization, you must run business-specific evaluations focusing on factual consistency, format adherence, long-text comprehension, and multi-turn conversation stability.
Inference optimization can be approached from the following directions:
- Batching: merging requests improves throughput but increases latency and memory usage.
- Context management: truncation, summarization, and retrieval-augmented generation reduce wasted long contexts.
- Cache reuse: caching stable prefixes or system prompts.
- Model tiering: route simple tasks to small models and complex tasks to large models.
- Multi-instance isolation: partition resources by business line to avoid mutual interference.
5. Deployment Workflow and a Scenario-Based Selection Matrix
A recommended workflow is: requirements definition → model filtering → offline evaluation → resource estimation → quantization and inference setup → service deployment → load testing → monitoring → security auditing. When exposing the model as a service, provide a unified API with authentication, rate limiting, timeouts, retries, and logging. Model versions should support rollback, and monitoring should cover VRAM usage, latency, throughput, error rates, and queue length.
A rough scenario-based selection guide:
| Scenario | Suggested Parameter Scale | Hardware Focus | Strategy |
|---|---|---|---|
| Lightweight text processing, offline batch jobs | Small models | Single GPU with 8–12 GB VRAM | Prioritize quantization and batching |
| Internal Q&A, summarization, extraction | Medium models | Single 24 GB GPU or multi-GPU | Evaluate against context length and concurrency |
| Complex reasoning, coding assistance | Larger models | Multi-GPU with 48–80 GB VRAM | Quantization, routing, and caching |
| High-concurrency online services | Multi-instance combinations | VRAM, bandwidth, queuing | Rate limiting, elastic scaling, tiered models |
If local resources are insufficient, non-sensitive workloads can be placed in cloud environments offering general-purpose capabilities such as containers, object storage, and monitoring/alerting—for example, the general cloud service categories provided by Baidu AI Cloud. However, data compliance, network latency, and cost must be evaluated first. Whether on-premises or in the cloud, never let marketing claims about model capabilities substitute for real load testing.
6. Common Pitfalls and Summary
Common pitfalls include: looking only at parameter count without considering task fit; counting only weight memory while ignoring the KV cache; overlooking long contexts and concurrency; skipping business regression tests after quantization; lacking version management and rollback; and missing monitoring and rate limiting. The key to local LLM deployment is not “chasing the newest model” but building an engineering loop that is evaluable, deployable, observable, and maintainable. Define constraints first, filter models with small-sample evaluations, determine hardware boundaries with resource estimation, control costs with quantization and inference optimization, and finally ensure stable operation through service deployment and monitoring. This is the more reliable path for local LLM deployment.
