gemma-4-e4b-glucolens
A LoRA adapter on top of
google/gemma-4-e4b-it that
returns a strict JSON projection of glucose over the next 6 hours for a given meal and CGM context.
The projection carries 12 trajectory points, 3 ranked drivers, an interpretation, a grounding in
history, and an overall confidence.
Built for the
Gemma 4 Good Hackathon,
health track, May 2026.
Where this fits
This is the third step in my applied post-training track. In the first step,
Phi-4 on dotnet/runtime, I changed what a small
model knows. In the second step, the
Gemma 3 reasoning
adapter, I changed how it thinks using a
verifiable reward. Here I take that same instinct into a domain where the output is a structured
rollout and correctness is not the whole story. The model also has to know when it cannot answer and
refuse, which is the behavior that matters most for an on-device health assistant.
Full documentation, training procedure, evaluation methodology, schema, demo, and limitations are in
the repository,
https://github.com/kotlarmilos/gemma-4-e4b-glucolens. The writeup is on Hugging Face,
https://huggingface.co/blog/kotlarmilos/gemma-4-e4b-glucolens.
Quick start
1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3from peft import PeftModel
4
5BASE = "google/gemma-4-e4b-it"
6ADAPTER = "kotlarmilos/gemma-4-e4b-glucolens"
7
8tok = AutoTokenizer.from_pretrained(BASE)
9base = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.bfloat16, device_map="auto")
10model = PeftModel.from_pretrained(base, ADAPTER)
See
demo.ipynb for the
prompt template and five worked scenarios.
Headline numbers
Evaluated on 50 in-distribution test triples and 50 out-of-distribution triples with greedy decoding.
The full table and methodology are in the repository.
| Metric | Base zero-shot | Fine-tuned |
|---|
| Trajectory MAE (mg/dL) | 19.9 | 6.9 |
| Peak timing error (min) | 6.6 | 1.2 |
| OOD refusal rate | 0.00 | 1.00 |
Two known failures, calibration ECE 0.30 and counterfactual consistency 0.00, are documented in the
repository README, section 6.
Training data
Synthetic only, about 15,000 rollouts from
kotlarmilos/glucolens-rollout-triples.
Generated by
src/sim.py from simglucose with a Bergman ODE fallback. No real patient data was used.
Not a medical device
This is research code. It does not provide diagnosis, treatment, or insulin guidance. It is aimed at
non-diabetic and pre-diabetic metabolic awareness only.
License
Apache 2.0 for the adapter weights and config. The base model is governed by the
Gemma usage policy.
Citation
1@misc{kotlar2026glucolens,
2 author = {Milos Kotlar},
3 title = {GlucoLens: 6-hour glucose rollouts with a fine-tuned Gemma 4 E4B},
4 year = {2026},
5 howpublished = {The Gemma 4 Good Hackathon},
6 url = {https://github.com/kotlarmilos/gemma-4-e4b-glucolens}
7}