Reference implementations

Reference implementations provide educational examples built around Google's Health AI Developer Foundations (HAI-DEF) models: narrow Python technical building blocks in the open-source HAI-DEF Cookbook and single-task demo apps. Each resource shows software techniques for specific technical problems and is an educational starting point, not a complete or clinically validated application.

HAI-DEF Cookbook New

⚠ Caution
Educational starting points, not a complete or verified solution. This codebase shows software techniques for narrow technical problems. The code is not production-grade nor validated for clinical use, and does not define a clinical workflow or intended use. To use the code, you need to set up your runtime environment, adapt it to your programming language (it is written in Python), harden and validate your application, and run it against your own instance of HAI-DEF models that you have separately fine-tuned, localized, and evaluated according to your requirements. Code is licensed under Apache 2.0 and provided "as is", without warranty; use of MedGemma or other HAI-DEF model weights remains governed by the HAI-DEF Terms of Use and Prohibited Use Policy.

The HAI-DEF Cookbook is an open-source (Apache 2.0) collection of narrow Python code scaffoldings built around open-weight HAI-DEF models, each showcasing one possible software technique for a specific technical problem. Every folder includes runnable examples, synthetic or openly licensed sample data, unit tests, and AI coding-agent guides (AGENTS.md).

On-device technical building blocks

Offline recipes built around MedGemma 2 E4B 4/8-bit mixed precision (.litertlm) with LiteRT-LM in an agentic configuration, runnable comfortably on devices with 12 GB+ of memory. See the on-device quickstart on GitHub for architecture, tests, and sample data.

Recipe Technical problem it solves Supporting models
Deterministic calculator tools Keep arithmetic out of the model: extract typed inputs from text, call deterministic Python functions, and report their results None
Rule-table tool calling Map free text onto a deterministic rule table's boolean arguments and relay its fixed label and text unchanged None
Three input paths in one session Serve a rule-table tool call, a direct image prompt, and human-reviewed transcript text in one offline process MedASR
Local guideline retrieval Retrieve passages from a local SQLite vector index by on-device cosine similarity, quote them with printed page numbers, and abstain below a threshold EmbeddingGemma 2 (Apache 2.0)
Read a table from a photo Transcribe printed table rows verbatim from a document photograph using vision input alone, with no tool calls None
Document → JSON Extract a photographed or scanned image or PDF page into a fixed JSON schema locally, with no server or terminology lookup None
Document → FHIR R4 Run the open-source Medical Data Toolkit 4-stage pipeline (render, segment, extract Pydantic models, serialize HL7® FHIR® R4 Bundles) on-device None
Audio transcription hand-off Transcribe English WAV audio with a separate ASR model, require human review of the transcript, and pass only reviewed text (never audio) to the LLM MedASR

Demo apps

Demo applications
These first-party demo applications are designed to showcase what can be built with HAI-DEF tools, and they include interactive user interfaces and full code. They are for illustrative purposes and don't represent finished products. Any real-world applications would require additional development, training, and adaptation. The experiences highlighted in these demos showcase the baseline capabilities of HAI-DEF models for the displayed tasks, and are intended to inspire further innovation.

These demos span multiple HAI-DEF model releases. Check each card's badges for the models used.