Skip to article
IICTPIICTP

Blog / AI & Machine Learning / Local & Private LLMs

Local & Private LLMsDecember 4, 20267 MIN READ

How to run MedGemma 2 locally with Ollama, step by step

Short answer: install Ollama, run the command ollama run medgemma2, and you have the E4B model answering on your own machine. Use the 26b tag for the larger model. This guide covers choosing a tag, the first prompt, images, the local API, Python, structured output and the checks to make before anyone relies on it.

MedGemma wordmark on a dark background, from the Ollama library page
Image: Ollama library page for medgemma2.

TL;DR The short version

  • Install Ollama and run ollama run medgemma2 for E4B, or use the 26b tag for the larger model.
  • The guide covers tags, images, the local API, Python and JSON schema output.
  • Keep the port local, pin the model ID and re-test after every change.
In this post
  1. TL;DR
  2. What do you need?
  3. Which Ollama tag should you pull?
  4. How do you install and run it?
  5. How do you call it from your own software?
  6. What about audio, phones and the cloud?
  7. How do you keep it private and safe?
  8. What should you try if it fails?
  9. Frequently asked questions
  10. Related reading
  11. Sources and further reading

Short answer: install Ollama, run the command ollama run medgemma2, and you have the E4B model answering on your own machine. Use the 26b tag for the larger model. This guide covers choosing a tag, the first prompt, images, the local API, Python, structured output and the checks to make before anyone relies on it.

What do you need?

  • A current version of Ollama from ollama.com/download.
  • Free disk space for the download: from 6.6 GB for the smallest E4B tag to 52 GB for the largest 26B tag.
  • Enough memory to load the weights plus the context. See how much RAM or VRAM a local LLM needs.
  • Synthetic or de-identified test data.

Which Ollama tag should you pull?

TagDownload sizeContextPick it when
medgemma2 or medgemma2:e4b6.6 to 7.5 GB128KYou are starting out on a laptop
medgemma2:e4b-q8_09.0 GB128KYou want less compression
medgemma2:e4b-bf1616 GB128KYou want full precision E4B
medgemma2:26b18 to 19 GB256KYou have a large GPU or high-memory Mac
medgemma2:26b-q8_028 GB256KQuality matters more than memory
medgemma2:26b-bf1652 GB256KServer-class evaluation
Source: Ollama tags page, read 4 December 2026. Tags with mlx in the name are built for Apple’s MLX.

How do you install and run it?

  1. Install Ollama. Download the installer for macOS, Windows or Linux from ollama.com/download, then confirm it is on your path.

    ollama --version
  2. Download the model. Start with E4B. Pull the 26B tag only if your hardware can hold it.

    ollama pull medgemma2
    # larger model
    ollama pull medgemma2:26b
  3. Ask a first question. This opens a chat in the terminal. Type /bye to leave.

    ollama run medgemma2
    >>> Explain what an HbA1c test measures, in four sentences.
  4. Give it an image. Put the image path in the prompt. Use a public or de-identified teaching image.

    ollama run medgemma2 ./teaching-xray.png "Describe what is visible. Say what you cannot determine."
  5. Raise the context for long records. Ollama’s default context can be far smaller than the model’s limit. Set it inside the chat, and expect memory use to rise.

    >>> /set parameter num_ctx 32768
  6. Check where it is running. This shows whether the model is on the GPU, the CPU or split between them.

    ollama ps

How do you call it from your own software?

Ollama serves a local API on port 11434.

  1. Call the REST API. Any language that can send HTTP can use the model.

    curl http://localhost:11434/api/chat \
      -d '{
        "model": "medgemma2",
        "messages": [{"role": "user", "content": "List the SOAP note sections."}],
        "stream": false
      }'
  2. Use Python. Install the official client, then send a message. Keep a system message that tells the model to admit gaps.

    # pip install ollama
    from ollama import chat
    
    r = chat(model='medgemma2', messages=[
        {'role': 'system', 'content': 'If information is missing, say so. Do not guess.'},
        {'role': 'user', 'content': 'Summarise: 61-year-old, cough for 3 weeks, non-smoker.'},
    ])
    print(r.message.content)
  3. Force a fixed shape. Pass a JSON schema in format so your code receives fields it can check.

    from ollama import chat
    from pydantic import BaseModel
    
    class Lab(BaseModel):
        test: str
        value: float | None
        unit: str | None
    
    class Report(BaseModel):
        labs: list[Lab]
    
    text = 'Synthetic report: haemoglobin 10.9 g/dL. Sodium not reported.'
    r = chat(model='medgemma2', format=Report.model_json_schema(),
             messages=[{'role': 'user', 'content': 'Extract the lab results as JSON: ' + text}])
    print(Report.model_validate_json(r.message.content))
  4. Send an image from code. The Python client accepts a file path in images.

    from ollama import chat
    
    r = chat(model='medgemma2', messages=[{
        'role': 'user',
        'content': 'Describe this teaching image. State your uncertainty.',
        'images': ['./teaching-image.png'],
    }])
    print(r.message.content)

