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.

Quick start

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

BASE    = "google/gemma-4-e4b-it"
ADAPTER = "kotlarmilos/gemma-4-e4b-glucolens"

tok   = AutoTokenizer.from_pretrained(BASE)
base  = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=torch.bfloat16, device_map="auto")
model = 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

@misc{kotlar2026glucolens,
  author = {Milos Kotlar},
  title  = {GlucoLens: 6-hour glucose rollouts with a fine-tuned Gemma 4 E4B},
  year   = {2026},
  howpublished = {The Gemma 4 Good Hackathon},
  url    = {https://github.com/kotlarmilos/gemma-4-e4b-glucolens}
}
Downloads last month
47
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train kotlarmilos/gemma-4-e4b-glucolens

Article mentioning kotlarmilos/gemma-4-e4b-glucolens

Evaluation results

  • Trajectory MAE (mg/dL) on GlucoLens rollout triples
    self-reported
    6.900
  • Peak timing error (min) on GlucoLens rollout triples
    self-reported
    1.200
  • OOD refusal rate on GlucoLens rollout triples
    self-reported
    1.000