Lune

EMNLP2023Top-tier venue

Do Transformers Parse while Predicting the Masked Word?

Haoyu Zhao, Abhishek Panigrahi, Rong Ge, Sanjeev Arora

Abstract

Pre-trained language models have been shown to encode linguistic structures like parse trees in their embeddings while being trained unsupervised. Some doubts have been raised whether the models are doing parsing or only some computation weakly correlated with it. Concretely: (a) Is it possible to explicitly describe transformers with realistic embedding dimensions, number of heads, etc. that are capable of doing parsing -or even approximate parsing? (b) Why do pre-trained models capture parsing structure? This paper takes a step toward answering these questions in the context of generative modeling with PCFGs. We show that masked language models like BERT or RoBERTa of moderate sizes can approximately execute the Inside-Outside algorithm for the English PCFG (Marcus et al., 1993) . We also show that the Inside-Outside algorithm is optimal for masked language modeling loss on the PCFG-generated data. We conduct probing experiments on models pre-trained on PCFG-generated data to show that this not only allows recovery of approximate parse tree, but also recovers marginal span probabilities computed by the Inside-Outside algorithm, which suggests an implicit bias of masked language modeling towards this algorithm. * When | P| < c| Ĩ|, we can simulate the computations in the final layer using c layers with | Ĩ| heads instead of | P| heads. Additionally, we can decrease the embedding size by only storing probabilities for relevant non-terminals.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

13 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammars cites Inductive Biases and Variable Creation in Self-Attention Mechanisms
  • Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammars cites Perturbed Masking: Parameter-free Probing for Analyzing and Interpreting BERT
  • Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammars cites Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformers
  • Inductive Biases and Variable Creation in Self-Attention Mechanisms cites Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformers
  • Sample Complexity and Representation Ability of Test-time Scaling Paradigms cites Inductive Biases and Variable Creation in Self-Attention Mechanisms
  • Sample Complexity and Representation Ability of Test-time Scaling Paradigms cites Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformers
  • Sample Complexity and Representation Ability of Test-time Scaling Paradigms cites Exploring Length Generalization in Large Language Models
  • Sample Complexity and Representation Ability of Test-time Scaling Paradigms cites Promises and Pitfalls of Generative Masked Language Modeling: Theoretical Framework and Practical Guidelines
  • Promises and Pitfalls of Generative Masked Language Modeling: Theoretical Framework and Practical Guidelines cites Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammars
  • Promises and Pitfalls of Generative Masked Language Modeling: Theoretical Framework and Practical Guidelines cites Inductive Biases and Variable Creation in Self-Attention Mechanisms
  • Promises and Pitfalls of Generative Masked Language Modeling: Theoretical Framework and Practical Guidelines cites Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with Transformers
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers13

  1. Transformers are uninterpretable with myopic methods: a case study with bounded Dyck grammarsKaiyue Wen, Yuchen Li, Bingbin Liu, Andrej RisteskiNeurIPS 2023 · 32 citations
  2. Sample Complexity and Representation Ability of Test-time Scaling ParadigmsBaihe Huang, Shanda Li, Tianhao Wu, Yiming Yang et al.ICLR 2026 · 11 citations
  3. Promises and Pitfalls of Generative Masked Language Modeling: Theoretical Framework and Practical GuidelinesYuchen Li, Alexandre Kirchmeyer, Aashay Mehta, Yilong Qin et al.ICML 2024 · 5 citations
  4. Deep networks learn to parse uniform-depth context-free languages from local statisticsJack T. Parley, Francesco Cagnetta, Matthieu WyartICML 2026 · 4 citations
  5. Context-free Recognition with TransformersSelim Jerad, Anej Svete, Sophie Hao, Ryan Cotterell et al.ICML 2026 · 3 citations

Builds on16

  1. Exploring Length Generalization in Large Language ModelsCem Anil, Yuhuai Wu, Anders Andreassen, Aitor Lewkowycz et al.NeurIPS 2022 · 267 citations
  2. Perturbed Masking: Parameter-free Probing for Analyzing and Interpreting BERTZhiyong Wu, Yun Chen, Ben Kao, Qun LiuACL 2020 · 158 citations
  3. Inductive Biases and Variable Creation in Self-Attention MechanismsBenjamin L. Edelman, Surbhi Goel, Sham M. Kakade, Cyril ZhangICML 2022 · 154 citations
  4. Probing Natural Language Inference Models through Semantic FragmentsKyle Richardson, Hai Hu, Lawrence S. Moss, Ashish SabharwalAAAI 2020 · 152 citations
  5. Statistically Meaningful Approximation: a Case Study on Approximating Turing Machines with TransformersColin Wei, Yining Chen, Tengyu MaNeurIPS 2022 · 117 citations

Related papers

  1. How Transformers Represent Hierarchies: A Local-to-Global MechanismZhiling Zhou, Tianhao Wang, Zhuoran YangICML 2026
  2. Contextual Distortion Reveals Constituency: Masked Language Models are Implicit ParsersJiaxi Li, Wei LuACL 2023 · 3 citations
  3. Unveiling the Black Box of PLMs with Semantic Anchors: Towards Interpretable Neural Semantic ParsingLunyiu Nie, Jiuding Sun, Yanlin Wang, Lun Du et al.AAAI 2023 · 9 citations
  4. What Do They Capture? - A Structural Analysis of Pre-Trained Language Models for Source CodeYao Wan, Wei Zhao, Hongyu Zhang, Yulei Sui et al.ICSE 2022 · 66 citations
  5. Probing for Constituency Structure in Neural Language ModelsDavid Arps, Younes Samih, Laura Kallmeyer, Hassan SajjadEMNLP Findings 2022 · 17 citations
Dusk over the sea between two cliffs drawn in fine vertical lines