What about audio, phones and the cloud?

  • Audio. Ollama’s page says E4B takes audio, but its tag list showed only text and image input when we read it. Test before you plan around speech.
  • Phones and tablets. Google offers a mixed-precision E4B build for LiteRT-LM, with ready converted checkpoints on Hugging Face.
  • Other runtimes. Google also points to Transformers, vLLM, llama.cpp, MLX and Unsloth.
  • Managed hosting. Model Garden on Google Cloud can serve online endpoints or batch jobs inside your own network boundary.

How do you keep it private and safe?

  1. Keep the port local. Ollama listens on 127.0.0.1 by default. If a team needs access, put it behind your own authentication and TLS rather than opening the port.

  2. Pin the tag and record the ID. The latest tag can move. Run the list command and write the ID into your evaluation notes.

    ollama list
  3. Log carefully. Prompts may contain patient details. Decide what is stored, who can read it and when it is deleted.

  4. Re-test after every change. A new tag, quantisation or runtime version is a new system. Run your test cases again.

What should you try if it fails?

  • The model is very slow. Check ollama ps. A split between CPU and GPU means the model or context does not fit.
  • Out of memory. Lower num_ctx, use a smaller tag or move to E4B.
  • Long documents are ignored. The context is probably too small.
  • Pull fails or the model will not load. Update Ollama, then try again.

MedGemma 2 is a starting point for developers, not a clinical tool. Google says its outputs are not intended to directly inform diagnosis, patient management or treatment, and need independent verification. Use synthetic or properly de-identified data while you build.

Sources were read on 4 December 2026. We have not benchmarked or run MedGemma 2 ourselves, and tags, sizes and terms can change, so check the linked originals.

Frequently asked questions

  • What is the command to run MedGemma 2? ollama run medgemma2 for E4B, or ollama run medgemma2:26b.
  • Do I need a GPU? E4B can run without a large GPU at reduced speed if memory allows. The 26B model realistically needs a large GPU or a high-memory Mac.
  • Does my data leave the machine? With a local model and local tools it does not need to. Check any other tool you connect.

Sources and further reading

  1. Ollama. medgemma2 library page and tags. https://ollama.com/library/medgemma2
  2. Google Research. Fereshteh Mahvar and Maddie Traverse. Introducing MedGemma 2: Our most capable open model for health AI developers. 3 December 2026. https://research.google/blog/introducing-medgemma-2-our-most-capable-open-model-for-health-ai-developers/
  3. Ollama documentation: vision, tool calling and structured outputs. https://docs.ollama.com/capabilities/vision, https://docs.ollama.com/capabilities/tool-calling, https://docs.ollama.com/capabilities/structured-outputs
  4. Google. Health AI Developer Foundations terms of use. https://developers.google.com/health-ai-developer-foundations/terms
Cite this article

Go deeper: LLMP™ credential · the TPBOK™ standard · Domain: Applied AI & Emerging Tech Integration · Check your experience

IICTP is an independent technical credentialing body.

Practitioners on Contour

New guides in your inbox

Plain-language guides on technical practice, now and then. You confirm your address first, and you can unsubscribe at any time.

Keep reading

← All posts

Where do you stand?

Find the credential that fits the work you do.

Keyboard shortcuts

LListen, pause or resume
SSave or unsave this post
FFocus mode on or off
TJump to the TL;DR
NNext post in this topic
PPrevious post in this topic
QCopy a link to the selected text
?Show this list