只调初始标记的注意力,就能让大模型性能提升,无需训练。
ZeroTuning: Unlocking the Initial Token's Power to Enhance Large Language Models Without Training
- 仅修改初始标记的注意力权重,无需参数更新。
- 在15个数据集上提升性能,最高相对增益19.9%。
- 适用于量化推理和长文本,兼容主流注意力核。
令牌级注意力调优是一种无需训练的方法,包括事后注意力引导(PASTA)和注意力校准(ACT),通过可解释干预提升冻结的大语言模型。然而,这些方法依赖辅助启发式识别任务相关的关键令牌,可能引入偏差,且当令牌重要性模糊或优化内核使注意力图不可访问时适用性受限。我们提出更简单的替代方案:仅对初始令牌(如LLaMA中的BOS)进行干预。理论上,向该令牌的注意力logits添加轻量级偏置可系统性地改变下游注意力模式——这一效应因其天然作为注意力汇聚点的角色而被放大。实证发现,该调优能提升模型性能并更好激发预训练知识,效果在早期层更强,不同注意力头呈现不同缩放偏好。基于此,我们提出ZeroTuning,一种通过头特定调整初始令牌注意力来提升模型性能的无训练方法,无需参数更新。提供两种变体:监督模式在验证集上校准,无监督模式直接最小化输出熵。ZeroTuning无需修改键值缓存或解码流程,与SDPA和FlashAttention兼容。仅需修改LlamaAttention代码四行,覆盖15个数据集,在Llama-3.1-8B上实现分类任务19.9%、问答任务4.5%、对话任务2.1%的相对提升。该方法开箱即用支持量化推理,并随上下文长度增加保持增益。
原文摘要 · Abstract (English)
Token-level attention tuning, a class of training-free methods including Post-hoc Attention Steering (PASTA) and Attention Calibration (ACT), has emerged as a promising approach for improving frozen LLMs via interpretable interventions. However, these methods rely on auxiliary heuristics to identify important task-specific tokens, which can introduce bias and limit applicability when token importance is ambiguous or when optimized kernels make attention maps inaccessible. We propose a simpler alternative: intervening only on the initial token (e.g., BOS in LLaMA). We theoretically show that adding lightweight biases to this token's attention logits systematically shifts and reshapes downstream attention patterns - an effect amplified by its natural role as an attention sink. Empirically, we find that this tuning can improve LLM performance and better elicit pretrained knowledge, with stronger effects in early layers and distinct scaling preferences across attention heads. Building on these findings, we introduce ZeroTuning, a training-free method that improves LLM performance by applying head-specific attention adjustments to the initial token, requiring no parameter updates. We present two variants: a supervised mode that calibrates on validation examples, and an unsupervised mode that directly minimizes output entropy. ZeroTuning requires no KV-cache or decoding changes and is kernel-agnostic (works with SDPA and FlashAttention). It requires only four lines of modification to the standard LlamaAttention code, achieves gains across 15 datasets, and outperforms prior, more complex methods. For example, on Llama-3.1-8B, it yields relative improvements of 19.9% on classification, 4.5% on question answering, and 2.1% on dialogue. ZeroTuning also works out of the box with quantized inference and maintains its improvements as context length increases.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。