arXiv:2510.19875cs.CLcs.AI2025-10被引 2

用稀疏注意力技术让大模型长文本解释变快,10万词也能实时分析。

Stream: Scaling up Mechanistic Interpretability to Long Context in LLMs via Sparse Attention

  • 用分层剪枝算法动态筛选关键注意力块,时间复杂度近线性。
  • 在百万词上下文中剪掉97%-99%的交互,仍保留核心推理路径。
  • 可在消费级显卡上运行,适合研究长链思维和信息流追踪的人。

随着大语言模型上下文长度扩展至百万词,传统机制可解释性方法的计算开销随上下文长度平方增长,超过10万词时需数TB内存。本文提出稀疏追踪(Sparse Tracing)技术,利用动态稀疏注意力高效分析长上下文注意力模式。我们设计了可编译的层级剪枝算法Stream,以近线性时间$O(T /log T)$和线性空间$O(T)$估算每头的稀疏注意力掩码,实现单遍可解释性分析。Stream通过二分搜索式精炼,仅保留每查询的前-k个关键块,同时保持模型下一个词预测行为不变。应用于长链思维推理轨迹时,识别出思维锚点并剪除97%-99%的词间交互。在RULER基准测试中,Stream保留关键检索路径,剔除90%-96%的交互,并揭示从‘针’到输出的逐层传递路径。该方法为长上下文注意力分析提供无需大量缓存的实用工具,使长上下文可解释性在消费级GPU上成为可能,助力思维链监控的普及。代码已公开于https://anonymous.4open.science/r/stream-03B8/。

原文摘要 · Abstract (English)

As Large Language Models (LLMs) scale to million-token contexts, traditional Mechanistic Interpretability techniques for analyzing attention scale quadratically with context length, demanding terabytes of memory beyond 100,000 tokens. We introduce Sparse Tracing, a novel technique that leverages dynamic sparse attention to efficiently analyze long context attention patterns. We present Stream, a compilable hierarchical pruning algorithm that estimates per-head sparse attention masks in near-linear time $O(T \log T)$ and linear space $O(T)$, enabling one-pass interpretability at scale. Stream performs a binary-search-style refinement to retain only the top-$k$ key blocks per query while preserving the model's next-token behavior. We apply Stream to long chain-of-thought reasoning traces and identify thought anchors while pruning 97-99\% of token interactions. On the RULER benchmark, Stream preserves critical retrieval paths while discarding 90-96\% of interactions and exposes layer-wise routes from the needle to output. Our method offers a practical drop-in tool for analyzing attention patterns and tracing information flow without terabytes of caches. By making long context interpretability feasible on consumer GPUs, Sparse Tracing helps democratize chain-of-thought monitoring. Code is available at https://anonymous.4open.science/r/stream-03B8/.

可解释性长上下文稀疏注意力链式思维

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。