RepoInclusionAI (Ant Group)InclusionAI (Ant Group)published Nov 20, 2026seen 1w

inclusionAI/LingSante-Pulse

Python

Open original ↗

Captured source

source ↗
published Nov 20, 2026seen 1wcaptured 1whttp 200method plain

inclusionAI/LingSante-Pulse

Language: Python

License: MIT

Stars: 2

Forks: 0

Open issues: 0

Created: 2026-11-20T08:03:24Z

Pushed: 2026-11-20T11:03:07Z

Default branch: main

Fork: no

Archived: no

README:

LingSante-Pulse

[English](README.md) | [简体中文](README_zh.md)

Representation learning for physiological time series, with waveform encoding and continuous glucose monitoring (CGM) workflows.

LingSante-Pulse provides reusable representations for signals such as ECG, EEG, and PPG. Its CGM branch supports daily glucose representations, longitudinal history modeling, public-data pretraining, and downstream evaluation.

[Technical report](docs/LingSante-Pulse_Technical_Report.pdf)

Features

| Branch | Input | Output | Workflows | | --- | --- | --- | --- | | Waveforms | Signal windows, actual sampling rates, and channel metadata | 256-dimensional CLS / PatchMean features per channel; optional patch sequences | Pretrained representation extraction for downstream tasks | | Continuous glucose (CGM) | Daily glucose windows, observation masks, subject IDs, and timestamps | A 146-dimensional representation per day and the number of contributing history windows | Representation extraction, public-data pretraining, classification, fixed-model evaluation, and candidate-selection evaluation |

The CGM branch implements Transferable Evidence Reconstruction (TER), combining daily representations, physical scale, temporal dynamics, and causal cross-day history. Training and evaluation share the project's installation, documentation, and versioning.

Each branch provides preprocessing appropriate to its inputs: sampling rates and physical channels for waveforms, and glucose units, daily grids, and subject histories for CGM. The entry points provide defaults and pretrained-weight loading.

Installation

Use Python 3.11 or 3.12. Run from the repository root:

python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python -m pip install . --no-deps

The root requirements.txt covers both branches and preserves the CGM evaluation dependency versions. GPU training requires a PyTorch build compatible with your accelerator. Both branches support CPU inference and synthetic examples.

Pretrained weights

| Branch | Source | Contents | | --- | --- | --- | | Waveforms | Hugging Face: inclusionAI/LingSante-Pulse-1.0 | Official encoder, configuration, and fixed channel assets | | CGM | src/lingsante_pulse/cgm/assets/checkpoints/ | Daily encoder, dynamics branch, longitudinal model, and physical-scale parameters |

The waveform encoder downloads weights from Hugging Face and uses the local cache by default. Local model directories are also supported. CGM deployment weights are included in the repository and installation package.

Quick start

Waveform features

Load the waveform encoder and extract features:

import numpy as np
from lingsante_pulse import LingSantePulse

model = LingSantePulse.from_pretrained()

# Two synthetic single-channel ECG windows, each 10 seconds at 128 Hz.
signals = np.random.default_rng(42).normal(size=(2, 1, 1280)).astype(np.float32)
features = model.encode(
signals,
sample_rate=128,
channels=[{"modality": "ECG", "lead": "II"}],
)

print(features["cls"].shape) # torch.Size([2, 256])
print(features["patch_mean"].shape) # torch.Size([2, 256])

To load a local model directory, replace the loading line with:

model = LingSantePulse.from_pretrained("models/pulse", local_files_only=True)

The directory must contain model.safetensors, config.json, channels.npz, and channels.json. An explicit Hugging Face repository ID can also be passed to from_pretrained.

CGM features

CGM deployment weights and a synthetic example are included in the repository:

python -m lingsante_pulse.cgm extract \
--input examples/cgm_synthetic.npz \
--output results/cgm_example_embeddings.npz

This command uses the packaged deployment weights and CPU inference by default. Its output contains embedding, history_days, and the corresponding window, subject, and timestamp metadata. Existing outputs are not overwritten; choose a new output path when running the example again.

Python interface:

import numpy as np
from lingsante_pulse.cgm import extract

with np.load("examples/cgm_synthetic.npz", allow_pickle=False) as archive:
payload = dict(archive)

embedding, history_days = extract(
payload,
device="cpu",
)

print(embedding.shape) # (6, 146)
print(history_days.shape) # (6,)

Inputs and outputs

Waveforms

  • Arrays may have shape [T], [C, T], or [B, C, T]. Use [B, 1, T] for a single-channel batch. Channel dictionaries are also supported.
  • Specify the actual sample_rate. Waveforms use fixed 128-Hz preprocessing; input channels must be aligned in time.
  • Provide channels in input order, with a modality and optional lead, for example {"modality": "ECG", "lead": "II"}.
  • Names ignore case and leading/trailing whitespace. ECG leads II, ii, "2", and 2 map to lead II. An omitted or empty lead uses the generic ECG identity.
  • Inspect supported identities with model.channel_names and model.channel_descriptions. Unsupported identities such as IMU raise an error.
  • Optional boolean masks observed and sample_present must match the input shape. They identify physical observations and storage padding, respectively.

| Output | Shape | Meaning | | --- | --- | --- | | cls | [B, C*256] | Per-channel CLS features concatenated in input order | | patch_mean | [B, C*256] | Mean features over valid patches for each channel | | channel_names | C names | Canonical channel identities | | patch_tokens | [B, P, C*256] | Patch features returned with return_tokens=True | | patch_valid | [B, P, C] | Optional per-channel patch-validity mask | | patch_times | [P] | Optional relative patch start times in seconds |

Channels are encoded independently and their features are concatenated. Waveforms use the mean and standard deviation of observed samples within each channel/window. Numeric channels use zero-order-hold resampling and fixed physical scales:

| Numeric channel | Input unit | Center | Scale | | --- | --- | --- | --- | | spo2 | Percent, e.g. 97 | 95 | 5 | | heart_rate, pulse_rate | Beats/min | 70 | 30 | | rr_primus, rr_solar | Breaths/min | 20 | 20 | |...

Excerpt shown — open the source for the full document.