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.


翻译:大型语言模型(LLMs)在生成式推理和长上下文任务上超越了早期架构,但其庞大体积带来了显著的内存占用、能耗成本和设备端部署挑战。由于扩展预训练语言模型能提升下游能力 \cite{zhao2023survey},键值(KV)缓存成为主导推理瓶颈。近年来的KV缓存压缩方法 \cite{jo2025fastkv,li2024snapkv,zhou2024dynamickv} 通过仅保留与注意力相关令牌子集来降低此成本。然而,尽管这些方法能保持良性工作负载下的精度,其压缩策略要么无法防御越狱攻击 \cite{jiang2024robustkv},要么在激进驱逐策略下削弱安全对齐。我们提出AnchorKV,一种对KV缓存压缩的即插即用修改方案,该方案使令牌保留分数偏离与有害提示相关的键空间方向。AnchorKV通过将差异均值表示工程方法 \cite{arditi2024refusal,zou2023representation} 适配至KV缓存使用的层级键投影空间,构建离线安全锚点。基于该锚点,软惩罚令牌选择规则以少量实用性换取显著提升的安全对齐,当惩罚为零时退化为原始压缩器。

0
下载
关闭预览

相关内容

《Palantir任务保障性软件安全标准(MA-S2)》
专知会员服务
24+阅读 · 5月30日
158页!天大等最新《大型语言模型安全:全面综述》
专知会员服务
50+阅读 · 2024年12月24日
KnowledGPT:基于知识库的检索和存储访问增强大型语言模型
基于知识蒸馏的BERT模型压缩
大数据文摘
18+阅读 · 2019年10月14日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
5+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
4+阅读 · 6月17日
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员