MedGemma-4B-Medical-notes — Clinical Documentation & Section Summarization

A QLoRA fine-tune of google/medgemma-4b-it for converting doctor–patient dialogues into structured clinical notes and extracting individual note sections from medical transcriptions.

The adapter was trained on a mixed-family curriculum drawn from ACI-Bench and MTS-Dialog, with a controllable draw-probability sampler to balance the two tasks during training.

Model Details

Model Description

This adapter turns MedGemma-4B into a clinical scribe: given a doctor–patient conversation, it produces either a complete clinical note (Chief Complaint, HPI, Assessment & Plan, etc.) or a specific section (e.g., Medications, Past Medical History) depending on the prompt template used.

Training was performed using 4-bit NF4 quantisation (QLoRA) with LoRA adapters scoped exclusively to the language tower's attention and MLP projections, leaving the vision encoder frozen and untouched.

Model Sources


Uses

Direct Use

Generate structured clinical notes from doctor–patient dialogue transcripts. Two prompt families are supported:

Family Input Output
ACI (full note) Complete encounter dialogue Full clinical note (CC, HPI, ROS, PE, A&P, etc.)
MTS (section) Clinical transcription + target section header Content for that specific section

Downstream Use

  • Integration into ambient clinical documentation (ACD) workflows
  • EHR note-drafting assistants
  • Clinical NLP pipelines that require dialogue-to-note conversion

Out-of-Scope Use

  • Not for clinical decision-making. This model summarises spoken content — it does not diagnose, prescribe, or recommend treatment.
  • Not for non-English text. Trained and evaluated on English clinical dialogues only.
  • Not for image-based tasks. Although MedGemma is a vision-language model, the LoRA adapters were scoped to the language tower only; the vision encoder was frozen and is untested with this adapter.
  • Not a substitute for a licensed clinician's review. All generated notes should be reviewed and edited by a qualified healthcare professional before entering a medical record.

Bias, Risks, and Limitations

  • Grounding errors: The model may occasionally infer information not explicitly stated in the dialogue, despite strict-grounding instructions in the prompt.
  • Dataset bias: Training data comes from ACI-Bench and MTS-Dialog, which may not represent all medical specialities, patient demographics, or documentation styles.
  • BERTScore truncation: BERTScore uses roberta-large (512-token context). ACI full notes average ~599 tokens, so the tail of longer notes is not captured by this metric. The reported BERTScore is effectively "over the first 512 tokens". ROUGE metrics are unaffected.
  • Section coverage: MTS-Dialog sections cover a subset of possible clinical note sections; unseen section headers may produce lower-quality output.

Recommendations

Users should treat model outputs as drafts that require clinical review. We recommend running the model with greedy decoding (do_sample=False) for deterministic, reproducible outputs in production settings.


How to Get Started with the Model

from peft import PeftModel
from transformers import AutoModelForImageTextToText, AutoProcessor, BitsAndBytesConfig
import torch

# 1. Load the base model in 4-bit
bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_use_double_quant=True,
)

base_model = AutoModelForImageTextToText.from_pretrained(
    "google/medgemma-4b-it",
    device_map="auto",
    quantization_config=bnb_config,
    torch_dtype=torch.bfloat16,
    attn_implementation="eager",
)

# 2. Load the LoRA adapter
model = PeftModel.from_pretrained(base_model, "Tser-vak/medgemma-4b-medical-notes")
model.eval()

# 3. Load the processor
processor = AutoProcessor.from_pretrained("Tser-vak/medgemma-4b-medical-notes")
processor.tokenizer.padding_side = "left"

# 4. Build a prompt (ACI full-note example)
dialogue = "[doctor] So what brings you in today? [patient] I've been having chest pain..."

messages = [
    {
        "role": "user",
        "content": (
            "You are an expert clinical scribe. Summarize the doctor-patient "
            "dialogue below into a clinical note. "
            "Strict Grounding Rules:\n"
            "- Record only facts, symptoms, medications, dosages, and exam "
            "findings explicitly spoken by either speaker.\n"
            "- If a section or finding was not discussed, omit it entirely "
            "or state 'Not discussed'.\n"
            "- Do not infer or extrapolate diagnoses.\n\n"
            f"Dialogue:\n{dialogue}\n\n"
            "Clinical Note:"
        ),
    }
]

prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor.tokenizer(prompt, return_tensors="pt").to(model.device)

# 5. Generate (greedy, deterministic)
with torch.inference_mode():
    output = model.generate(
        **inputs,
        do_sample=False,
        max_new_tokens=1536,
        eos_token_id=[
            processor.tokenizer.eos_token_id,
            processor.tokenizer.convert_tokens_to_ids("<end_of_turn>"),
        ],
        pad_token_id=processor.tokenizer.pad_token_id,
    )

