Transformers as CFG Learners: A Formal Framework for Structured Data

Transformers excel at sequence modeling but lack theoretical grounding in learning context-free grammars (CFGs). We formalize this relationship, proving that transformers with d ≥ 2|V | layers and h ≥ 3 heads can provably recognize CFG-derived patterns. Experiments demonstrate 96.7% accuracy in JSON parsing and Dyck-k recognition, although ambiguity handling and energy efficiency remain challenges. Our framework provides tools for interpretable, grammar-aware structured data processing, with open-source implementations for reproducibility.

Authors

Institutions

Publication Details

Published
2025-08-07
DOI
https://doi.org/10.1109/acdsa65407.2025.11166184
Primary Topic
Business Process Modeling and Analysis
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Transformers as CFG Learners: A Formal Framework for Structured Data

Blessing Ogbuokiri
Business Process Modeling and Analysis
article

Transformers as CFG Learners: A Formal Framework for Structured Data

Blessing Ogbuokiri
article en

Abstract

Transformers excel at sequence modeling but lack theoretical grounding in learning context-free grammars (CFGs). We formalize this relationship, proving that transformers with d ≥ 2|V | layers and h ≥ 3 heads can provably recognize CFG-derived patterns. Experiments demonstrate 96.7% accuracy in JSON parsing and Dyck-k recognition, although ambiguity handling and energy efficiency remain challenges. Our framework provides tools for interpretable, grammar-aware structured data processing, with open-source implementations for reproducibility.

Brock University (CA)
Openalex Percentile: Top 58%
Business Process Modeling and Analysis
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Transformers as CFG Learners: A Formal Framework for Structured Data — Blessing Ogbuokiri · (2025) | TGRS Research Map | TGRS