FlashAttention with Statistics: Low-Overhead Attention Features for Compact Hallucination Detectors

📄 arXiv: 2610.21483v1 📥 PDF

作者: Andrei Volodichev, Maksim Savichev, Nikita Sviridov, Artem Yuliy, Dmitry Simakov, Alexey Zaytsev

分类: cs.AI

发布日期: 2026-10-15


💡 一句话要点

提出低开销注意力特征以提升紧凑型幻觉检测器的性能

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 幻觉检测 注意力机制 大型语言模型 统计特征 内存优化

📋 核心要点

  1. 现有的基于注意力的检测器在处理大型语言模型生成的幻觉回答时,面临着内存消耗过大的挑战。
  2. 论文提出了一种新方法,通过在FlashAttention过程中计算注意力统计数据,避免了注意力矩阵的物化,从而降低了内存开销。
  3. 实验结果显示,使用该方法的探测器在多个基准测试中表现优异,显著提升了F1得分,且延迟增加幅度较小。

📝 摘要(中文)

大型语言模型可能会生成与提供的上下文不符的流畅回答。紧凑的冻结代理模型可以通过读取上下文和其他模型的响应来检测这些回答。基于注意力的检测器使用代理注意力权重的汇总统计,但标准流程会物化注意力矩阵,导致内存随序列长度呈平方增长。本文通过在FlashAttention过程中进行累积、稀疏查找或对得分进行第二次分块处理,计算这些统计数据,而无需物化注意力,并将其分类为几乎免费的和成本较高的。实验结果表明,五个已发布检测器的统计数据在H100上对Qwen3-8B的前向推理增加了16%的延迟,在35K时降至1.4%,每个响应令牌存储22.5 KiB。经过训练的探测器在三个基准上表现出色,4B代理在F1上超越了九个零样本4-9B LLM评估者中的最强者。

🔬 方法详解

问题定义:本文旨在解决大型语言模型生成的幻觉回答检测中的内存消耗问题。现有方法需要物化注意力矩阵,导致内存需求随序列长度平方增长,限制了其应用。

核心思路:论文的核心思路是通过在FlashAttention过程中直接计算注意力统计数据,避免物化注意力矩阵,从而降低内存开销并提高检测效率。

技术框架:整体架构包括三个主要模块:FlashAttention过程中的统计数据累积、稀疏查找以及对得分的第二次分块处理。通过这些模块,能够高效地提取注意力特征。

关键创新:最重要的技术创新在于通过不物化注意力矩阵而直接计算统计数据,这与传统方法形成了本质区别,显著降低了内存需求。

关键设计:在设计中,采用了高效的累积算法和稀疏查找策略,确保在计算注意力统计时的低开销,同时保持检测器的性能。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,五个已发布检测器的统计数据在H100上对Qwen3-8B的前向推理增加了16%的延迟,在35K时降至1.4%。此外,经过训练的探测器在多个基准测试中表现优异,4B代理在F1得分上超越了九个零样本4-9B LLM评估者中的最强者。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理中的幻觉检测、对话系统的可靠性提升以及大型语言模型的安全性评估。通过提高检测器的效率和准确性,可以在实际应用中更好地识别和处理不准确的生成内容,增强用户信任。

📄 摘要(原文)

Large language models can produce fluent answers that the supplied context does not support. A compact frozen proxy model can detect such answers by reading the context and another model's response, even from a proprietary generator. Attention-based detectors use summary statistics of the proxy's attention weights, but standard pipelines materialize the attention matrix, whose memory grows quadratically with sequence length. We compute these statistics without materializing attention, by accumulation in the FlashAttention pass, sparse lookups after it, or a second tiled pass over the scores, and classify them by this path into nearly free and costlier ones. On an H100, the statistics of five published detectors add 16% to the latency of a Qwen3-8B forward at 2K tokens, falling to 1.4% at 35K, and store 22.5 KiB per response token. On three benchmarks, probes trained on frozen Qwen3 proxies of 0.6B to 8B parameters prove strong detectors: a 4B proxy outperforms the strongest of nine zero-shot 4-9B LLM judges in F1 on two of the three, the proxies match or outperform specialized grounding checkers of up to 7B parameters, probing each proxy beats prompting it as a judge, and adding attention features significantly improves F1 in half of the 12 benchmark-proxy pairs, never significantly lowering it.