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
Figure 1: Overview of MedGuardBench. 5,001 scenarios over 87 common medications are generated from Drugs.com and DrugBank monographs, audited by a teacher LLM, and human-checked. Guardrails are then trained with Personalized Reasoning Distillation (SFT), then two follow-up steps applied on their own from the SFT checkpoint—Context Unrolling and Guided GRPO—and tested with and without the patient profile.
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
Table 1: Personalized medication-safety results on the drug-disjoint test set with patient profiles. Acc : verdict accuracy; Rec : unsafe recall; FPR : false-positive rate on safe cases ( ↓ ); Mac : 17-category macro-F1; EM : exact match. Bold indicates the best result per metric within each method (Zero-Shot, SFT, CU, and GRPO), including ties. Profile-trained models substantially outperform off-the-shelf guardrails. CU achieves the highest verdict accuracy and exact match, while GRPO achieves the highest unsafe recall.
Figure 2: Safety operating points on the drug-disjoint test set. Colors indicate experimental arms and markers denote backbones. The target region requires recall ≥95% and FPR <20% . Key takeaway: Personalized models achieve high unsafe recall while limiting false alarms; removing patient context generally shifts models toward over-blocking or reduced recall.
Figure 3: Radar view of test-time profile perturbations. Rows are Qwen models, columns are training arms; each panel overlays the four test conditions (True Profile, No Profile, Shuffled Profile, and Non-Personalized) across all six metrics: verdict accuracy (Acc), unsafe recall (Rec), false-positive rate on safe prescriptions (FPR), 17-category micro-F1 and macro-F1 (Mic/Mac), and 17-category exact match (EM). Axes are oriented so that farther from the center is better (FPR shown as 100−FPR ). The personalized arms (SFT, CU, and GRPO) contract sharply when the profile is removed or shuffled, while the zero-shot arm stays stable.
Figure 4: Per-category F1 across 12 models and training arms. Each panel shows one model’s F1 scores across 17 risk categories (0–100; higher is better), comparing SFT, CU and GRPO. CU generally outperforms across categories, although GRPO occasionally performs better on individual categories. , while Alcohol Use, Pregnancy & Breastfeeding, and Substance Use consistently achieve high scores. Risk category names are abbreviated.
Appendix figures & tables16 assets
Supplementary material from the paper’s appendix.
Appendix
Figure 5: Number of Safe ( + ) and Unsafe ( − ) samples for each medication, shown in three panels: Train (65 drugs, 3,769 samples), Validation (11 drugs, 503 samples), and Test (11 drugs, 729 samples). Each drug is shown in one panel. Acetaminophen, bupropion, dapagliflozin, erythromycin, propranolol, and warfarin are shown in Train, and atorvastatin is shown in Validation. Most drugs have a close balance of Safe and Unsafe samples.
Figure 6: Number of samples flagged as risky ( Risk=True ) in each of the 17 risk categories, shown separately for the Train, Validation, and Test splits. Categories are sorted from most to least common. Drug–Drug Interaction is the most common risk in every split, and Caffeine Intake is the least common. A sample can have more than one flag. Exact counts and percentages are in Table 2 .
Figure 7: An example record from MedGuardBench ( Patient ID = 1 ), illustrating the 20 patient profile attributes, proposed prescription, 17 binary risk category flags, binary Is_Safe verdict, and the clinical reasoning.
Figure 8: Heatmap of risk counts for the 87 medications (rows) and the 17 risk categories (columns). Each cell is the number of samples for that drug flagged as risky ( Risk=True ) in that category. Darker cells mean higher counts. A sample can have more than one flag, so the plot shows 5,127 risk flags in total. We designed the risk mix to follow how often these risks occur in real clinical practice, so darker cells point to risks that are more common in the real world.
Figure 9: Heatmap of the portion of Unsafe samples flagged in each of the 17 risk categories (columns), for each of the 87 medications (rows). Each cell is a fraction between 0 and 1. For example, a cell of 0.50 means half of that drug’s Unsafe samples have that risk. Darker cells mean a higher share. A drug can have more than one risk category flagged as True, so the shares for one drug can add up to more than 1. Darker cells tend to be risks that are more common in real-world practice.
Figure 10: Alphabetical list of the 87 active medications in MedGuardBench, selected from the most commonly used drugs in ( clincalc2024top300 ) .
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
Appendix
Table 3: Per-category F1 (%) on the test set ( n=729 ) for every personalized arm in Table 1 (all 12 fine-tuned backbones), evaluated with the profile. Base=zero-shot, CU=Context Unrolling, GRPO=Guided GRPO. Bold marks the best value per category across all three blocks.
Non-Personalized SFT ( *-NP )
Risk Category
n
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
Appendix
Table 4: Per-category F1 (%) on the test set ( n=729 ) for the six non-personalized SFT models ( *-NP ): the same backbones, data, and recipe as the personalized SFT arms in Table 3 , but with the patient profile removed at both training and test time. Bold marks the best value per category. Each column should be read against the SFT column of the same backbone in Table 3 : macro-F1 falls by 16–22 points on every backbone (e.g. Qwen3-4B 65.4 → 47.0, Qwen3-8B 67.6 → 45.4).
Figure 11: Per-category Δ F1 on the drug-disjoint test set ( n=729 ) for Qwen3-4B, Qwen3-8B, and Qwen3Guard-4B. Each cell is the mean, over personalized SFT, CU, and Guided GRPO, of true-profile F1 minus the same arm with the profile removed (left) or replaced by a shuffled profile (right). Positive values (red) are categories the model names only when the patient’s own profile is present. Shuffled-profile F1 is computed against the original patient’s labels, which may not hold for the donor patient, so the right panel measures sensitivity to profile content rather than counterfactual accuracy (Appendix D.2 ).
Figure 12: Precision vs. recall of the unsafe verdict on the drug-disjoint test set ( n=729 ), true-profile condition, for every backbone (marker) and training arm (colour); dashed grey curves are iso-F1 lines. Hollow markers are the non-personalized controls (trained and tested without the profile). The plot separates two ways of being wrong that accuracy alone hides. Zero-shot models (grey) and the non-personalized controls (hollow) sit low on precision : the ones that recall 85–98% of unsafe prescriptions flag 32–80% of safe ones, so the “unsafe” label becomes uninformative. Personalized SFT (blue) sits at 87–98% recall and 80–96% precision. Context Unrolling (green) gives the best F1 on 11 of the 12 trained backbones and overall (Qwen3-8B CU: P=91.6 , R=97.4 , F1=94.4 ). Guided GRPO (red) pushes recall to 95–99% at some cost in precision, so it occupies the lower-right edge of the trained cluster. Within every backbone, the best personalized arm is 4–33 precision points above each hollow non-personalized twin at recall within 1 point or higher, which is the pattern a profile-aware guardrail should show. Six runs fall outside the window and are listed at lower right. Llama-Guard-7B zero-shot is degenerate (it flags almost nothing); Llama-Guard-2-8B zero-shot flags almost everything and sits on the bottom edge of the window.
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
Appendix
Table 5: Test-time profile perturbation ablations ( n=729 ): each model is trained once and evaluated under four input conditions, True Profile (real profile), No Profile (profile blank), Shuffled Profile (another patient’s profile), and Non-Personalized (no profile and no patient framing in the prompt). All rows are scored against the original patient’s labels; for Shuffled Profile these labels may not be correct for the donor patient, so those rows measure sensitivity to profile content (agreement with the original-patient decision), not counterfactual accuracy. Acc : verdict accuracy; Rec : unsafe recall; FPR : false-positive rate on safe prescriptions; Mic / Mac : 17-category micro- and macro-F1; EM : 17-category exact match. Bold marks the best value within each arm.
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
Appendix
Table 6: Controlled ablations on test set; each row changes one training choice from the SFT checkpoint. CU ladder: more epochs or unrolling supplied in the prompt leave FPR at 22–26%; only unrolling the model generates itself cuts it to 17.1% at > 97% recall, so the audit must be produced, not read. RL variants: dropping reference guidance costs GRPO 4.5 accuracy and 6.8 FPR points; DPO has the lowest FPR but misses 12% of unsafe cases. Qwen3-8B repeats the pattern. Bold: best per block.
FAERS ( n=538 )
NHANES ( n=600 )
MIMIC-IV ( n=480 )
DDInter ( n=750 )
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
Appendix
Table 7: Real-patient evaluation (%) on four public sources with rule-grounded labels. balAcc ( ↑ ): balanced verdict accuracy, the mean of recall on rule-unsafe patients and specificity on rule-safe patients (50 = always answering safe or always unsafe); FPR ( ↓ ): over-blocking, the share of rule-safe patients wrongly flagged unsafe; Attr ( ↑ ): hazard attribution recall , the share of rule-unsafe patients for which the model fires the specific risk category matching the rule-defined hazard (e.g., Drug–Drug Interaction for a DDInter Major pair), not merely an unsafe verdict; it does not penalise firing additional categories, so it should be read with the category-level precision and firing breadth in Table 9 . DDInter uses Major+Moderate vs. non-interacting pairs. † Repetition penalty 1.1 (plain greedy decoding yields 28%–60% unparseable outputs).
Figure 13: Balanced verdict accuracy vs. hazard attribution on real patients (the vertical axis is balanced accuracy, i.e. the mean of unsafe recall and safe specificity; we report no probability-calibration metric such as ECE or Brier). Open markers are untrained models (base / zero-shot); filled markers are MedGuardBench-trained arms. The desired region is the upper right: high balanced accuracy and high hazard attribution. Current systems split between better verdict specificity with little attribution and better attribution with too many false alarms.
Qwen3-4B
Qwen3-8B
MedGemma-4B
Hazard
n
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
Appendix
Table 8: Hazard attribution on real patients by risk category (%), pooled over FAERS, NHANES, and MIMIC-IV: the share of rule-unsafe patients for which the model fires the category of the rule-defined hazard. n is the number of unsafe patients with that hazard. Bold: best per row.
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
Appendix
Table 9: Attribution recall is not attribution precision on the pooled real-patient cohorts (FAERS + NHANES + MIMIC-IV). All columns are computed over the same 780 rule-unsafe patients (826 gold hazard labels; 46 patients carry two), with an unparsable completion counting as firing no category. AttrRec : share of patients whose primary rule-defined hazard fires. CatP / CatR / CatF1 : category-level micro precision / recall / F1 over all (patient, category) pairs. Fired : mean categories fired per patient. Because the rules label only the decisive hazard(s), a fired-but-unlabelled category may still be genuine, so CatP is a conservative lower bound read as a category-discrimination signal, not a clinical error rate. Every MedGuardBench-trained arm except Qwen3-4B CU pairs high AttrRec (76–93%) with low CatP (27–41%) while firing 2.1–3.6 categories; zero-shot MedGemma reaches 92% AttrRec at 18% CatP (firing 5.5), i.e. broad over-firing rather than reliable discrimination—mirroring the high false-positive rates in Table 7 .