软注意力可模拟硬注意力,关键在温度调控与位置编码。
Simulating Hard Attention Using Soft Attention
- 用温度缩放和无界位置编码实现逻辑公式的计算
- 通过动态温度控制,使软注意力聚焦特定位置
- 为理解注意力机制提供理论支持,适合模型设计者
我们研究了使用软注意力的Transformer在何种条件下可模拟硬注意力,即有效将注意力集中于部分位置。首先,我们分析了几类由硬注意力Transformer识别的语言,这些语言可用线性时序逻辑的变体定义。我们证明了利用无界位置编码或温度缩放,软注意力Transformer能够计算这些逻辑公式。其次,我们展示了温度缩放如何使Softmax Transformer模拟通用硬注意力Transformer,其中温度依赖于最大注意力得分与其他得分之间的最小差距。
原文摘要 · Abstract (English)
We study conditions under which transformers using soft attention can simulate hard attention, that is, effectively focus all attention on a subset of positions. First, we examine several subclasses of languages recognized by hard-attention transformers, which can be defined in variants of linear temporal logic. We demonstrate how soft-attention transformers can compute formulas of these logics using unbounded positional embeddings or temperature scaling. Second, we demonstrate how temperature scaling allows softmax transformers to simulate general hard-attention transformers, using a temperature that depends on the minimum gap between the maximum attention scores and other attention scores.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。