← Nathan Ranchin

Reading 12-lead ECGs with LFM3-1.7B

Nov 24, 2026

OpenTSLM turns a language model into a time-series reader. The signal is encoded into tokens the model can attend to, interleaved with text, and the model answers questions about it with a step-by-step rationale. The published models use Llama-3.2 (1B and 3B) and Gemma-3 backbones, either as a soft prompt or through Flamingo-style cross-attention.

Over a weekend I rebuilt the soft-prompt variant on LFM3-1.7B-Base, with Amazon's Chronos-2 encoder reading every ECG lead at the full 500 Hz. It beats every published OpenTSLM model on macro-F1 across all four benchmarks, matches the most accurate published ECG model (Flamingo on Llama-3.2-3B) with greedy decoding while running twice as fast on a MacBook, and surpasses every published model on accuracy with 8-sample majority voting. Below are real ECG test cases with the model's unedited output.

Real PTB-XL test cases (CC BY 4.0, 25 mm/s · 10 mm/mV) and the model's unedited output, misses included.

Results

LFM3-1.7BPrevious best
TSQA+0.16
99.87
99.71
HAR-CoT+2.59
70.23
67.64
Sleep-CoT+8.48
78.36
69.88
ECG-QA-CoT+2.54
44.46
41.92
Macro-F1 on the full official test sets (greedy decoding). Previous best: the strongest published OpenTSLM model for each task, Flamingo and Chronos-2 variants included.

On ECG-QA-CoT (41,093 test questions over 3,207 recordings), single-pass greedy accuracy is 45.93% against 46.25% for the most accurate published model (Flamingo on Llama-3.2-3B). With a majority vote over 8 sampled rationales (temperature 0.6, chosen on validation), accuracy reaches 48.37% (+2.12 points over every published model) and macro-F1 reaches 46.01 (40.75 support-weighted), at the cost of 8 generations instead of greedy decoding. Accuracy on the other tasks: TSQA 99.88%, HAR-CoT 73.83% (previous best 72.20%) and Sleep-CoT 87.74% (81.08%). The previous best macro-F1 comes from Flamingo with Chronos-2 on TSQA, HAR-CoT (Llama-3.2-3B) and ECG-QA-CoT (Llama-3.2-1B), and the 1B soft-prompt model on Sleep-CoT. Two scoring notes: ECG macro-F1 above is the unweighted per-template average from the paper's scorer (the support-weighted variant is 38.88 greedy / 40.75 majority-of-8, and the paper does not state which one it reports); and on Sleep-CoT the EEG prompt reports amplitude in microvolts instead of volts rounded to 4 decimals (the stock prompt prints std 0.0001, erasing the amplitude cue).

Why LFM3

ECG accuracy
35%40%45%
LFM3-1.7B · 4.5 s
Flamingo 3B · 9.3 s
SoftPrompt 3B · 8.8 s
Flamingo 1B · 4.0 s
SoftPrompt 1B · 3.2 s
0246810
seconds per question
Seconds to answer one ECG question (a 180-token rationale, greedy decoding) on a MacBook Pro M4 Max, PyTorch on the GPU, bf16, batch 1, median of 21 runs, against accuracy on the ECG-QA-CoT test set. Flamingo and SoftPrompt are the published OpenTSLM models on Llama-3.2. Up and to the left is better.

The 1B Llama models are faster still, but they are 7 to 10 points less accurate on ECG.

What moved the needle

Best published · 46.3%
Paper recipe: CNN encoder, 100 Hz, a quarter of the dataF1 32.3
36.8%
Chronos-2 encoder, weighted loss, class balancing, all dataF1 38.2
40.0%
500 Hz signal, trainable encoder, merged tokens (half the data)F1 40.9
42.2%
Continued on the other half of the ECG dataF1 44.5
45.9%
Majority vote over 8 samplesF1 46.0
48.4%
ECG-QA-CoT test accuracy (and unweighted macro-F1) after each change, all on the same LFM3-1.7B-Base backbone. Dashed marker: best published ECG accuracy (46.25%, Flamingo on Llama-3.2-3B). The last row changes the decoding, not the model.

Most of the ECG gain over the paper came from the encoder, the full-resolution signal and more training data. LFM3's part is delivering that at 1.7B parameters and laptop speed. Reinforcement learning (GRPO with a verifiable answer reward) on top of supervised fine-tuning did not improve validation accuracy: at a low learning rate it only sharpened answers the model already gave, and at a higher one it lost diversity.

Does LFM3 need the encoder?

With Chronos-2Encoder-free
TSQA
+0.2
−0.9
HAR-CoT
+2.6
−2.0
Sleep-CoT
+8.5
+6.1
ECG-QA-CoT
+2.5
−2.8
−100 (prev. best)+10
Macro-F1 relative to the best published model for each task (0 line). Encoder-free: raw 16-sample patches through a per-patch linear layer and the same MLP projector, LoRA rank 256 from stage 1, same curriculum. Its ECG score comes from a separate, shorter run (1.5 passes over the ECG data from plain LFM3-1.7B-Base, 32-sample patches).

To see what Chronos-2 contributes, I removed it: each 16-sample window of the raw signal passes through a per-patch linear layer and the same MLP projector straight into LFM3, with no mixing across patches or leads before the language model. Reading raw patches requires more capacity in the LLM itself (LoRA rank 256 from stage 1, instead of rank 16 from stage 3). Trained with the same curriculum on TSQA, HAR-CoT and Sleep-CoT, this encoder-free model still beats every published Sleep model and lands within 1 to 2 F1 of the best published results on TSQA and HAR-CoT; a separate shorter ECG run from plain LFM3-1.7B-Base (32-sample patches, 1.5 passes) lands within 3 F1 of the best published ECG score. On an equal short ECG budget from scratch, encoder-free even slightly beat Chronos-2 (34.4 vs 33.4 F1). With longer training the pretrained encoder pulls ahead by 1 to 5.3 F1, which is why the main model keeps it.

How it works

You are an expert cardiologist analyzing an ECG. Clinical Context: ... Question: ...
This is ECG Lead I, it has mean -0.0043 and std 0.0784: <158 ECG tokens>
...
This is ECG Lead V6, it has mean 0.0021 and std 0.0912: <158 ECG tokens>
Select your answer from the following options: ... You MUST end your response with "Answer: "

Caveats

Try it

The model is on Hugging Face at nathanrchn/OpenTSLM-LFM3-1.7B-ECG and runs on a laptop:

# pip install torch transformers chronos-forecasting huggingface_hub wfdb
import sys, wfdb
from huggingface_hub import snapshot_download

path = snapshot_download("nathanrchn/OpenTSLM-LFM3-1.7B-ECG")
sys.path.append(path)
from inference import EcgReader

reader = EcgReader(path)
# a PTB-XL recording: 10 s, 12 leads, 500 Hz, millivolts
ecg = wfdb.rdrecord("09879_hr", pn_dir="ptb-xl/1.0.3/records500/09000").p_signal
out = reader.ask(
    ecg,
    "Which rhythm-related symptom does this ECG show, "
    "sinus tachycardia or atrial fibrillation?",
    options=["sinus tachycardia", "atrial fibrillation"],
)
print(out["answer"])  # atrial fibrillation
print(out["rationale"])

Code and training scripts: github.com/nathanrchn/OpenTSLM.