698 Downloads Updated 1 month ago
ollama run dcarrascosa/medgemma-1.5-4b-it:Q4_K_M
Updated 1 month ago
1 month ago
b90601f010ec · 3.3GB ·
This repository provides an Ollama-ready build of Google’s MedGemma 1.5 4B instruction-tuned model:
google/medgemma-1.5-4b-itThis repo publishes the same model under multiple precision/quantization tags so you can choose quality vs speed:
:F16 — full precision (best quality, highest VRAM/RAM):Q8_0 — high-quality quant (strong quality/speed trade-off):Q4_K_M — smaller/faster quant (best for local demos / edge-ish constraints)MedGemma is intended as a developer foundation model, not a drop-in clinical system.
This model can generate medical content and may sound authoritative. Always:
Follow Ollama installation for your OS, then:
ollama --version
ollama list
ollama run dcarrascosa/medgemma-1.5-4b-it:Q8_0 "Summarize possible causes of upper abdominal discomfort after overeating and list red flags."
Ollama supports constraining model output to valid JSON using a JSON Schema via format.
$schema = @{
type="object"
required=@("summary","differential","next_steps","red_flags")
properties=@{
summary=@{type="string"}
differential=@{type="array"; items=@{type="string"}; maxItems=3}
next_steps=@{type="array"; items=@{type="string"}; maxItems=4}
red_flags=@{type="array"; items=@{type="string"}; maxItems=5}
}
}
$body = @{
model="dcarrascosa/medgemma-1.5-4b-it:Q4_K_M"
messages=@(@{
role="user"
content="Return JSON only. Adult (45M) ate a large meal 2 hours ago; now mild nausea and upper abdominal fullness. No fever, vomiting, black stools. Give general guidance, differential, next steps, red flags."
})
format=$schema
options=@{
temperature=0.2
top_p=0.9
repeat_penalty=1.25
num_predict=1200
}
stream=$false
} | ConvertTo-Json -Depth 10
$res = Invoke-RestMethod http://localhost:11434/api/chat -Method Post -ContentType "application/json" -Body $body
$res.message.content | ConvertFrom-Json | Format-List
Tip: Keep schemas practical. Overly strict schemas can reduce answer quality.
Ollama vision works through /api/chat by passing base64 images in messages[].images.
$imgPath = "C:\Users\User\Downloads\00000001_000.png"
$imgB64 = [Convert]::ToBase64String([IO.File]::ReadAllBytes($imgPath))
$schema = @{
type="object"
required=@("findings","differential","next_steps")
properties=@{
findings=@{type="array"; items=@{type="string"}}
differential=@{type="array"; items=@{type="string"}; maxItems=3}
next_steps=@{type="array"; items=@{type="string"}; maxItems=3}
}
}
$body = @{
model="dcarrascosa/medgemma-1.5-4b-it:Q8_0"
messages=@(@{
role="user"
content="Return JSON only. Analyze this chest X-ray. Provide findings, differential (max 3), next steps (max 3). Avoid repetition."
images=@($imgB64)
})
format=$schema
options=@{
temperature=0.2
repeat_penalty=1.25
num_predict=1200
}
stream=$false
} | ConvertTo-Json -Depth 10
$res = Invoke-RestMethod http://localhost:11434/api/chat -Method Post -ContentType "application/json" -Body $body
$res.message.content | ConvertFrom-Json | Format-List
Important: For medical imaging, treat outputs as non-diagnostic and validate with a clinician and real datasets.
Ollama can return structured “tool calls” if your application layer implements a tool schema and runs the tools. The model doesn’t execute tools by itself—you do.
Typical loop:
Best use cases:
Security tip: Validate tool args. Treat them as untrusted input.
Some models emit visible “thinking” tokens depending on the template and model behavior. For production:
If you need strict separation (final vs reasoning), enforce it via JSON schema fields like { "final": "...", "reasoning": "..." }.
These are sane defaults for a “medical assistant” style:
temperature: 0.2top_p: 0.9repeat_penalty: 1.25num_predict: 1200 (raise to 4096 if you want long structured outputs)This Ollama repo packages the upstream model:
google/medgemma-1.5-4b-itPlease cite the upstream technical report when appropriate:
Sellergren et al., “MedGemma Technical Report.” arXiv:2507.05201 (2025).
Use is governed by the Health AI Developer Foundations terms of use. Ensure your downstream use and any redistribution complies with those terms.