Transformer Language Models without Positional Encodings Still Learn Positional Information

Adi Haviv, Ori Ram, Ofir Press, Peter Izsak, Omer Levy
3/30/2022
cs.CLcs.AIcs.LG
transformer-attention

Official code: adihaviv/nopos (23 stars, Python, MIT, last commit 2023-07-27).

Abstract

Causal transformer language models (LMs), such as GPT-3, typically require some form of positional encoding, such as positional embeddings. However, we show that LMs without any explicit positional encoding are still competitive with standard models, and that this phenomenon is robust across different datasets, model sizes, and sequence lengths.

Show full abstract

Probing experiments reveal that such models acquire an implicit notion of absolute positions throughout the network, effectively compensating for the missing information. We conjecture that causal attention enables the model to infer the number of predecessors that each token can attend to, thereby approximating its absolute position. Our findings indicate that causal LMs might derive positional awareness not only from the explicit positioning mechanism, but also from the effects of the causal mask.

View on arXivView PDF

Code Implementations(1)

adihaviv/noposOfficial100%
MIT
236Python, CudaOct 21, 20223 years agoMIT

Similar Papers

Cite this paper

@article{haviv2022transformer,
  title  = {Transformer Language Models without Positional Encodings Still Learn Positional Information},
  author = {Adi Haviv and Ori Ram and Ofir Press and Peter Izsak and Omer Levy},
  year   = {2022},
  eprint = {2203.16634},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.16634}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.16634.svg)](https://codeofpaper.com/paper/2203.16634)

Discussion