Position Information in Transformers: An Overview

Philipp Dufter, Martin Schmitt, Hinrich Schütze

The Transformer architecture has revolutionized NLP, but it possesses a fundamental quirk: by default, it is "permutation invariant." To a vanilla Transformer, the sentence "The cat chases the dog" is identical to the set {cat, chases, dog, the, the}. Without a way to represent order, the model loses the syntax and semantics essential to language.

In the survey paper "Position Information in Transformers: An Overview," authors Philipp Dufter, Martin Schmitt, and Hinrich Schütze provide a much-needed taxonomy for the dozens of methods researchers have developed to give Transformers a sense of "where" words are.

TL;DR

This paper provides a comprehensive survey and unified notation for over 30 different methods of incorporating position information into Transformers. It categorizes approaches into absolute vs. relative encodings and "adding" vs. "modifying" strategies, offering a roadmap for selecting the right encoding for specific applications.

What Problem Does This Paper Address?

The core mechanism of a Transformer is self-attention, which treats inputs as an unordered bag of embeddings. To process sequential data like text, we must inject "positional bias."

While the original 2017 Transformer used simple sine and cosine functions, the field has since exploded with complex alternatives. The challenge for researchers is that these methods are often described using inconsistent notation and tested on different tasks, making head-to-head comparisons nearly impossible. This paper addresses this fragmentation by creating a systematic framework to categorize and analyze the "vibrant and extensive" research area of positional encoding.

Methods

The authors categorize position models along several key dimensions:

  1. Reference Point:
    • Absolute: Each position (e.g., index 1, 2, 3) gets a unique signature.
  2. Relative: The model focuses on the distance between tokens (e.g., token $i$ is 2 slots away from token $j$).
  3. Injection Method:
    • Adding Position Embeddings (APE): Position vectors are simply added to word embeddings at the input layer.
  4. Modifying Attention Matrix (MAM): Position information is injected directly into the attention mechanism as a bias or a multiplier, often at every layer.
  5. Representation Type:
    • Learned: Parameters are updated during training (like BERT).
  6. Functional/Sinusoidal: Fixed mathematical functions (like the original Vaswani Transformer) or continuous dynamical models (like FLOATER).
  7. Structure: Beyond simple sequences, the paper covers Graph and Tree-based encodings that represent hierarchical relationships (like dependency parses).

Datasets

As a survey paper, this work does not introduce a new dataset. Instead, it synthesizes results from a vast array of benchmarks used in the referenced literature, including:

  • GLUE/SuperGLUE: For general natural language understanding.
  • WMT (Machine Translation): Where position information is critical for fluency.
  • WikiText/Project Gutenberg: For long-range language modeling.
  • Graph-to-Text benchmarks: For evaluating structural position models.

Key Insights and Ideas

  • The "APE vs. MAM" Distinction: While adding embeddings (APE) is common, it implicitly modifies the attention matrix anyway. However, explicitly modifying the matrix (MAM) allows for more "disentangled" representations where word-to-word and word-to-position interactions are handled separately (e.g., DeBERTa).
  • Generalization to Length: Absolute encodings often fail when the model encounters sequences longer than those seen during training. Relative encodings and certain functional methods (like Rotary embeddings) generalize much better to "unbound" lengths.
  • Recurring Injection: Most early models only added position info at the first layer. Newer research suggests that "reminding" the model of positions at every layer (Recurring) significantly boosts performance, especially in deep networks.
  • The [CLS] Token is Special: Some models (like TUPE) treat the special classification token as having no position, preventing it from being biased by its arbitrary placement at the start of a sentence.

Key Results

The paper provides a massive comparison table (Table 2) that serves as a "cheat sheet" for the field. High-level takeaways include:

  • Absolute Encodings are generally sufficient for classification tasks where global context matters more than local word-swapping.
  • Relative Encodings consistently perform better for span prediction (like SQuAD) and tasks involving very long sequences.
  • Parameter Efficiency: Functional methods (Sinusoidal, RoPE) add zero or very few parameters compared to learned embeddings, which can require millions of parameters for large vocabularies and long contexts.

Limitations and Future Work

The authors identify several "blind spots" in current research:

  1. Lack of Empirical Head-to-Head: There is still no single study that compares all 30+ methods on the same hardware, dataset, and model size.
  2. The "Bag-of-Words" Mystery: For some tasks, Transformers perform surprisingly well even without position info. We don't fully understand when and why word order is strictly necessary for the model's internal logic.
  3. Beyond Sequences: Most models focus on 1D sequences. The authors suggest that future work should better integrate document-level structure (tables, lists, layout) into the positional framework.

Summary updated

BibTeX
@inproceedings{dufter2022position,
  author = {Philipp Dufter and Martin Schmitt and Hinrich Schütze},
  title = {{Position Information in Transformers: An Overview}},
  booktitle = {Comput. Linguistics},
  year = {2022},
  url = {https://openreview.net/forum?id=1ZMsAvTf_w},
}

Loading related content...

Figure