arXiv:2607.04319cs.CLcs.LG2026-07被引 2

让Transformer的注意力机制可读,且不损失语言模型性能。

Legible-by-Construction: Attention and End-to-End Transformers

论文配图:Legible-by-Construction: Attention and End-to-End Transformers
图 1 · 摘自论文原文
  • 用sigmoid将值通道转为可读的特征检测器,零参数增加。
  • 44%至62%的通道成为清晰、上下文敏感的逻辑检测器。
  • 端到端可读模型生成结果可逐层解析,适合可解释性研究。

前一篇论文表明,Transformer的前馈层可通过显式的模糊集合运算(交集、差集、自遗忘序列量化器)重构,使隐藏单元读作命名逻辑算子,且不影响语言模型质量。本文将此思路扩展至注意力机制,并融合二者形成统一模型。核心机制极简:将注意力头的值通过sigmoid处理,使每个值通道变为可读的特征存在检测器,不增加参数且保持原有结构不变。布尔变体进一步重构值为显式的词内交集与可否定差集。两种设计均保留输出投影自由,不绑定词汇表——这是关键:限定检测范围而不限制输出,才能实现选择性检测;若限制输出则无法实现。通过双重选择性压力(稀疏激活与边缘决策),不同设计效果各异。在5种专用注意力设计中,125M参数规模下,44%至62%的值通道成为清晰、上下文敏感的检测器,且其可读性随深度提升而非仅集中在标点处。语言模型性能与标准基线持平。最终,我们将布尔注意力与可读前馈层结合,训练出端到端可读的生成模型,在基准性能上达成一致:其前馈单元始终为命名的集合与量化操作,可对生成的词逐层解读构成过程。

原文摘要 · Abstract (English)

A companion paper showed that a transformer's feed-forward layer can be rebuilt from explicit fuzzy set operations - intersection, set-difference, and a self-forgetting sequence quantifier - so its hidden units read as named logical operators at no cost to language-model quality. That left the other half of the transformer opaque. Here we carry the same idea into attention and join the two into one model. The mechanism is minimal: a head's value is passed through a sigmoid, so each value channel becomes a readable detector of whether a feature holds at a token. This adds no parameters and leaves the standard head otherwise untouched. A Boolean variant goes further, restructuring the value into an explicit within-token intersection and negation-capable set-difference. In both designs the output projection is left free, not tied to the vocabulary, which is the load-bearing decision: bounding what a head detects while leaving what it writes unconstrained yields selective detectors, whereas constraining the write does not. A bounded value is shaped into a readable detector by two selectivity pressures - one for sparse firing, one for decisive firing at the rails - and which a design wants is not universal. Across five specialized-attention designs at 125M parameters, 44 to 62 percent of value channels become crisp, contextually selective detectors, and their legibility rises with depth rather than crystallizing only on punctuation. Language-model quality is at parity with a conventional baseline. Finally, we couple the Boolean attention to the legible feed-forward layer and train an end-to-end legible-by-construction language model at benchmark parity: its feed-forward units are named set and quantifier operations throughout, and we can take a token it generates and read the named units that compose to produce it.

可解释性Transformer注意力机制生成模型

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