Compact and Decodable Electrocardiogram Text for Large Language Models

Elif Dorukbaşı, İlker TürkerarXiv 2026 · arXiv

Large Language Models (LLMs) are increasingly being asked to act as multi-modal assistants, processing everything from images to complex medical signals. But how do you "show" a 12-lead electrocardiogram (ECG)—a high-frequency, multi-channel voltage recording—to a model that only understands text?

A new paper from researchers at Karabük University introduces ECG-26c, a deterministic text encoding designed to bridge the gap between clinical waveforms and the token-limited world of LLMs.

TL;DR

ECG-26c is a novel text-based encoding that compresses 12-lead ECG signals by over 60% while preserving their diagnostic utility. By using a specialized "alphabet" for amplitudes and exact timing gaps, it ensures full 10-second recordings fit within standard LLM context windows without losing the critical features needed for medical diagnosis.

What Problem Does This Paper Address?

The standard 12-lead ECG is a cornerstone of cardiology, but it is data-heavy. A typical 10-second recording sampled at 100 Hz contains 12,000 raw voltage values. If you simply transcribed these numbers into text, the resulting sequence would be massive—likely exceeding the "context window" (the memory limit) of most LLMs or making the computational cost of processing them (which grows quadratically with length) prohibitively expensive.

Previous attempts to solve this either used "black box" embeddings that humans can't read, or symbolic methods that truncated long records or lost timing precision. The authors identify a critical research gap: we need a way to quantify exactly how much diagnostic information is lost during the "translation" to text, independent of the specific LLM being used.

Methods

The authors developed ECG-26c, a pipeline that turns raw signals into a compact string of letters.

  1. Lead Reduction: Since the 12 leads of an ECG are mathematically related, the system only encodes 8 independent leads. The remaining 4 are reconstructed algebraically by the decoder, saving 33% of the token budget immediately.
  2. Smart Key-Point Selection: Instead of keeping every single sample, they use a variant of the Ramer–Douglas–Peucker (RDP) algorithm. Crucially, the "tolerance" for error changes based on the cardiac cycle: it stays very tight during the fast-moving QRS complex (the "heartbeat") and loosens up during the flatter baseline segments.
  3. The 26-Letter Alphabet: Amplitudes are mapped to a 26-letter lowercase alphabet (a–z) using a logarithmic ($\mu$-law) codebook. This provides high resolution for small signals near the baseline and lower resolution for large spikes, mimicking how human ears and eyes perceive intensity.
  4. Exact Timing: Unlike previous methods that "binned" time, ECG-26c uses uppercase letters (A–Z) to represent the exact number of samples between key points. This prevents "temporal drift," ensuring the heart rate and intervals remain perfectly accurate.
  5. Token Budgeting: If a record is too "noisy" and generates too many tokens, the system automatically re-encodes it with slightly coarser tolerances until it fits within a strict 4,080-token limit.
The ECG-26c encoding and decoding pipeline.

Datasets

The study utilized the PTB-XL database, a large, publicly available collection of 21,388 clinical 12-lead ECGs. The records were split into standard training, validation, and test folds to ensure results are comparable to other state-of-the-art benchmarks.

Key Insights and Ideas

  • Fidelity $\neq$ Diagnosis: A major "aha moment" in the paper is that traditional signal error metrics (like PRD) are poor predictors of diagnostic loss. A tiny error in a short segment might look insignificant on a graph but could represent a missing "Q-wave," which is vital for identifying a past heart attack.
  • Logarithmic Quantization: By using narrower bins near 0 mV, the encoding preserves the subtle "wiggles" of the P and T waves while still handling the large voltage of the QRS complex efficiently.
  • Algebraic Recovery: The realization that 4 leads can be perfectly recovered from the other 8 allows for massive compression without any information loss in those specific channels beyond what is lost in the source leads.
The logarithmic amplitude codebook, showing narrower bins near the isoelectric line.

Key Results

The researchers evaluated the "sufficiency" of their text by training a Convolutional Neural Network (CNN) on both the original signals and the decoded text-based signals.

  • Compression: The average record was reduced to 2,866 tokens—a 64.3% reduction compared to raw transcription.
  • Signal Fidelity: The average correlation between the original and decoded signals was a high 0.982.
  • Diagnostic Performance: The CNN achieved a macro-AUROC of 0.9167 on original signals and 0.9157 on decoded signals. This tiny difference (-0.0010) was statistically non-inferior, meaning the text encoding successfully preserved the diagnostic "meat" of the ECG.
Fig. 4. The first four seconds of leads II and V2 in PTB-XL record 1: filtered reference (solid line) and signal decoded from ECG-26c text (dashed line).

Limitations and Future Work

While the results are promising, the authors note a few hurdles:

  • Small Feature Loss: A wave-level audit showed that about 2% of "Q-waves" were missing after decoding, which could impact specific diagnoses like myocardial infarction.
  • Data Exposure: The test fold was partially used during the development of the encoder's tolerances, so these results should be confirmed on entirely unseen datasets.
  • The "Reading" Challenge: This paper proves the information exists in the text; the next step is proving that an LLM can actually "read" and reason about these letter sequences as effectively as a dedicated CNN.

By providing a deterministic, decodable, and compact format, ECG-26c offers a standardized way for the research community to start feeding heart health data into the next generation of AI medical assistants.

Summary updated

Abstract

When a twelve-lead electrocardiogram is written as text for a large language model, the number of tokens has to be balanced against the information lost through compression. This paper presents a deterministic encoding that writes eight independent leads as amplitude letters and exact time gaps and recovers the remaining four limb leads algebraically. The key points are selected with a cardiac-cycle-dependent tolerance, the amplitudes are parameterized by a 26-letter logarithmic codebook learned from a training set, and a 10-step tolerance schedule keeps all records within a fixed token budget. The encoding was applied to 21,388 records from the public PTB-XL database and evaluated using an exact decode-and-re-encode round trip, waveform reconstruction error, and a paired comparison of convolutional classifiers trained with 5 different seeds on signals from the original and decoded databases. All records were contained in 4,080 tokens (average: 2,866 tokens, 64.3% fewer than a per-sample transcription), and all stored lead strings were exactly reproduced. The average correlation between the decoded and reference signals was 0.982. The macro-averaged area under the receiver operating characteristic curve was 0.9167 for the reference signals and 0.9157 for the decoded signals (paired difference -0.0010; 95% patient-level bootstrap interval, -0.0028 to 0.0007), within the pre-specified non-inferiority margin of -0.010; this is not a confirmatory result, because the test fold had been used during encoder development. The diagnostic content of a compact text can therefore be preserved, while the language model's ability to read the text is yet another matter.
BibTeX
@misc{dorukbas2026compact,
  author = {Elif Dorukbaşı and İlker Türker},
  title = {{Compact and Decodable Electrocardiogram Text for Large Language Models}},
  year = {2026},
  eprint = {2611.22827},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.22827},
}
Figure