From Scores to Safe Sets: Exact Safety-Constrained Decoding for Medication Recommendation
Abstract
Recent generative medication recommendation systems ultimately produce sets of drugs, but drug–drug interaction (DDI) safety depends on the set as a whole. A natural post-hoc approach is to first predict medications and then locally repair interacting pairs by removing one drug at a time. We ask whether this local re- pair step itself introduces avoidable error. Using fixed medication scores from FLAME’s frozen classifier on MIMIC-III, we compare increasingly strong local repair strategies with an exact global decoder while holding the scores, output size, and DDI constraint fixed. The global decoder jointly selects the highest-scoring feasible medication set using mixed-integer linear programming. Across validation and test splits, global decoding consistently achieves higher Jaccard similarity than greedy repair, degree-aware repair, and degree-aware repair strengthened with ex- haustive 1-swap local search. Its advantage is small under loose safety constraints and becomes larger as the constraint tightens; on the test split it reaches +0.0064 Jaccard over the strongest local baseline at the strict operating point. The finding also holds across a fine accuracy–safety sweep at matched realized DDI exposure and under three score representations. At the strict setting, global decoding re- tains more true-positive medications while removing more false positives. These results show that medication recommendation is not only a representation-learning problem: even with a frozen clinical model, how its scores are converted into a constrained medication set can materially affect the final prediction.