Deploying and Fine-Tuning a Large Language Model On-Premises for Public Health: A Practical Architecture Under Data Compliance and Hardware Constraints

    This article presents a practical reference architecture for deploying and fine-tuning a large language model inside a public health agency's private network, where data cannot leave the internal network and hardware is limited to a small number of accelerators. It covers making constraints explicit, a five-layer system design that separates the control plane from the data plane, a memory-expansion middleware that maps enterprise flash storage into addressable extended memory for parameter and activation swapping, a parameter-efficient fine-tuning workflow (4-bit base model, LoRA/QLoRA, gradient checkpointing) with data governance and regression evaluation, security and audit controls, a three-year total cost of ownership comparison, common risks, and a phased rollout roadmap. Readers will find concrete configuration examples, tuning guidance, and a replicable delivery checklist for data-sensitive deployments.

    1. Background: Compliance and Compute Cost as Dual Constraints

    Demand for large language models in public health is rising quickly, but adoption keeps stalling on two barriers.

    The first is compliance. Disease control agencies have accumulated large volumes of data on infectious disease reporting, immunization programs, chronic disease follow-up, and laboratory testing. Much of it contains sensitive personal health information. Under applicable data security and personal information protection regulations, together with industry data classification requirements, raw data must not leave the internal network, must not be uploaded to public clouds, and must not cross borders.

    The second is cost. Mainstream LLMs range from a few billion to tens of billions of parameters. Full-parameter fine-tuning typically requires 8 to 16 high-end accelerator cards. Once servers, storage, and data center modifications are included, the investment can reach several million yuan, which is difficult for grassroots agencies to absorb. After training finishes, the equipment sits idle most of the time, so utilization is very low.

    Put together, the conclusion is straightforward: public health scenarios need a combination of a closed internal network, a small memory footprint, and parameter-efficient fine-tuning, not simply more compute. This article starts from the real constraints of a provincial or municipal disease control agency and lays out a deployable reference architecture and implementation steps. Note that the accelerators, flash storage, and middleware discussed here are described as general capability categories; specific selections should be based on local testing.

    2. Making Goals and Constraints Explicit

    Before implementation, write the constraints down as verifiable items to avoid rework later:

    • Data stays in domain: training, fine-tuning, inference, logging, and backups all run inside the internal network. The external network is used only for pre-approved import of models and dependency packages.
    • Limited hardware: the baseline is 2 general-purpose GPUs plus 2 domestic AI accelerators, with no additional high-end cards.
    • Memory capacity extended externally: middleware virtualizes an enterprise flash pool into extended memory addressable by the accelerators, used to swap parameters and activations in and out.
    • Limited fine-tuning approach: no full-parameter updates. Use parameter-efficient fine-tuning (LoRA/QLoRA-style methods) combined with quantized inference.
    • Auditable: all data access, model calls, prompts, and outputs are logged and traceable by person, project, and dataset.
    • Replicable: the solution must be reproducible across multiple municipal agencies using the same steps, forming a standardized delivery checklist.

    3. Layered Architecture

    Split the system into five layers, decoupled through standard interfaces so components can be replaced and upgraded.

    1. Infrastructure layer: general-purpose GPUs, AI accelerators, enterprise flash arrays, and a high-speed internal network (RDMA or high-bandwidth Ethernet recommended).
    2. Resource and virtualization layer: a container platform handles orchestration and isolation; the memory-expansion middleware maps flash into addressable extended memory and manages page tables, prefetching, and eviction policies.
    3. Model layer: the quantized base model stays resident, with adapter weight files enabling task switching.
    4. Fine-tuning and evaluation layer: data processing pipelines, training jobs, evaluation benchmarks, and regression tests.
    5. Application and security layer: retrieval-augmented question answering, report drafting assistance, and terminology normalization services, all routed through a gateway for authentication and auditing.

    The key design principle is separating the control plane from the data plane. The control plane handles scheduling, auditing, and model version management, and can be deployed in a management zone. The data plane performs the actual computation and stays fully enclosed in the business internal network.

    4. Key Mechanisms of the Memory-Expansion Middleware

    With only 4 accelerator cards, running fine-tuning for a model with tens of billions of parameters depends less on compute than on how efficiently memory capacity and bandwidth are scheduled. The middleware typically has to solve four problems:

    • Address mapping: map flash blocks into a unified logical address space so upper-layer frameworks access them like ordinary memory.
    • Prefetching and caching: based on access locality, load pages of soon-to-be-used parameters into high-speed memory ahead of time to reduce synchronization waits.
    • Eviction policy: combine least-recently-used with weight importance scoring to decide what to swap out and avoid thrashing.
    • Compression and verification: compress swapped-out data to reduce write amplification while keeping verification fields to prevent silent errors.

    Illustrative paging logic (pseudocode, conveying the idea only):

    1. def access_param(page_id, mode):
    2. if page_in_hbm(page_id):
    3. return hbm_read(page_id)
    4. if mode == "forward":
    5. prefetch_pages(predict_next(page_id), budget=8)
    6. page = storage_read(page_id) # from the flash expansion pool
    7. hbm_write(page_id, page)
    8. if hbm_usage() > 0.92:
    9. victim = choose_victim(score=w_lru + w_importance)
    10. storage_write(victim, hbm_read(victim))
    11. return hbm_read(page_id)

    Tuning priorities: keep the most frequently accessed embedding layers and key attention weights resident in memory, and push optimizer states and cold-layer parameters down to extended memory; enable gradient checkpointing to trade time for space; treat micro-batch size and sequence length as a joint tuning pair, fix the memory ceiling first, then search for the throughput optimum.

    5. Domain Fine-Tuning Workflow and Data Governance

    Data quality sets the ceiling on fine-tuning results. A four-step approach works well:

    1. Corpus construction: sources include de-identified clinical and epidemiological investigation text, lab indicator descriptions, immunization and disinfection/isolation standards, and prior Q&A tickets. De-identify every record first by removing names, ID numbers, contact details, and precise addresses, and apply date offsets.
    2. Instruction construction: normalize tasks into instruction-context-answer triples covering five categories: extraction, classification, summarization, question answering, and terminology normalization. Label high-risk questions with a “requires human review” tag.
    3. Training configuration: load the base model in 4-bit quantization, set LoRA rank between 8 and 32, use a learning rate on the order of 1e-4, train for 2 to 3 epochs with early stopping. When memory is tight, increase gradient accumulation steps rather than the micro-batch size.
    4. Evaluation and regression: build an internal benchmark covering factuality, timeliness, and correct refusal. Run the full regression after every fine-tuning round and roll back the adapter version if any metric drops.

    A minimal reproducible training launch example:

    1. python train.py \
    2. --base_model ./models/base-30b-int4 \
    3. --dataset ./data/instruction_v3.jsonl \
    4. --adapter_out ./adapters/cdc-taskA-v3 \
    5. --lora_r 16 --lora_alpha 32 \
    6. --micro_batch 1 --grad_accum 16 \
    7. --seq_len 2048 --max_steps 1200 \
    8. --offload_target extended_memory \
    9. --eval_set ./data/eval_regression.jsonl

    6. Security, Compliance, and Audit Design

    Compliance is not an add-on; it is an architectural constraint. Implementation recommendations:

    • Network isolation: the business zone is fully internal. Models and dependencies enter via offline media with retained source verification records.
    • Identity and permissions: unified identity access, with dataset and model invocation permissions divided by role under least-privilege.
    • Encryption in transit and at rest: enable mutual authentication and transport encryption for internal calls; store data and adapter files encrypted, with keys managed by an internal key management service.
    • Audit trails: the gateway records the caller, time, input digest, model version, and output digest. Requests containing sensitive fields are masked before being written to logs.
    • Output control: intercept generated content that contains sensitive information or out-of-scope recommendations, and force medical and disease-control conclusions to carry a note that they are for reference only and require confirmation by a qualified professional.
    • Data lifecycle: define retention periods and destruction procedures, and manage intermediate training artifacts and checkpoints under the same controls.

    7. Cost Model and Benefits Assessment

    Cost should not be judged by purchase price alone; compare total cost of ownership over three years. A traditional full-parameter approach needs 8 to 16 high-end cards plus supporting modifications. This approach replaces them with 4 cards and a flash expansion pool, with the main savings coming from fewer accelerators and less data center work. Utilization also improves significantly because the equipment is time-shared: inference during the day, fine-tuning at night. On the benefits side, quantify three metrics: reduction in document processing hours, reduction in terminology and coding error rates, and change in manual review workload. Actual numbers must come from local measurement; this article makes no unmeasured performance claims.

    8. Common Risks and Mitigations

    • Extended memory bandwidth becomes the bottleneck: prioritize the hit rate of resident layers, and add flash channels rather than cards when necessary.
    • Quantization causes accuracy loss: keep a higher-precision branch for critical extraction tasks, or quantize only the base model while keeping adapters at higher precision.
    • Hallucination and stale information: enforce retrieval augmentation against a local knowledge base, and require answers to cite source passages.
    • Benchmark contamination: strictly isolate the internal benchmark from the training set and periodically rephrase questions.
    • Limited operations capability: deliver a standardized checklist and one-click deployment scripts, with monitoring and alerts covering memory usage, throughput, queue latency, and error rates.

    9. Rollout Roadmap

    Phase 1 (weeks 2 to 4): set up the internal network environment, the memory-expansion middleware, and quantized inference, and get single-task question answering working. Phase 2 (weeks 4 to 8): complete data governance and the first round of parameter-efficient fine-tuning, and establish regression evaluation. Phase 3 (weeks 8 to 12): integrate retrieval augmentation and the audit gateway to form a multi-task adapter matrix. Phase 4: iterate continuously, version adapters and benchmark sets, and replicate delivery to other municipal agencies. Following this path, data-sensitive agencies can obtain a sustainably evolving LLM capability with a very small hardware footprint, turning compliance pressure into a manageable engineering constraint.