Table of Contents
Fetching ...

GlyRAG: Context-Aware Retrieval-Augmented Framework for Blood Glucose Forecasting

Shovito Barua Soumma, Hassan Ghasemzadeh

TL;DR

GlyRAG introduces a context-aware, retrieval-augmented framework for CGM-based glucose forecasting that leverages an LLM as a contextualization agent to extract morphology-rich summaries from glucose traces. A multimodal transformer fuses textual context with CGM patches, and a retrieval module conditions forecasts on similar historical episodes, guided by a cross-translational loss to align embeddings. Across two large T1D cohorts, GlyRAG achieves superior long-horizon accuracy and clinically relevant performance, with strong safety metrics (e.g., high CEGA Zones A–B and improved CG-EGA) and notable dysglycemia-prediction gains. The work suggests that agentic AI with semantic context can enhance decision support in diabetes management, enabling safer, more interpretable, and scalable CGM forecasting without extra sensors.

Abstract

Accurate forecasting of blood glucose from CGM is essential for preventing dysglycemic events, thus enabling proactive diabetes management. However, current forecasting models treat blood glucose readings captured using CGMs as a numerical sequence, either ignoring context or relying on additional sensors/modalities that are difficult to collect and deploy at scale. Recently, LLMs have shown promise for time-series forecasting tasks, yet their role as agentic context extractors in diabetes care remains largely unexplored. To address these limitations, we propose GlyRAG, a context-aware, retrieval-augmented forecasting framework that derives semantic understanding of blood glucose dynamics directly from CGM traces without requiring additional sensor modalities. GlyRAG employs an LLM as a contextualization agent to generate clinical summaries. These summaries are embedded by a language model and fused with patch-based glucose representations in a multimodal transformer architecture with a cross translation loss aligining textual and physiological embeddings. A retrieval module then identifies similar historical episodes in the learned embedding space and uses cross-attention to integrate these case-based analogues prior to making a forecasting inference. Extensive evaluations on two T1D cohorts show that GlyRAG consistently outperforms state-of-the art methods, achieving up to 39% lower RMSE and a further 1.7% reduction in RMSE over the baseline. Clinical evaluation shows that GlyRAG places 85% predictions in safe zones and achieves 51% improvement in predicting dysglycemic events across both cohorts. These results indicate that LLM-based contextualization and retrieval over CGM traces can enhance the accuracy and clinical reliability of long-horizon glucose forecasting without the need for extra sensors, thus supporting future agentic decision-support tools for diabetes management.

GlyRAG: Context-Aware Retrieval-Augmented Framework for Blood Glucose Forecasting

TL;DR

GlyRAG introduces a context-aware, retrieval-augmented framework for CGM-based glucose forecasting that leverages an LLM as a contextualization agent to extract morphology-rich summaries from glucose traces. A multimodal transformer fuses textual context with CGM patches, and a retrieval module conditions forecasts on similar historical episodes, guided by a cross-translational loss to align embeddings. Across two large T1D cohorts, GlyRAG achieves superior long-horizon accuracy and clinically relevant performance, with strong safety metrics (e.g., high CEGA Zones A–B and improved CG-EGA) and notable dysglycemia-prediction gains. The work suggests that agentic AI with semantic context can enhance decision support in diabetes management, enabling safer, more interpretable, and scalable CGM forecasting without extra sensors.

Abstract

Accurate forecasting of blood glucose from CGM is essential for preventing dysglycemic events, thus enabling proactive diabetes management. However, current forecasting models treat blood glucose readings captured using CGMs as a numerical sequence, either ignoring context or relying on additional sensors/modalities that are difficult to collect and deploy at scale. Recently, LLMs have shown promise for time-series forecasting tasks, yet their role as agentic context extractors in diabetes care remains largely unexplored. To address these limitations, we propose GlyRAG, a context-aware, retrieval-augmented forecasting framework that derives semantic understanding of blood glucose dynamics directly from CGM traces without requiring additional sensor modalities. GlyRAG employs an LLM as a contextualization agent to generate clinical summaries. These summaries are embedded by a language model and fused with patch-based glucose representations in a multimodal transformer architecture with a cross translation loss aligining textual and physiological embeddings. A retrieval module then identifies similar historical episodes in the learned embedding space and uses cross-attention to integrate these case-based analogues prior to making a forecasting inference. Extensive evaluations on two T1D cohorts show that GlyRAG consistently outperforms state-of-the art methods, achieving up to 39% lower RMSE and a further 1.7% reduction in RMSE over the baseline. Clinical evaluation shows that GlyRAG places 85% predictions in safe zones and achieves 51% improvement in predicting dysglycemic events across both cohorts. These results indicate that LLM-based contextualization and retrieval over CGM traces can enhance the accuracy and clinical reliability of long-horizon glucose forecasting without the need for extra sensors, thus supporting future agentic decision-support tools for diabetes management.
Paper Structure (34 sections, 26 equations, 10 figures, 4 tables, 1 algorithm)

This paper contains 34 sections, 26 equations, 10 figures, 4 tables, 1 algorithm.

Figures (10)

  • Figure 1: Approaches of time‑series forecasting using LLM: (a) Existing methods either use LLM directly on CGM time series or depend on other sensors. (b) GlyRAG first uses an LLM agent to contextualize CGM windows, then fuses text and signal embeddings with retrieval‑augmented attention for forecasting.
  • Figure 2: Overview of the proposed GlyRAG pipeline: Three‑hour CGM windows are extracted and summarized by an LLM agent into short morphology‑aware text, which is embedded and fused with glucose patches in a multimodal encoder. A retrieval‑augmented module then attends to similar historical patterns to generate multi‑horizon forecasts that can be used for behavioral feedback and decision support.
  • Figure 3: Overall GlyRAG architecture: (a) An LLM agent generates a morphology‑aware text summary from the input CGM window, which is encoded by a language model and fused with patch‑based glucose embeddings in a multi‑head self‑attention encoder to produce a joint context–CGM representation ($z$). (b) The fused query embedding searches a retrieval index for K similar historical episodes; cross‑attention branches combine the query with each neighbor, and the aggregated retrieval‑aware representation is fed to a predictor to forecast.
  • Figure 4: Qualitative effect of contextual summaries on glucose forecasting (three examples). Panels (a–c) show a 3-hour CGM window (blue), 12-step/60-min forecasts from GlyRAG (red) and a baseline model (orange), and the ground truth future trajectory (green). Shaded bands indicate clinical ranges (low, target 70–180 mg/dL, high). The callout under each panel is the LLM-generated context summarizing morphology (e.g., post-meal rise, rebound, early recovery or sustained decline). GlyRAG leverages this context to anticipate turning points and slope changes, closely tracking the subsequent decrease or stabilization, whereas the baseline tends to overshoot or miss reversals. These examples illustrate how contextual reasoning improves longer-horizon, physiologically coherent forecasts.
  • Figure 5: GlyRAG glucose forecasts across prediction horizons (PH = 5, 30, 60 minutes). GlyRAG predictions (red) closely follow actual CGM traces (green) within shaded clinical zones, leveraging contextual morphology to anticipate peaks and nadirs. Dashed oval marks risk markers (hypo/hyper) where GlyRAG preserves turning-point fidelity even as the horizon lengthens.
  • ...and 5 more figures