arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2305.13673cs.CLcs.AIcs.LG
收藏

语言模型的物理学:第1部分,学习分层语言结构

Physics of Language Models: Part 1, Learning Hierarchical Language Structures

Meta / FAIR Labs(Meta / FAIR 实验室);Mohamed bin Zayed University of AI(穆罕默德·本·扎耶德人工智能大学)

Zeyuan Allen-Zhu, Yuanzhi Li

AI总结:

该研究探究Transformer语言模型对上下文无关文法定义的递归分层语言结构的推理能力,验证了GPT类模型的学习推理效果,揭示其内部机制,并提出关于位置嵌入、注意力类型等多方面推论。

摘要:

基于Transformer的语言模型虽效果出色但结构复杂,理解其内部运作与推理机制是一项重大挑战。以往研究主要探索这类模型如何处理名称复制或选择等简单任务,我们在此基础上拓展研究,探究这些模型如何执行由上下文无关文法(CFGs)定义的递归语言结构推理。我们提出了一类能产生分层规则的合成CFG,这类文法可生成长句(例如数百个token),这些句子存在局部歧义,需要通过动态规划来解析。尽管存在这种复杂性,我们证明了GPT等生成式模型能够准确学习并基于CFG定义的分层结构进行推理,还能据此生成句子。我们探究了模型的内部机制,发现其隐藏状态能精准捕捉CFG的结构,且注意力模式与动态规划算法中的信息传递相似。\n本文还提出了若干推论,包括解释了绝对位置嵌入为何劣于相对位置嵌入与旋转位置嵌入;仅均匀注意力本身就具有出人意料的效果(这也推动了我们后续关于Canon层的研究);与自回归模型(例如GPT)相比,仅编码器模型(例如BERT、DeBERTa)在CFG的深度结构推理上表现不佳;在预训练数据中注入结构或句法噪声,能显著提升模型对被破坏的语言提示的鲁棒性。

英文摘要:

Transformer-based language models are effective but complex, and understanding their inner workings and reasoning mechanisms is a significant challenge. Previous research has primarily explored how these models handle simple tasks like name copying or selection, and we extend this by investigating how these models perform recursive language structure reasoning defined by context-free grammars (CFGs). We introduce a family of synthetic CFGs that produce hierarchical rules, capable of generating lengthy sentences (e.g., hundreds of tokens) that are locally ambiguous and require dynamic programming to parse. Despite this complexity, we demonstrate that generative models like GPT can accurately learn and reason over CFG-defined hierarchies and generate sentences based on it. We explore the model's internals, revealing that its hidden states precisely capture the structure of CFGs, and its attention patterns resemble the information passing in a dynamic programming algorithm. This paper also presents several corollaries, including showing why absolute positional embeddings is inferior to relative and rotary embeddings; uniform attention alone is surprisingly effective (motivating our follow-up work on Canon layers); encoder-only models (e.g., BERT, DeBERTa) struggle with deep structure reasoning on CFGs compared to autoregressive models (e.g., GPT); and injecting structural or syntactic noise into pretraining data markedly improves robustness to corrupted language prompts.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