TL;DR
This paper introduces BAM, a probabilistic framework for positional encoding in transformers, unifying existing methods and significantly enhancing long-context extrapolation capabilities.
Contribution
It proposes BAM as a theoretical foundation that unifies and extends existing positional encoding methods, improving long-context generalization in language models.
Findings
BAM enables accurate retrieval at 500x training context length.
It outperforms previous methods in long-context retrieval accuracy.
BAM maintains perplexity and adds minimal parameters.
Abstract
Transformer-based language models rely on positional encoding (PE) to handle token order and support context length extrapolation. However, existing PE methods lack theoretical clarity and rely on limited evaluation metrics to substantiate their extrapolation claims. We propose the Bayesian Attention Mechanism (BAM), a theoretical framework that formulates positional encoding as a prior within a probabilistic model. BAM unifies existing methods (e.g., NoPE and ALiBi) and motivates a new Generalized Gaussian positional prior that substantially improves long-context generalization. Empirically, BAM enables accurate information retrieval at the training context length, outperforming previous state-of-the-art context length generalization in long context retrieval accuracy while maintaining comparable perplexity and introducing minimal additional parameters.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
