How to use from
llama.cpp
# Gated model: Login with a HF token with gated access permission
hf auth login
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh
# Start a local OpenAI-compatible server with a web UI:
llama serve -hf jxx123/loop-qwen-v8:Q4_K_M
# Run inference directly in the terminal:
llama cli -hf jxx123/loop-qwen-v8:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp
# Start a local OpenAI-compatible server with a web UI:
llama serve -hf jxx123/loop-qwen-v8:Q4_K_M
# Run inference directly in the terminal:
llama cli -hf jxx123/loop-qwen-v8:Q4_K_M
Use pre-built binary
# Download pre-built binary from:
# https://github.com/ggerganov/llama.cpp/releases
# Start a local OpenAI-compatible server with a web UI:
./llama-server -hf jxx123/loop-qwen-v8:Q4_K_M
# Run inference directly in the terminal:
./llama-cli -hf jxx123/loop-qwen-v8:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
cmake -B build
cmake --build build -j --target llama-server llama-cli
# Start a local OpenAI-compatible server with a web UI:
./build/bin/llama-server -hf jxx123/loop-qwen-v8:Q4_K_M
# Run inference directly in the terminal:
./build/bin/llama-cli -hf jxx123/loop-qwen-v8:Q4_K_M
Use Docker
docker model run hf.co/jxx123/loop-qwen-v8:Q4_K_M
Quick Links

You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

loop-qwen-v8 — on-device insulin-dosing controller (Qwen3-4B)

A Qwen3-4B policy distilled from a Gemini-3-flash-preview insulin-control teacher, for closed-loop Type-1-diabetes insulin dosing. It runs on-device (2.5 GB Q4 GGUF via Ollama/llama.cpp; one decision per 5-min loop) and reaches teacher parity in the simglucose closed-loop simulator.

Results (held-out 9 patients, 48 h, seed 42)

TIR (70–180) Survival TBR (<70)
Gemini teacher 73.5% 8/9 7.0%
loop-qwen-v8 (this model) 72.4% 9/9 9.5%

Confirmed on a novel meal scenario (seed 99): 73.0% TIR, 9/9 survival. All-30 patients: v8 75.8% TIR / 28-30 survival vs Gemini 76.6% / 29-30.

Files

  • model.safetensors + config/tokenizer — merged fp16 (for transformers / re-quantizing)
  • loop-qwen-v8-Q4_K_M.gguf — deployable 4-bit (Ollama / llama.cpp)

Usage (Ollama)

ollama create loop-qwen-v8 --quantize q4_K_M -f Modelfile   # or import the gguf
# prompt = patient metadata + 6h CGM/insulin/carb history (JSON)
# output = {"reasoning": "...", "basal_chunk":[5], "bolus_chunk":[5]}

Deployment applies safety clamps: basal ∈ [0,5] U/hr, bolus ∈ [0,20] U.

Recipe

Qwen3-4B + LoRA (r=32) SFT on Gemini Chain-of-Draft demonstrations, +DAgger (relabel student-visited states), + multi-seed meal diversity (the key to matching the teacher without dosing oscillation). Full log: docs/distill_experiment_log.md in the loop-gpt repo.

⚠️ Not a medical device

Research artifact evaluated only in simulation. Residual hypoglycemia (TBR ~10% vs teacher 7%) remains; a low-glucose-suspend safety rail is recommended before any real use. Do not use for actual insulin dosing.

Downloads last month
14
Safetensors
Model size
4B params
Tensor type
F16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for jxx123/loop-qwen-v8

Finetuned
Qwen/Qwen3-4B
Quantized
(283)
this model