Instructions to use Japhari/cds-maternal-4b-en with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Japhari/cds-maternal-4b-en with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/medgemma-4b-it") model = PeftModel.from_pretrained(base_model, "Japhari/cds-maternal-4b-en") - Notebooks
- Google Colab
- Kaggle
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
| Property | Value |
|---|---|
| Base model | google/medgemma-4b-it |
| Adapter type | LoRA (PEFT) |
| Task | Causal LM โ structured maternal clinical JSON extraction |
| Language | en |
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| Dropout | 0.05 |
| Target modules | down_proj, gate_proj, k_proj, o_proj, q_proj, up_proj, v_proj |
Training
| Setting | Value |
|---|---|
| Epochs | 1 |
| Train samples | 34000 |
| Peak learning rate | 0.0002 |
| LR schedule | Linear warmup (5%) + linear decay |
| Batch size / grad accumulation | 2 / 8 (effective 16) |
| Precision | bf16 (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:
| Metric | Value |
|---|---|
| Exact match (full structured object) | 97.70% |
| JSON validity rate | 100.00% |
| Condition accuracy | 100.00% |
| ICD-10 accuracy | 100.00% |
| Selection score | 0.9908 |
| Test samples | 1000 |
Comparison Against Baselines
Measured on the identical held-out test set with the identical prompt template:
| System | Exact Match | JSON Valid | Condition 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.
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.
- Downloads last month
- 40