[论文解读] Transformers meet Neural Algorithmic Reasoners
本文提出 TransNAR,一种混合模型,将基于预训练图神经网络的神经算法推理器(NAR)与 Transformer 结合,以增强自然语言任务中的算法推理能力。通过采用两阶段训练流程,使 Transformer 的标记与 NAR 的节点嵌入之间实现交叉注意力,TransNAR 在 CLRS-Text 基准测试中实现了显著提升——在分布外泛化性能上取得超过 20% 的绝对增益,尤其在形状得分和 CLRS 得分方面表现优异,优于纯 Transformer 模型。
Transformers have revolutionized machine learning with their simple yet effective architecture. Pre-training Transformers on massive text datasets from the Internet has led to unmatched generalization for natural language understanding (NLU) tasks. However, such language models remain fragile when tasked with algorithmic forms of reasoning, where computations must be precise and robust. To address this limitation, we propose a novel approach that combines the Transformer's language understanding with the robustness of graph neural network (GNN)-based neural algorithmic reasoners (NARs). Such NARs proved effective as generic solvers for algorithmic tasks, when specified in graph form. To make their embeddings accessible to a Transformer, we propose a hybrid architecture with a two-phase training procedure, allowing the tokens in the language model to cross-attend to the node embeddings from the NAR. We evaluate our resulting TransNAR model on CLRS-Text, the text-based version of the CLRS-30 benchmark, and demonstrate significant gains over Transformer-only models for algorithmic reasoning, both in and out of distribution.
研究动机与目标
- 为解决纯 Transformer 模型在算法推理任务中,尤其是在分布外泛化情况下的脆弱性问题。
- 通过将预训练的神经算法推理器(NAR)集成到 Transformer 架构中,弥合自然语言理解与稳健算法计算之间的差距。
- 通过将推理过程建立在基于图神经网络的结构化嵌入之上,使 Transformer 能够有效泛化到未见过的输入规模和问题结构。
- 证明将语言模型与算法推理器结合的混合架构,可在复杂、符号化的文本推理任务中实现更优且更可靠的性能。
提出的方法
- TransNAR 模型采用两阶段训练流程:首先在图结构化的算法任务上预训练 NAR,然后通过交叉注意力对混合的 Transformer-NAR 系统进行微调。
- Transformer 通过可学习的交叉注意力层关注 NAR 的节点和边嵌入,使其在解码过程中能够动态访问结构化的算法知识。
- NAR 是一个预训练的基于图神经网络的模型(例如,Triplet-GMPNN),能够对图输入执行多种算法,提供稳健且可泛化的推理能力。
- 在多个网络层应用交叉注意力,使 Transformer 能够在整个序列中利用高维 NAR 嵌入来调节其标记表示。
- 在 CLRS-Text 上进行评估,该数据集是 CLRS-30 基准的文本版本,采用多维评估指标,包括形状、解析和 CLRS 得分。
- 通过在标准 Transformer 层之间交错插入门控交叉注意力层,实现语言模型与 NAR 之间的双向信息流动。
![Figure 1 : Our TransNAR architecture, with its direct synergy of Transformers and Neural Algorithmic Reasoners, yields clear improvements in out-of-distribution reasoning across wide categories of algorithmic tasks in CLRS-Text [ 20 ] , a textual version of the CLRS-30 benchmark [ 35 ] . Here, the $](https://ar5iv.labs.arxiv.org/html/2406.09308/assets/icml2024/imgs/block-plot.png)
实验结果
研究问题
- RQ1预训练的神经算法推理器(NAR)能否被有效集成到 Transformer 中,以提升自然语言输入下的算法推理能力?
- RQ2将语言模型与基于图神经网络的 NAR 融合,是否能相比纯 Transformer 模型,在算法任务上实现更好的分布外泛化能力?
- RQ3NAR 嵌入在缓解大型语言模型常见失败模式(如输出形状错误或解析错误)方面发挥何种作用?
- RQ4Transformer 与 NAR 嵌入之间的交叉注意力机制,是否能实现对多样化算法族和输入规模的更稳健、更准确的推理?
- RQ5当前混合方法的局限性是什么,特别是在处理基于索引的搜索或新型边界条件的任务时?
主要发现
- 与基线 Transformer 相比,TransNAR 在多个算法族的分布外设置下,CLRS 得分提升超过 20% 的绝对值。
- 该模型显著提升了形状准确率,表明其缓解了大型语言模型在输出长度或结构错误方面的关键失败模式。
- 在二分查找、最大子数组查找、最小值查找和快速选择等任务中,索引搜索为核心操作,TransNAR 未能超越基线模型,表明其存在与未见索引边界相关的共性失败模式。
- TransNAR 的形状得分始终更高,表明将输出基于 NAR 嵌入可显著提高生成结构正确响应的可能性。
- 两种模型的解析准确率均保持较高水平,表明主要失败模式并非源于解析错误,而在于输出的结构与语义正确性。
- 结果表明,经 NAR 增强的大型语言模型可在纯 Transformer 完全失效的外推场景中实现涌现的分布外泛化能力,尤其在需要外推的设置中表现突出。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。