Abstract
The complexity and heterogeneity of data in many real-world applications pose significant challenges for traditional machine learning and signal processing techniques. For instance, in medicine, effective analysis of diverse physiological signals is crucial for patient monitoring and clinical decision-making and yet highly challenging. We introduce MedTsLLM, a general multimodal large language model (LLM) framework that effectively integrates time series data and rich contextual information in the form of text to analyze physiological signals, performing three tasks with clinical relevance: semantic segmentation, boundary detection, and anomaly detection in time series. These critical tasks enable deeper analysis of physiological signals and can provide actionable insights for clinicians. We utilize a reprogramming layer to align embeddings of time series patches with a pretrained LLM's embedding space and make effective use of raw time series, in conjunction with textual context. Given the multivariate nature of medical datasets, we develop methods to handle multiple covariates. We additionally tailor the text prompt to include patient-specific information. Our model outperforms state-of-the-art baselines, including deep learning models, other LLMs, and clinical methods across multiple medical domains, specifically electrocardiograms and respiratory waveforms. MedTsLLM presents a promising step towards harnessing the power of LLMs for medical time series analysis that can elevate data-driven tools for clinicians and improve patient outcomes.
Introduction
In modern Intensive Care Units (ICUs), clinicians are often overwhelmed by a deluge of high-frequency data, ranging from physiological waveforms like electrocardiograms (ECGs) and respiratory signals to unstructured clinical notes and Electronic Health Records (EHRs). Traditionally, machine learning models designed to interpret these signals have been highly specialized—often referred to as "bespoke" models—optimized for a single task or a single type of signal.
However, medical diagnosis is inherently multimodal. A heartbeat waveform does not exist in a vacuum; its clinical significance is filtered through the lens of a patient’s age, medical history, and current medications. The challenge lies in effectively combining the sophisticated reasoning capabilities of Large Language Models (LLMs) with raw, high-dimensional numerical signals while maintaining the clinical context that makes the data meaningful. MedTsLLM addresses this by creating a unified framework that allows LLMs to "speak" the language of physiological waveforms.
The MedTsLLM Framework
MedTsLLM utilizes a four-stage pipeline to transform raw physiological signals into a format compatible with the reasoning architecture of a frozen LLM (specifically Llama 2 7B).
1. Patching and Encoding
Rather than processing individual data points, which lack semantic meaning, the framework breaks signals into discrete "patches" (e.g., 16 time points). This approach mirrors the way language models process tokens, allowing the model to capture local temporal patterns.
2. The Patch Reprogrammer
A central innovation of MedTsLLM is the reprogramming layer. Instead of the computationally prohibitive task of fine-tuning a massive LLM, the researchers use a cross-attention mechanism to map signal patches into a linear combination of the LLM’s existing word embeddings. This effectively "translates" numerical waveforms into the LLM's native vocabulary without altering the underlying model weights.
3. Multivariate Covariate Strategies
Medical data is rarely univariate. To handle multiple signals—such as simultaneous airway pressure and flow—the authors evaluated several strategies: Concatenation, Averaging, Interleaving, and Independent processing. The study found that Interleaving and Concatenating were most effective, as they allow the LLM to attend to the critical interactions between different physiological systems.
4. Contextual Prompting
To leverage the LLM's pre-trained medical knowledge, the input includes a structured text prompt. This prompt contains dataset descriptions, task instructions, and patient-specific metadata (age, sex, medications) formatted as JSON. This ensures the model interprets the waveforms within the correct clinical context.
Experimental Evaluation
The model was benchmarked across a diverse array of medical and non-medical datasets to test its versatility in semantic segmentation, boundary detection, and anomaly detection:
- ECG Analysis: Using the LUDB (Lobachevsky University ECG Database) for wave segmentation (P, T, and QRS complexes) and the MIT-BIH Arrhythmia database for anomaly detection.
- Respiratory Monitoring: Utilizing BIDMC PPG and Respiration data for boundary detection and an internal pediatric ICU dataset from Johns Hopkins for breath phase segmentation.
- General Benchmarks: To test generalizability, the model was also applied to non-medical datasets, including NASA’s Mars Science Laboratory (MSL) and eBay’s Pooled Server Metrics (PSM).
Key Results and Insights
MedTsLLM consistently outperformed specialized deep learning models (such as PatchTST and TimesNet) and existing LLM-based time series approaches (like GPT4TS).
- Superior Accuracy: In ECG segmentation (LUDB), the model achieved an F1 score of 89.89 and an IoU of 81.73. In anomaly detection (MIT-BIH), it reached an F1 of 94.70, significantly higher than the 89.53 achieved by the next best baseline.
- Clinical Utility: On pediatric ventilator data, MedTsLLM outperformed standard clinical segmentation tools. Notably, it achieved these results with only a few hours of labeled data, suggesting high potential for rapid deployment in specialized clinical settings.
- The Power of Context: Ablation studies confirmed that including patient-specific information (like medications) significantly boosted performance. This indicates that the LLM is not just processing numbers but is actively using its internal knowledge to refine its interpretation of the signals.
Discussion and Future Directions
While MedTsLLM represents a significant step forward, several challenges remain. Like many LLM-based systems, the "black box" nature of the model poses a hurdle for clinical adoption; future iterations may focus on generating textual explanations alongside classifications to improve interpretability. Additionally, while the use of a frozen backbone is efficient, the computational requirements for a 7B parameter model still necessitate substantial GPU resources, which may limit real-time bedside application in some environments.
Ultimately, MedTsLLM demonstrates that by "reprogramming" LLMs to understand physiological signals, we can move toward a more integrated, context-aware approach to medical AI that enhances clinical decision-making and patient outcomes.
Summary updated