Local LLM Deployment for Enterprise AI: Architecture, Tenant Isolation, RAG, and Security Practices
This article explains how a government-backed high-tech zone deployed an open-source LLM locally and offered shared access to local enterprises. It covers the three-layer architecture, tenant isolation, API integration with retry handling, RAG knowledge bases, LoRA fine-tuning trade-offs, representative use cases, and a go-live security checklist for enterprise LLM adoption.
Large language models (LLMs) are moving into daily business operations across industries. In fields such as industrial manufacturing and finance and tax management, where core commercial secrets are involved, data security is often the first issue enterprises face when adopting LLMs. Once employees paste production process parameters or financial statements into an external model, the enterprise loses control over that data. This article uses the practice of a government-backed high-tech zone as an example to explain how local deployment and a shared-service operating model can reduce enterprise data concerns, and to clarify the technical details and boundaries that need attention.
1. Background and Challenges
In the context of Industry 4.0, data analysis, intelligent production scheduling, and financial analysis are key methods for enterprises to reduce costs and improve efficiency. A preliminary survey showed that most surveyed enterprises had concerns about using public cloud LLMs. If production process parameters, production schedules, customer orders, and financial statements are uploaded to external services, they may be leaked or used by the service provider for retraining. These concerns led many enterprises to postpone AI projects.
The high-tech zone relied on the computing power of a local intelligent computing center and adopted a model in which the government builds the platform and enterprises receive inclusive services. It completed a local private deployment of an open-source LLM and provided services to enterprises in its jurisdiction. Local deployment keeps inference and data storage within the park’s internal network, reducing the data path through the public internet. However, local deployment does not automatically bring security. Access control, tenant isolation, log auditing, and key management must be implemented item by item; otherwise, internal misoperations or overly broad permissions can still lead to data leakage.
2. Overall Architecture and the Government-Led Shared-Service Model
The division of responsibilities is as follows: the local government initiates the project and provides policy guidance and initial investment; the intelligent computing center provides the GPU computing pool; the technical service provider handles model deployment and platform packaging; and local enterprises access the service on an inclusive or free basis.
The technical architecture has three layers:
- Computing and infrastructure layer: Based on a GPU server cluster, it uses container orchestration technologies such as Kubernetes to schedule resources. Health checks and automatic restarts are configured to support long-running services.
- Model and data layer: An open-source model base is deployed, together with a vector database and a relational database. These store knowledge base vectors, account information, and interaction logs, respectively. In the initial phase, the platform preprocessed the basic information, preferential policies, and incentive and subsidy policies of more than 1,000 enterprises in the jurisdiction, making the model more targeted in policy Q&A.
- Application and interface layer: HTTPS interfaces are provided through a unified API gateway. Enterprises can upload private documents to build knowledge bases and perform lightweight fine-tuning within the authorized scope.
Common options and selection considerations for core components are as follows:
| Component | Common options | Selection considerations |
|---|---|---|
| GPU scheduling | Kubernetes with GPU plugins | High team familiarity; suitable for multi-tenancy and elastic scaling |
| Vector database | pgvector, Milvus, Qdrant | When data volume is small and PostgreSQL is already in use, pgvector has the lowest operational cost; choose Milvus when data volume or concurrency is high |
| API gateway | Nginx, Kong, self-developed gateway | Needs to support rate limiting, authentication, and per-tenant metering |
| Inference framework | vLLM, TGI, etc. | Focus on throughput, GPU memory usage, and support for the selected model |
3. API Access and Data Isolation
The platform provides standardized interfaces externally. Enterprises only need to focus on business integration and do not need to manage the underlying computing power or model operations. The platform partitions storage space for session context, uploaded documents, and logs by tenant. Isolation must be implemented on the server side and must not rely on parameters passed from the client. For each request, the gateway parses the tenant ID from the token, and the server then adds that ID as a filter condition to queries.
The following is an example of an enterprise-side call. The address and key in the example are placeholders and must be replaced in actual deployment.
import osimport timeimport requestsAPI_URL = os.environ["LLM_GATEWAY_URL"] # e.g. https://ai.park.example.cn/v1/chat/completionsAPI_KEY = os.environ["LLM_API_KEY"] # Read from environment variables or a secret manager; never hard-codeRETRYABLE_STATUS = {429, 500, 502, 503, 504}def ask_policy_assistant(question: str, max_retries: int = 3) -> str:headers = {"Authorization": f"Bearer {API_KEY}","Content-Type": "application/json",}payload = {"model": "local-llm-v1","messages": [{"role": "system", "content": "You are a professional enterprise policy assistant. Answer only based on the provided materials."},{"role": "user", "content": question},],"temperature": 0.3,"max_tokens": 1024,}for attempt in range(1, max_retries + 1):try:resp = requests.post(API_URL, headers=headers, json=payload, timeout=(5, 60))except requests.exceptions.Timeout:print(f"Request timed out on attempt {attempt}")except requests.exceptions.ConnectionError:print(f"Connection failed on attempt {attempt}")else:if resp.status_code in RETRYABLE_STATUS:print(f"Retryable error on attempt {attempt}: {resp.status_code}")elif resp.status_code >= 400:# 4xx errors are usually authentication or parameter issues; retrying is pointlessraise RuntimeError(f"Request rejected: {resp.status_code}")else:try:return resp.json()["choices"][0]["message"]["content"]except (ValueError, KeyError, IndexError) as e:raise RuntimeError(f"Unexpected response format: {e}") from eif attempt < max_retries:time.sleep(2 ** attempt)raise RuntimeError("Call failed after the maximum number of retries")if __name__ == "__main__":answer = ask_policy_assistant("We are a semiconductor manufacturing company with expected revenue of RMB 50 million this year. Which incentive and subsidy policies apply to us?")print(answer)
Call notes:
- Runtime environment: Python 3.9 or later; requests 2.31 or later is recommended.
- Address and key: The API address must use HTTPS and be read from environment variables. Keys should be stored in a secret management service and rotated regularly. Keys must not be hard-coded in code, and logs must not print keys or full user inputs.
- Timeout settings: The connection timeout is 5 seconds, and the read timeout is 60 seconds. For long-text generation scenarios, the read timeout can be extended appropriately.
- Retry strategy: Use exponential backoff retries for 429 and 5xx errors. 4xx errors are usually authentication failures or parameter errors; retrying is meaningless, so an error should be raised directly.
- Return result: On success, the model-generated text is returned. If response fields are missing or the format is abnormal, a RuntimeError is raised so that upstream systems can handle it uniformly.
4. Private Knowledge Bases Based on RAG
General-purpose models do not know an enterprise’s internal rules or latest policies. When asked directly, the model is prone to hallucination, that is, fabricating content that looks plausible but does not exist. Retrieval-augmented generation (RAG) allows the model to answer based on enterprise documents without modifying model parameters.
The technical pipeline includes four steps:
- Document parsing: Support formats such as PDF, Word, and Excel. Scanned documents need OCR first, and tables should preserve row and column structure. Files that fail to parse should be recorded with the reason and reported to the uploader; they must not be silently discarded.
- Chunking: A common practice is 500 to 800 characters per chunk (or the corresponding number of tokens), with about 10% to 15% overlap between adjacent chunks to avoid cutting key sentences. Policy and regulation documents can be split by chapter, which usually works better than mechanically splitting by length.
- Vectorization and storage: Use a locally deployed Chinese embedding model to convert text chunks into vectors, and store metadata such as tenant ID, document ID, update time, and confidentiality level together with the vectors.
- Retrieval and generation: After a user asks a question, the system first filters by tenant ID, then performs vector similarity retrieval, and concatenates about the top 5 results into the prompt. The model is required to answer only based on the provided materials and to clearly state “insufficient evidence” when the materials are inadequate.
Knowledge base evaluation recommendations:
- First build a baseline of at least 200 annotated question-answer pairs, covering common questions and boundary cases that are easy to get wrong.
- On the retrieval side, focus on Recall@5, that is, whether the correct document appears in the top 5 results.
- On the generation side, focus on answer accuracy and check whether each answer is supported by the materials.
- Monitor P95 response time online, that is, the time within which 95% of requests complete.
- After documents are updated, re-chunk and re-vectorize them, and delete vectors for old versions to avoid the model citing obsolete policies.
- After each release, run cross-tenant query test cases as regression tests to confirm that documents from other tenants cannot be retrieved.
5. Choosing Between Model Fine-Tuning and RAG
For enterprises with higher customization needs, the platform supports LoRA fine-tuning using desensitized private data. LoRA trains only a small set of additional weights and does not change all parameters of the base model. It is suitable for standardizing output formats, learning industry terminology, and fixing task styles, such as generating production scheduling plans in a specific format.
Fine-tuning cannot reliably add the latest facts, nor can it easily explain which document an answer came from. Therefore, policy and regulation questions usually prioritize RAG. The comparison is as follows:
| Comparison item | RAG knowledge base | LoRA fine-tuning |
|---|---|---|
| Suitable problems | Querying specific facts such as rules, policies, and historical records | Standardizing output formats, learning industry terminology, and fixing task styles |
| Knowledge updates | Take effect immediately after replacing documents | Requires re-preparing data, training, and evaluation |
| Cost | Mainly storage and retrieval services | Requires training compute and evaluation manpower |
| Traceability | Can cite the document paragraphs referenced by the answer | Difficult to explain which material the answer comes from |
| Main risks | Irrelevant answers when retrieval is inaccurate | If training data contains sensitive information, the model may memorize it; general capabilities may also be weakened |
When using LoRA, note the following: training data must be desensitized and versioned; the LoRA rank is commonly 8 to 64 and should be compared with the base model’s original capabilities in tests; before launch, use an independent test set to confirm that there is no obvious capability degradation.
6. Typical Application Scenarios
1. Policy matching and intelligent answering
Enterprises enter their own situation, for example: “We are a semiconductor manufacturing company with expected revenue of RMB 50 million this year and R&D investment accounting for about 6%. Which incentive and subsidy policies can we apply for?” The model lists potentially applicable policy names, eligibility conditions, application materials, and deadlines, and cites the policy documents on which the answer is based. The platform improves matching relevance through preliminary preprocessing of information and policies for more than 1,000 enterprises. However, policy conclusions must include the original source, and a responsible person still needs to check the original text before application.
2. Intelligent finance and tax risk alerts
Enterprises upload desensitized financial statements. Desensitization includes replacing fields such as company name, unified social credit code, bank account number, and customer name. The model can flag anomalies in indicators such as accounts receivable turnover, inventory turnover, and expense ratio, and provide risk points based on rules configured by the enterprise. Several boundaries must be observed: output is only for assisted self-checking and cannot replace professional advice from tax advisers or lawyers; key judgments must be reviewed by humans; and the system should record who uploaded which data and which results were invoked, with log retention periods following company policy.
3. Production scheduling optimization
Enterprises push data such as equipment capacity, material inventory, and delivery dates from ERP to the local model through the API. The model combines historical scheduling experience to generate a preliminary production scheduling plan and provides optimization ideas for bottleneck processes. Data owner authorization must be obtained before data is pushed. The ERP integration account should use read-only permissions, and material codes and customer information in logs need to be desensitized. The scheduling plan is only a recommendation and must be confirmed by a planner before execution. Local processing reduces the data path through the public internet, but it cannot replace access control.
7. Practical Results and Scope Notes
As of the first quarter of 2025, more than 70 enterprises had applied to access the platform, covering manufacturing, technology services, and other fields. This figure is the number of enterprises that applied for access; it does not include active users, call volume, or outcome metrics. Citations should be based on the statistical report published by the project owner.
This practice shows that under local computing power and unified operations, small and medium-sized enterprises can use LLMs with a relatively low barrier to entry. However, it has not yet demonstrated stability and economic viability after large-scale operation, and these aspects still require continuous observation.
8. Go-Live Checklist
- Data classification: Clarify which data is allowed to enter the model and which is prohibited.
- Authentication and isolation: Issue tokens by tenant, filter tenant IDs on the server side, and maintain cross-tenant test cases.
- Keys and logs: Rotate keys regularly, desensitize logs, and do not record complete sensitive inputs.
- Evaluation baseline: Maintain annotated sets for RAG retrieval and model output, and run regression tests regularly.
- Human review: Results involving finance and tax, contracts, and production scheduling must be confirmed by clearly assigned responsible persons.
- Emergency response: Have a clear fallback process for service interruptions or incorrect model outputs.
Local LLMs can reduce the risk of data outflow, but the degree of risk reduction depends on the combined configuration of deployment, permissions, auditing, and business processes. Before adoption, enterprises can start with a small-scale pilot in a policy Q&A scenario and then decide whether to expand based on evaluation data.
