LingSante-Pulse 开源生理时序表征模型
inclusionAI 开源 LingSante-Pulse,为 ECG、EEG、PPG 等生理信号提供可复用表征,并单独提供连续血糖监测(CGM)分支。CGM 分支支持每日血糖表征、纵向历史建模、公开数据预训练与下游评估,并实现融合日表征、物理尺度、时序动态与因果证据的 TER 方法。
报道正文
本文目录6 个章节
LingSante-Pulse
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.
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-depsThe 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.npzThis 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.
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,)(注:更多技术实现细节与完整 API 文档请查阅原项目 README)