MedGuardBench: A Patient-Oriented Benchmark for Personalized Guardrail Development
Organizations: University of California, Los Angeles · University of California, Davis
Abstract
Safety is personal: the same action can be safe for one person but unsafe for another. Yet current guardrails judge content without considering who is affected. Using medication safety, we introduce patient-conditioned medication guarding, which predicts a safety verdict and 17 risk categories from a patient profile and prescription. We release MedGuardBench, a drug-disjoint benchmark of 5{,}001 scenarios across 87 medications. We find that standard guardrails rely on surface cues, such as wording and profile presence, rather than patient facts. To address this, we develop personalized reasoning guardrails with three components. Personalized Reasoning Distillation links risks to relevant patient fields. Context Unrolling (CU) makes models check each field themselves, reducing false alarms on most backbones; controls show that providing the check does not yield the same benefit. A rule-based reward (guided GRPO) improves unsafe recall and complex-risk detection, including allergies and adverse reactions, on some backbones, but increases false alarms on others. Our models outperform base models and matched no-profile controls in accuracy, while reducing false alarms relative to no-profile controls. Profile removal and swapping confirm that gains come from patient information, not fine-tuning alone.
Figures & tables
| Zero-Shot | SFT | Context Unrolling (CU) | Guided GRPO | ||||||||||||||||||
| Family | Backbone | Acc | Rec | FPR | Mac | EM | Acc | Rec | FPR | Mac | EM | Acc | Rec | FPR | Mac | EM | Acc | Rec | FPR | Mac | EM |
| General LLMs | Qwen3-4B-Instruct | 82.3 | 75.2 | 10.0 | 50.3 | 54.0 | 87.4 | 98.4 | 24.6 | 65.4 | 62.1 | 90.3 | 97.1 | 17.1 | 70.0 | 67.5 | 91.5 | 95.5 | 12.9 | 69.2 | 67.1 |
| Qwen3-8B-Instruct | 75.5 | 95.8 | 47.7 | 45.9 | 36.2 | 90.9 | 97.4 | 16.0 | 67.6 | 65.8 | 94.0 | 97.4 | 9.7 | 69.8 | 70.0 | 91.1 | 97.4 | 15.7 | 68.4 | 69.5 | |
| Qwen3-14B-Instruct | 84.1 | 83.2 | 15.0 | 51.3 | 57.4 | 91.8 | 96.6 | 13.4 | 67.5 | 66.4 | 94.5 | 96.0 | 7.2 | 72.4 | 71.2 | 93.0 | 97.6 | 12.0 | 69.0 | 70.2 | |
| Llama-3.1-8B-Instruct | 58.8 | 80.2 | 64.5 | 22.2 | 38.2 | 88.3 | 96.3 | 20.3 | 64.7 | 62.7 | 91.8 | 96.3 | 13.1 | 64.7 | 66.4 | 86.3 | 98.7 | 27.5 | 63.3 | 62.0 | |
| Safety Guardrails | Qwen3Guard-Gen-4B | 78.2 | 70.7 | 13.7 | 48.1 | 53.4 | 87.0 | 96.3 | 23.1 | 66.5 | 62.6 | 92.2 | 96.3 | 12.3 | 70.0 | 68.7 | 87.8 | 98.9 | 24.3 | 67.4 | 63.8 |
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
| Qwen3-4B | Qwen3-8B | Qwen3-14B | Qwen3Guard-4B | Qwen3Guard-8B | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Risk Category | Base | SFT | CU | GRPO | Base | SFT | CU | GRPO | Base | SFT | CU | GRPO | Base | SFT | CU | GRPO | Base | SFT | CU | GRPO |
| Drug-Drug Interaction | 64.1 | 81.3 | 83.5 | 84.2 | 66.1 | 82.2 | 85.7 | 84.5 | 74.4 | 83.8 | 83.9 | 85.2 | 60.7 | 79.9 | 82.9 | 84.4 | 69.0 | 82.4 | 83.7 | 80.7 |
| Cardiac Impairment | 67.4 | 80.9 | 82.4 | 83.7 | 54.2 | 84.1 | 84.4 | 81.8 | 68.1 | 82.6 | 84.7 | 80.0 | 59.6 | 80.0 | 82.9 | 85.9 | 48.9 | 84.7 | 83.5 | 77.9 |
| Dosage & Toxicity | 37.6 | 57.1 | 58.3 | 55.9 | 35.2 | 58.9 | 64.3 | 56.7 | 46.9 | 56.6 | 62.4 | 63.3 | 29.7 | 50.9 | 56.5 | 54.8 | 41.2 | 59.6 | 64.5 | 60.2 |
| Age | 44.4 | 69.0 | 67.3 | 70.8 | 45.5 | 66.7 | 65.5 | 64.7 | 40.5 | 66.1 | 67.3 | 68.7 | 39.5 | 64.3 | 67.3 | 65.5 | 23.4 | 65.3 | 62.9 | 61.8 |
| Allergy | 41.7 | 45.5 | 43.6 | 53.1 | 37.4 | 43.7 | 46.8 | 68.7 | 48.0 | 47.1 | 51.3 | 61.3 | 45.8 | 43.2 | 51.9 | 51.7 | 41.7 | 44.4 | 46.3 | 60.0 |
| Non-Personalized SFT ( *-NP ) | |||||||
|---|---|---|---|---|---|---|---|
| Risk Category | Qwen3 4B | Qwen3 8B | Qwen3 14B | Qwen3Guard 4B | Qwen3Guard 8B | ShieldGemma 2B | |
| Drug-Drug Interaction | 180 | 54.4 | 53.5 | 60.6 | 52.3 | 46.7 | 54.2 |
| Cardiac Impairment | 77 | 59.4 | 58.7 | 61.9 | 59.9 | 47.8 | 57.6 |
| Dosage & Toxicity | 61 | 40.4 | 37.2 | 47.4 | 40.7 | 46.4 | 29.9 |
| Age | 60 | 42.0 | 37.6 | 51.1 | 35.7 | 38.2 | 38.9 |
| Allergy & Adverse Drug React. | 56 | 18.8 | 32.1 | 31.3 | 25.6 | 25.0 | 23.0 |
| Model | Arm | Test Condition | Acc | Rec | FPR | Mic | Mac | EM |
|---|---|---|---|---|---|---|---|---|
| Qwen3-4B | Zero-Shot | True Profile | 82.3 | 75.2 | 10.0 | 54.3 | 50.3 | 54.0 |
| No Profile | 81.2 | 81.3 | 18.9 | 50.7 | 45.9 | 49.2 | ||
| Shuffled Profile | 61.8 | 69.8 | 47.1 | 29.0 | 23.9 | 30.0 | ||
| Non-Personalized | 66.9 | 64.9 | 30.9 | 26.4 | 25.9 | 37.2 | ||
| Pers. SFT | True Profile | 87.4 | 98.4 | 24.6 | 72.3 | 65.4 | 62.1 | |
| No Profile | 72.3 | 99.7 | 57.4 | 50.9 | 31.4 | 42.2 |
| Method / Ablation Arm | Acc | Rec | FPR | Mic | Mac | EM |
|---|---|---|---|---|---|---|
| Qwen3-4B: reference arms | ||||||
| Base (Zero-Shot) | 82.3 | 75.2 | 10.0 | 54.3 | 50.3 | 54.0 |
| SFT (Canonical Checkpoint) | 87.4 | 98.4 | 24.6 | 72.3 | 65.4 | 62.1 |
| Context Unrolling Ladder | ||||||
| SFT + 1 Epoch (Control) | 86.3 | 97.9 | 26.3 | 71.9 | 65.6 | 61.5 |
| Unroll Prompt-Only (No Train) | 87.2 | 95.8 | 22.0 | 70.9 | 66.0 | 62.4 |
| FAERS ( ) | NHANES ( ) | MIMIC-IV ( ) | DDInter ( ) | ||||||||||
| Backbone | Arm | balAcc | FPR | Attr | balAcc | FPR | Attr | balAcc | FPR | Attr | balAcc | FPR | Attr |
| Qwen3-4B | Base (zero-shot) | 71.7 | 37.9 | 1 | 70.8 | 43.7 | 6 | 65.6 | 58.8 | 5 | 54.4 | 45.2 | 4 |
| SFT | 53.2 | 91.6 | 92 | 57.7 | 82.7 | 88 | 52.1 | 95.8 | 90 | 50.1 | 1.2 | 1 | |
| CU | 51.2 | 94.3 | 76 | 52.8 | 89.3 | 37 | 52.1 | 92.9 | 46 | 50.1 | 2.8 | 3 | |
| Guided GRPO | 61.3 | 74.8 | 90 | 60.5 | 71.3 | 84 | 54.2 | 90.4 | 90 | 52.0 | 2.0 | 6 | |
| Qwen3-8B | Base (zero-shot) | 53.5 | 92.6 | 1 | 50.8 | 97.0 | 13 | 52.3 | 95.4 | 5 | 63.7 | 50.4 | 5 |
| Qwen3-4B | Qwen3-8B | MedGemma-4B | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Hazard | Zero-Shot | SFT | CU | GRPO | Base | SFT | CU | GRPO | Zero-Shot | SFT | |
| Drug–Drug Interaction | 417 | 0 | 95 | 58 | 95 | 1 | 96 | 94 | 95 | 93 | 95 |
| Age (Beers) | 213 | 0 | 78 | 43 | 73 | 0 | 84 | 78 | 78 | 88 | 91 |
| Pregnancy | 16 | 0 | 100 | 100 | 100 | 0 | 100 | 100 | 100 | 100 | 100 |
| Renal Impairment | 17 | 94 | 100 | 35 | 94 | 100 | 94 | 100 | 100 | 94 | 100 |
| Hepatic Impairment | 11 | 36 | 82 | 27 | 82 | 36 | 64 | 73 | 91 | 100 | 100 |
| Backbone | Arm | AttrRec | CatP | CatR | CatF1 | Fired |
| Qwen3-4B | Base | 4 | 10 | 4 | 6 | 0.4 |
| Qwen3-4B | SFT | 90 | 36 | 90 | 51 | 2.7 |
| Qwen3-4B | CU | 52 | 41 | 52 | 46 | 1.4 |
| Qwen3-4B | GRPO | 88 | 33 | 88 | 48 | 2.9 |
| Qwen3-8B | Base | 7 | 9 | 7 | 7 | 0.8 |
| Qwen3-8B | SFT | 91 | 34 | 91 | 50 | 2.8 |
LLM Guardrails
Large language model guardrails detect or constrain harmful outputs, prompt attacks, and unsafe agent actions before they cause harm.
See all 210 papers