[Paper Review] A Lightweight Explainable Guardrail for Prompt Safety
LEG presents a lightweight, modular guardrail that jointly classifies prompts as safe/unsafe and highlights contributing words, trained with synthetic explanations and a novel joint loss, achieving strong in-domain and out-of-domain performance with much smaller models.
We propose a lightweight explainable guardrail (LEG) method for the classification of unsafe prompts. LEG uses a multi-task learning architecture to jointly learn a prompt classifier and an explanation classifier, where the latter labels prompt words that explain the safe/unsafe overall decision. LEG is trained using synthetic data for explainability, which is generated using a novel strategy that counteracts the confirmation biases of LLMs. Lastly, LEG's training process uses a novel loss that captures global explanation signals and combines cross-entropy and focal losses with uncertainty-based weighting. LEG obtains equivalent or better performance than the state-of-the-art for both prompt classification and explainability, both in-domain and out-of-domain on three datasets, despite the fact that its model size is considerably smaller than current approaches. If accepted, we will release all models and the annotated dataset publicly.
Motivation & Objective
- Motivate safe deployment of LLMs by detecting unsafe prompts with transparent reasoning.
- Develop a modular guardrail that does not require fine-tuning the base LLM.
- Enable explainability by identifying words in prompts that drive safety decisions.
- Leverage synthetic explanation data to train explainability without excessive data collection.
- Propose a joint loss that blends strong supervision with weak, explainability-guided signals.
Proposed method
- A lightweight architecture with a shared transformer encoder, attention pooling, and two linear heads for prompt safety and explanation labeling.
- Synthetic word-level explanation labels generated via adversarial prompts to counter LLM confirmation bias, using GPT-4o-mini.
- A novel multitask loss combining cross-entropy with focal loss and uncertainty-based weighting to balance tasks.
- Auxiliary weak supervision δt (token polarization) and δp (prompt polarization) derived from global token usage statistics, with constant-time lookup during training.
- Joint optimization of prompt classification and explainability classification in a multi-task learning framework.
Experimental results
Research questions
- RQ1Can a lightweight guardrail achieve competitive prompt safety classification performance relative to larger baselines?
- RQ2Do jointly trained explainability classifiers produce faithful, actionable word-level explanations?
- RQ3Does synthetic explanation data guided by counter-bias strategies improve explainability and robustness across domains?
- RQ4What is the impact of the proposed joint loss (with weak supervision and focal modulation) on in-domain and out-of-domain performance?
- RQ5Is the guardrail computationally efficient enough for real-time deployment while maintaining quality explanations?
Key findings
- LEG achieves state-of-the-art or near-SOTA prompt safety performance on three datasets in-domain and out-of-domain, with significantly smaller models (xs, base, large).
- Explainability classification by LEG consistently outperforms baselines, with explainable outputs that are faithful to the model’s decisions (faithfulness shown by token masking tests).
- A lightweight model (as small as 22M parameters) rivals larger baselines on several out-of-domain settings, demonstrating robustness and efficiency.
- A novel joint loss with weak supervision signals δp and δt and focal loss modulation improves out-of-domain performance in 71% of cases in ablation studies.
- The auxiliary weak supervision adds negligible training overhead but improves robustness and generalization across datasets.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.