Abstract
Large Language Models (LLMs) have demonstrated remarkable proficiency in natural language processing; however, their application in sensitive domains such as healthcare, especially in processing Electronic Health Records (EHRs), is constrained by limited computational resources and privacy concerns. This paper introduces a compact LLM framework optimized for local deployment in environments with stringent privacy requirements and restricted access to high-performance GPUs. Our approach leverages simple yet powerful preprocessing techniques, including regular expressions (regex) and Retrieval-Augmented Generation (RAG), to extract and highlight critical information from clinical notes. By pre-filtering long, unstructured text, we enhance the performance of smaller LLMs on EHR-related tasks. Our framework is evaluated using zero-shot and few-shot learning paradigms on both private and publicly available datasets (MIMIC-IV), with additional comparisons against fine-tuned LLMs on MIMIC-IV. Experimental results demonstrate that our preprocessing strategy significantly supercharges the performance of smaller LLMs, making them well-suited for privacy-sensitive and resource-constrained applications. This study offers valuable insights into optimizing LLM performance for local, secure, and efficient healthcare applications. It provides practical guidance for real-world deployment for LLMs while tackling challenges related to privacy, computational feasibility, and clinical applicability.
Introduction
Analyzing Electronic Health Records (EHRs) is a high-stakes task essential for clinical research and patient care. While state-of-the-art Large Language Models (LLMs) like GPT-4 offer immense potential, their deployment in clinical settings is hindered by two primary obstacles: data privacy and hardware limitations. Sending sensitive patient data to cloud-based APIs often violates regulations such as HIPAA, necessitating local deployment. However, local infrastructure typically relies on consumer-grade or mid-range GPUs, limiting models to smaller parameter counts (e.g., 7B).
These smaller models frequently struggle with the "needle in a haystack" problem. Clinical notes are often thousands of words long, unstructured, and noisy. Smaller models tend to lose focus within these long context windows, leading to poor performance in identifying specific disease phenotypes, such as cancer metastasis, which are often poorly captured by standard ICD billing codes.
Methodology
The proposed framework prioritizes Smart Preprocessing to maximize the utility of smaller, locally-hosted models like Gemma-7B and LLaMA-7B. The approach consists of several key components:
- Regex-based Filtering: Clinical experts defined keywords (e.g., "metastasis," "distant spread") to scan notes and extract relevant sentences along with their immediate context (one sentence before and after).
- Retrieval-Augmented Generation (RAG): Sentences are retrieved based on semantic similarity to a query using cosine similarity for cases where keyword matching is insufficient.
- Local Inference: The condensed, high-signal text is fed into the LLM.
- Evaluation Paradigms: Performance was assessed using zero-shot and few-shot learning, and compared against models fine-tuned via Low-Rank Adaptation (LoRA).
The study utilized a private Head-and-Neck Cancer (HNC) dataset from the University of North Carolina and the publicly available MIMIC-IV database.
Results and Discussion
Experimental results indicate that preprocessing is a more effective strategy than increasing model size or complexity for these specific tasks.
Preprocessing vs. Fine-Tuning
A significant finding was that simple regex preprocessing on a zero-shot model outperformed models fine-tuned on small annotated samples. This suggests that guiding the model to relevant data is more efficient than attempting to "teach" the task through weight adjustments when data is scarce.
The Few-Shot Paradox
Interestingly, increasing the number of examples in the prompt (few-shot learning) actually degraded performance for smaller models. The increased prompt length appeared to distract the models from the primary clinical note, making zero-shot performance with robust preprocessing the superior choice.
Quantitative Performance
The impact of preprocessing was most evident in sensitivity metrics. On the MIMIC-IV dataset, the sensitivity for identifying metastasis using a zero-shot Gemma-7B model rose from 5.11% without preprocessing to 78.52% with regex filtering. In contrast, fine-tuned models (2B and 7B) only reached sensitivities between 18% and 29%. Specificity remained consistently high (>96%) across all configurations. Furthermore, preprocessing significantly reduced inference time, allowing 80,000 notes to be processed in 1-2 days rather than weeks.
Conclusion
This study demonstrates that smart preprocessing can "supercharge" small, locally-deployed LLMs, allowing them to outperform larger or fine-tuned counterparts in specific clinical extraction tasks. By reducing the input to high-relevance snippets, researchers can overcome the hardware and privacy constraints inherent in healthcare AI. Future work will explore more advanced NLP techniques, such as deep-learning-based Named Entity Recognition (NER), to further refine the filtering process across a broader range of clinical conditions.
Summary updated