MedGemma Documentation

repository·main·Indexed 23 days ago

https://github.com/google-health/medgemma

MedGemma provides specialized Gemma 3 model variants, including a 4B multimodal model and a 27B text-only model, fine-tuned for medical text and image comprehension. It supports tasks such as chest X-ray anatomy localization, longitudinal comparison, and high-dimensional imaging (CT and digital pathology). The library includes a serving framework for Vertex AI custom containers and supports fine-tuning via Hugging Face using SFT, LoRA, and reinforcement learning. It can also be used to build EHR Navigator Agents for navigating FHIR-formatted data.

Tokens
15K
Snippets
33
Records
64
Agent score
81%

What's inside MedGemma

  1. Overview of MedGemma variants

    main

    MedGemma is a collection of Gemma 3 variants optimized for medical text and image comprehension. It is designed to accelerate the development of healthcare-based AI applications. There are two primary variants available:

    1. MedGemma 4B (Multimodal): Uses a SigLIP image encoder pre-trained on de-identified medical data (chest X-rays, dermatology, ophthalmology, and histopathology) and an LLM component trained on medical images and text.
    2. MedGemma 27B (Text-only): A larger model focused on medical text comprehension.

    Developers can fine-tune these variants for specific performance requirements.

  2. Overview of the MedGemma Serving Framework

    main
    The MedGemma serving framework is a Python library designed to simplify the creation of custom prediction containers for Vertex AI. It provides a structured way to build HTTP servers that comply with Vertex AI custom container requirements. Developers use this framework to implement model-specific HTTP servers by wrapping custom data handling and orchestration logic within the framework's predefined structure.
  3. Get started with MedGemma

    main

    To begin using MedGemma, you can follow these paths:

    • Developer Documentation: Access the full range of next steps and technical details via the official developer documentation.
    • Model Details: Review the model card to understand model performance and characteristics.
    • Code Examples: Explore the ./notebooks directory in this repository for practical implementation examples.
    • Model Access: Download or deploy the models via Hugging Face or Google Cloud Model Garden.
  4. Configure shared memory for MedGemma models

    main

    By default, the container downloads models into shared memory to accommodate Vertex endpoint disk size limits. This requires significant shared memory allocation.

    Suggested shared memory sizes:

    • 4b model: 16 GB
    • 27b model: 80 GB

    How to set shared memory:

    • In Vertex AI: Use the sharedMemorySizeMb parameter during model upload.
    • Via gcloud CLI: Use the --container-shared-memory-size-mb flag when running gcloud ai models upload.

    Optimization: You can reduce shared memory requirements (especially for the 27b model) by setting the environment variable MODEL_TO_DISK="true".

  5. MedGemma 1.5: High-dimensional imaging (CT and Pathology)

    main

    MedGemma 1.5 can be prompted using 3D representations and high-dimensional imaging. Examples are available for both local Hugging Face execution and Vertex AI (Model Garden) deployment:

    • Computed Tomography (CT): Use 3D representations of CT imaging.
    • Digital Pathology: Use whole slide digital pathology imaging.