ChatPaper.aiChatPaper

SeqPE: Transformer met Sequentieel Positiecodering

SeqPE: Transformer with Sequential Position Encoding

June 16, 2025
Auteurs: Huyang Li, Yahui Liu, Hongyu Sun, Deng Cai, Leyang Cui, Wei Bi, Peilin Zhao, Taro Watanabe
cs.AI

Samenvatting

Aangezien self-attention-lagen in Transformers per ontwerp permutatie-invariant zijn, moeten positionele coderingen expliciet worden geïntegreerd om ruimtelijk begrip mogelijk te maken. Traditionele leerbare positionele embeddings (PE's) gebruiken echter vaste grootte lookup-tabellen, wat de extrapolatiemogelijkheden beperkt voorbij de vooraf getrainde sequentielengtes. Expert-ontworpen methoden zoals ALiBi en RoPE verminderen deze beperking, maar vereisen uitgebreide aanpassingen om zich aan nieuwe modaliteiten aan te passen, wat fundamentele uitdagingen in aanpasbaarheid en schaalbaarheid benadrukt. In dit werk presenteren we SeqPE, een uniform en volledig leerbaar positioneel coderingsframework dat elke n-dimensionale positie-index representeert als een symbolische sequentie en een lichtgewicht sequentiële positie-encoder gebruikt om hun embeddings end-to-end te leren. Om de embeddingruimte van SeqPE te regulariseren, introduceren we twee complementaire doelstellingen: een contrastieve doelstelling die de embeddingafstanden afstemt op een vooraf gedefinieerde positie-afstandsfunctie, en een knowledge distillation-verlies dat out-of-distribution positionele embeddings verankert aan in-distribution leraarrepresentaties, wat de extrapolatieprestaties verder verbetert. Experimenten op het gebied van taalmodellering, lange-context vraag-antwoordtaken en 2D-beeldclassificatie tonen aan dat SeqPE niet alleen sterke baselines overtreft in perplexiteit, exacte overeenkomst (EM) en nauwkeurigheid—met name onder contextlengte-extrapolatie—maar ook naadloze generalisatie naar multidimensionale inputs mogelijk maakt zonder handmatige architectuurherontwerpen te vereisen. We hebben onze code, data en checkpoints vrijgegeven op https://github.com/ghrua/seqpe.
English
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.
PDF52June 17, 2025