When classifying grammatical role, BERT doesn't care about word order... except when it matters

Isabel Papadimitriou, Richard Futrell, Kyle Mahowald

Abstract

Large language models (LLMs) like BERT are often praised for their syntactic capabilities, yet they frequently maintain high performance even when input word order is scrambled. This paper investigates whether BERT relies on genuine syntax or merely "coasts" on lexical semantics—the inherent meaning of words. By testing models on "non-prototypical" sentences (e.g., "The onion chopped the chef"), we find that while early layers are biased toward lexical expectations, later layers successfully utilize word order to resolve grammatical roles. Our results suggest that syntax in transformers is a late-stage process used primarily when lexical cues are ambiguous or contradictory.

Introduction: The "Onion-Chopping Chef" Paradox

A growing puzzle in Natural Language Processing (NLP) is the apparent indifference of models like BERT to word order. If a model encounters the words chef, chopped, and onion, it can accurately guess the subject and object based on real-world knowledge, regardless of their position. This redundancy in natural language makes it difficult to determine if a model actually understands syntax. This paper addresses this gap by isolating cases where word order is the only reliable cue for determining grammatical roles.

Methodology

The researchers employed probing classifiers—simple 2-level perceptrons—to examine the internal embeddings of BERT and GPT-2. These probes were trained to predict whether a specific noun is a "subject" or an "object."

The key innovation lies in the linguistically-informed data selection. The evaluation was split into:

  1. Prototypical: Sentences where the subject is expected (e.g., "The chef chopped the onion").
  2. Non-prototypical: Sentences where roles are reversed or unusual (e.g., "The onion chopped the chef").

The study utilized the Universal Dependencies (UD) treebanks for English, filtering for unusual subjects or manually swapping arguments to create syntactically valid but semantically "absurd" sentences.

Key Results

The Lexical-to-Syntactic Shift

The study reveals that the "average" performance of BERT is misleading. In prototypical sentences, probes achieve high accuracy (~0.80+) from the very first layer (Layer 0). However, for non-prototypical sentences, accuracy starts at chance levels (0.50) and only begins to improve in middle and later layers.

Average probe probability of subject across BERT layers for prototypical and non-prototypical sentences.

This progression indicates that the "syntax" observed in early layers is actually lexical semantics in disguise. The model gradually overrides its initial lexical bias with syntactic evidence as information flows through the network.

Argument Swapping and Contextualization

To further test this, the authors performed "Argument Swapping," where the same words are used in different roles within identical contexts. In later layers, BERT clearly differentiates the embedding of a word like "chef" depending on whether it is the subject or the object.

Progression of embeddings for 'chef' and 'onion' in original and argument-swapped sentences.

This experiment confirms that the model is not just looking at the "bag of words" but is actively using position to contextualize word meanings.

Discussion: Word Order as a Late-Stage Tie-Breaker

The findings suggest that BERT uses word order as a critical tool specifically when lexical cues are contradictory. It doesn't "care" about order when the words themselves tell the whole story, but it "cares" deeply when they don't. Furthermore, experiments with local shuffling showed that the model relies on global syntactic structure rather than just local word proximity; when sentences were locally shuffled, the ability to identify roles in non-prototypical cases collapsed.

Conclusion

This research clarifies the role of syntax in transformer-based models. BERT is not a simple bag-of-words model, but it is "lazy"—it relies on easier lexical cues whenever possible. Syntactic machinery is a late-stage process that acts as a tie-breaker for complex or unusual inputs. Future work should explore if this pattern holds in languages with rich case-marking systems where word order is less critical.

Summary updated

BibTeX
@inproceedings{papadimitriou2022when,
  author = {Isabel Papadimitriou and Richard Futrell and Kyle Mahowald},
  title = {{When classifying grammatical role, BERT doesn't care about word order... except when it matters}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=Lyzt4nuGDgh},
}
Figure