- Introduced by
- Shizhan Liu et al.
- Year
- 2022
- Type
- Pyramidal self-attention transformer for time-series forecasting
- Family
- Time-series forecasting
What does it do?
Pyraformer is a Transformer-based model for long-range time-series forecasting introduced by Liu et al. at ICLR 2022.
Its central innovation is a Pyramidal Attention Module (PAM) that organizes tokens into a multi-resolution hierarchy, so the model can capture temporal dependencies across multiple scales. The design aims at lower time and memory cost than the quadratic cost of vanilla self-attention. The exact complexity order should be confirmed in the original paper before it is used for capacity planning.
The intuition behind the method
Consider reading a long document at several zoom levels at once: individual words, paragraphs, and chapters. Pyraformer applies a similar idea to time series. It builds a pyramid of temporal resolutions, with fine-grained time steps at the base and coarser aggregated representations at higher levels. Attention is then computed within each level and between adjacent levels, so distant time steps can exchange information through the coarser levels without every pair of steps being compared directly.
History
Pyraformer was proposed by Shizhan Liu, Hang Yu, Cong Liao, Jianguo Li, Weiyao Lin, Alex X. Liu and Schahram Dustdar, and appeared at ICLR 2022. It belongs to a set of efficient Transformer proposals for long-range forecasting that include Informer, Reformer and Autoformer. Its distinctive choice was to model multi-scale structure through a pyramidal graph of coarsened nodes and attention between scales.
When to use it
Choose Pyraformer for long-sequence forecasting on regularly sampled series where dependencies at several temporal granularities matter, such as the electricity load, traffic flow and weather settings listed under applications. The hierarchy is designed to give a useful multi-scale structure, so it is most relevant when the series has patterns at more than one timescale. With short input sequences the pyramid has few levels and the multi-scale benefit may be limited, so check the level count for your input length and aggregation size. Do not choose it for irregularly sampled data, which the design does not address. Like many Transformer variants, it may not beat simpler linear baselines on some benchmarks, so a comparison against models such as DLinear or PatchTST is advisable before deployment.
Limitations and considerations
- The coarsening creates a fixed hierarchy of k-node aggregations, which may represent irregular or non-stationary patterns poorly when those patterns do not align with the chosen scales
- Gains over simpler linear models such as DLinear are not always consistent across datasets, so the attention-based inductive bias is not guaranteed to help
- Results can be sensitive to the number of pyramid levels C and the aggregation size k, which generally need tuning for each dataset
- The architecture is more involved than standard Transformer or convolutional baselines, which makes independent reproduction harder
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Designed to reduce the cost of attention over long sequences relative to full self-attention; the complexity order should be confirmed in the original paper before it is used for capacity planning
- The explicit pyramid gives every input a path to coarser summaries of the whole history, so short- and longer-range dependencies are represented within one forward pass
- Forecasts are produced in parallel from the finest-scale representations, avoiding autoregressive decoding at inference
- The pyramid imposes a multi-scale structure on the model, which suits series whose patterns repeat at several timescales
Applications
- Electricity consumption and demand forecasting over long horizons
- Traffic flow and speed prediction
- Weather and meteorological variable forecasting
- Industrial sensor monitoring where signals show periodicity at several scales
How it works
How it works
A Coarser-Scale Construction Module (CSCM) builds the pyramid. Each coarser scale aggregates k nodes from the scale below, so the number of nodes shrinks from level to level. Because the reduction is a constant factor per level, the total number of nodes across all levels forms a geometric series and stays proportional to the input length. The resulting hierarchy is the structure on which all later attention operates.
Formula
\text{Construct a multi-resolution pyramidal graph } \mathcal{G} = (\mathcal{V}, \mathcal{E}) \text{ with } C \text{ scales, where each coarser scale } s+1 \text{ aggregates } k \text{ nodes from scale } s.At each scale s, the nodes are projected to queries, keys and values, and attention is computed with the scaled dot-product form given in the mechanics. That formula is written over all nodes at the scale, so it is a simplification. The pyramidal graph has edges E, and attention is intended to follow those connections. The exact restriction pattern and its masking are set out in the original paper and should be taken from there rather than from the formula alone.
Formula
\text{Intra-scale attention at scale } s: \quad \text{Attn}(Q_s, K_s, V_s) = \text{softmax}\!\left(\frac{Q_s K_s^{\top}}{\sqrt{d_k}}\right)V_s,Between adjacent scales, attention is computed across parent and child nodes, with queries from one scale and keys and values from the next. This lets coarse-scale summaries inform fine-scale representations and lets fine-scale detail reach the coarser levels, so context from distant time steps can be carried through the hierarchy.
Formula
\text{Inter-scale (parent-child) connections transfer context between adjacent scales via cross-attention: } \text{Attn}(Q_s, K_{s+1}, V_{s+1}),After pyramidal attention, the finest-scale representations are passed through a linear output projection (W_o and b_o in the mechanics) to produce the forecast. Because the finest-scale representations are computed after the pyramid has been processed, the head reads predictions directly from them without autoregressive decoding.
Formula
\text{Final output } \hat{y} = W_o \, h_1^{(\text{finest scale})} + b_o, \text{ where } h_1 \text{ encodes all temporal scales via the CSCM coarsening and pyramidal attention.}Common pitfalls
- Equating a lower asymptotic complexity with faster wall-clock time: constant factors from the coarsening and multi-level attention can make runtime larger than that of a lightweight baseline on the same input
- Applying Pyraformer to short sequences, where the pyramid has few levels and the multi-scale structure may give little benefit; check the level count against your input length and aggregation size
- Skipping input normalisation, such as per-window standardisation. Normalisation is often important for forecast accuracy whatever the backbone, so test it with Pyraformer as with any other forecaster
- Treating benchmark numbers from the original paper as predictive for your own data, since they depend on the paper's dataset splits and hyperparameters
Frequently asked questions
How does Pyraformer differ from Informer?
Informer reduces attention cost with a ProbSparse mechanism that selects a subset of query-key pairs by estimated importance. Pyraformer instead builds an explicit multi-resolution pyramid and computes attention within each scale and between adjacent scales through parent-child connections. Both aim to reduce the cost of attention, but Pyraformer's pyramid gives the model an explicit multi-scale structure, while Informer's sparsity is selected from the attention scores.
Is Pyraformer still competitive with more recent models?
Later work, including PatchTST, TimesNet and iTransformer, and simple linear models such as DLinear and NLinear, has shown that Transformer-based forecasters do not uniformly outperform simpler alternatives. Pyraformer remains a useful architectural reference and may perform well in multi-scale or long-horizon settings, but it should be benchmarked against current baselines on your own data.
What is the role of the CSCM in Pyraformer?
The Coarser-Scale Construction Module (CSCM) builds the coarser levels of the pyramid. In the mechanics recorded here, each coarser scale aggregates k nodes from the scale below. The exact aggregation operator, whether learned or fixed, should be taken from the original paper.
What does Pyraformer take as input and produce, and how should its forecasts be evaluated?
Pyraformer is a direct multi-step forecaster. It reads a fixed-length history window and, from the finest-scale representations, produces the forecast in a single pass, as described in the forecasting head above. The lookback length and forecast horizon are chosen per experiment and should be reported with every result, since accuracy changes with both. Handling of multivariate series, the training loss and other training details should be taken from the original paper. Forecast accuracy is commonly reported as mean squared error (MSE) and mean absolute error (MAE) on a held-out test split. Compare models on the same split, horizon and metric.
Related methods
Sources
Liu, S., Yu, H., Liao, C., Li, J., Lin, W., Liu, A. X., & Dustdar, S. (2022). Pyraformer: Low-complexity pyramidal attention for long-range time series modeling and forecasting. ICLR.
Open publication reference