Downloads · 30 days
11
17% of all-time downloads
outlawpink/rtl-medgemma-lora
rtl-medgemma-lora is a text generation model from outlawpink. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
A PEFT LoRA adapter that extends google/medgemma-4b-it for structured radiology report auditing. Built for the MedGemma Impact Challenge on Kaggle.
Downloads · 30 days
11
17% of all-time downloads
All-time downloads
66
Public
Repo size
101 MB
Likes
0
Public
Click a slice to open those files.
.json167 MB · 76%
From the Hugging Face model README
A PEFT LoRA adapter that extends google/medgemma-4b-it for structured radiology report auditing. Built for the MedGemma Impact Challenge on Kaggle.
The Radiology Trust Layer (RTL) is a 6-step AI pipeline that audits radiology reports against imaging evidence. It extracts claims from free-text reports, analyzes the corresponding medical image with MedGemma's vision encoder, and aligns each claim to visual findings.
This adapter addresses two reliability gaps in the base MedGemma model when used for structured auditing:
Evaluated on 50 held-out synthetic test cases across two task types (JSON schema compliance and uncertainty calibration):
| Metric | Base MedGemma | + RTL LoRA | Delta |
|---|---|---|---|
| JSON Schema Valid Rate | 84.0% | 100.0% | +16.0% |
| Overconfidence Rate | 10.0% | 0.0% | -10.0% |
| Label Value Valid Rate | 80.0% | 100.0% | +20.0% |
| Label Accuracy | 65.3% | 87.3% | +22.0% |
| Schema Repair Needed Rate | 84.0% | 0.0% | -84.0% |
alignments array structure.supported, uncertain, needs_review).from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoProcessor
import torch
base_model_id = "google/medgemma-4b-it"
adapter_id = "outlawpink/rtl-medgemma-lora"
# Load base model (requires HF token for gated model access)
processor = AutoProcessor.from_pretrained(base_model_id, token="YOUR_HF_TOKEN")
model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
token="YOUR_HF_TOKEN",
)
# Load and merge LoRA adapter
model = PeftModel.from_pretrained(model, adapter_id)
model = model.merge_and_unload() # Merge for faster inference
# Inference
prompt = """Align the following claims to the image findings.
Claims: [{"claim_id": "c1", "text": "There is consolidation in the right lower lobe."}]
Respond with JSON: {"alignments": [{"claim_id": "...", "label": "supported|uncertain|needs_review", "evidence": "...", "confidence": 0.0-1.0}]}"""
inputs = processor(text=[prompt], return_tensors="pt").to(model.device)
with torch.no_grad():
output = model.generate(**inputs, max_new_tokens=512, do_sample=False)
response = processor.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
The adapter was trained on synthetic radiology claim-alignment pairs. No real patient data or protected health information (PHI) was used at any stage.
| Parameter | Value |
|---|---|
| Base model | google/medgemma-4b-it (4B parameters) |
| Method | PEFT LoRA (Hu et al., 2021) |
| LoRA rank (r) | 8 |
| LoRA alpha | 16 |
| Target modules | q_proj, v_proj |
| LoRA dropout | 0.05 |
| Quantization | 8-bit (bitsandbytes) |
| Epochs | 3 |
| Batch size | 4 |
| Learning rate | 2e-4 |
| Scheduler | Cosine with warmup |
| Precision | fp16 |
| Framework | PEFT 0.18.1 + TRL SFTTrainer |
| Hardware | Kaggle T4 GPU (16GB VRAM) |
| Training time | ~15 minutes |
| Trainable parameters | ~0.08% of base model |
Training data is formatted using the Gemma chat template:
<start_of_turn>user
{prompt}<end_of_turn>
<start_of_turn>model
{completion}<end_of_turn>
This adapter is designed for use within the Radiology Trust Layer system, specifically for:
supported, uncertain, needs_review)| Resource | Link |
|---|---|
| Live Demo | RTL on Hugging Face Spaces |
| Source Code | GitHub Repository |
| Training Notebook | Kaggle Notebook |
| Competition | MedGemma Impact Challenge |
| Base Model | google/medgemma-4b-it |
@misc{rtl-lora-2025,
title={RTL LoRA: Radiology Trust Layer Adapter for MedGemma},
author={Carmen},
year={2025},
url={https://huggingface.co/outlawpink/rtl-medgemma-lora},
note={MedGemma Impact Challenge submission}
}
This adapter is a research demonstration for the MedGemma Impact Challenge. It is not intended for clinical use. Do not use it to make medical decisions. Always consult qualified radiologists for clinical interpretations.