I have trained a model to predict my blood sugar [P]

I have trained a model to predict my blood sugar [P]

It's an encoder-only transformer that consumes past(blood glucose + carbs + insulin) and future(carbs + insulin) and predicts future blood glucose for the next 2 hours. Announced meals and boluses/basal are used to condition its predictions. The context size is variable (8 – 24 hours), and model can work in autoregressive mode to predict the next >2 hours. It also predicts time by looking at the context, but it never consumes time. The architecture is BERT-style: bidirectional attention with future BG masked. DILATE loss was used to fit the median line; pinball loss to fit the uncertainty bands. The two are "mixed" via Kendall-Gal. All blood glucose is in kovatchev risk space reparameterized to [40, 400] range.

I have trained 4 model classes (nano, small, medium, large) and 3 variants for each (pretrained on simulator only, pretrained + finetuned on ohiot1dm, pretrained and finetuned on ohiot1dm + azt1d + shanghait1dm). The largest one has ~17 million parameters (16 heads across 16 layers). Pretraining for the largest model took ~48 hours. Finetuning took <10 minutes. There is also another version finetuned on my own data that I am currently running on my phone.

Source is available here, released under the MIT license. The repo also contains links to trained weights and evaluation data.

I've worked on this project since March. There are still things to improve (e.g. it always requires announced carbs + insulin, would be better if it could also predict without them), but I have decided to publish it here to get your opinion (and also answer your questions, if any).

submitted by /u/0xdeadf1sh
[comments]

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *