potentialpaper

Context-free Recognition with Transformers

Keep the title, authors and abstract in paper.json

potentialpaper · 2026-11-23 18:47 UTC · 4f746ff80d35 ·

.potentialpaper/metadata.json modified

+++ b/.potentialpaper/metadata.json
@@ -1,25 +1,5 @@
{
- "layout": 5,
- "identifiers": [
- {
- "scheme": "openreview",
- "value": "ACn1hhGcV4"
- }
- ],
- "title": "Context-free Recognition with Transformers",
- "authors": [
- "Selim Jerad",
- "Anej Svete",
- "Sophie Hao",
- "Ryan Cotterell",
- "William Merrill"
- ],
- "abstract": "Transformers excel 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 internally. 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. Merrill & Sabharwal (2025) show that $\\mathcal{O}(log(n))$ looping layers (w.r.t. input length $n$) allows transformers to recognize regular languages, but the question of context-free recognition remained open. In this work, we show that looped transformers with $\\mathcal{O}(log(n))$ looping layers and $\\mathcal{O}(n^6)$ padding tokens can recognize all CFLs. However, training and inference with $\\mathcal{O}(n^6)$ padding tokens 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.\nWe empirically validate our results and show that looping helps on languages that require logarithmic depth.\nOverall, 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.",
- "year": 2026,
- "venue": "ICLR 2026 submission",
- "source": "openreview",
- "license": {
- "metadata": "CC0-1.0",
- "abstract": "CC0-1.0"
- }
+ "layout": 6,
+ "kind": "paper",
+ "key": "658b4515-92c9-4b08-87a0-9eaf81a69e9c"
}

paper.json added

+++ b/paper.json
@@ -0,0 +1,15 @@
+{
+ "title": "Context-free Recognition with Transformers",
+ "authors": [
+ "Selim Jerad",
+ "Anej Svete",
+ "Sophie Hao",
+ "Ryan Cotterell",
+ "William Merrill"
+ ],
+ "abstract": "Transformers excel 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 internally. 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. Merrill & Sabharwal (2025) show that $\\mathcal{O}(log(n))$ looping layers (w.r.t. input length $n$) allows transformers to recognize regular languages, but the question of context-free recognition remained open. In this work, we show that looped transformers with $\\mathcal{O}(log(n))$ looping layers and $\\mathcal{O}(n^6)$ padding tokens can recognize all CFLs. However, training and inference with $\\mathcal{O}(n^6)$ padding tokens 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.\nWe empirically validate our results and show that looping helps on languages that require logarithmic depth.\nOverall, 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.",
+ "license": {
+ "metadata": "CC0-1.0",
+ "abstract": "CC0-1.0"
+ }
+}