Fourier 위치 임베딩: 길이 일반화를 위한 주기적 확장을 강화하기
Fourier Position Embedding: Enhancing Attention's Periodic Extension for Length Generalization
December 23, 2024
저자: Ermo Hua, Che Jiang, Xingtai Lv, Kaiyan Zhang, Ning Ding, Youbang Sun, Biqing Qi, Yuchen Fan, Xue Kai Zhu, Bowen Zhou
cs.AI
초록
언어 모델(Language Models, LMs)의 문맥 길이를 연장하기 위해 로터리 위치 임베딩(Rotary Position Embedding, RoPE)을 개선하는 것이 트렌드가 되었습니다. 기존 연구들은 대부분 RoPE의 제한 사항을 주로 어텐션 메커니즘 내에서 다루었지만, 본 논문은 LM의 거의 모든 부분을 대상으로 분석을 제공하여 RoPE 기반 어텐션의 길이 일반화에 미치는 부정적인 영향을 밝혀냅니다. 이산 신호 처리 이론을 활용하여, RoPE가 비주기적 어텐션을 가능하게 하며 비균일 이산 푸리에 변환을 암묵적으로 달성함을 보여줍니다. 그러나 이 주기성은 주파수 영향력의 손상으로 약화되는데, 이는 1) 어텐션 외부의 선형 레이어 및 활성화 함수에 의한 것과 2) 시간 영역 절단으로 인한 충분히 훈련되지 않은 주파수 성분에 기인합니다. 우리의 관찰을 기반으로, 주파수 도메인 특성을 향상시켜 어텐션의 주기적 확장과 길이 일반화를 개선하는 푸리에 위치 임베딩(Fourier Position Embedding, FoPE)을 제안합니다. FoPE는 푸리에 급수를 구성하고 파괴적인 주파수 성분을 제거하여 모델의 스펙트럼 손상에 대한 강건성을 향상시킵니다. 다양한 모델 규모를 대상으로 한 실험 결과, 다양한 문맥 창에서 FoPE는 RoPE 및 ALiBi에 비해 바늘 찾기 작업에서 더 안정적인 페르플렉서티와 일관된 정확도를 유지할 수 있음을 보여줍니다. 다양한 분석 및 제거 실험은 우리의 방법과 이론적 모델링을 더욱 지지합니다.
English
Extending the context length of Language Models (LMs) by improving Rotary
Position Embedding (RoPE) has become a trend. While existing works mainly
address RoPE's limitations within attention mechanism, this paper provides an
analysis across nearly all parts of LMs, uncovering their adverse effects on
length generalization for RoPE-based attention. Using Discrete Signal
Processing theory, we show that RoPE enables periodic attention by implicitly
achieving Non-Uniform Discrete Fourier Transform. However, this periodicity is
undermined by the spectral damage caused by: 1) linear layers and activation
functions outside of attention; 2) insufficiently trained frequency components
brought by time-domain truncation. Building on our observations, we propose
Fourier Position Embedding (FoPE), which enhances attention's frequency-domain
properties to improve both its periodic extension and length generalization.
FoPE constructs Fourier Series and zero-outs the destructive frequency
components, increasing model robustness against the spectrum damage.
Experiments across various model scales show that, within varying context
windows, FoPE can maintain a more stable perplexity and a more consistent
accuracy in a needle-in-haystack task compared to RoPE and ALiBi. Several
analyses and ablations bring further support to our method and theoretical
modeling.