mlsanityData to 7 Oct 2026

Lightweight Safety Classification Using Pruned Language Models

arXiv 2412.13435 ↗First posted 18 Dec 2024cs.CL cs.AI cs.LGcited by 5

On the map: LLM safety and security → Safety alignment, refusal and guardrails

Abstract (arXiv)

In this paper, we introduce a novel technique for content safety and prompt injection classification for Large Language Models. Our technique, Layer Enhanced Classification (LEC), trains a Penalized Logistic Regression (PLR) classifier on the hidden state of an LLM's optimal intermediate transformer layer. By combining the computational efficiency of a streamlined PLR classifier with the sophisticated language understanding of an LLM, our approach delivers superior performance surpassing GPT-4o and special-purpose models fine-tuned for each task. We find that small general-purpose models (Qwen 2.5 sizes 0.5B, 1.5B, and 3B) and other transformer-based architectures like DeBERTa v3 are robust feature extractors allowing simple classifiers to be effectively trained on fewer than 100 high-quality examples. Importantly, the intermediate transformer layers of these models typically outperform the final layer across both classification tasks. Our results indicate that a single general-purpose LLM can be used to classify content safety, detect prompt injections, and simultaneously generate output tokens. Alternatively, these relatively small LLMs can be pruned to the optimal intermediate layer and used exclusively as robust feature extractors. Since our results are consistent on different transformer architectures, we infer that robust feature extraction is an inherent capability of most, if not all, LLMs.

Key facts. Cited by 5 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 28 of its 34 references that are in the map. First posted on arXiv 18 Dec 2024.

Builds on

28 of 34 references.

References · 28

  1. 2024The Llama 3 Herd of Modelscited by 14,192
  2. 2017A Unified Approach to Interpreting Model Predictionscited by 6,488
  3. 2019Explainable Artificial Intelligence (XAI): Concepts, Taxonomies, Opportunities and Challenges toward Responsible AIcited by 1,543
  4. 2016Understanding intermediate layers using linear classifier probescited by 1,279
  5. 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,130
  6. 2023Llama Guard: LLM-based Input-Output Safeguard for Human-AI Conversationscited by 1,124
  7. 2023LLM-Pruner: On the Structural Pruning of Large Language Modelscited by 643
  8. 2023LMSYS-Chat-1M: A Large-Scale Real-World LLM Conversation Datasetcited by 449
  9. 2024SALAD-Bench: A Hierarchical and Comprehensive Safety Benchmark for Large Language Modelscited by 225
  10. 2024The Unreasonable Ineffectiveness of the Deeper Layerscited by 219
  11. 2018Deep k-Nearest Neighbors: Towards Confident, Interpretable and Robust Deep Learningcited by 203
  12. 2024AEGIS: Online Adaptive AI Content Safety Moderation with Ensemble of LLM Expertscited by 126
16 more
  1. 2023The geometry of hidden representations of large transformer modelscited by 108
  2. 2024Attention Tracker: Detecting Prompt Injection Attacks in LLMscited by 82
  3. 2018Seq2Seq-Vis: A Visual Debugging Tool for Sequence-to-Sequence Modelscited by 69
  4. 2024From Understanding to Utilization: A Survey on Explainability for Large Language Modelscited by 47
  5. 2022On the Explainability of Natural Language Processing Deep Modelscited by 37
  6. 2024Diff-eRank: A Novel Rank-Based Metric for Evaluating Large Language Modelscited by 35
  7. 2019exBERT: A Visual Analysis Tool to Explore Learned Representations in Transformers Modelscited by 33
  8. 2024SPML: A DSL for Defending Language Models Against Prompt Attackscited by 33
  9. 2024Does Representation Matter? Exploring Intermediate Layers in Large Language Modelscited by 31
  10. 2023Prompt Packer: Deceiving LLMs through Compositional Instruction with Hidden Attackscited by 30
  11. 2022Prompt-Augmented Linear Probing: Scaling beyond the Limit of Few-shot In-Context Learnerscited by 18
  12. 2021Model Explainability in Deep Learning Based Natural Language Processingcited by 14
  13. 2023Towards Agile Text Classifiers for Everyonecited by 13
  14. 2024Large Language Models Are Overparameterized Text Encoderscited by 6
  15. 2024MINI-LLM: Memory-Efficient Structured Pruning for Large Language Modelscited by 5
  16. 2024Logistic Regression makes small LLMs strong and explainable "tens-of-shot" classifierscited by 3

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2025: 4; 2026: 1.

5 papers.