new_tokens = output[:, inputs["input_ids"].shape[1]:]
print(processor.tokenizer.decode(new_tokens[0], skip_special_tokens=True))

Training Details

Training Data

Dataset Family Train Rows Description
ACI-Bench ACI (full notes) ~147 Doctor–patient dialogues → complete clinical notes
ACI Synthetic + TaskB/C ACI (full notes) Additional pool rows Augmented / competition splits merged into the train pool
MTS-Dialog MTS (sections) ~1195 Dialogues → individual note sections (e.g., Medications, History)

Train/test deduplication was performed to remove hash collisions between train and held-out splits. The ACI validation split (20 rows) was held out for checkpoint selection.

Training Procedure

Preprocessing

  • Speaker-tag normalisation (four roles → [doctor]/[patient])
  • MTS section-header expansion via a curated normalisation map
  • Dead-section and empty-row removal
  • Text cleaning with ftfy (mojibake repair)
  • Dialogue–note hash deduplication across train ↔ test boundaries

Training Hyperparameters

Parameter Value
Base model google/medgemma-4b-it
Quantisation NF4 4-bit (double quant), compute dtype bfloat16
LoRA rank (r) 16
LoRA alpha 32 (scaling = α/r = 2.0)
LoRA dropout 0.05
LoRA targets q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj — language tower only
Training regime bf16 mixed precision
Optimiser paged_adamw_8bit
Learning rate 2e-4 (cosine schedule)
Warmup 3% of total steps
Effective batch size 16 (per-device 2 × grad accumulation 8)
Max sequence length 4608 tokens
Loss masking completion_only_loss=True (prompt/completion format)
ACI draw probability (p) 0.5
Epochs (approx.) ~2.0 (stopped at best eval_aci_val_loss)
Checkpoint selection Best eval_aci_val_loss (every 25 steps)
Seed 42

Best Checkpoint Metrics (epoch ≈ 1.97)

Metric Value
Train loss 0.5722
Train mean token accuracy 82.2%
Grad norm 0.9492
ACI val loss 0.9046
ACI val mean token accuracy 76.0%
MTS val loss 1.2400
MTS val mean token accuracy 70.1%

Evaluation

Testing Data

  • ACI test (aci_test.csv): 40 frozen held-out full-note encounter dialogues from ACI-Bench (CLEF 2023 Task C test3). Never used during training or checkpoint selection.

Results

ACI Test Set (n = 40)

Metric Mean 95% CI
ROUGE-1 0.6227 [0.5737, 0.6623]
ROUGE-2 0.3551 [0.3151, 0.3907]
ROUGE-L 0.4239 [0.3855, 0.4615]
BERTScore 0.8965 [0.8863, 0.9058]

Summary

The fine-tuned model achieves strong lexical overlap with reference clinical notes (ROUGE-1 > 0.62) and high semantic similarity (BERTScore ≈ 0.90) on the frozen ACI test split, indicating that generated notes closely match the structure and content of ground-truth clinical documentation. Per-example predictions and references are available in results_hold.csv.


Technical Specifications

  • Hardware type: NVIDIA L4 GPU (GCP)
  • Training time: ~6 hours
  • Cloud provider: Google Cloud Platform (GCP)
  • Quantisation framework: bitsandbytes (NF4)
  • Training framework: HuggingFace TRL SFTTrainer (v1.8.0)
  • PEFT framework: peft v0.19.1
  • Transformers: v5.13.1

Citation

If you use this model, please cite MedGemma:

Gemma is provided under and subject to the Gemma Terms of Use found at ai.google.dev/gemma/terms

@article{medgemma2025,
  title={MedGemma: Medical Gemma Model Family},
  author={Google DeepMind and Google Research},
  year={2025},
  url={https://huggingface.co/google/medgemma-4b-it}
}

And the training data sources:

@inproceedings{yim2023aci,
  title={ACI-BENCH: a Novel Ambient Clinical Intelligence Dataset for Benchmarking Automatic Visit Note Generation},
  author={Yim, Wen-wai and Fu, Yujuan and Ben Abacha, Asma and Snider, Neal and Lin, Thomas and Yetisgen, Meliha},
  booktitle={Scientific Data},
  year={2023}
}

@inproceedings{abacha2023mtsdialog,
  title={An Empirical Study of Clinical Note Generation from Doctor-Patient Encounters},
  author={Ben Abacha, Asma and Yim, Wen-wai and Fan, Yadan and Lin, Thomas},
  booktitle={Proceedings of the 17th Conference of the European Chapter of the ACL},
  year={2023}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for Tser-vak/medgemma-4b-medical-note

Adapter
(116)
this model

Space using Tser-vak/medgemma-4b-medical-note 1