# rishi-1482/finetuning-medgemma-27b architecture

> Architecture diagram of the GitHub repository rishi-1482/finetuning-medgemma-27b, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishi-1482/finetuning-medgemma-27b
- Repository: https://github.com/rishi-1482/finetuning-medgemma-27b

## Overview

This repository is a notebook-based guide to fine-tuning MedGemma into an empathetic medical assistant. Its documented workflow prepares conversational data, configures a quantized base model and LoRA adapters, performs supervised fine-tuning, then uses the trained adapter for inference. The README also highlights paged optimization and gradient checkpointing. No notebook source was available, so the graph reflects documented stages and data flow rather than verified implementation-level calls.

Main entry points: [`finetuning_LoRA-2.ipynb`](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb) (Supervised fine-tuning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset["Medical conversations"]
  node_loading["Data loading"]
  node_formatting["Prompt formatting"]
end

subgraph group_training["Model training"]
  node_base_model["MedGemma 27B"]
  node_quantization["4-bit quantization"]
  node_lora["LoRA adapters"]
  node_optimizer["Paged optimizer"]
  node_checkpointing["Gradient checkpointing"]
  node_sft["Supervised fine-tuning"]
  node_trained_adapter["Trained adapter"]
end

subgraph group_inference["Inference"]
  node_inference["Adapter inference"]
  node_response["Medical assistant response"]
end

node_researcher(("Researcher"))
node_notebook["Fine-tuning notebook"]

node_researcher -->|"runs"| node_notebook
node_notebook -->|"orchestrates"| node_loading
node_dataset -->|"loads"| node_loading
node_loading -->|"formats data"| node_formatting
node_notebook -->|"configures"| node_quantization
node_base_model -->|"quantizes"| node_quantization
node_quantization -->|"prepares model"| node_lora
node_notebook -->|"runs"| node_sft
node_formatting -->|"provides examples"| node_sft
node_lora -->|"provides adapters"| node_sft
node_sft -->|"uses"| node_optimizer
node_sft -->|"uses"| node_checkpointing
node_sft -->|"produces"| node_trained_adapter
node_notebook -->|"runs"| node_inference
node_trained_adapter -->|"loads"| node_inference
node_inference -->|"generates"| node_response

click node_notebook "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_loading "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_formatting "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_quantization "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_lora "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_optimizer "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_checkpointing "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_sft "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"
click node_inference "https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dataset,node_loading,node_formatting toneBlue
class node_base_model,node_quantization,node_lora,node_optimizer,node_checkpointing,node_sft,node_trained_adapter toneAmber
class node_inference,node_response toneMint
class node_researcher toneIndigo
class node_notebook toneTeal
```

## Components

### Data preparation

- **Medical conversations**
- [Data loading](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`
- [Prompt formatting](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`

### Model training

- **MedGemma 27B**
- [4-bit quantization](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`
- [LoRA adapters](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`
- [Paged optimizer](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`
- [Gradient checkpointing](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`
- [Supervised fine-tuning](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`
- **Trained adapter**

### Inference

- [Adapter inference](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`
- **Medical assistant response**

### Other components

- **Researcher**
- [Fine-tuning notebook](https://github.com/rishi-1482/finetuning-medgemma-27b/blob/main/finetuning_LoRA-2.ipynb): `finetuning_LoRA-2.ipynb`

## Connections

- Researcher → Fine-tuning notebook: runs
- Fine-tuning notebook → Data loading: orchestrates
- Medical conversations → Data loading: loads
- Data loading → Prompt formatting: formats data
- Fine-tuning notebook → 4-bit quantization: configures
- MedGemma 27B → 4-bit quantization: quantizes
- 4-bit quantization → LoRA adapters: prepares model
- Fine-tuning notebook → Supervised fine-tuning: runs
- Prompt formatting → Supervised fine-tuning: provides examples
- LoRA adapters → Supervised fine-tuning: provides adapters
- Supervised fine-tuning → Paged optimizer: uses
- Supervised fine-tuning → Gradient checkpointing: uses
- Supervised fine-tuning → Trained adapter: produces
- Fine-tuning notebook → Adapter inference: runs
- Trained adapter → Adapter inference: loads
- Adapter inference → Medical assistant response: generates
