A LoRA adapter for google/gemma-4-E4B-it that grades a patient's teach-back before hospital discharge. Given the discharge facts a patient must understand and what the patient (or a caregiver) said back in their own language, it grades every fact as correct, partial, incorrect or missing, with a short English rendering of what it heard and one sentence to re-teach.
It is the on-site grader of Homeward, built for the AMD Developer Hackathon: ACT III (Health and Wellbeing track) by team Solus. Trained and evaluated on one AMD Radeon PRO W7900D (48 GB) with ROCm.
Published model: Homeward adapter, run 4 (eval key homeward_run4), applied at LoRA scale 1.
The test set is synthetic. The grader has not been tested with real patients.
Teach-back means asking the patient to explain their instructions in their own words. Homeward asks open questions by voice, one per screen, in the patient's language, and this adapter grades each answer against the facts the nurse confirmed:
| Verdict | Meaning |
|---|---|
| correct | conveys the fact accurately enough to act on safely (paraphrase and everyday medicine names are fine if unambiguous) |
| partial | conveys part of it but leaves out or is vague about a key element; says nothing wrong |
| incorrect | says something that conflicts with the fact (wrong dose, timing, medicine, action, threshold, date or person) |
| missing | does not mention it |
When unsure between two verdicts, the prompt asks for the less reassuring one. Output is JSON only:
{"facts": [{"id": "f1", "verdict": "correct|partial|incorrect|missing", "heard": "short English rendering, empty if missing", "reteach": "one short English sentence, empty if correct"}]}
The exact system and user prompt is in grader_prompt.json (the same file the app, training and evaluation use). In the app, a code rule (not the model) marks "understanding confirmed" only when every critical fact is graded correct; anything else goes back to the nurse.
Languages: Arabic, Bengali, Chinese, English, French, Hindi, Italian, Portuguese, Spanish, Tagalog, Tamil, Vietnamese.
All training data is synthetic and fictional. Cases and patient answers were written only by open models served on AMD Token Factory; the labels come from those open models plus Cloudflare Clef, also served on Token Factory, as one extra vote. Clef is post-trained from Qwen3.8-27B; we could not confirm that its own weights are open. No Claude output and no real patient data was used for training.
heard and reteach targets are the 31B's wording where it is the label source, otherwise the wording of the label that won.LoRA on the attention and MLP projections of the language model only (q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj); the vision and audio towers are frozen and untouched. Loss on the assistant reply tokens only.
| Setting | Value |
|---|---|
| LoRA rank / alpha / dropout | 32 / 32 / 0.05 |
| LoRA modules | 258 |
| Trainable parameters | 69,763,072 of 8,010,863,904 |
| Learning rate, schedule | 0.0002, linear warm-up (0.05 of steps) then cosine, AdamW, no weight decay |
| Epochs, optimiser steps | 2, 468 |
| Batch | 4 x 4 gradient accumulation = 16 sequences per step, max length 1536 tokens |
| Training rows | 3,738 |
| Target order | heard before verdict in each fact's JSON |
| Verdict loss weight | 3 on the verdict-value tokens |
| Unlikelihood term | 0.5 on P("correct") wherever the gold verdict is incorrect or missing (half for partial), to push against false reassurance |
| Gradient checkpointing | on |
| Precision | bf16 |
| Seed | 1234 |
| Epoch averaging | none: the published weights are the adapter at the end of training |
| LoRA scale at inference | 1 (each LoRA module's scaling multiplied by this before merging; chosen on validation) |
| Decoding | greedy decoding, one pass; escalation threshold 0.5 (0 means no extra escalation) |
Hardware and software: one AMD Radeon PRO W7900D (48 GB, gfx1100) on the AMD hackathon notebook service, ROCm, PyTorch 2.13.0+rocm10.0.0, Transformers 5.19.0, PEFT 0.21.2. Training took 58.8 minutes at 1,045 tokens/s, peak 23.6 GiB allocated; validation loss 0.792 before training, 0.331 after.
val_independent, cases separate from the test set). Chosen: run4_final at LoRA scale 1, escalation threshold 0.5.Metrics: accuracy is the share of facts whose verdict equals the designed verdict. A "critical miss passed" is a fact marked critical that the speaker got wrong or left out but that the system graded correct: the unsafe error. False reassurance is the same over all facts. Over-flag is the share of facts the speaker got right that were not graded correct (extra nurse work, not unsafe). 95% intervals are case-level bootstrap with 1,000 resamples. Unreadable verdicts count as wrong for every system.
| System | Size | Ran on | Accuracy (95% CI) | Macro-F1 | Critical misses passed | False reassurance, all facts | Over-flag | Valid JSON |
|---|---|---|---|---|---|---|---|---|
| Gemma 4 31B (teacher) | 30.7B dense | AMD Token Factory | 97.1% (94.9–99.1) | 0.971 | 1 of 108 | 0.7% | 2.9% | 100.0% |
| Homeward adapter (run 4) | 8B total, 4.5B effective, plus 69.8M LoRA parameters | AMD Radeon PRO W7900D | 94.7% (91.9–97.5) | 0.946 | 1 of 108 | 1.4% | 2.9% | 100.0% |
| Qwen3.8 Flash Next | 180B total, 6B active | AMD Token Factory | 91.2% (89.7–92.8) | 0.913 | 1 of 108 | 0.7% | 8.7% | 99.3% |
| Cloudflare Clef | 27B dense | AMD Token Factory | 88.9% (86.1–92.7) | 0.897 | 1 of 108 | 0.7% | 13.0% | 100.0% |
| MiniCPM-V 4.7 35B-A3B | 35B total, about 3B active | AMD Token Factory | 85.9% (79.4–90.7) | 0.852 | 3 of 108 | 2.2% | 13.8% | 100.0% |
| Gemma 4 E4B, base (no adapter) | 8B total, 4.5B effective | AMD Radeon PRO W7900D | 83.0% (80.6–85.8) | 0.832 | 5 of 108 | 4.3% | 10.9% | 100.0% |
| DeepSeek V4 Flash | 284B total, 13B active | AMD Token Factory | 80.4% (73.4–86.3) | 0.825 | 3 of 108 | 2.9% | 14.5% | 90.7% |
Sizes are total parameters from the makers' model cards. Gemma 4 31B is the teacher whose labels trained this adapter, so it is shown as the reference this adapter learned from rather than as a competitor. Comparators ran zero-shot on AMD Token Factory with the same grader prompt and the same scoring; only this adapter was fine-tuned for the task. Cloudflare Clef is a decision model with its own endpoint, so it was asked one multiple-choice question per fact with the same grading criteria instead of the free-text prompt. The difference between this adapter and the run 2 adapter (branch run2, below) is not significant on this set (exact McNemar p = 0.8). Gemma 4 E4B base and this adapter ran on the W7900D.
Per language (this adapter):
| Language | Facts | Accuracy |
|---|---|---|
| Arabic | 31 | 93.5% |
| Bengali | 25 | 92.0% |
| Chinese | 30 | 96.7% |
| English | 28 | 96.4% |
| French | 30 | 96.7% |
| Hindi | 30 | 93.3% |
| Italian | 28 | 92.9% |
| Portuguese | 31 | 93.5% |
| Spanish | 27 | 96.3% |
| Tagalog | 26 | 92.3% |
| Tamil | 29 | 96.6% |
| Vietnamese | 26 | 96.2% |
Confusion matrix (this adapter, facts):
| Gold \ predicted | correct | partial | incorrect | missing | unreadable |
|---|---|---|---|---|---|
| correct | 134 | 4 | 0 | 0 | 0 |
| partial | 1 | 63 | 0 | 1 | 0 |
| incorrect | 2 | 10 | 84 | 0 | 0 |
| missing | 0 | 0 | 0 | 42 | 0 |
On a second, generator-labelled test split (348 answers from held-out cases, labels written by the same models that wrote the training data, so noisier) the adapter scores 86.0% (83.3–88.7) and the 31B teacher 85.3%; the run 2 adapter scores 87.0%. The independent set above is the headline because its labels do not come from the training-data pipeline.
Bf16, LoRA merged: 1.47 answers per second at batch 16, 4.9 s per answer at batch 1 (median), peak 16.3 GiB allocated during the test run.
The adapter grades text. In the on-site setup the same Gemma 4 E4B, with the adapter switched off, transcribes the patient's speech first. On 15 real recordings (238 words in Hindi, Bengali and English; the author's own voice reading scripted answers), word error rate was 20.2% for Gemma 4 E4B against 38.2% for Whisper large-v3-turbo on the same GPU (Bengali: 33.3% against 91.3%). This is a small sample from one speaker.
heard and reteach fields are model-written English and can be wrong; the verdict is what was measured.The adapter is used at its trained scale (1.0); homeward_inference.json records the inference settings.
import json
import torch
import transformers
from huggingface_hub import hf_hub_download
from peft import PeftModel
BASE = "google/gemma-4-E4B-it"
ADAPTER = "oktash/homeward-teachback-gemma4-e4b"
LORA_SCALE = 1 # the evaluated setting; also in homeward_inference.json
tok = transformers.AutoProcessor.from_pretrained(BASE).tokenizer
cls = getattr(transformers, "AutoModelForMultimodalLM", None) or transformers.AutoModelForImageTextToText
# On AMD gfx1100 (Radeon PRO W7900 / W7900D, RX 7900) SDPA in the text model gave NaN logits in bf16,
# so the text model uses eager attention; the audio tower needs SDPA. Elsewhere the default is fine.
attn = {"text_config": "eager", "audio_config": "sdpa", "vision_config": "eager"}
model = cls.from_pretrained(BASE, dtype=torch.bfloat16, device_map="auto", attn_implementation=attn)
model = PeftModel.from_pretrained(model, ADAPTER)
for module in model.modules(): # apply the LoRA scale before merging
if hasattr(module, "scaling") and isinstance(module.scaling, dict) and "default" in module.scaling:
module.scaling["default"] *= LORA_SCALE
model = model.merge_and_unload().eval()
prompt = json.load(open(hf_hub_download(ADAPTER, "grader_prompt.json")))
facts = [ # one line per fact: id, category, critical flag, statement (fictional example)
{"id": "f1", "category": "medication", "critical": True, "statement": "Take furosemide 40 mg once every morning."},
{"id": "f2", "category": "warning sign", "critical": True, "statement": "Call the clinic if your weight goes up by 2 kg in 3 days."},
]
fact_lines = "\n".join(f"- {f['id']} [{f['category']}{', critical' if f['critical'] else ''}]: {f['statement']}" for f in facts)
user = prompt["user"].format(facts=fact_lines, question="How will you take your water tablet, and when do you call us?",
language_name="Spanish",
transcript="la pastilla del agua la tomo por la mañana, una, y si me hincho llamo")
messages = [{"role": "system", "content": prompt["system"]}, {"role": "user", "content": user}]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tok(text, add_special_tokens=False, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=768, do_sample=False)
print(tok.decode(out[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# -> {"facts": [{"id": "f1", "verdict": "...", "heard": "...", "reteach": "..."}, ...]}
The reported numbers also apply an escalation rule on top of greedy decoding: for each fact graded "correct", the probability of each verdict is computed (softmax over the four verdicts' sequence log-probabilities), and if P(correct) is below the threshold (0.5) the verdict becomes the most likely other verdict, so the nurse re-checks it. It changed 2 of 341 facts on the independent test. The snippet above does not apply it; see verdict-probs and escalate in ml/eval.py in the GitHub repo.
Requirements used for the reported numbers: transformers==5.19.0, peft==0.21.2, PyTorch 2.13.0+rocm10.0.0. Chat template with thinking off, greedy decoding, one pass, up to 768 new tokens.
adapter_model.safetensors: the LoRA weights exactly as evaluated.adapter_config.json: the training config; the only change is base_model_name_or_path, set to google/gemma-4-E4B-it instead of the notebook's local path.homeward_inference.json: LoRA scale, decoding, attention settings and the source of each number on this card.grader_prompt.json: the grader prompt.Branch run2 holds the earlier run 2 adapter (an average of its epoch checkpoints), which was evaluated at LoRA scale 0.5, not 1.0: 94.1% accuracy and 2 of 108 critical misses on the independent test set. main (run 4) is the published model and is used at LoRA scale 1.0.
The Homeward app and training code are MIT-licensed in the GitHub repository.
ml/results/eval.md)@misc{homeward2026,
title = {Homeward teach-back grader: a Gemma 4 E4B LoRA for multilingual discharge teach-back},
author = {Team Solus},
year = {2026},
note = {AMD Developer Hackathon: ACT III},
url = {https://huggingface.co/oktash/homeward-teachback-gemma4-e4b}
}
Built with AI coding assistance (Claude). Training data was generated and labelled by models on AMD Token Factory (see Training data); the independent validation and test sets were written by Claude and never used for training.
google/gemma-4-E4B-it