SeqPE: 순차적 위치 인코딩을 적용한 트랜스포머
SeqPE: Transformer with Sequential Position Encoding
June 16, 2025
저자: Huyang Li, Yahui Liu, Hongyu Sun, Deng Cai, Leyang Cui, Wei Bi, Peilin Zhao, Taro Watanabe
cs.AI
초록
트랜스포머의 셀프 어텐션 레이어는 설계상 순열 불변이므로, 공간적 이해를 가능하게 하기 위해 위치 인코딩을 명시적으로 통합해야 합니다. 그러나 전통적인 학습 가능한 위치 임베딩(PE)에서 사용되는 고정 크기 룩업 테이블은 사전 학습된 시퀀스 길이를 넘어서는 외삽 능력을 제한합니다. ALiBi 및 RoPE와 같은 전문가 설계 방식은 이러한 한계를 완화하지만, 새로운 모달리티에 적응하기 위해 광범위한 수정이 필요하여 적응성과 확장성에 대한 근본적인 문제를 강조합니다. 본 연구에서는 각 n차원 위치 인덱스를 기호 시퀀스로 표현하고, 경량 순차 위치 인코더를 사용하여 이를 종단 간 방식으로 임베딩을 학습하는 통합적이고 완전히 학습 가능한 위치 인코딩 프레임워크인 SeqPE를 제안합니다. SeqPE의 임베딩 공간을 정규화하기 위해 두 가지 상호 보완적인 목표를 도입했습니다: 임베딩 거리를 사전 정의된 위치-거리 함수와 정렬하는 대조 목표, 그리고 분포 외 위치 임베딩을 분포 내 교사 표현에 고정하여 외삽 성능을 더욱 향상시키는 지식 증류 손실입니다. 언어 모델링, 장문 질의응답, 2D 이미지 분류에 걸친 실험을 통해 SeqPE가 특히 컨텍스트 길이 외삽 하에서 perplexity, 정확도(EM), 정확도 측면에서 강력한 베이스라인을 능가할 뿐만 아니라, 수동적인 아키텍처 재설계 없이도 다차원 입력으로의 원활한 일반화를 가능하게 함을 입증했습니다. 코드, 데이터, 체크포인트는 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.