Introduction
For years, the prevailing wisdom in Natural Language Processing (NLP) was that Recurrent Neural Networks (RNNs), such as LSTMs, were the natural choice for language modeling because they process text sequentially. This sequential nature was thought to be essential for capturing the hierarchical structure of syntax—the way words group into nested phrases.
With the advent of BERT and the Transformer architecture, recurrence was replaced by self-attention. Unlike RNNs, Transformers do not have an inherent notion of word order, relying instead on position embeddings and simultaneous processing of all words in a sentence. This shift raised a fundamental question: Can a model that doesn't "read" in order truly understand syntax? Specifically, can it handle long-distance dependencies where a subject and its verb are separated by several "distractor" words?
Methodology: The Masked Verb Probe
Yoav Goldberg addressed this by adapting a "targeted syntactic evaluation" protocol. Because BERT is bidirectional, the standard "predict the next word" approach used for LSTMs was inapplicable. Instead, Goldberg employed a Masked Verb Probe:
- A sentence with a specific syntactic challenge (e.g., subject-verb agreement) is selected.
- The focus verb is masked (e.g., "The keys to the cabinet [MASK]...").
- BERT is asked to predict the scores for the correct form ("are") versus the incorrect form ("is").
The model is considered "correct" if it assigns a higher probability to the grammatically accurate word. This evaluation is performed zero-shot, using pre-trained BERT models (Base and Large) without additional fine-tuning.
Datasets
The study utilizes three established sets of linguistic stimuli:
- Linzen et al. (2016): Naturally occurring Wikipedia sentences containing "agreement attractors" (nouns between the subject and verb with a different grammatical number).
- Gulordava et al. (2018): "Colorless green ideas" sentences—grammatically correct but semantically nonsensical (e.g., "The colorless green ideas sleep furiously"). This forces the model to rely on syntax rather than semantic patterns.
- Marvin and Linzen (2018): Manually crafted "minimal pairs" that isolate specific phenomena like reflexive anaphora (e.g., "The waiters that the manager likes greeted themselves" vs. "himself").
Key Insights
Attention as a Syntactic Powerhouse
BERT performs exceptionally well across the board, often significantly outperforming LSTMs. This suggests that the Transformer's self-attention mechanism is highly capable of capturing hierarchical dependencies without explicit recurrence.
Syntax over Semantics
BERT’s high performance on the "nonsense" sentences from the Gulordava dataset proves it isn't merely relying on semantic associations (e.g., knowing that "dogs" usually "bark"). It has learned the underlying structural rules of the language.
The "Base vs. Large" Paradox
Surprisingly, the smaller BERT-Base model frequently matched or outperformed BERT-Large on these syntactic tasks. This suggests that increasing parameter count does not necessarily lead to better syntactic precision and might even lead to overfitting on non-syntactic patterns.
Results
BERT's performance remained consistently high even as sentence complexity increased. In Wikipedia-based agreement tasks, BERT maintained near-perfect accuracy even with up to four "attractor" nouns placed between the subject and the verb.
On the most difficult manually crafted stimuli, BERT showed a massive lead over LSTMs. For instance, in cases involving "object relative clauses," BERT achieved scores in the 80-90% range, while LSTMs often hovered around 50-60%—barely better than chance.
Limitations and Future Work
While these results are impressive, some caveats apply. Because BERT is bidirectional, it sees the "suffix" (words after the verb), giving it more information than unidirectional LSTMs. While this is a necessary adaptation for the architecture, it complicates direct comparisons of model capacity. Additionally, some stimuli were discarded due to BERT’s specific WordPiece vocabulary constraints.
Finally, while this research proves BERT can process syntax, it doesn't explain how the attention heads are organized to achieve this. Exploring the specific mechanisms within the transformer layers remains a critical next step for the field.
Summary updated