AnchorKV: 通过拒绝锚点的软惩罚实现安全感知的KV缓存压缩
AnchorKV: Safety-Aware KV Cache Compression via Soft Penalty with a Refusal Anchor
AI总结:
提出AnchorKV,一种通过软惩罚机制调整令牌保留分数以远离有害提示的KV缓存压缩方法,在保持实用性的同时显著提升安全性。
摘要:
大型语言模型(LLMs)在生成推理和长上下文任务上优于早期架构,但其庞大的规模在内存使用、能耗和设备端部署方面带来了重大挑战。由于缩放预训练语言模型能提升下游能力\cite{zhao2023survey},键值(KV)缓存成为主要的推理瓶颈。最近的KV缓存压缩方法\cite{jo2025fastkv,li2024snapkv,zhou2024dynamickv}通过仅保留注意力相关令牌的子集来降低这一成本。然而,虽然这些方法在良性工作负载上保持了准确性,但其压缩策略要么无法防御越狱攻击\cite{jiang2024robustkv},要么在激进驱逐下降低安全对齐。我们提出AnchorKV,一种对KV缓存压缩的即插即用修改,它使令牌保留分数偏向远离与有害提示相关的键空间方向。AnchorKV通过将均值差异表示工程方法\cite{arditi2024refusal,zou2023representation}适配到KV缓存中使用的层特定键投影空间,构建了一个离线安全锚点。基于该锚点,一种软惩罚令牌选择规则以少量效用换取显著改善的安全对齐,当惩罚为零时则退化为原始压缩器。
英文摘要:
Large language models (LLMs) outperform earlier architectures on generative inference and long-context tasks, but their large size introduces significant challenges in memory usage, energy cost, and on-device deployment. Since scaling pre-trained language models improves downstream capability \cite{zhao2023survey}, the key-value (KV) cache becomes a dominant inference bottleneck. Recent KV cache compression methods \cite{jo2025fastkv,li2024snapkv,zhou2024dynamickv} reduce this cost by retaining only a subset of attention-relevant tokens. However, while these approaches preserve accuracy on benign workloads, their compression policies either fail to defend against jailbreak attacks \cite{jiang2024robustkv} or degrade safety alignment under aggressive eviction. We propose AnchorKV, a drop-in modification to KV cache compression that biases token retention scores away from directions in key space associated with harmful prompts. AnchorKV constructs an offline safety anchor by adapting a difference-of-means representation engineering approach \cite{arditi2024refusal,zou2023representation} to the layer-specific key projection space used in KV caching. Based on this anchor, a soft penalty token selection rule trades a small amount of utility for substantially improved safety alignment, while reducing to the original compressor when the penalty is zero.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。