CoolFace
Modelpublic

Japhari/cds-maternal-4b-en

sourceHugging Faceotherupdated 2mo agoView on Hugging Face
0likes14downloads
Model Card

Japhari/cds-maternal-4b-en

A LoRA adapter fine-tuned on google/medgemma-4b-it for structured clinical data extraction from maternal health case narratives. Given a free-text case story, the model outputs a structured JSON object capturing triage-relevant fields (condition, ICD-10 code, vitals, symptoms, risk factors, etc.).

Model Details

PropertyValue
Base modelgoogle/medgemma-4b-it
Adapter typeLoRA (PEFT)
TaskCausal LM — structured maternal clinical JSON extraction
Languageen
LoRA rank (r)16
LoRA alpha32
Dropout0.05
Target modulesdownproj, gateproj, kproj, oproj, qproj, upproj, v_proj

Training

SettingValue
Epochs1
Train samples34000
Peak learning rate0.0002
LR scheduleLinear warmup (5%) + linear decay
Batch size / grad accumulation2 / 8 (effective 16)
Precisionbf16 (base model loaded 8-bit)

Evaluation Results

Free-running (autoregressive) generation accuracy on the full held-out test set — the deployment-realistic evaluation, not teacher-forced token accuracy:

MetricValue
Exact match (full structured object)97.70%
JSON validity rate100.00%
Condition accuracy100.00%
ICD-10 accuracy100.00%
Selection score0.9908
Test samples1000

Comparison Against Baselines

Measured on the identical held-out test set with the identical prompt template:

SystemExact MatchJSON ValidCondition Acc.ICD-10 Acc.
Zero-shot base google/medgemma-4b-it (no fine-tuning)0.00%68.80%0.00%0.00%
Full fine-tuning (100% of parameters, same data/LR/epochs)96.40%100.00%100.00%98.70%
This adapter (LoRA)97.70%100.00%100.00%100.00%

The unadapted base model rarely produces the correct clinical content even when its JSON is syntactically valid; this adapter closes essentially all of that gap at roughly 1% of the trainable-parameter cost of full fine-tuning.

Usage

This adapter was trained on a specific tagged prompt format — using a different prompt structure at inference time will not reproduce the evaluation numbers above.

python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base_model_id = "google/medgemma-4b-it"
adapter_id = "Japhari/cds-maternal-4b-en"

tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base_model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()

case = """A 28-year-old woman at 36 weeks gestation presents with severe headache,
blurred vision, BP 160/110, +3 proteinuria."""

SYSTEM_PROMPT = "You are a maternal triage information extractor. Return ONLY compact JSON, no prose. Preserve numeric values from the case exactly when provided. Always include the best matching icd10Code. Do not invent patientId when it is not present in the story."
prompt = f"<system>\n{SYSTEM_PROMPT}\n</system>\n<user>\n{case}\n</user>\n<assistant>\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.no_grad():
    output = model.generate(**inputs, max_new_tokens=220, do_sample=False)

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

Intended Use

  • —Research and prototyping for maternal triage decision-support tools.
  • —Assistive extraction of structured data from clinical notes to reduce manual documentation burden.
  • —Outputs must be reviewed by a qualified clinician before influencing any clinical decision.

Limitations

  • —Not for autonomous clinical use. This model does not replace clinical judgement and has not undergone prospective clinical validation.
  • —Evaluation metrics reflect structured-JSON generation fidelity (exact match, field accuracy against reference annotations), not validated clinical diagnostic accuracy.
  • —Field-level precision/recall against clinician-adjudicated ground truth, and hallucination rate on out-of-distribution presentations, have not yet been measured.
  • —Trained for a single epoch on one language; performance on writing styles, abbreviations, or terminology outside the training distribution is unverified.

License

Inherits the license of the base model (google/medgemma-4b-it). Check Google's MedGemma terms of use before deployment.