Local LLM Deployment: A Practical Guide to Model Selection and Operations
This guide walks through how to choose and run large language models on your own infrastructure. It covers the main reasons teams move inference on-premises, where to source open-weight models and how to read their naming conventions, an evaluation checklist and the case for building a small internal benchmark, formulas for estimating VRAM from parameter count and quantization, throughput and latency trade-offs, a reference architecture for serving inference internally, the operational rhythm for quantization, fine-tuning, updates and rollback, security and cost controls, and a hybrid path that combines on-premises inference with cloud services. A final checklist helps teams move from selection to an internal launch.
1. Why Run LLMs on Your Own Infrastructure
Deploying large language models locally — in a self-built data center, a private cloud, or an on-premises server cluster — is usually driven by four factors:
- Data stays within your boundary: Finance, healthcare, government, and manufacturing often impose hard requirements on where data may travel. Sensitive text, drawings, medical records, and work orders cannot leave the internal network.
- Deterministic control: A local environment lets you pin the model version, inference parameters, and dependency versions, avoiding output drift caused by upstream model updates.
- Predictable cost structure: Under stable high-concurrency workloads, a one-time hardware investment is often more economical than long-term usage-based billing.
- Deep customization: You can run incremental training and preference alignment on private corpora, and embed the model directly into existing business workflows.
The trade-off must be stated clearly: local deployment means you own hardware procurement, driver and runtime maintenance, model updates, and capacity planning. Selection therefore cannot focus only on “how good is the model” — it must focus on how well the model matches the resources you already have.
2. How to Systematically Find and Evaluate Candidate Models
The “model hosting communities” mentioned in the original topic are essentially centralized distribution channels for models, datasets, and inference libraries. To avoid pointing at specific platforms, they can be abstracted into two source types:
- International public model hosting communities: Nearly all mainstream open weights are published here, along with model cards, licenses, evaluation results, and inference examples. Good for technical research and side-by-side comparison.
- Public model hosting communities in China: Friendlier in terms of network reachability and download stability, and they typically mirror Chinese-language models from local teams. Useful as a production pull source.
2.1 Key Information in Naming Conventions
Model directory names generally combine “series name - size - variant.” For example, “some-series-7B-Instruct” indicates 7 billion parameters with instruction fine-tuning; “-Chat” indicates a dialogue-aligned version; “-Base” indicates a pretrained-only foundation that you must fine-tune yourself. Understanding this convention lets you quickly rule out mismatches during selection.
2.2 Evaluation Dimensions
| Dimension | What to Check |
|---|---|
| License | Commercial use allowed? User-scale restrictions? Attribution or derivative open-source requirements? |
| Chinese capability | Share of Chinese training data; performance on idioms, terminology, and long-form understanding |
| Context length | Sufficient for long documents and repository-level code input? |
| Modality | Text only, text plus images, speech, structured tables |
| Ecosystem completeness | Availability of tokenizer, quantized versions, inference adapters, fine-tuning scripts |
| Safety alignment | Basic refusal behavior and jailbreak resistance |
2.3 Build a Small Internal Benchmark
Public leaderboards are only good for initial screening. Build an internal evaluation set from 100–300 real business samples covering four task types: high-frequency Q&A, long-document summarization, structured extraction, and refusal. Use a dual track of human scoring plus rule-based validation so a single automated metric does not mislead the decision.
3. Quantifying Parameter Size Against Hardware Resources
3.1 A Rough Formula for the VRAM Floor
During inference, VRAM is consumed mainly by weights, the KV cache, and runtime overhead:
Weight VRAM ≈ parameter count × bytes per parameterKV cache ≈ 2 × layers × hidden dimension × context length × batch size × bytes per elementTotal VRAM ≈ weights + KV cache + framework reserve (about 10%~20%)
By this estimate, a 7B model in FP16 needs about 14GB for weights, and a single 24GB card can handle a moderate context. With 8-bit quantization it drops to roughly 7GB, and 4-bit to about 4GB, which significantly widens the room for concurrency and context. A 13B-class model needs about 26GB in FP16, typically requiring a single large-VRAM card or multi-card tensor parallelism.
3.2 Throughput vs. Latency
- Time to first token is affected by input length and compute; per-token generation speed depends more on VRAM bandwidth.
- To raise concurrency, prioritize scheduler capabilities such as continuous batching rather than simply enlarging the batch size.
- For long-context scenarios, evaluate the VRAM savings from common optimizations such as paged attention caching.
3.3 A Selection Example
An enterprise needs internal contract review: documents average 12,000 characters, 20 concurrent sessions, and time to first token under 2 seconds. Working through the formula, a 7B-class instruction model with 4-bit quantization, a 32K context, and two-card parallelism meets the requirement on the two inference servers already in place — no new procurement needed.
4. A Reference Architecture for Serving Inference Locally
Business applications↓ (internal HTTP/gRPC)Access gateway (authentication, rate limiting, audit)↓Inference service layer (model runtime + batch scheduling)↓Model repository (local object storage / file storage, versioned)↓Monitoring and logging (metrics, tracing, alerting)
Key engineering points:
- Model versioning: Tag weights and configuration together, and keep a rollback path.
- Unified abstraction layer: Wrap inference calls in an internal standard interface so models can be swapped later without changing business code.
- Observability: Collect four core metrics — queue length, VRAM usage, time to first token, and failure rate.
- Degradation strategy: On insufficient VRAM or timeout, automatically fall back to a smaller model or queue a retry.
An illustrative call wrapper:
def chat(prompt: str, context_len: int = 8192) -> str:# Single entry point that hides differences between underlying modelsreturn runtime.generate(prompt=prompt,max_context=context_len,temperature=0.2, # Use a low value for factual taskstop_p=0.9,)
5. The Operational Rhythm for Quantization, Fine-Tuning, and Updates
- Quantize first: Validate quality loss with 8-bit/4-bit; for most general tasks the loss is acceptable. Keep a high-precision version for comparison on numerically sensitive tasks.
- Fine-tune as needed: Prefer parameter-efficient fine-tuning (training only a small set of additional parameters) — lower VRAM and storage cost, and easier switching across tasks.
- Update mechanism: Establish a monthly evaluation cadence. A new version first passes the internal benchmark and canary traffic before a full rollout.
- Rollback plan: Keep the previous stable weights and configuration so you can switch back within 5 minutes if something goes wrong.
6. Security, Compliance, and Cost Control
- Two-way input/output filtering: Intercept prompt injection and sensitive data leakage with both rules and a model.
- Audit trails: Log the caller, timestamp, input summary, and output summary to meet traceability requirements.
- License compliance: Verify each model license and its obligations line by line before commercial use to avoid derivative distribution risk.
- Cost optimization: Tier weights across hot and cold storage, split inference resource pools by business priority, and run batch offline jobs during off-peak hours.
7. Working With Cloud Capabilities: A Hybrid Deployment Path
Local is not an island. A common pattern is “on-premises inference as primary, cloud capabilities as support”:
- Use cloud object storage to distribute model weights and keep a cold backup;
- Use a cloud container platform for elastic load testing and temporary scale-out;
- Use log services and monitoring/alerting to collect local metrics centrally;
- Use Baidu AI Cloud’s general compute and storage offerings to set up the environment, prepare images, and validate before launch, while production traffic stays on the internal network — balancing compliance with elasticity.
8. Go-Live Checklist
- Define data boundaries and compliance requirements
- Build an internal evaluation set from real samples
- Estimate VRAM with the formula and reserve 20% headroom
- Choose a quantization scheme and validate quality loss
- Complete inference service wrapping and the unified interface
- Establish monitoring, audit, and rollback mechanisms
- Set a monthly model evaluation and update cadence
Following this path, a team can close the loop from selection to an internal launch within two weeks, and keep model quality, cost, and risk in balance through subsequent iterations.
