ScissorHands
分类: 高效推理与部署
ScissorHands
定义
一种基于重要性感知的 KV cache 驱逐(eviction)方法,通过识别历史 attention 中的”关键 token”来选择性保留 KV cache 条目,减少 LLM 长序列推理的内存开销
数学形式
其中 是第 步对第 个 token 的 attention weight, 为重要性阈值。累计被频繁关注的 token 保留在 cache 中
核心要点
观察到 LLM attention 分布具有 持久性(pivotal tokens):少数 token 在多个生成步骤中持续获得高 attention weight
利用此观察,仅保留历史上重要性得分高的 token 的 KV 对,驱逐不重要的
是 training-free 方法,直接在推理时应用,无需重新训练模型
与 SnapKV 类似思路但实现策略不同:ScissorHands 更侧重历史累计重要性
代表工作
ScissorHands (Liu et al., 2023): 提出 pivotal token 概念和基于历史重要性的 KV cache eviction
SnapKV: 类似思路,基于 attention pattern 压缩 KV cache
AttentionPack: per-head 自适应 KV 压缩,与 ScissorHands 的全局策略互补
相关概念
SnapKV — 同属 KV cache 压缩方法
FlashAttention — 系统级 attention 优化,与 KV cache 压缩正交
FastV — token 级视觉 token 剪枝,不同粒度的推理优化