Supervised Contrastive Learning and Classification using LLM-Generated Synthetic Data for Medical LLM Safety

Read full text
Authors: Ryan Bresnahan, Princewill Uzoaru, Zoe Diflo, Galathara Kahanda
Cited by: 0

Abstract

The increasing deployment of large language models (LLMs) in healthcare applications has increased the need for reliable methods to assess the safety and guideline consistency of synthetically generated medical statements. In this work, we propose a clinical guideline-anchored pipeline for detecting guideline-unaligned LLM outputs, with a particular focus on treatment (remdesivir) recommendations for COVID-19 whose correctness depends on adherence to authoritative medical guidance. The pipeline is comprised of automated extraction of disease treatment specific clinical guidelines, retrieval-augmented generative summaries of treatment recommendations, generation of semantically consistent safe paraphrases and their corresponding unsafe variants. These synthetically generated data are then used for a supervised contrastive learning objective applied to biomedical transformer encoders, thus creating embedding spaces optimized to distinguish guideline-consistent (safe) from guideline-inconsistent (unsafe) statements. A downstream classifier trained on these representations is evaluated on both in-distribution (GPT-4o-mini) and out-of-distribution (DeepSeek) LLM outputs derived from synthetic and expert-validated labels. Across all metrics, contrastively fine-tuned encoders substantially outperform their baseline counterparts. Average improvements ranging from 0.12 to 0.26 in F1 score are observed across the datasets, with similar gains in AUC, average precision, and balanced accuracy. Difficulty-stratified test results further demonstrate increased detection performance of clinically subtle unsafe variants. These findings indicate that clinical guideline-aware contrastive representation learning provides an effective and lightweight method for the safety assessment of medical LLM outputs.

Fields of Study & Subjects

Artificial Intelligence in Healthcare and Education Machine Learning in Healthcare Topic Modeling

Publication details

Journal / source
Zenodo (CERN European Organization for Nuclear Research)
Publication date
10 February 2026
Language
EN
Document type
Preprint