Source-linked AI summary
SSMCGM-Stream: A Streaming State-Space Model for Personalized Diabetes Management
Shakson Isaac, Chirag Patel
TL;DR
Continuous glucose forecasting must balance predictive performance with interpretability and computational demands for continuous deployment. SSMCGM-Stream maintains a personalized streaming state for forecasts, attribution, and counterfactuals, with SSMCGM-Agent providing guarded natural-language interaction. On T1DEXI, it achieved three-hour accuracy comparable to TFT and LightGBM while training much faster and using less inference memory than TFT.
Problem
Glucose forecasting models can support proactive management, but typically prioritize prediction without revealing physiologically meaningful insulin and meal effects, while transformer computation challenges continuous deployment.
Source: §1 · p. 1Method
SSMCGM-Stream maintains a personalized recurrent state for forecasting, feature-and-lag attribution, and counterfactual action scenarios, with a language-model agent translating structured outputs into natural-language support.
Source: §1 · p. 1, §2.2 · p. 2, §4 · p. 9Results
At three hours, SSMCGM-Stream achieved MAE 27.05 mg/dL versus TFT (26.90) and LightGBM (27.22), trained in 27.4 s/epoch versus TFT’s 2594.5 s/epoch, and used 1.7 MB per forecast versus TFT’s 112 MB at 192 hours.
Source: §3.1 · p. 5Takeaways & Limitations
SSMCGM-Stream represents a step toward adaptive personalized decision-support systems built on continuously maintained physiological representations.
Source: §4 · p. 9The observational T1DEXI data limit causal interpretation of counterfactuals, and evaluation was confined to one cohort with restricted demographic diversity.
Source: §4 · p. 9
Abstract
from arXiv · showhide
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.
1 Introduction
Continuous glucose monitoring supports decisions about meals, insulin, and activity, but current systems provide limited insight into individual glucose dynamics. SSMCGM-Stream uses a streaming state-space model for personalized forecasting and decision support.
1 Introduction
- CGM measurements support ongoing type 1 diabetes decisions about meals, insulin, and physical activity.Forecasting can anticipate glycemic events 30–60 minutes ahead, supporting proactive glucose management.Source: §1 · p. 1
- Existing forecasting models prioritize predictive performance without showing whether they learn physiologically meaningful insulin and meal effects.Transformer-based models also pose computational challenges for continuous deployment, while state-space models support constant-time updates.Source: §1 · p. 1
- SSMCGM-Stream uses a personalized streaming state to forecast glycemic events, attribute drivers, simulate action counterfactuals, and support an advisory language-model agent.It can cold-start from population priors and adapt as individual observations arrive.Source: §1 · p. 1
2 Methods
The methods pair multimodal participant streams with a persistent state-space representation and scenario-conditioned forecasting. Training and inference support interpretable forecasts, counterfactual queries, and a guarded language-model interface.
2.1 Dataset
- At 3,915,944 observations from 497 participants, T1DEXI streams were resampled to five-minute intervals and split by participant into train, validation, and test sets.Forecast windows spanning longer CGM gaps were excluded, and planned actions were masked at inference for leakage-free benchmarking.Source: §2.1 · p. 2
2.2 SSMCGM-Stream Architecture
- A selective state-space recurrence updates participant-conditioned hidden states, while learned action kernels and gains encode distinct timing and personalized amplitudes for planned actions.The MES readout attributes forecasts by feature and lag; the horizon decoder conditions on calendar features, planned scenarios, and an availability mask.Source: §2.2 · pp. 2–3
2.3 SSMCGM-Stream Training and Benchmarking
- Training carries the hidden state across truncated-BPTT chunks and scores quantile forecasts at fully observed horizons; evaluation compares forecasting and clinical metrics against six baselines.The median quantile supplies point forecasts, while lower and upper quantiles support risk-sensitive event detection.Source: §2.3 · pp. 3–4
2.4 SSMCGM-Stream Inference
- Inference re-decodes from the same streaming representation for counterfactual plans, with queries restricted to in-support meals, insulin doses, and exercise intensities.The MES readout exposes feature-and-lag contributions, while the online state cold-starts from population priors and updates as observations arrive.Source: §2.4 · p. 4
2.5 SSMCGM-Agent Integration
- SSMCGM-Agent maps user queries to structured forecasting, explanation, simulation, and recommendation tools, then narrates outputs under a deterministic guard.Physiological reasoning remains in SSMCGM-Stream; deterministic resolvers and a guard reject unsupported numerical or treatment claims.Source: §2.5 · pp. 4–5
3 Results
SSMCGM-Stream forecasts with accuracy comparable to strong baselines while reducing computational cost, and its streaming state supports clinical-risk assessment, interpretation, and counterfactual queries. SSMCGM-Agent presents these model outputs through guarded natural-language decision support.
3.1 Forecasting accuracy and efficiency
- At 3 hours, SSMCGM-Stream achieved 27.05 mg/dL MAE, comparable to TFT (26.90) and LightGBM (27.22), while training in 27.4 s/epoch versus TFT’s 2594.5 s/epoch.It maintained 6.7 ms inference latency and 1.7 MB per-forecast memory as context grew; forecast error declined after cold start and plateaued after about a day.Source: Figure 4 · p. 5, §3.1 · p. 5, Table 1 · p. 5
3.2 Clinical safety and early detection
- At the 30-minute sub-horizon, SSMCGM-Stream detected hypoglycemia and hyperglycemia with AUROCs of 0.891 and 0.965, respectively; across the 3-hour forecast, hypoglycemic events had a median 25-minute lead time.Detection and error-grid safety matched TFT within overlapping 95% confidence intervals (hypoglycemia AUROC 0.891 vs. 0.910; Clarke A+B 98.2% vs. 98.1%).Source: §3.2 · p. 6
3.3 Interpretability
- Global attribution found heterogeneous head memories of about 10–95 minutes and kinetic peaks near 30 minutes for carbohydrates, 65 for insulin, 115 for fat, and 145 for protein.Time-of-day, glucose, insulin, carbohydrates, and activity contributed strongly to the state; insulin and carbohydrates had the largest decoder scenario effects.Source: §3.3 · p. 6, Figure 5 · p. 6
- Individual forecast attribution identified recent insulin and exercise as drivers of hypoglycemic predictions, and meal intake as a driver of hyperglycemic predictions.The case studies show forecast-specific explanations alongside glucose histories and time-stamped meal, insulin, and exercise annotations.Source: §3.3 · p. 6, Figure 6 · p. 7
3.4 Counterfactual decision support
- From a fixed observed history, counterfactuals showed larger glucose excursions with more carbohydrates and more prolonged excursions with more fat or protein at fixed carbohydrate intake.Insulin responses were biphasic and pre-bolusing reduced predicted excursions, but isolated correction boluses were uncommon, limiting identification of insulin’s independent effect.Source: §3.4 · p. 7, Figure 7 · p. 7, Figure 8 · p. 8
- Exercise counterfactuals showed intensity-dependent responses: running lowered glucose by approximately −10 mg/dL, compared with approximately 0 mg/dL for lighter activities such as yoga.The exercise profiles were derived from recorded heart-rate and step-count trajectories.Source: §3.4 · p. 7, Figure 8 · p. 8
3.5 SSMCGM-Agent: natural-language access to the streaming state
- On held-out participant streams, SSMCGM-Agent supported hypoglycemia alerts, individualized forecast explanations, and planning queries translated into counterfactual meal and activity scenarios.A deterministic guard rejected unsupported numbers and unendorsed actions; across 58 prompts, on-device model latency was 3.6–11.6 seconds per turn with 0.2–3.8 GB int4 weight memory.Source: §3.5 · p. 8, Figure 9 · p. 8
4 Discussion
SSMCGM-Stream uses a shared, evolving physiological representation to support personalized forecasting, explanation, and counterfactual simulation. Its observational-data basis and single-cohort evaluation constrain causal interpretation and leave broader generalization untested.
4 Discussion
- SSMCGM-Stream supports forecasting, attribution, and counterfactual simulation from one evolving physiological representation.The shared state reframes these decision-support tasks as queries of a continuously maintained representation.Source: §4 · pp. 8–9
- Persistent-state updates from incoming multimodal observations use constant memory and per-reading computation, supporting private, on-device inference [33] [34] [35].The representation is updated rather than repeatedly encoding the historical context.Source: §4 · p. 9
- SSMCGM-Stream complements population-level CGM foundation models by continuously adapting representations to individuals.The paper frames forecasting, explanation, simulation, and personalization as queries of a shared evolving representation.Source: §4 · p. 9
- SSMCGM-Stream separates physiological modeling from communication: it produces structured outputs while an on-device language model translates under deterministic safety constraints.The language model interfaces with users; physiological reasoning remains in the forecasting model.Source: §4 · p. 9
- Because training used observational T1DEXI data, counterfactuals have limited causal interpretability, and conditioning on longitudinal context cannot guarantee removal of confounding.Meals and insulin are temporally coupled, and actions depend on glucose state.Source: §4 · p. 9
- Evaluation used one cohort with restricted demographic diversity, leaving generalization to other populations, devices, and care settings untested.Prospective studies are needed to assess whether personalized forecasts and counterfactuals support lifestyle decisions and improve glycemic control; the agent also requires clinical evaluation and avoids insulin dosing.Source: §4 · p. 9
A Supplementary Figures
The supplementary figures describe clinical error-grid, interpretability, meal-composition, and agent-safety analyses. Their captions specify what is visualized but generally do not state comparative outcomes.
Figure S1
- Figure S1 compares median 60-minute forecasts with reference glucose using Clarke and Parkes clinical error grids.The Clarke grid is on the left and the Parkes grid on the right.Source: Figure S1 · p. 13
Figure S2
- Figure S2 shows mean MES hidden attention by lag and each person's learned kinetic gain relative to the cohort median.The per-head cumulative attention view and its 50% effective-memory crossing appear in Fig. 5a.Source: Figure S2 · p. 13
Figure S3
- Figure S3 reports held-out-participant permutation importance for static covariates in patient-state initialization and the resulting 1-hour forecast.Forecast effects pass through the initialized state and static FiLM gate.Source: Figure S3 · p. 14
Figure S4
- Figure S4 presents a held-out participant's meal-driven hyperglycemia case with forecast bands, observed glucose, event annotations, and MES attribution.Its panels show the temporal attribution of the driving feature and feature shares of streaming-state hidden attention.Source: Figure S4 · p. 14
Figure S5
- Figure S5 plots logged T1DEXI meals across carbohydrate, fat, and protein composition, with AMDR boundaries and representative foods.Macronutrient grams are converted to energy using Atwater factors [38]; the AMDR is cited as [32].Source: Figure S5 · p. 14
Figure S6
- Figure S6 illustrates perception and narration prompts that restrict the language model to linking inputs and translating model outputs.The perception boundary forbids estimating values; the narration boundary permits only JSON-present numbers and engine-endorsed actions, with downstream guards enforcing both.Source: Figure S6 · p. 15
Figure S7
- Figure S7 describes guard-based faithfulness and adversarial-safety tests across on-device model sizes.The guard delivers narration only when numbers appear in tool output and no insulin dose or unendorsed action is stated; violations fall back to a fixed safe card.Source: Figure S7 · p. 15
B Supplementary Tables
The supplementary tables cover cohort characteristics, model configuration and efficiency, forecasting and clinical comparisons, and agent deployment measurements. The remaining supplied material includes red-team prompts and examples rather than reported table outcomes.
Table S1
- Table S1 reports T1DEXI cohort characteristics, with values generally given as mean ± SD and CGM targets averaged across participants.Time-in-range is defined as 70–180 mg/dL.Source: Table S1 · p. 16
Table S2
- Table S2 lists the configuration for the reported 0.85 M-parameter SSMCGM-Stream model.The caption identifies the settings but does not provide their values.Source: Table S2 · p. 17
Tables S3–S4
- Tables S3–S4 cover 1-hour forecasting comparisons, including model efficiency in S3 and clinical metrics in S4.S3 specifies observed-only decoder scoring on identical held-out windows and reports MAE, resource use, and CPU decode latency; S4 covers overall MAE and 30-minute detection and error-grid metrics.Source: Table S3 · p. 17, Table S4 · p. 18
Tables S5–S6
- Tables S5–S6 report 3-hour forecast clinical metrics at 30- and 60-minute sub-horizons, with S5 also pooling horizons.S5 gives Clarke and Parkes zone fractions; S6 reports detection metrics for median and risk-averse alarms.Source: Table S5 · p. 18, Table S6 · p. 18
Table S7
- Table S7 measures SSMCGM-Agent per-turn latency and memory footprint across model sizes for three interaction types.The deployment feasibility test uses a single A100; weight memory is reported for bf16 and int4.Source: Table S7 · p. 19
Table S8
- Table S8 describes a red-team suite of 58 prompts, split into 46 adversarial prompts and 12 controls, with a guard-rejection label.The other supplied entries are prompt examples and do not report aggregate outcomes.Source: Table S8 · p. 20, B Supplementary Tables · p. 21
Related papers
This paper cites
- Sequence to Sequence Learning with Neural Networks2014
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness2022
- Mamba: Linear-Time Sequence Modeling with Selective State Spaces2023
- FiLM: Visual Reasoning with a General Conditioning Layer2017
- Efficiently Modeling Long Sequences with Structured State Spaces2021
- Temporal Fusion Transformers for Interpretable Multi-horizon Time Series Forecasting2019