SeqPE: Transformer with Sequential Position Encoding

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Li, Huayang, Liu, Yahui, Sun, Hongyu, Cai, Deng, Cui, Leyang, Bi, Wei, Zhao, Peilin, Watanabe, Taro
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912435364954112
author Li, Huayang
Liu, Yahui
Sun, Hongyu
Cai, Deng
Cui, Leyang
Bi, Wei
Zhao, Peilin
Watanabe, Taro
author_facet Li, Huayang
Liu, Yahui
Sun, Hongyu
Cai, Deng
Cui, Leyang
Bi, Wei
Zhao, Peilin
Watanabe, Taro
contents Since self-attention layers in Transformers are permutation invariant by design, positional encodings must be explicitly incorporated to enable spatial understanding. However, fixed-size lookup tables used in traditional learnable position embeddings (PEs) limit extrapolation capabilities beyond pre-trained sequence lengths. Expert-designed methods such as ALiBi and RoPE, mitigate this limitation but demand extensive modifications for adapting to new modalities, underscoring fundamental challenges in adaptability and scalability. In this work, we present SeqPE, a unified and fully learnable position encoding framework that represents each $n$-dimensional position index as a symbolic sequence and employs a lightweight sequential position encoder to learn their embeddings in an end-to-end manner. To regularize SeqPE's embedding space, we introduce two complementary objectives: a contrastive objective that aligns embedding distances with a predefined position-distance function, and a knowledge distillation loss that anchors out-of-distribution position embeddings to in-distribution teacher representations, further enhancing extrapolation performance. Experiments across language modeling, long-context question answering, and 2D image classification demonstrate that SeqPE not only surpasses strong baselines in perplexity, exact match (EM), and accuracy--particularly under context length extrapolation--but also enables seamless generalization to multi-dimensional inputs without requiring manual architectural redesign. We release our code, data, and checkpoints at https://github.com/ghrua/seqpe.
format Preprint
id arxiv_https___arxiv_org_abs_2506_13277
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle SeqPE: Transformer with Sequential Position Encoding
Li, Huayang
Liu, Yahui
Sun, Hongyu
Cai, Deng
Cui, Leyang
Bi, Wei
Zhao, Peilin
Watanabe, Taro
Machine Learning
Artificial Intelligence
Computation and Language
Computer Vision and Pattern Recognition
Since self-attention layers in Transformers are permutation invariant by design, positional encodings must be explicitly incorporated to enable spatial understanding. However, fixed-size lookup tables used in traditional learnable position embeddings (PEs) limit extrapolation capabilities beyond pre-trained sequence lengths. Expert-designed methods such as ALiBi and RoPE, mitigate this limitation but demand extensive modifications for adapting to new modalities, underscoring fundamental challenges in adaptability and scalability. In this work, we present SeqPE, a unified and fully learnable position encoding framework that represents each $n$-dimensional position index as a symbolic sequence and employs a lightweight sequential position encoder to learn their embeddings in an end-to-end manner. To regularize SeqPE's embedding space, we introduce two complementary objectives: a contrastive objective that aligns embedding distances with a predefined position-distance function, and a knowledge distillation loss that anchors out-of-distribution position embeddings to in-distribution teacher representations, further enhancing extrapolation performance. Experiments across language modeling, long-context question answering, and 2D image classification demonstrate that SeqPE not only surpasses strong baselines in perplexity, exact match (EM), and accuracy--particularly under context length extrapolation--but also enables seamless generalization to multi-dimensional inputs without requiring manual architectural redesign. We release our code, data, and checkpoints at https://github.com/ghrua/seqpe.
title SeqPE: Transformer with Sequential Position Encoding
topic Machine Learning
Artificial Intelligence
Computation and Language
Computer Vision and Pattern Recognition
url https://arxiv.org/abs/2506.13277