Introduction
As Large Language Models (LLMs) transition from experimental sandboxes to core enterprise infrastructure, the need for robust, real-time safety mechanisms has become paramount. OneShield is a modular, model-agnostic guardrail framework developed by IBM Research designed to secure LLM interactions. By decoupling risk detection from policy enforcement, OneShield enables enterprises to implement customized safety measures—ranging from PII redaction to fact-checking—without being constrained by a specific model's internal safety tuning.
The Challenge of LLM Safety
Current safety filters often suffer from three critical limitations that hinder enterprise adoption:
- Self-Referentiality: Many safety features are embedded within the model itself, leading to "blind spots" where a model cannot objectively evaluate its own potentially biased or harmful output.
- Rigidity: Existing solutions are frequently difficult to adapt to specific industry regulations (e.g., HIPAA) or regional legal requirements (e.g., GDPR).
- Inconsistency: Guardrail behaviors can be unpredictable, making them difficult for developers to audit or interpret.
OneShield addresses these gaps by providing a standalone "firewall" layer that operates at inference time, independent of the underlying LLM.
System Architecture and Methods
OneShield utilizes a microservices-based architecture to ensure scalability and flexibility. The system is composed of an Orchestrator, a suite of Detectors, and a Policy Manager.
The core innovation of OneShield lies in its three-pronged approach to detection:
- Classification Detectors: Utilizing BERT-based embeddings and Separable Convolutional Neural Networks (SepCNN), these detectors categorize text into risk categories such as self-harm, inappropriate content (Hate, Abusive, Profane), and unauthorized medical advice.
- Extractor Detectors: These are specialized for privacy, identifying and scoring Personally Identifiable Information (PII) based on context to allow for nuanced redaction.
- Comparison Detectors: These perform large-scale text matching to identify data leakages, copyright violations, or hallucinations by comparing LLM outputs against verified external knowledge bases.
To minimize impact on user experience, all detectors run in parallel. This ensures that total system latency is determined only by the slowest individual detector, making the framework viable for high-throughput live applications.
Datasets and Training
The researchers trained and benchmarked OneShield using a diverse array of public and internal datasets:
- Safety Benchmarks: AttaQ, ALERT, SALAD-Bench, HarmBench, and StrongREJECT.
- Specialized Content: The "SuicideWatch" subreddit for self-harm detection and the HeAL benchmark for health advice.
- Privacy/PII: The Enron Email Dataset alongside various synthetic PII datasets.
- Production Data: Internal IBM interactive logs (156 million records) and X-Force cybersecurity data were used to refine detectors for real-world enterprise environments.
Performance and Real-World Impact
OneShield demonstrates high precision and low latency across various safety tasks. The system is optimized for speed; for example, the PII extractor can process a 150-token prompt in just 0.521 milliseconds.
As shown in the performance data, the self-harm detector (SepCNN) achieved a 96.60% accuracy on test datasets. Furthermore, the system was integrated into InstructLab, an open-source project by IBM and Red Hat. In this deployment, OneShield automatically vetted over 1,200 Pull Requests, identifying violations in 8.25% of submissions and significantly reducing the manual workload for human moderators.
Key Insights
- Decoupling Detection from Action: By separating the identification of a risk from the response, the Policy Manager can apply different rules to the same detection based on context (e.g., masking a name in customer support while allowing it in general chat).
- Contextual PII Scoring: OneShield evaluates context to determine if data is truly sensitive, reducing false positives that disrupt natural conversation flow.
- Model Agnosticism: Because it sits outside the LLM, OneShield can be integrated with any model (GPT-4, Llama, Granite, etc.), providing a consistent safety layer across an organization's entire AI portfolio.
Limitations and Future Work
Maintaining effective guardrails is an ongoing challenge as prompt injection techniques and harmful content types evolve. While OneShield utilizes a "sparse-human-in-the-loop" alignment to stay current, rapid shifts in data distributions remain a hurdle. Future research will focus on expanding the detector library and refining the Policy Manager to handle multi-modal interactions involving images and code.
Summary updated