A Practical Guide to Local Deployment and Enterprise Application of Open-Source Large Models
This article provides a practical guide for the local deployment of open-source large language models (LLMs) in enterprise environments. It covers the benefits of local deployment regarding data sovereignty and predictable costs, hardware selection methodology, deployment implementation processes, adaptation for alternative hardware ecosystems, and security protection systems. Readers will learn actionable steps ranging from environment preparation to API integration and performance tuning.
I. Why Deploy Large Models Locally
Government and enterprise data often involves personal information, internal approvals, and unpublished business materials. Submitting this content to external services introduces risks of data leaving the organizational boundary, retention by third parties, and unauthorized access. Localized deployment places the inference process within the institution’s own network perimeter, ensuring data never leaves a controlled environment, which is its most direct benefit.
Beyond compliance, local deployment offers value in three areas:
- Data Sovereignty: Prompts, inference logs, and retrieval results are stored in proprietary storage, providing a clear audit trail.
- Predictable Costs: Costs primarily stem from hardware depreciation and electricity. As call volumes increase, expenses do not scale linearly with pay-as-you-go billing.
- Customizability: You can connect internal knowledge bases for retrieval-augmented generation (RAG), optimize prompts for specific tasks, or perform fine-tuning.
Local deployment also brings operational burdens, including model version upgrades, driver maintenance, and high-availability design. The decision to deploy should be based on data sensitivity levels, concurrency scale, and team capabilities.
II. Hardware Selection Methodology
2.1 VRAM is the Primary Constraint
During inference, the VRAM occupied by model weights determines whether the model can run. A preliminary estimate can be made using the following empirical formula:
VRAM Requirement ≈ Parameter Count × Bytes per Parameter + Runtime Overhead
For half-precision, each parameter takes about 2 bytes; for 8-bit quantization, about 1 byte; and for 4-bit quantization, about 0.5 bytes. Runtime overhead includes activations and the KV cache, which grows with context length and concurrency. In actual planning, a 20% to 40% margin is typically reserved, an engineering rule of thumb that must be calibrated with stress testing.
Taking a 70-billion parameter model as an example, 4-bit quantized weights take about 35 GB. Including cache and margins, a single standard graphics card usually cannot support it, requiring multiple cards or devices with larger VRAM.
2.2 CPU, Memory, and Storage
The CPU does not handle primary model computation but is responsible for document preprocessing, retrieval, API services, and system scheduling. Memory should cover temporary usage during model loading and document processing tasks. Model files typically range from tens to hundreds of GBs. The storage solution needs to reserve space for multiple versions and support integrity verification.
2.3 Tiered Configuration Approach
| Scenario | Model Scale | Configuration Approach |
|---|---|---|
| Internal Q&A pilot, low concurrency | Tens of billions of parameters, quantized | Single general-purpose GPU with medium VRAM |
| Department-level knowledge base, medium concurrency | Hundreds of billions of parameters, quantized | Multi-GPU or single machine with large VRAM |
| Global service, high concurrency | Hundreds of billions+ parameters | Multi-machine cluster with load balancing |
III. Deployment Implementation Process
3.1 Environment Preparation
- Standardize operating system, driver, and dependency library versions to form a baseline environment for reproducibility.
- Segment an independent network for the inference service, allowing internal network access only.
- Establish model storage directories and permission rules; standard accounts are forbidden from writing.
3.2 Model Acquisition and Integrity Verification
Obtain model files from trusted channels, record file hashes, and compare them with the checksums provided by the publisher. Set files to read-only upon entering the repository, and complete all changes through version tracking.
3.3 Inference Service Configuration
Use a mature inference framework to load the model as a service process. Below is an example configuration; parameter names may vary by framework:
service:host: 127.0.0.1port: 8000api_key_env: LLM_SERVICE_KEY # Read from environment variables, do not hardcode in configmodel:name: enterprise-chatpath: /srv/models/chat-model-int4max_context_tokens: 8192max_concurrency: 16logging:audit_log: /var/log/llm/audit.logstore_prompt: false # Do not retain prompt content long-term by default
3.4 API Invocation
Business systems access the model through a unified chat API. A request example is as follows:
POST /v1/chat/completionsAuthorization: Bearer <access_token>Content-Type: application/json{"model": "enterprise-chat","messages": [{"role": "system", "content": "You are an internal enterprise document assistant. Answers must cite the source of evidence."},{"role": "user", "content": "Please summarize the key changes in this quarter's recruitment process."}],"temperature": 0.3}
The calling party should authenticate through a unified gateway, set timeout and retry limits, and prevent a single long-text request from consuming all inference resources.
3.5 Performance Tuning
- Batching: Merge multiple short requests to improve GPU utilization.
- Context Control: Limit the input length per request. Split overly long documents before retrieval.
- Result Caching: Cache answers for high-frequency questions. Cached content must be managed according to data sensitivity levels.
- Stress Testing: Conduct stress tests using real business request distributions. Record Time to First Token (TTFT) and overall throughput as a basis for scaling.
IV. Alternative Hardware Ecosystem Adaptation
For organizations adopting alternative or domestically produced infrastructure ecosystems, common combinations include non-mainstream chips, operating systems, and databases. When adapting, note the following points:
- First, confirm the inference framework’s support for the target chip architecture. Do not assume all components will run directly.
- The model quantization format must match the inference backend. After format conversion, re-run regression tests.
- Use the same batch of test questions to compare output consistency and response latency across different hardware, and record deviations.
- Establish an adaptation checklist, recording component versions and validation conclusions item by item as acceptance materials.
V. Security Protection System
5.1 Access Control
- Service interfaces use token authentication. Tokens are assigned per application and rotated regularly.
- Limit the available models and knowledge base scopes by department and role.
- Enable multi-factor authentication for the admin backend, and ensure all operations are logged.
5.2 Data Protection
- Perform sensitive information identification on inputs and outputs before storing them. Mask sensitive data such as ID numbers and phone numbers according to predefined rules.
- Long-term retention of prompt and response content is disabled by default. If auditing requirements exist, specific retention policies can be configured.
