Skip to content
AI.info

Research

SSMCGM-Stream: A Streaming State-Space Model for Personalized Diabetes Management

Overview Research area: Machine learning for healthcare — specifically, streaming time-series forecasting and decision support for type 1 diabetes using continuous glucose monitoring (CGM) data. Techn

SSMCGM-Stream: A Streaming State-Space Model for Personalized Diabetes Management
arXiv
2610.28976
Published
2026-10-20
Authors
Shakson Isaac, Chirag Patel

AI summary

Overview

Research area: Machine learning for healthcare — specifically, streaming time-series forecasting and decision support for type 1 diabetes using continuous glucose monitoring (CGM) data.

Technical level: Intermediate. The paper assumes familiarity with sequence models (state-space models, recurrent networks, transformers) but explains its clinical framing and architecture choices in accessible terms.

Scope: The paper introduces SSMCGM-Stream, a Mamba-2-based streaming state-space forecaster that maintains a constant-memory personalized hidden state for glucose prediction, explanation, counterfactual simulation, and language-model-mediated advice, evaluated on the T1DEXI cohort of 497 participants.

What This Paper Is About

Glucose forecasting models can warn about hypoglycemia and hyperglycemia 30–60 minutes ahead, but existing systems are usually optimized purely for prediction accuracy, are expensive to deploy continuously (transformer attention scales quadratically with sequence length), and offer little insight into why a forecast looks the way it does. The authors build a model that instead carries a compact recurrent state updated once per 5-minute CGM reading, from which forecasts, feature-level attributions, "what-if" simulations, and natural-language advice can all be read off the same state.

Key Contributions

  1. A constant-cost streaming forecaster. SSMCGM-Stream encodes history with a stack of selective state-space (Mamba-2) blocks plus an interpretable multi-expand SSM (MES) readout, so state updates and forecasts cost the same per reading regardless of how much history has accumulated.

  2. Physiologically structured scenario decoding. A horizon decoder separates a scenario-free baseline forecast from an additive scenario effect, and convolves planned actions (insulin, carbohydrate, fat, protein, exercise) with learned kinetic kernels that have per-participant learned gains and learned delay peaks.

  3. Built-in interpretability and counterfactual reasoning. Forecasts are attributed to per-feature, per-lag contributions of the hidden state; counterfactual queries are answered by re-decoding from the same state under an edited action plan with a mask indicating which actions are revealed.

  4. SSMCGM-Agent, a guarded language-model interface. An on-device instruction-tuned Qwen2.5 model routes user queries to forecasting, explanation, simulation, and recommendation tools and narrates the results, with a deterministic guard that rejects any number not present in the tool output and any insulin dose or unendorsed action.

