Downloads · 30 days
7
11% of all-time downloads
Japhari/cds-maternal-4b-en
cds-maternal-4b-en is a text generation model from Japhari. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as other.
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 triag…
Downloads · 30 days
7
11% of all-time downloads
All-time downloads
65
Public
Repo size
165 MB
Likes
0
Public
Click a slice to open those files.
.safetensors131 MB · 80%
From the Hugging Face model README
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.).
| 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 |
| 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) |
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 |
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.
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))
Inherits the license of the base model (google/medgemma-4b-it). Check Google's MedGemma terms of use before deployment.