Legilimens: Practical and Unified Content Moderation for Large Language Model Services
On the map: LLM safety and security → Safety alignment, refusal and guardrails
Abstract (arXiv)
Given the societal impact of unsafe content generated by large language models (LLMs), ensuring that LLM services comply with safety standards is a crucial concern for LLM service providers. Common content moderation methods are limited by an effectiveness-and-efficiency dilemma, where simple models are fragile while sophisticated models consume excessive computational resources. In this paper, we reveal for the first time that effective and efficient content moderation can be achieved by extracting conceptual features from chat-oriented LLMs, despite their initial fine-tuning for conversation rather than content moderation. We propose a practical and unified content moderation framework for LLM services, named Legilimens, which features both effectiveness and efficiency. Our red-team model-based data augmentation enhances the robustness of Legilimens against state-of-the-art jailbreaking. Additionally, we develop a framework to theoretically analyze the cost-effectiveness of Legilimens compared to other methods. We have conducted extensive experiments on five host LLMs, seventeen datasets, and nine jailbreaking methods to verify the effectiveness, efficiency, and robustness of Legilimens against normal and adaptive adversaries. A comparison of Legilimens with both commercial and academic baselines demonstrates the superior performance of Legilimens. Furthermore, we confirm that Legilimens can be applied to few-shot scenarios and extended to multi-label classification tasks.
Key facts. Cited by 13 papers in the map (data through 7 Oct 2026). Placed in Safety alignment, refusal and guardrails, one of 12 directions in LLM safety and security. Builds on 50 of its 92 references that are in the map. First posted on arXiv 28 Aug 2024.
Builds on
50 of 92 references.
Closest ancestors · 2
Same direction, newest first
- 2023Robust Safety Classifier for Large Language Models: Adversarial Prompt Shield31 Oct
- 2023Fine-tuning Aligned Language Models Compromises Safety, Even When Users Do Not Intend To!5 Oct
Other references · 48
- 2017Attention Is All You Needcited by 59,932
- 2015Deep Residual Learning for Image Recognitioncited by 51,809
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,160
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2016Layer Normalizationcited by 5,579
- 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,634
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 2,914
- 2019PIQA: Reasoning about Physical Commonsense in Natural Languagecited by 2,818
- 2023Pythia: A Suite for Analyzing Large Language Models Across Training and Scalingcited by 1,734
- 2020GLU Variants Improve Transformercited by 1,724
36 more
- 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,565
- 2019Generating Long Sequences with Sparse Transformerscited by 1,523
- 2024HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusalcited by 1,330
- 2023Jailbreaking Black Box Large Language Models in Twenty Queriescited by 1,326
- 2021A General Language Assistant as a Laboratory for Alignmentcited by 1,023
- 2021Ethical and social risks of harm from Language Modelscited by 957
- 2023BeaverTails: Towards Improved Safety Alignment of LLM via a Human-Preference Datasetcited by 828
- 2023The RefinedWeb Dataset for Falcon LLM: Outperforming Curated Corpora with Web Data, and Web Data Onlycited by 755
- 2017Automated Hate Speech Detection and the Problem of Offensive Languagecited by 724
- 2019Universal Adversarial Triggers for Attacking and Analyzing NLPcited by 709
- 2019Fast Transformer Decoding: One Write-Head is All You Needcited by 700
- 2016Language Modeling with Gated Convolutional Networkscited by 688
- 2019Unified Language Model Pre-training for Natural Language Understanding and Generationcited by 668
- 2023Tree of Attacks: Jailbreaking Black-Box LLMs Automaticallycited by 619
- 2023Jailbreaking ChatGPT via Prompt Engineering: An Empirical Studycited by 478
- 2023GPT-4 Is Too Smart To Be Safe: Stealthy Chat with LLMs via Ciphercited by 401
- 2021A Survey of Transformerscited by 399
- 2022A Holistic Approach to Undesired Content Detection in the Real Worldcited by 337
- 2018Adversarial Example Generation with Syntactically Controlled Paraphrase Networkscited by 282
- 2017Generating Natural Adversarial Examplescited by 182
- 2019Build it Break it Fix it for Dialogue Safety: Robustness from Adversarial Human Attackcited by 176
- 2024COLD-Attack: Jailbreaking LLMs with Stealthiness and Controllabilitycited by 162
- 2024AdvPrompter: Fast Adaptive Adversarial Prompting for LLMscited by 146
- 2019Text Processing Like Humans Do: Visually Attacking and Shielding NLP Systemscited by 99
- 2020Toxicity Detection: Does Context Really Matter?cited by 93
- 2023Identifying and Mitigating the Security Risks of Generative AIcited by 90
- 2024JailbreakRadar: Comprehensive Assessment of Jailbreak Attacks Against LLMscited by 87
- 2020OpenAttack: An Open-source Textual Adversarial Attack Toolkitcited by 84
- 2020Measuring a hate speech spectrum with faceted Rasch item response theory and perspective-aware, explainable-by-design deep learningcited by 67
- 2024Risk Taxonomy, Mitigation, and Assessment Benchmarks of Large Language Model Systemscited by 63
- 2022Transcending Scaling Laws with 0.1% Extra Computecited by 55
- 2023Evaluating GPT-3 Generated Explanations for Hateful Content Moderationcited by 44
- 2023Adapting Large Language Models for Content Moderation: Pitfalls in Data Engineering and Supervised Fine-tuningcited by 28
- 2024GPT-4 Jailbreaks Itself with Near-Perfect Success Using Self-Explanationcited by 24
- 2021Automatically Exposing Problems with Neural Dialog Modelscited by 5
- 2023Analyzing Norm Violations in Live-Stream Chatcited by 3
Built on by
Citing papers per year: 2024: 3; 2025: 4; 2026: 6.
13 papers.
Sort:
By area:
- 2025PIShield: Detecting Prompt Injection Attacks via Intrinsic LLM Featurescited by 13
- 2025Advancing Embodied Agent Security: From Safety Benchmarks to Input Moderationcited by 12
- 2024Efficient and Effective Universal Adversarial Attack against Vision-Language Pre-training Modelscited by 4
- 2026GAVEL: Towards Rule-Based Safety Through Activation Monitoringcited by 4
- 2026Are LLM-Enhanced Graph Neural Networks Robust against Poisoning Attacks?cited by 4
- 2025When Grammar Guides the Attack: Uncovering Control-Plane Vulnerabilities in LLMs with Structured Outputcited by 3
- 2024Bridging Today and the Future of Humanity: AI Safety in 2024 and Beyondcited by 1
- 2024Behind Closed Words: Creating and Investigating the forePLay Annotated Dataset for Polish Erotic Discoursecited by 1
- 2026What Do Compliance Detectors Read? An Audit of Activation Probes and Guard Modelscited by 1
- 2025EdgeAIGuard: Agentic LLMs for Minor Protection in Digital Spacescited by 0
- 2026VLMShield: Efficient and Robust Defense of Vision-Language Models against Malicious Promptscited by 0
- 2026CHAIRO: Contextual Hierarchical Analogical Induction and Reasoning Optimization for LLMscited by 0
1 more
- 2026ForeSight: Enhancing Risk Monitoring via Early Safety Signal Distillation12 Sep 2026
- 2026What Do Compliance Detectors Read? An Audit of Activation Probes and Guard Models17 Aug 2026
- 2026CHAIRO: Contextual Hierarchical Analogical Induction and Reasoning Optimization for LLMs12 Apr 2026
- 2026VLMShield: Efficient and Robust Defense of Vision-Language Models against Malicious Prompts7 Apr 2026
- 2026Are LLM-Enhanced Graph Neural Networks Robust against Poisoning Attacks?27 Mar 2026
- 2026GAVEL: Towards Rule-Based Safety Through Activation Monitoring27 Jan 2026
- 2025PIShield: Detecting Prompt Injection Attacks via Intrinsic LLM Features15 Oct 2025
- 2025Advancing Embodied Agent Security: From Safety Benchmarks to Input Moderation22 Apr 2025
- 2025When Grammar Guides the Attack: Uncovering Control-Plane Vulnerabilities in LLMs with Structured Output31 Mar 2025
- 2025EdgeAIGuard: Agentic LLMs for Minor Protection in Digital Spaces28 Feb 2025
- 2024Behind Closed Words: Creating and Investigating the forePLay Annotated Dataset for Polish Erotic Discourse23 Dec 2024
- 2024Efficient and Effective Universal Adversarial Attack against Vision-Language Pre-training Models15 Oct 2024
1 more
- 2026GAVEL: Towards Rule-Based Safety Through Activation Monitoringcited by 4
- 2026Are LLM-Enhanced Graph Neural Networks Robust against Poisoning Attacks?cited by 4
- 2024Bridging Today and the Future of Humanity: AI Safety in 2024 and Beyondcited by 1
- 2024Behind Closed Words: Creating and Investigating the forePLay Annotated Dataset for Polish Erotic Discoursecited by 1
- 2026What Do Compliance Detectors Read? An Audit of Activation Probes and Guard Modelscited by 1
- 2026What Do Compliance Detectors Read? An Audit of Activation Probes and Guard Models17 Aug 2026
- 2026Are LLM-Enhanced Graph Neural Networks Robust against Poisoning Attacks?27 Mar 2026
- 2026GAVEL: Towards Rule-Based Safety Through Activation Monitoring27 Jan 2026
- 2024Behind Closed Words: Creating and Investigating the forePLay Annotated Dataset for Polish Erotic Discourse23 Dec 2024
- 2024Bridging Today and the Future of Humanity: AI Safety in 2024 and Beyond9 Oct 2024