Abstract
Because meaning can often be inferred from lexical semantics alone, word order is often a redundant cue in natural language. For example, the words chopped, chef, and onion are more likely used to convey "The chef chopped the onion," not "The onion chopped the chef." Recent work has shown large language models to be surprisingly word order invariant, but crucially has largely considered natural prototypical inputs, where compositional meaning mostly matches lexical expectations. To overcome this confound, we probe grammatical role representation in English BERT and GPT-2, on instances where lexical expectations are not sufficient, and word order knowledge is necessary for correct classification. Such non-prototypical instances are naturally occurring English sentences with inanimate subjects or animate objects, or sentences where we systematically swap the arguments to make sentences like "The onion chopped the chef". We find that, while early layer embeddings are largely lexical, word order is in fact crucial in defining the later-layer representations of words in semantically non-prototypical positions. Our experiments isolate the effect of word order on the contextualization process, and highlight how models use context in the uncommon, but critical, instances where it matters.
Introduction
A persistent puzzle in the study of Large Language Models (LLMs) is their relationship with syntax. While these models perform complex linguistic tasks, several studies have suggested they are surprisingly invariant to "word salad"—shuffled inputs that lack coherent structure. This raises a fundamental question: Are models like BERT actually learning the structural rules of language, or are they merely sophisticated "bag-of-words" models that rely on lexical associations?
This research, conducted by a collaborative team from Stanford, UC Irvine, and UT Austin, argues that the apparent indifference to word order is a measurement error caused by the inherent redundancy of natural language. In most sentences, you can guess "who did what to whom" simply by looking at the vocabulary. To truly test a model's syntactic capabilities, one must look at the cases where word order is the only available cue.
The Redundancy of Language
In a typical English sentence like "The chef chopped the onion," the roles of the participants are obvious from the words themselves. Our real-world knowledge tells us that chefs are agents who chop, and onions are patients that get chopped. In these "prototypical" cases, syntax and lexical semantics provide redundant signals.
The researchers hypothesize that LLMs prioritize these lexical cues in early layers. However, when lexical cues are misleading or absent—such as in the sentence "The onion chopped the chef"—the model must rely on word order to correctly identify the subject and object. By isolating these non-prototypical cases, the study reveals how and where BERT and GPT-2 process syntactic information.
Methodology
The study utilized diagnostic probing to track how grammatical information is encoded across the layers of BERT and GPT-2.
1. The Probing Framework
The researchers trained a simple two-layer perceptron (MLP) to predict whether a specific word embedding represented a "subject" or an "object." By applying this probe to different layers of the model, they could see when the model "decided" on a word's grammatical role.
2. Defining Prototypicality
A key innovation of this study is the "prototypicality metric." A word is considered prototypical if its grammatical role can be guessed from its static embedding (Layer 0) alone. If a probe can identify "chef" as a subject without any context, it is a prototypical subject. This allowed the researchers to separate sentences into two groups: those where lexical semantics are sufficient, and those where they are not.
3. Experimental Conditions
- Natural Sentences: Comparing probe accuracy on prototypical vs. non-prototypical words in the Universal Dependencies (UD) English treebanks.
- Argument Swapping: Creating minimal pairs by manually swapping subjects and objects (e.g., "The chef chopped the onion" becomes "The onion chopped the chef"). This ensures the bag-of-words remains identical, forcing the model to rely entirely on order.
- Local Shuffling: Scrambling words within a small window (2 slots) to determine if the model relies on precise syntax or merely general sentence position (e.g., "the first noun is usually the subject").
Key Insights
The "Lexical First" Strategy
In the earliest layers of BERT, representations are dominated by lexical semantics. The model organizes its internal space based on what words usually do in the real world. For prototypical sentences, probe accuracy is high (80-90%) right from Layer 0. However, for non-prototypical cases, Layer 0 accuracy is near or below chance, as the model's "prior" about the word's role is incorrect.
Syntax as a Fallback Mechanism
As the signal progresses through the transformer layers, a "recovery" process occurs. For non-prototypical words, the model gradually incorporates context to override its initial lexical bias. By Layer 12, the probe reaches approximately 75% accuracy for these difficult cases. This suggests that syntax isn't always the primary driver of representation; rather, it is a computed feature that emerges in the second half of the network when lexical cues are insufficient.
Precision Matters
The local shuffling experiment proved that the model is not just using a heuristic like "the word at the start is the subject." When word order was slightly perturbed, the model's ability to identify roles in non-prototypical cases collapsed. This demonstrates that the models are indeed sensitive to precise structural relations when the context demands it.
Conclusion
This research clarifies why LLMs often appear to ignore word order: they are efficient processors that leverage the redundancy of language. In the majority of natural language instances, word order is a secondary cue. However, the models possess a robust syntactic fallback mechanism. While they may appear to be "bags-of-words" on the surface, the later layers of BERT and GPT-2 perform the heavy lifting of syntactic re-contextualization exactly when it matters most—in the uncommon, but critical, instances where lexical expectations fail.
Summary updated