Transformers excel empirically on tasks that process well-formed inputs according to some grammar, such as natural language and code. However, it remains unclear how they can process grammatical syntax. In fact, under standard complexity conjectures, standard transformers cannot recognize context-free languages (CFLs), a canonical formalism to describe syntax, or even regular languages, a subclass of CFLs. Past work has shown that $\mathcal{O}(\log(N))$ looping layers (w.r.t. input length $N$) allow transformers to recognize regular languages, but the question of context-free recognition with looped transformers remained open. In this work, we show that looped transformers with $\mathcal{O}(\log(N))$ looping layers and $\mathcal{O}(N^6)$ padding symbols can recognize all CFLs. However, training and inference with $\mathcal{O}(N^6)$ padding symbols is potentially impractical. Fortunately, we show that, for natural subclasses such as unambiguous CFLs, the recognition problem on transformers becomes more tractable, requiring $\mathcal{O}(N^3)$ padding. Empirically, looped and padded transformers perform better than fixed-depth transformers in recognizing CFLs. Overall, our results shed light on the intricacy of CFL recognition by transformers: while general recognition may require an intractable amount of padding, natural constraints such as unambiguity yield efficient recognition algorithms.


翻译:Transformer在处理符合语法规则的结构化输入(如自然语言和代码)时展现出卓越的实验性能。然而,它们如何解析语法结构仍不明确。事实上,在标准复杂度猜想下,标准Transformer既无法识别上下文无关语言(语法描述的经典形式化体系),也无法识别其子类正则语言。已有研究表明,$\mathcal{O}(\log(N))$个循环层(相对于输入长度$N$)可使Transformer识别正则语言,但循环Transformer是否能识别上下文无关语言仍是悬而未决的问题。本文证明,具有$\mathcal{O}(\log(N))$个循环层及$\mathcal{O}(N^6)$个填充符号的循环Transformer可识别所有上下文无关语言。但$\mathcal{O}(N^6)$量级的填充符号在训练与推理中可能缺乏实用性。值得关注的是,对于无歧义上下文无关语言等自然子类,Transformer的识别问题更易处理,仅需$\mathcal{O}(N^3)$个填充符号。实验表明,循环填充Transformer在上下文无关语言识别任务上优于固定深度Transformer。总体而言,我们的研究揭示了Transformer识别上下文无关语言的复杂性:虽然通用识别可能需要难以承受的填充量,但无歧义性等自然约束可催生高效的识别算法。

0
下载
关闭预览

相关内容

【CMU博士论文】长度可外推的Transformer,149页pdf
专知会员服务
27+阅读 · 2024年6月30日
Transformer文本分类代码
专知会员服务
118+阅读 · 2020年2月3日
【Tutorial】计算机视觉中的Transformer,98页ppt
专知
21+阅读 · 2021年10月25日
百闻不如一码!手把手教你用Python搭一个Transformer
大数据文摘
18+阅读 · 2019年4月22日
多图带你读懂 Transformers 的工作原理
AI研习社
10+阅读 · 2019年3月18日
BERT大火却不懂Transformer?读这一篇就够了
大数据文摘
12+阅读 · 2019年1月8日
国家自然科学基金
3+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 6月5日
Arxiv
0+阅读 · 5月15日
Arxiv
0+阅读 · 5月7日
Arxiv
0+阅读 · 3月25日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
4+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
4+阅读 · 6月17日
相关VIP内容
【CMU博士论文】长度可外推的Transformer,149页pdf
专知会员服务
27+阅读 · 2024年6月30日
Transformer文本分类代码
专知会员服务
118+阅读 · 2020年2月3日
相关基金
国家自然科学基金
3+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
8+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员