Main Findings

  • Accuracy at 3 hours is competitive, not superior. SSMCGM-Stream reached MAE 27.05 ± 1.4 mg/dL and RMSE 39.38 ± 2.1, versus TFT at 26.90 ± 1.4 / 38.90 ± 2.0 and LightGBM at 27.22 ± 1.3 / 39.92 ± 2.1. It outperformed ARIMA (35.16), LSTM (30.94), NHiTS (33.95), and persistence (33.99).

  • Training is dramatically cheaper. 27.4 s/epoch versus 2594.5 s/epoch for TFT, with peak GPU memory of 5.15 GB (TFT: 3.20 GB) and peak system RAM of 16.0 GB (TFT: 246.3 GB), on a single A100.

  • Constant inference cost with growing context. Per-reading decode latency of 6.70 ms and roughly 1.7 MB per-forecast memory, with 0.85 M parameters. TFT's latency grew with context (10–48× slower over 24–192 h) and its inference memory reached 112 MB at 192 h, approximately 66× greater.

  • 1-hour results follow the same pattern. MAE 14.40 and RMSE 22.55, against TFT at 14.24 / 22.65 and LightGBM at 14.42 / 22.91, with 26.5 s/epoch versus 2550.8 for TFT.

  • Clinical risk grids are essentially tied with TFT. At the 30-minute sub-horizon, 98.2% of forecasts fell in Clarke A+B zones and 99.3% in Parkes A+B (TFT: 98.1% and 99.2%).

  • Early warning is comparable to TFT but less sharp on hypoglycemia. Hypo AUROC 0.891 ± 0.012 versus TFT's 0.910 ± 0.015; sensitivity at 95% specificity 0.735 ± 0.035 versus 0.747 ± 0.040; hyper AUROC 0.965 for both. Hypoglycemic events were anticipated with a median lead time of 25 min over the 3-hour forecast. The authors note these differences fall within overlapping 95% confidence intervals.

  • Personalization plateaus quickly. Forecast error decreases as the streaming state accumulates participant history from the cold-start initialization, plateauing after approximately the first day.

  • Learned kernels recover plausible physiology. Peak effects near 30 min for carbohydrates, 65 min for insulin, 115 min for fat, and 145 min for protein, with per-head effective memory spanning roughly 10–95 min and kernel gains varying across individuals.

  • Static-feature influence is concentrated. Income (10.3%), insulin-delivery modality (10.2%), and lifetime hypoglycemia history (8.5%) dominated the initialized state's static influence, while race, ethnicity, and sex contributed least.

  • Counterfactuals behave directionally as expected. More carbohydrate produced larger excursions, higher exercise intensity produced greater glucose lowering (running at peak HR ≈145 gave roughly −10 mg/dL, versus ≈0 mg/dL for yoga at peak HR ≈96), and pre-bolusing reduced the predicted excursion for a 40 g carbohydrate meal with a 3 U bolus. Insulin showed a biphasic dose response that the authors explicitly caution should not be read causally, since isolated correction boluses occurred in only about one third of cases.

  • The language-model guard trades coverage for faithfulness. Across 58 prompts (46 adversarial, 12 controls), unguarded narration fabricated unsupported numbers in 14–16% of number-tracking tests at sizes ≤1.5 B, and a 0.5 B model reported the specific value in only 56% of cases versus 80% at ≥1.5 B. Over-rejection of legitimate control queries fell from 25% at 0.5 B to ≤8% at ≥1.5 B, at 3.6–11.6 s per-turn latency and 0.2–3.8 GB int4 weight memory.

Methodology in Plain English

Data. The authors used 24–30 days of 5-minute multimodal data from 497 T1DEXI participants (3,915,944 observations reported in the methods; the cohort table lists 3,748,266 total CGM measurements), covering CGM, insulin, meals, exercise, heart rate, steps, and static demographics. Everything was resampled to a common 5-minute grid; short CGM gaps were linearly interpolated up to 15 min and forward-filled up to 30 min, and forecast windows crossing longer gaps were excluded. Participants were split 70/15/15 into 338 train, 73 validation, and 73 test.

Leakage control. For fair benchmarking, the decoder only observes calendar time; planned meal, insulin, and exercise events are masked at inference, so the model must forecast from observed history alone.

Architecture. A static encoder turns participant characteristics into an embedding that both initializes the recurrent state and modulates history features through a FiLM scale-and-shift layer. History is then encoded by Mamba-2 blocks whose step size, input matrix, and output matrix all depend on the current input. A separate horizon decoder starts from the streaming representation and rolls the same recurrence forward, conditioned on calendar features and on gated scenario actions multiplied by an availability mask.

Training. Training uses truncated backpropagation through time over 12-hour chunks (144 steps at 5 minutes), with the hidden state carried across chunks and detached at boundaries. Forecasts are scored at anchors that have fully observed horizons, using a pinball loss over the 0.1, 0.5, and 0.9 quantiles over a 3-hour (36-step) horizon; the median gives the point forecast and the tails support risk-sensitive alarms. Targets are residuals against the current glucose anchor with per-horizon scales fit on training participants only, so no per-participant center is learned and the transform still works at cold start. Optimization used Adam at a learning rate of 10⁻³, weight decay 10⁻², plateau scheduling, 30 epochs, batch size 64, and gradient clipping at 1.0.

Inference. Interpretability comes from the MES readout, which decomposes the readout into additive per-feature contributions and can be unrolled to show at what delay each feature acted. Counterfactuals compare two decodes from the identical hidden state — one masking all actions (a do-nothing forecast) and one revealing only the edited action — restricting queries to in-support meal, insulin, and exercise configurations.

Benchmarking. Baselines were persistence, ARIMA, LightGBM, LSTM, NHiTS, and TFT under the same leakage-free protocol and equivalent inputs, scored with MAE and RMSE at 1- and 3-hour horizons, hypo/hyperglycemia detection (thresholds of 70 and 180 mg/dL), and Clarke and Parkes error grids.

