{"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/first-de-trend-then-attend-rethinking","title":"First De-Trend then Attend: Rethinking Attention for Time-Series Forecasting","arxiv_id":"2212.08151","date":"2022-12-15","proceeding":null,"authors":["Xiyuan Zhang","Xiaoyong Jin","Karthick Gopalswamy","Gaurav Gupta","Youngsuk Park","Xingjian Shi","Hao Wang","Danielle C. Maddix","Yuyang Wang"],"abstract":"Transformer-based models have gained large popularity and demonstrated promising results in long-term time-series forecasting in recent years. In addition to learning attention in time domain, recent works also explore learning attention in frequency domains (e.g., Fourier domain, wavelet domain), given that seasonal patterns can be better captured in these domains. In this work, we seek to understand the relationships between attention models in different time and frequency domains. Theoretically, we show that attention models in different domains are equivalent under linear conditions (i.e., linear kernel to attention scores). Empirically, we analyze how attention models of different domains show different behaviors through various synthetic experiments with seasonality, trend and noise, with emphasis on the role of softmax operation therein. Both these theoretical and empirical analyses motivate us to propose a new method: TDformer (Trend Decomposition Transformer), that first applies seasonal-trend decomposition, and then additively combines an MLP which predicts the trend component with Fourier attention which predicts the seasonal component to obtain the final prediction. Extensive experiments on benchmark time-series forecasting datasets demonstrate that TDformer achieves state-of-the-art performance against existing attention-based models.","url_abs":"https://arxiv.org/abs/2212.08151v1","url_pdf":"https://arxiv.org/pdf/2212.08151v1.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":"first-de-trend-then-attend-rethinking","repo_url":"https://github.com/BeBeYourLove/TDformer","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"time-series-1","task_name":"Time Series"},{"task_slug":"time-series","task_name":"Time Series Analysis"},{"task_slug":"time-series-forecasting","task_name":"Time Series Forecasting"}],"methods":[{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2212.08151","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2212.08151"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/BeBeYourLove/TDformer","reach":null}],"summary":{"ran":14,"unverified":3},"by_repo_kind":{"listed":{"samples":17,"ran":14,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":17,"samples":[{"code_sha256_prefix":"68aca50b866b5c44","entry":"DataEmbedding","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"68aca50b866b5c44"}},{"code_sha256_prefix":"a764d7bf11731507","entry":"DecoderLayer","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a764d7bf11731507"}},{"code_sha256_prefix":"262ec83d671e7e73","entry":"Encoder","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"262ec83d671e7e73"}},{"code_sha256_prefix":"13ebf522358d72ce","entry":"EncoderLayer","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"13ebf522358d72ce"}},{"code_sha256_prefix":"16e89fafa4d72549","entry":"FixedEmbedding","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"16e89fafa4d72549"}},{"code_sha256_prefix":"e25d8996d3335ae8","entry":"FourierAttention","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e25d8996d3335ae8"}},{"code_sha256_prefix":"cf298e4e52b231ae","entry":"FullAttention","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cf298e4e52b231ae"}},{"code_sha256_prefix":"cc9347d9fcbd79f0","entry":"PositionalEmbedding","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cc9347d9fcbd79f0"}},{"code_sha256_prefix":"63e737eb80bffe5c","entry":"RevIN","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"63e737eb80bffe5c"}},{"code_sha256_prefix":"0047413d8e7fb6de","entry":"TemporalEmbedding","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0047413d8e7fb6de"}},{"code_sha256_prefix":"a06a4f88ba660a18","entry":"TokenEmbedding","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a06a4f88ba660a18"}},{"code_sha256_prefix":"94ce7d58219032b2","entry":"moving_avg","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"94ce7d58219032b2"}},{"code_sha256_prefix":"e8b308d6f4a51e9c","entry":"series_decomp","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"e8b308d6f4a51e9c"}},{"code_sha256_prefix":"24c312878bd471eb","entry":"series_decomp_multi","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"24c312878bd471eb"}},{"code_sha256_prefix":"626ecbcf3c8c36f8","entry":"AttentionLayer","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"626ecbcf3c8c36f8"}},{"code_sha256_prefix":"2f76a320461e09fc","entry":"Decoder","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2f76a320461e09fc"}},{"code_sha256_prefix":"f2783576a62ba4e8","entry":"Model","repo":"BeBeYourLove/TDformer","repo_kind":"listed","path":"model/TDformer.py","file_url":"https://github.com/BeBeYourLove/TDformer/blob/HEAD/model/TDformer.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f2783576a62ba4e8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}