Safety
SafeSpec: Fast and Safe LLM via Dynamic Reflective Sampling
SafeSpec is a novel framework designed to enhance the safety of speculative inference in large language models (LLMs) by integrating risk estimation into the verification process. It introduces a lightweight latent safety head that allows for simultaneous evaluation of semantic validity and safety during a single forward pass, enabling rollback and safety-guided reflective multi-sampling to recover safe continuations when unsafe generations are detected. Tested on the Qwen3-32B model, SafeSpec achieved a 15% reduction in attack success rates while maintaining a 2.06x speedup in inference, demonstrating a significant improvement in the safety-efficiency trade-off for practitioners working with LLMs.
speculative inferencesafetyLLM