Downloads · 30 days
9
12% of all-time downloads
kotlarmilos/gemma-4-e4b-glucolens
gemma-4-e4b-glucolens is a text generation model from kotlarmilos. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
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…
Downloads · 30 days
9
12% of all-time downloads
All-time downloads
75
Public
Repo size
160 MB
Likes
0
Public
Click a slice to open those files.
.safetensors128 MB · 80%
From the Hugging Face model README
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.
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.
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.
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.
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.
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.
Apache 2.0 for the adapter weights and config. The base model is governed by the Gemma usage policy.
@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}
}