The problem
Given a known R-peak, where does the T wave peak? Precise T-peak timing underpins ECG interval analysis. The open question was whether a time-series LLM (OpenTSLM) actually reads the waveform, or only learns timing priors, and how it compares with simpler waveform models across databases.
Approach
- LoRA fine-tuning: fine-tuned OpenTSLM SoftPrompt (Llama 3.2 1B, Hugging Face checkpoint OpenTSLM/llama-3.2-1b-ecg-sp) with LoRA on a Nebius H100 to generate the T-peak sample index, with integer-only prompts and greedy decoding.
- Rigorous controls: a matched waveform-swap test showed MAE unchanged at 64.5 ms after swapping waveforms, so waveform dependence of the generative model stayed unverified. We reported that honestly rather than claiming a win.
- Representation probing: a numerical readout over frozen OpenTSLM ECG patch features plus local raw waveform samples, with separate kernels per input and their product capturing interactions, trained on QTDB beat windows.
- Benchmarks against a training-set timing prior and a waveform-only candidate ranker, with cross-database development panels on LUDB and MIT-BIH (separate manual T-peak labels) and a beat-level error audit.
- Explainable AI: Temporal LIME (replace short ECG segments, fit a local surrogate of the change in predicted time) and Integrated Gradients (attribute the timing shift from a reference to the input), shown in an interactive explorer.
- Engineering: Python/PyTorch package managed with uv, Streamlit workbench, live web explorer, and a TimeNet connector that maps QTDB records into sparse localisation tasks (validated with TimeNet 0.12.0).
Result
On LUDB (1,603 windows) the OpenTSLM interaction-kernel readout reached 18.60 ms MAE against 30.92 ms for the timing prior, and the waveform-only ranker reached 11.08 ms. On the MIT-BIH pilot (2,112 windows) the OpenTSLM readout made the fewest large misses (453 errors over 80 ms, against 571). Research use only; not clinically validated.