Agent. SSMCGM-Agent wraps the model with Qwen2.5-Instruct, using a "perception" boundary that maps free text to typed actions via deterministic resolvers over USDA FoodData Central and an empirical activity-curve library from T1DEXI, and an "expression" boundary that narrates structured outputs under the deterministic guard. Physiological reasoning stays in SSMCGM-Stream; the language model links and translates only.

Why This Matters

Impact on research. The paper reframes CGM modeling as maintaining an evolving physiological representation rather than repeatedly re-encoding history. It positions streaming state-space models as a complement to large CGM foundation models — population priors from big models, continuous individual adaptation from streaming ones — and makes forecasting, explanation, simulation, and personalization into different queries of one shared object rather than four separate learning problems.

Real-world applications:

  • On-device hypoglycemia alerts that run with constant memory and per-reading cost, suitable for phones or embedded hardware rather than cloud inference.
  • Patient-facing explanation of why a low is predicted (recent insulin, recent exercise) rather than just that it is predicted, which is what someone deciding whether to act needs.
  • Structured "what-if" planning over meals, exercise intensity, and pre-bolus timing, constrained to configurations observed in the data.
  • A conversational front end that translates plain-language questions into model calls and back, while structurally refusing to invent numbers or recommend insulin doses.

Industry relevance. The efficiency profile (0.85 M parameters, 6.7 ms per-reading decode, 16.0 GB peak training RAM versus 246.3 GB for TFT) is directly relevant to continuous-monitoring vendors, closed-loop insulin delivery systems, and digital-health platforms that need private on-device inference. The separation of physiological modeling from language-model narration, enforced by a deterministic output guard, is a reusable pattern for any regulated domain where an LLM sits in front of a numerical engine.

Future Directions

  1. Causal validation of counterfactuals. The model is trained on observational data where actions were observed rather than assigned, so meals and boluses are temporally coupled and actions depend on glucose state. The authors state that conditioning on the evolving representation may reduce confounding but cannot guarantee it, and that consistency, exchangeability, and positivity are required for causal interpretation.

  2. Generalization beyond one cohort. Evaluation was limited to a single T1DEXI cohort with restricted demographic diversity (454 of 497 participants White). Performance on other populations, devices, and care settings is untested.

  3. Prospective clinical studies. Whether personalized forecasts and counterfactual simulations actually support lifestyle decisions and improve glycemic control remains to be shown outside retrospective held-out evaluation.

  4. Clinical evaluation of the agent. SSMCGM-Agent is presented as a demonstration of how a language interface can be constrained by a physiological model, not as a validated clinical system; it intentionally avoids insulin dosing and precise treatment recommendations, and the guard's over-rejection rate (up to 25% at 0.5 B, ≤8% at ≥1.5 B) leaves room for improving usability without sacrificing faithfulness.

Target Audience

Researchers and practitioners working at the intersection of streaming sequence modeling and clinical decision support — particularly those building CGM-based forecasting, closed-loop insulin delivery, or on-device health AI. It is also useful for machine-learning engineers interested in state-space models as a constant-cost alternative to transformers for long-context physiological time series, for clinical informaticists evaluating interpretability and error-grid safety rather than raw MAE alone, and for anyone designing guardrailed LLM interfaces over numerical models in safety-critical settings. Readers without a machine-learning background will find the clinical motivation and the counterfactual results accessible, but the architecture and training sections assume comfort with recurrent models and quantile loss.

Authors’ abstract

Continuous glucose monitoring supports diabetes management but requires forecasting models that are accurate, interpretable, and efficient enough for real-time deployment. We present SSMCGM-Stream, a streaming state-space model that maintains a personalized hidden state updated with each incoming glucose reading to provide constant-time forecasting, physiologically structured counterfactual reasoning, and interpretable forecasts through hidden-state attribution. Built on this foundation, SSMCGM-Agent delivers risk-aware, natural-language decision support by translating forecasts, explanations, and counterfactuals into grounded recommendations through a guarded language-model interface. Evaluated on the T1DEXI cohort, SSMCGM-Stream achieves forecasting performance comparable to strong neural baselines while substantially reducing computational cost, enabling continuous on-device diabetes decision support.

Read the original paper