Instructions to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0 # Run inference directly in the terminal: llama cli -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0 # Run inference directly in the terminal: llama cli -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Use Docker
docker model run hf.co/jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
- Llama new
- LM Studio
- Jan
- Ollama
How to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with Ollama:
ollama run hf.co/jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
- Unsloth Desktop
- Pi
How to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with Docker Model Runner:
docker model run hf.co/jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
- Lemonade
How to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Run and chat with the model
lemonade run user.MedGemma-2-E4B-it-Weight-Space-Programming-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use jstarks/MedGemma-2-E4B-it-Weight-Space-Programming with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "jstarks/MedGemma-2-E4B-it-Weight-Space-Programming:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
MedGemma-2-E4B-it β Single-Pass Dual-Subspace Woodbury Weight-Space Programmed (Q8_0 + F16 Baked)
Important HAI-DEF & Non-Clinical Research Notice: This artifact is a research derivative of
google/medgemma-2-E4B-it(revision394ee9f08c07a240872abc64a7b63e0bb8cbc13b) andggml-org/medgemma-2-E4B-it-GGUFdistributed under the Health AI Developer Foundations (HAI-DEF) Terms of Use. Use of this model remains governed by those terms. It is intended solely for experimental research and benchmarking β not for clinical diagnosis, patient management, or medical decision-making without independent clinical validation and qualified medical supervision.
What Changed & Why
A 200-task live audit + BF16 activation/logit probe of baseline google/medgemma-2-E4B-it (medgemma-2-E4B-it-Q8_0.gguf) identified two Gemma 4 E4B failure modes alongside strong clinical accuracy:
- Non-Thinking Silent Monologue Cutoffs (
21/100inNT_agent100,2/20inCLIN20_NT): With tools bound andenable_thinking=False, baseline frequently enters an unclosed"Okay, let's see..."monologue untilmax_tokens=1024, causing timeouts in shell routing (EST_NL2BASH:9/20), multi-tool routing (S3_ROUTER:3/5), FHIR lab queries (cf_1), and abstention turns (cr_5). - Thinking Bullet-Outline Cutoffs (
9/60inTH_probe60,1/20inCLIN20_TH): Underenable_thinking=True, bullet-outline verbosity inside<|channel>thoughtexhausts budgets onEST_GSM8K(16/20,cut=4) andEST_HUMANEVAL(11/15,cut=4).
Using Single-Pass Dual-Subspace Woodbury Weight-Space Programming (WSP) (92 strictly disjoint NT + TH calibration examples, 40 general + clinical preservation prompts, min iso_norm_ret = 0.92000), deltas were constrained strictly to 14 linear writers across mid full-attention anchors (L23, L29, L35) and late residual writers (L38, L39, L40, L41) {mlp.down_proj, self_attn.o_proj} (blk.{l}.{ffn_down,attn_output}.weight), SVD-factored at rank=32, and losslessly baked in F16 into medgemma-2-E4B-it-WSP-Q8_0.gguf (scale=1.0). All 706/720 other tensors β including Per-Layer Embeddings (per_layer_token_embd), token_embd, L0..22, norms, and multimodal weights (mmproj-medgemma-2-E4B-it-BF16.gguf) β remain raw byte-for-byte identical (7.454 GiB -> 7.6646 GiB, F16 bake error <= 1.19e-04).
Verified 200-Task Standalone Benchmark (llama-server.exe -c 8192 --jinja)
| Evaluation Track | Baseline Q8_0 |
Baked WSP Q8_0 + F16 (scale=1.0) |
Delta |
|---|---|---|---|
| Grand Total (200 tasks) | 159 / 200 (79.5%) | 175 / 200 (87.5%) | +8.0% (+16 tasks) |
Token Cutoffs (finish_reason=length) |
33 / 200 | 3 / 200 | -90.9% (-30 cutoffs) |
| End-to-End Inference Time | 1469.6 s (24.5 min) | 531.6 s (8.9 min) | 2.76x faster |
NT_agent100 (100 Non-Thinking tasks) |
76/100 (cut=21, 684.6s) |
84/100 (cut=1, 214.6s) |
+8.0% (3.19x faster) |
TH_probe60 (60 Thinking tasks) |
48/60 (cut=9, 541.2s) |
54/60 (cut=2, 248.6s) |
+10.0% (2.17x faster) |
CLIN20_NT (20 Non-Thinking clinical tasks) |
18/20 (cut=2, 104.5s) |
18/20 (cut=0, 19.3s) |
0 cutoffs (5.4x faster) |
CLIN20_TH (20 Thinking clinical tasks) |
17/20 (cut=1, 139.3s) |
19/20 (cut=0, 49.1s) |
+10.0% (2.8x faster) |
Established Benchmarks (105 tasks) |
82 / 105 (78.1%) | 96 / 105 (91.4%) | +13.3% |
EST_NL2BASH (NT) |
9/20 (cut=11) |
18/20 (cut=0) |
+45.0% |
EST_HUMANEVAL (NT + TH, 30 tasks) |
26/30 (15 NT + 11 TH) |
30/30 (15 NT + 15 TH) |
+13.3% (100.0%) |
EST_BFCL_IRR (NT) |
12/15 (cut=2) |
14/15 (cut=0) |
+13.3% |
CLIN_MEDQA_ANCHOR (NT + TH, 10 tasks) |
9/10 | 10/10 | +10.0% (100.0%) |
| BF16 Clinical Prose PPL (20 passages) | 13.7358 |
13.3994 |
-0.3364 (improved) |
Observed Limitations & Trade-Offs
- Non-Thinking Prompt-Injection Guard (
S7_INJ_GUARD NT): Direct no-preamble tool emission reducedS7_INJ_GUARD NT(0/3baseline cutoffs ->0/3executing untrusted<|tool_response>instructions cleanly without cutoff), whereas Thinking ModeS7_INJ_GUARD THimproved to3/3 (100%). When handling untrusted external files/logs/web pages, preferenable_thinking=True(reasoning mode) or enforce sandboxed tool execution policies. - Formatting / Code Block Edge Cases (
S4_CODE NT): BothS4_CODEholdouts (s4_h1_valid_parens,s4_h2_top_k) emitted inline usage examples inside the fenced Python block (2/2 -> 0/2under strict test harness extraction), even though all30/30EST_HUMANEVALtasks passed. - Mental Arithmetic in Non-Thinking Mode:
EST_GSM8K NTshifted19/20 -> 17/20andCLIN_MEDCALC NTshifted5/5 -> 4/5(mc_4_crcl_cg), while Thinking Mode improved (EST_GSM8K TH:16/20 -> 17/20,CLIN_MEDCALC TH:5/5).
Repository Contents
medgemma-2-E4B-it-WSP-Q8_0.gguf(7.6646 GiB): Standalone baked GGUF (14modifiedblk.{23,29,35,38..41}.{ffn_down,attn_output}.weightin losslessF16; remaining706tensors raw byte-exact fromggml-org/medgemma-2-E4B-it-GGUF).mmproj-medgemma-2-E4B-it-BF16.gguf(0.923 GiB): Untouched upstream multimodal projector for image/audio inputs.adapters/medgemma2_e4b_wsp_r32.safetensors&adapters/medgemma2_e4b_wsp_r32.gguf: Portable rank-32 LoRA exports (15.9 MiBeach).scripts/&results/: Reproducible probing, Woodbury WSP synthesis, Pareto scale sweep, lossless F16 GGUF baker, and 200-task audit JSON logs.
Quickstart (llama.cpp)
llama-server -m medgemma-2-E4B-it-WSP-Q8_0.gguf \
--mmproj mmproj-medgemma-2-E4B-it-BF16.gguf \
-ngl 99 -c 8192 -ctk q8_0 -ctv q8_0 --jinja
Attribution
- Upstream weights & clinical pretraining: Google Health AI Developer Foundations (
google/medgemma-2-E4B-it) - Upstream GGUF quantization:
ggml-org/medgemma-2-E4B-it-GGUF
- Downloads last month
- -
8-bit
Model tree for jstarks/MedGemma-2-E4B-it-Weight-Space-Programming
Base model
google/medgemma-2-E4B-it