AID : Adaptive Integration of Detectors for Safe AI with Language Models (2025)

Abstract: As Large Language Models (LLMs) increasingly influence content generation across diverse platforms, there is a heightened urgency to regulate their outputs to ensure safe usage. However, defining safety is complex, given that entities across domains may interpret it through varied lenses and develop safety detectors—models trained to identify specific unsafe content based on predefined criteria. To address this complexity, we introduce the approach of Adaptive Integration of Detectors (AID) to orchestrate the strengths of multiple pretrained detectors to ensure comprehensive effectiveness in diverse scenarios. AID employs a Mixture-of-Experts (MoE) framework, wherein it dynamically assigns and learns data-adaptive weights for each detector using domain-specific annotated data and LLM-extracted features. We provide theoretical insights into why MoE can be effective by showing its optimality in a Neyman-Pearson setting. Our experimental studies using various detection tasks curated from benchmark datasets demonstrate AID’s ability to synergistically combine the unique capabilities of individual detectors. For example, it is observed that AID can improve the area under the curve (AUC) by an absolute value of 0.07 to 0.21, with a median of 0.12, compared to the best individual detectors developed for specific safety aspects. The improvement is particularly significant for complex detection tasks that mix different unsafe data sources.

## introduction large language models (llms) have seen widespread use across diverse domains, including healthcare, education, finance @xcite , and more, due to their remarkable ability to process and generate human-like text. however, with the increasing deployment of llms, safety concerns have emerged, including issues of bias, misinformation, and potential ethical implications. to address these challenges, there is a pressing need for customized, scalable safety detection mechanisms specific to llms, enabling effective and responsible application in various domains. this has motivated recent advancements in developing content safety detectors, which are pretrained models designed to identify specific types of unsafe content by outputting a score that quantifies the likelihood of unsafety. notable examples include perspective api @xcite by jigsaw and google for detecting toxic comments, hate-bert @xcite , a bert-based model fine-tuned for hate speech detection, robertabased models trained on abusive language @xcite @xcite , and detoxify (hanu and unitary team, 2020), an open-source tool for predicting toxic comments. however, the concept of "safety" in digital content can be multifaceted and subjective, varying across different domains and societal norms. the existing developed detection models are either closed-source or pretrained from a specific data source that focuses on a specific type of unsafe content. as a result, despite their individual strengths, these state-of-the-art detectors typically operate in isolation. this siloed approach leads to limited effectiveness when encountering complex content that spans multiple categories of unsafety. furthermore, fixed trained models may not adapt to evolving online data, leading to reduced efficacy over time. these challenges motivate our work to adaptively integrate diverse detection mechanisms. this paper proposes a perspective to address the safety detection through an adaptive integration of detectors (aid), which seeks to leverage the strengths of various pretrained detectors for comprehensive and effective safety regulation in content generation. existing ai safety approaches focus on single-task detection, training specialized detectors to identify predefined safety tags. in contrast, our approach addresses compound-task detec-figure 1 : illustration of the detection system that aims to detect user-specified set of unsafe tags. then, we train an aid model, inspired by the mixture-of-experts (moe) framework @xcite @xcite @xcite . here, the experts represent pretrained detectors, and we learn to aggregate their outputs using data-adaptive weights to support various userselected tasks without intensive retraining. in deep learning, moe divides tasks among specialized neural networks, with only relevant experts activated for each input through a routing function. this framework is recently used in large language models to reduce memory costs by selectively activating subsets of the model. unlike standard moe approaches that train new experts, our method integrates pretrained detectors into the moe architecture. our work also relates to ensemble methods like bagging, stacking, and boosting @xcite , which combine multiple models to improve generalization and reduce variance. however, these methods typically assume homogeneous models and are not designed for adaptive integration of heterogeneous pretrained detectors. the main contribution of this work is as follows: a detector associated with this task is defined as a function that maps from x to y ∆ = {0, 1}, written as d t : @xmath0, where d t (x) = 1 means x should be tagged as positive t. suppose d(x) can be written as d(x) = 1 s(x)-τ for a score function s @xcite , in which varying choices of τ determine the tradeoffs between the false positive rate and detection power. a classical score function is s(x) = log p t (x), where p t is the density of x associated with positive t. a larger s(x) is interpreted as more likelihood of x following p t . while this logarithmic score has been widely used in decision theory and anomaly detection @xcite due to its deep root in the uniformly most powerful test @xcite and kullback-leibler divergence @xcite . in practice, the distribution p t is often approximated through generative models such as the autoencoders @xcite . our evaluation metric for detection performance is the area under the curve (auc), which measures the two-dimensional area underneath the roc curve determined by the score function s. auc is a suitable metric for detection as it is less affected by data imbalance. in practice, it is common for most content to be safe, with only small unsafe data available for curation. formulation. suppose a user can access a set of k pretrained detectors from several entities, e.g., companies and research labs that release models or their apis, through private or public clouds platform such as huggingface @xcite . each detector d k has been trained to detect a tag t k , for @xmath1. the union of all tags is denoted by @xmath2, @xmath3. suppose a user is interested in detecting whether any given input is associated with a particular subset of unsafe tags c ⊆ t . our problem is to develop a detection strategy to meet any user-specific need, namely to accurately flag an input as positive if it is associated with any tags within c (as shown in figure 1 ). rationale. to put this problem into perspective, let us consider two special cases as examples. in the first case, @xmath4. our insight is that detectors associated with tags in t -c can possibly provide side information to enhance detection accuracy if they contain mutual information (from an information-theoretic perspective) with the tag of interest conditional on the input. as a result, there should exist a way to utilize detectors associated with seemingly unrelated tags to contribute to the decision about t. for example, detecting whether content has 'toxicity' could be closely related to detecting 'violence'. the second case is @xmath5, which concerns a union of the existing tags available, e.g., detecting whether content falls into either 'toxic', 'violent', or 'offensive' as they may constitute all those that should be moderated. the two cases show the interest for integrating detectors for any user-specific task c. ## adaptive integration of detectors (aid) this section proposes 1) an approach to learn the integration mechanism, 2) a theoretical justification of using the moe structure for detection, 3) an example to show why data-adaptive integration can perform significantly better than nonadaptive methods, and 4) natural baselines of data-free integrating detectors to be revisited in the experiments. ## conclusion we introduced an aid approach to harness the collective strengths of pretrained detectors to enhance content safety detection. we theoretically elucidated the adaptability of its mixture-of-experts structure, and empirically demonstrated its effectiveness through several detection tasks and input distributions. however, we acknowledge the technical limitations of our work. the efficacy of aid is contingent upon the quality and diversity of the detectors it incorporates. when domain-specific data is scarce or lacks comprehensive representation, aid's ability to generalize across distinct domains, such as identifying moral hazards in healthcare or detecting money laundering in finance, may be compromised. addressing these challenges will be a focus of our future research endeavors.