{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/fourier-position-embedding-enhancing","title":"Fourier Position Embedding: Enhancing Attention's Periodic Extension for Length Generalization","arxiv_id":"2412.17739","date":"2024-12-23","proceeding":null,"authors":["Ermo Hua","Che Jiang","Xingtai Lv","Kaiyan Zhang","Ning Ding","Youbang Sun","Biqing Qi","Yuchen Fan","Xuekai Zhu","BoWen Zhou"],"abstract":"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 and benchmarks show that, within varying context windows, FoPE maintains a more stable performance compared to RoPE and ALiBi. Several analyses and ablations bring further support to our method and theoretical modeling.","url_abs":"https://arxiv.org/abs/2412.17739v3","url_pdf":"https://arxiv.org/pdf/2412.17739v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"fourier-position-embedding-enhancing","repo_url":"https://github.com/tsinghuac3i/fourier-position-embedding","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":null,"task_name":"Position"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"fope","method_name":"FoPE"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[{"slug":"fope","name":"FoPE","full_name":"Fourier Position Embedding"}],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2412.17739","atlas_url":"https://app.syntology.ai/?focus=2412.17739","mcp":null,"developers":"https://syntology.ai/developers"},"arxiv_metadata":null,"syntology_extracted_results":null}