Local LLMs as Strategic Infrastructure
01
What problem did this system solve?
A healthcare analytics company processed a heavy daily volume of queries against patient records, clinical notes, and diagnostic reports. Their existing architecture sent every query to GPT-4 via the OpenAI API. This created compounding problems.
First, cost. With long prompts and responses on every query, the monthly inference bill was large and kept growing as usage expanded. Second, data sovereignty. Every query transmitted protected health information (PHI) to OpenAI’s servers. While OpenAI’s BAA covered HIPAA requirements technically, the company’s largest hospital client demanded that PHI never leave their cloud environment. Third, latency. API round-trip times were slow on average and worse at the tail during peak hours, which made the system unusable for real-time clinical decision support.
The mandate was clear: process PHI-containing queries locally, use cloud APIs only for queries that required frontier reasoning and contained no sensitive data, and reduce costs substantially.
02
How was the architecture designed?
I designed a tiered inference architecture with an intelligent router at its core.
The first tier was a local inference cluster running a large Llama model, quantized with GPTQ, on NVIDIA A100 GPUs hosted in the client’s private cloud. This tier handled all queries containing PHI, which I identified using a combination of a fine-tuned NER model (trained on labeled clinical text samples to detect PHI entities with high recall) and rule-based pattern matching for structured identifiers (MRNs, SSNs, dates of birth). The local cluster processed queries at a low average latency, with a tail that stayed well inside the clinical limit.
The second tier was Claude 3.5 Sonnet via Anthropic’s API, reserved for complex reasoning tasks that contained no PHI. These included clinical guideline interpretation, differential diagnosis reasoning, and research synthesis. The PHI classifier ensured no sensitive data reached this tier. Average latency was a little over a second, acceptable for these non-real-time analytical tasks.
The third tier was a locally-hosted small Llama model (also GPTQ quantized) running on NVIDIA L40S GPUs. This handled simple, high-volume tasks: formatting structured data, generating standard report templates, translating between medical coding systems, and answering FAQ-type queries from the knowledge base. Latency was the lowest of the three tiers.
The router was a lightweight classifier (a fine-tuned DistilBERT model with negligible inference time) that categorized each incoming query on two axes: PHI presence (yes/no) and reasoning complexity (simple/moderate/complex). The routing logic: if PHI is present, route to Tier 1 (local 70B) regardless of complexity. If no PHI and complex, route to Tier 2 (cloud Sonnet). If no PHI and simple/moderate, route to Tier 3 (local 8B). The router also maintained a fallback chain: if Tier 3 returned low-confidence output (measured by a calibrated confidence score), the query was promoted to Tier 1.
I deployed the local models using vLLM for efficient batched inference, with dynamic batching that grouped concurrent requests. The entire infrastructure ran in the client’s AWS VPC with no external data egress for PHI-containing queries. Monitoring used Prometheus for GPU utilization, vLLM metrics for inference throughput, and a custom dashboard tracking per-tier query volumes, latencies, and costs.
03
What were the measurable outcomes?
The cost breakdown: the first tier (local large model) handled a minority of queries at a fixed GPU cost. The second tier (cloud Sonnet) handled a smaller share of queries and was billed in API fees. The third tier (local small model) handled the largest share of queries at a fixed GPU cost. Total: the infrastructure bill came to well under the old cloud-only spend, after subtracting the existing GPU capacity the client was already paying for.
The small quality drop on the internal eval suite came almost entirely from the third-tier local small model, which struggled with nuanced medical terminology on a minority of its assigned queries. I addressed this by fine-tuning the small model on domain-specific examples, which recovered most of the lost quality. The remaining gap was a deliberate tradeoff: the cost and sovereignty benefits justified a marginal quality concession on low-complexity tasks.
04
What would I change in hindsight?
I would have invested more heavily in the PHI classifier from day one. The initial version had high recall, which sounds good but meant that a steady stream of queries containing PHI each month were misclassified as clean and routed to the cloud tier. I caught this in the first week of production monitoring and expedited a retraining cycle that raised recall, but that first week represented an unacceptable data handling gap. For healthcare applications, the PHI classifier should be treated as a safety-critical component with the same rigor as the core inference models.
I also underestimated the operational complexity of managing local GPU infrastructure. The A100 cluster required repeated firmware updates, a vLLM version migration, and several model quantization adjustments in the first months. Each required coordinated downtime and traffic rerouting. Building automated failover from Tier 1 to a privacy-preserving cloud option (using Anthropic’s data processing agreement) would have provided resilience I did not have initially.
The broader lesson is that local LLMs are not “set and forget” infrastructure. They are living systems that require the same operational investment as any production database or compute cluster. The sovereignty and cost benefits are real, but they come with operational overhead that must be budgeted honestly.