General-purpose large language models can encode longitudinal electronic health records for clinical prediction without being trained on private clinical datasets. Research published in npj Digital Medicine shows that converting medical codes into plain-text descriptions allows these models to support simple prediction classifiers. The leading approach matched a specialised health record model across 15 tasks and performed modestly better on several UK Biobank tasks, but required substantially more computing time and memory.
Plain-Text Records Reduce Dependence on Local Vocabularies
Electronic health records contain irregular sequences of visits, missing entries, noisy information and large numbers of hierarchical medical concepts. Code-based foundation models can learn from these records, but fixed vocabularies and dependence on institution-specific training data may limit transfer between organisations and healthcare systems.
Must Read: Blockchain for Strengthening EHR Security
The evaluated approach replaced medical codes with natural-language descriptions and arranged them as a simple newline-separated list. Units and values were retained when available, while only the most recent occurrence of each code was kept within the input limit. A general-purpose embedding model converted each patient record into a high-dimensional numerical representation. Logistic regression classifiers then used these representations for prediction, allowing the comparison to focus on record encoding rather than a complex downstream architecture. The same classifier type was applied to every representation to keep downstream modelling consistent and limit overfitting in settings with few labelled examples.
The primary benchmark contained records from 6,739 adults treated at 2 hospitals between 1990 and 2023. Its 15 tasks covered operational outcomes, laboratory results, new diagnoses and chest X-ray findings. External validation used a processed UK Biobank cohort of 387,464 participants for one-year predictions of hospitalisation, mortality and the onset of 23 diseases. Comparisons also included a specialised health record model, biomedical language encoders and a count-based approach enriched with values and time information.
Performance Transfers Across Different Coding Environments
With all available labelled examples, the leading general-purpose embedding model and the specialised health record model achieved the same overall score across the primary benchmark task groups. Most task-level differences were not statistically significant. The language-model representation performed better on some laboratory predictions, while the specialised model was stronger on others. Combining both representations produced the highest result among the embedding approaches, indicating that they retained complementary information.
A strengthened count-based model slightly exceeded both pretrained approaches when all labelled data were available. It was particularly competitive for several laboratory tasks. Its performance was weaker in the smallest training settings, while the language-model embeddings showed their clearest advantage when only limited labelled examples were available. Most few-shot comparisons still showed no significant difference, so the gains were generally modest rather than uniform.
In UK Biobank validation, the general-purpose model achieved a slightly higher overall result than the specialised model and significantly improved 6 of 25 tasks, with no significant difference on the remainder. Only 16% of UK Biobank codes mapped to the specialised model’s fixed vocabulary. Restricting the general-purpose model to those same codes reduced its performance. The improvement therefore reflected both broader vocabulary coverage and slightly stronger transfer across datasets and coding systems. The results support the value of natural-language code descriptions where local terminologies and coding practices differ.
Portability Comes with Substantial Computing Demands
Input design affected performance, but elaborate formatting offered little overall benefit. Retaining the most recent occurrence of each medical code worked better than retaining the first, particularly for laboratory predictions and chest X-ray findings. Adding explicit dates and times did not improve the simple list representation. Structured alternatives using Markdown, JSON, XML or YAML also produced only minor differences and generally did not outperform the basic list.
Task-specific instructions helped the embedding model focus on relevant information. Replacing them with a generic prompt caused a small decline, while removing them entirely reduced performance further. Laboratory values were especially important for laboratory prediction, but excluding most individual categories had limited overall effects. Conditions, medications, procedures and laboratory results each supported prediction when used alone, yet no single category matched the complete record.
Longer inputs were not consistently better. The strongest model handled extended records more robustly than the other language-model encoders, but its best overall performance occurred at 4,096 tokens and with a one-year data window. A one-hour window provided too little information across all approaches. The specialised model encoded the benchmark in about 6 minutes, whereas the general model required more than 20 hours and substantially more memory. Portability without institution-specific code mapping therefore carried a considerable operational cost. Broader validation across different healthcare systems remains necessary for generalisability, robustness and fairness.
General-purpose language-model embeddings can represent structured health records competitively and transfer between different coding environments without institution-specific pretraining or extensive code mapping. Their strongest benefits appear where labelled data are limited or fixed vocabularies omit substantial clinical information. Specialised models remain far more computationally efficient, while well-designed count-based methods remain strong when extensive labelled data are available. The approach also requires manual text conversion and task instructions, captures only the most recent occurrence of each code and still needs validation across a wider range of healthcare systems and patient populations.
Source: npj Digital Medicine
Image Credit: iStock
References:
Hegselmann S, von Arnim G, Rheude T et al. (2026) Large language models are powerful electronic health record encoders. npj Digit Med; 9, 530.