用稀疏编码思想改进注意力机制,让模型更好理解组合规则。
In-Context Compositional Learning via Sparse Coding Transformer
- 将注意力重构成稀疏编码框架,用字典原子分解输入结构
- 在S-RAVEN和RAVEN数据集上显著提升组合泛化性能
- 适合需要理解复杂规则的推理任务,如视觉推理与符号逻辑
Transformer架构在语言、视觉和多模态任务中表现卓越,但对上下文组合学习任务仍具挑战。这类任务要求模型从上下文样例中推断出由基本组件按潜在规则组合而成的规律。然而,标准Transformer缺乏对组合结构的固有归纳偏置。受稀疏编码启发,本文提出一种注意力机制的重构:将输入映射到输出的过程视为在两个可学习字典(编码字典与解码字典)上的投影。编码字典将输入分解为稀疏系数,表示其组合结构,并通过施加稀疏性增强结构表达能力;这些系数再线性组合解码字典原子生成输出。为进一步支持组合泛化,我们通过上下文样例系数的线性组合来估计目标问题的系数。实验表明,在S-RAVEN和RAVEN数据集上,该方法在某些组合泛化任务中表现优于标准Transformer,尤其在后者失效时仍保持稳定性能,归因于其对组合规则的学习与应用能力。
原文摘要 · Abstract (English)
Transformer architectures have achieved remarkable success across language, vision, and multimodal tasks, and there is growing demand for them to address in-context compositional learning tasks. In these tasks, models solve the target problems by inferring compositional rules from context examples, which are composed of basic components structured by underlying rules. However, some of these tasks remain challenging for Transformers, which are not inherently designed to handle compositional tasks and offer limited structural inductive bias. In this work, inspired by the principle of sparse coding, we propose a reformulation of the attention to enhance its capability for compositional tasks. In sparse coding, data are represented as sparse combinations of dictionary atoms with coefficients that capture their compositional rules. Specifically, we reinterpret the attention block as a mapping of inputs into outputs through projections onto two sets of learned dictionary atoms: an encoding dictionary and a decoding dictionary. The encoding dictionary decomposes the input into a set of coefficients, which represent the compositional structure of the input. To enhance structured representations, we impose sparsity on these coefficients. The sparse coefficients are then used to linearly combine the decoding dictionary atoms to generate the output. Furthermore, to assist compositional generalization tasks, we propose estimating the coefficients of the target problem as a linear combination of the coefficients obtained from the context examples. We demonstrate the effectiveness of our approach on the S-RAVEN and RAVEN datasets. For certain compositional generalization tasks, our method maintains performance even when standard Transformers fail, owing to its ability to learn and apply compositional rules.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。