  Calculating mealtime insulin doses poses a significant challenge for
individuals with Type 1 Diabetes (T1D). Doses should perfectly compensate for
expected post-meal glucose excursions, requiring a profound understanding of
the individual's insulin sensitivity and the meal macronutrients'. Usually,
people rely on intuition and experience to develop this understanding. In this
work, we demonstrate how a reinforcement learning agent, employing a
self-attention encoder network, can effectively mimic and enhance this
intuitive process. Trained on 80 virtual subjects from the FDA-approved
UVA/Padova T1D adult cohort and tested on twenty, self-attention demonstrates
superior performance compared to other network architectures. Results reveal a
significant reduction in glycemic risk, from 16.5 to 9.6 in scenarios using
sensor-augmented pump and from 9.1 to 6.7 in scenarios using automated insulin
delivery. This new paradigm bypasses conventional therapy parameters, offering
the potential to simplify treatment and promising improved quality of life and
glycemic outcomes for people with T1D.
