A Guide to Local LLM Deployment: Model Selection, VRAM Estimation, and Implementation
This guide provides a comprehensive methodology for deploying large language models locally. It covers how to select models based on specific task requirements, accurately estimate VRAM consumption including weights and KV cache, evaluate quantization trade-offs, and adapt deployment strategies to different hardware constraints. Additionally, it outlines a step-by-step implementation process from initial minimum viable validation to achieving a stable production service.
1. Answer Three Questions Before Local Deployment
The question “Which LLMs can be deployed locally?” might seem like a request for model recommendations, but it actually involves three interconnected judgments: Is the model suitable for the task? Can the hardware support it? Will it meet usability standards after deployment?
A downloadable model is not necessarily suitable for your business, and a model that fits into memory may not provide stable service. For individual developers, the focus might be on simple installation, smooth interaction, and controllable costs. For enterprises, considerations also include data isolation, licensing, concurrency capacity, auditing, and continuous maintenance.
Therefore, rather than listing a string of model names, it is more valuable to establish a selection methodology that will not quickly become obsolete as models update:
- Define the task type and filter the appropriate model category.
- Estimate resources based on weights, context, and concurrency.
- Validate quality and speed using actual business samples.
- Deploy under observable and rollback-capable conditions.
This article focuses primarily on inference deployment. Training and fine-tuning require additional storage for gradients, optimizer states, and intermediate activations, meaning inference-phase resource estimates cannot be directly applied.
2. Select Model by Task, Then Parameter Size
2.1 General Chat and Knowledge Q&A
For chat, text organization, summarization, and general Q&A, prioritize instruction-aligned models rather than directly using base pre-trained models.
Base models lean more towards text continuation, whereas instruction models are better at organizing answers based on user requirements. However, instruction alignment does not guarantee factual reliability. When dealing with proprietary knowledge like enterprise policies or equipment manuals, you typically need to combine Retrieval-Augmented Generation (RAG) so the model answers based on traceable materials.
When selecting, pay close attention to language fluency, instruction following, factual accuracy, and whether the model can explicitly state uncertainty when information is insufficient.
2.2 Coding and Structured Processing
For tasks like code explanation, program completion, and data extraction, you cannot only look at whether the response is fluent; you must also check if the results are verifiable.
For example, code should pass syntax checks and tests; structured outputs should comply with field constraints without extraneous explanatory text. For these tasks, a smaller parameter model with specific capabilities might be more economical than a larger general-purpose model.
2.3 Images, Voice, and Other Multimodal Tasks
If inputs include images or audio, you need to confirm whether the model has the corresponding input capabilities. A pure text model cannot understand raw images or audio just by adding prompt text.
Multimodal deployment may also involve additional encoder components, preprocessing pipelines, and caches. When estimating resources, you cannot just calculate the parameter count of the language component.
2.4 Do Not Treat “Newest” as the Only Standard
New models may show improvements on certain tasks, but they can also bring issues like immature inference implementations, insufficient quantization versions, and complex runtime dependencies.
A more prudent approach is to build a candidate list, evaluating task fit, license, runtime compatibility, resource requirements, and maintenance costs together. For production environments, a reproducible deployment process and stable behavior are often more important than the release date.
3. How to Acquire and Verify Deployable Models
When acquiring models, you can search through public model hosting platforms, institutional release pages, or audited internal model repositories, but you should verify the following information before downloading.
3.1 Licenses and Usage Restrictions
“Can be downloaded” does not mean “can be used commercially at will.” You need to confirm whether commercial use, modification, and redistribution are allowed, and whether there are usage restrictions or attribution requirements.
Model weights, inference code, and accompanying data may also be subject to different licensing conditions; you should not just read one of them.
3.2 File Completeness
A complete deployment usually requires more than just a weight file; it may also need model architecture configs, text encoder/tokenizer files, chat templates, and generation configs.
Missing some of these components can cause the model to fail to load, or it might run but produce noticeably abnormal responses. Incorrect chat templates, in particular, are easily misdiagnosed as a lack of model capability.
3.3 Runtime Compatibility
You need to verify whether your inference engine supports the model architecture, weight precision, and quantization format, and confirm that the compute devices and driver environment meet the requirements.
Quantization formats are not universally interchangeable. Even with low-bit weights, different storage layouts and computational implementations may not be directly swappable.
3.4 Source Security and Version Management
Some model loading processes may execute embedded code. In production environments, try to use audited standard loading methods, isolating and reviewing any code that must be executed.
Simultaneously, retain model versions, file checksums, configurations, and test results. Otherwise, when output behavior changes, it is difficult to determine whether the cause is the weights, the template, or the runtime environment.
4. VRAM Estimation: Weights Are Only Part of the Overhead
The common rule of thumb that “every billion parameters takes about two times the capacity” actually corresponds to each parameter using two bytes for storage. This is primarily used to estimate weights, not the complete inference VRAM.
4.1 Basic Formula for Weight Capacity
Assuming the total number of parameters is N and each parameter occupies b bits, the theoretical weight capacity is:
Weight Bytes ≈ N × b ÷ 8
The following provides an ideal estimate in decimal GB:
| Parameter Scale | 16-bit Weights | 8-bit Weights | 4-bit Weights |
|---|---|---|---|
| 3 Billion | 6 GB | 3 GB | 1.5 GB |
| 7 Billion | 14 GB | 7 GB | 3.5 GB |
| 14 Billion | 28 GB | 14 GB | 7 GB |
| 32 Billion | 64 GB | 32 GB | 16 GB |
| 70 Billion | 140 GB | 70 GB | 35 GB |
These numbers do not represent the actual VRAM after loading. Quantized models usually need to save auxiliary information like scaling coefficients, some tensors may retain higher precision, and device capacity displays may use different units.
4.2 Composition of Total Inference VRAM
A more practical estimation method is:
Total VRAM ≈ Weights + Attention KV Cache + Intermediate Tensors + Compute Workspace + Runtime Overhead
The attention KV cache is used to save partial computation results of already processed tokens, reducing redundant calculations during the generation phase. Its scale typically grows with sequence length and the number of active requests.
For common decoder-only architectures, the following formula helps in understanding:
Cache Bytes ≈ 2 × Layers × Total Cached Tokens × KV Heads × Head Dimension × Bytes Per Element
The 2 here corresponds to Keys and Values respectively. Different model architectures, cache precision, and management mechanisms will alter actual usage, so this formula is suitable for capacity analysis but cannot replace empirical testing.
4.3 Context Length Changes Deployment Outcomes
Short conversations running normally does not mean long document analysis will run stably.
The longer the input, the more generated content, and the more concurrent requests, the higher the cache and compute overhead. A deployment with only a small amount of VRAM margin might encounter Out of Memory (OOM) when processing longer inputs.
Therefore, you should determine the maximum input, maximum output, and concurrency goals based on actual business needs, rather than just using “model successfully loaded” as the acceptance criteria.
5. Quantization Trade-offs: Saving Resources Requires Quality Validation
Quantization reduces storage and transmission overhead by lowering the representation precision of certain values, making it a crucial method for local deployment.
However, a “4-bit model” usually describes certain weights using low-bit storage; it does not mean all computations, intermediate results, and caches are in 4-bit representation.
5.1 Main Benefits of Quantization
First, it reduces weight capacity, giving models that originally couldn’t fit into a device a chance to run. Second, it reduces read traffic for some weights; when hardware and computational implementations match, it may also improve inference speed.
It must be emphasized that low-bit does not necessarily mean faster. If the runtime needs to frequently convert data, or lacks efficient compute support, saved capacity does not always translate into speed gains.
5.2 Potential Costs of Quantization
Quantization can affect output quality, and the sensitivity varies by task. Changes that are unnoticeable in simple rewriting tasks might be amplified in complex reasoning, numerical calculations, code generation, and strict format outputs.
Therefore, you should not judge the quantization effect based on just one or two rounds of chat. You should test multiple precision versions under the same prompts and generation conditions using business samples.
5.3 Recommended Selection Order
First, determine the model scale that meets the task requirements, then choose the precision that fits your resource budget. If quality drops significantly after lowering precision, compare the actual effects of a “small model with high precision” versus a “large model with low precision,” rather than assuming the latter is always better.
6. Deployment Strategies for Different Resource Constraints
The following suggestions are for determining experimental directions, not guaranteed hardware lists for running models.
6.1 CPU Only or Low VRAM
You can start with models in the 1B to 10B parameter range, using low-bit weights, controlling context length, and minimizing concurrency.
This configuration is suitable for feature validation, offline processing, and low-frequency interaction. If you put part of the weights into system memory, you need to pay attention to the latency caused by memory bandwidth and inter-device data transfer.
6.2 Medium VRAM Single-Device Environment
You can test models in the 10B to 100B parameter range, combining quantization to free up cache space.
When selecting, do not let weights consume all the VRAM. Compared to勉强 squeezing in a larger model, appropriately reducing the scale to allow for longer context and more stable responses often better meets actual needs.
6.3 High VRAM or Multi-Device Environments
Larger models and higher concurrency become possible, but deployment complexity also increases. Multi-device inference requires considering weight sharding, inter-device communication, cache allocation, and scheduling strategies.
Sufficient total VRAM does not mean multi-device operation will definitely be efficient. Communication capabilities and the inference engine’s parallel implementation will both affect the final outcome.
7. From First Launch to Stable Service
Step 1: Build a Resource Inventory
Record device VRAM, system memory, available disk space, drivers, and runtime dependencies, and confirm whether the device is occupied by other tasks.
In addition to saving weights, disk space should also account for download temporary files, conversion artifacts, and version rollback copies.
Step 2: Complete Minimum Viable Validation
Use short inputs, low concurrency, and controlled output lengths to complete the first inference. Check whether model loading, chat templates, output language, and termination behavior are correct.
At this stage, variables should be minimized; it is not advisable to simultaneously introduce long context, complex retrieval, and multi-request scheduling.
Step 3: Build a Business Evaluation Set
Evaluation samples should cover common tasks, difficult tasks, and edge cases, such as insufficient information, ultra-long inputs, format conflicts, and prompt injections embedded in documents.
For tasks that can be automatically verified, try to use programmatic checks; for open-ended tasks, establish uniform evaluation criteria to avoid selecting models based solely on subjective impressions.
Step 4: Gradually Increase Load
First increase input length, then output length, and finally increase concurrency. Record peak VRAM, response latency, and error conditions at each step.
This step-by-step testing helps pinpoint the source of problems: whether it is insufficient weight capacity, rapid cache growth, or a compute and scheduling bottleneck.
Step 5: Add Service Protections
The service entry point should have authentication, request length limits, concurrency control, and timeout and cancellation mechanisms. When capacity limits are reached, new requests should be queued or rejected, rather than continuously accepting them until the process crashes.
Local deployment does not automatically equate to data security. Logs, caches, backups, and management interfaces also require access control.
8. How to Determine if Deployment is Truly Successful
It is recommended to record at least the following metrics:
- Task Quality: Business accuracy, format compliance rate, and manual review results.
- Time to First Token (TTFT): The time users wait for the model to start responding.
- Generation Speed: The number of tokens output per unit time after generation begins.
- End-to-End Latency: The time from receiving a request to fully returning the response.
- Resource Peaks: VRAM, system memory, and processor utilization.
- Stability: Failures, timeouts, and OOM situations during long-term operation.
When testing, you must specify input length, output length, concurrency count, and weight precision. Separating “how many tokens generated per second” from these conditions can easily be misleading.
Enterprise scenarios should also pay attention to retrieval hit rates, citation accuracy, sensitive information handling, and human-in-the-loop mechanisms. Model inference is just one link in the entire application chain.
9. Conclusion: Prioritize the Minimum Viable Solution
There is no one-size-fits-all recommendation for local LLM deployment outside of specific scenarios. A reasonable choice must simultaneously satisfy task effectiveness, resource capacity, response speed, licensing, and maintenance capabilities.
For individual developers, it is recommended to first complete the full process with a small-scale, low-concurrency solution, and then upgrade resources based on test results. For enterprises, build an evaluation set and capacity baseline first, then decide whether to scale up the model, add devices, or adopt a more complex service architecture.
The true capability worth mastering is not memorizing how much VRAM a specific model needs, but being able to explain why resources are consumed, why quality changes, and how to find a suitable solution through reproducible testing. This way, even as models continue to update, your deployment methodology remains effective.
