FiLM: Frequency Improved Legendre Memory Model

Machine Learning
Introduced by
Tian Zhou et al.
Year
2022
Type
Frequency-domain time-series forecasting model
Family
Time-series forecasting

What does it do?

FiLM (Frequency Improved Legendre Memory Model) is a long-term time-series forecasting architecture introduced by Tian Zhou and colleagues at NeurIPS 2022.

It represents the historical input as a truncated set of Legendre polynomial coefficients, filters those coefficients in the frequency domain, and evaluates the resulting polynomial at future time points. Because the memory size is set by the polynomial order rather than by the look-back length, the model avoids the cost of full self-attention over the input window.

The intuition behind the method

Think of FiLM as summarising recent history with a smooth polynomial and then adjusting how each frequency component of that summary is passed on. The Legendre coefficients act as a compact stand-in for the look-back window, and the learned frequency weights decide which oscillations in that stand-in are kept, rescaled or suppressed. The polynomial is then extended past the window to produce the forecast. Because the summary has only K coefficients, detail beyond polynomial order K is discarded by design, which is part of what keeps the model small.

History

FiLM was presented at NeurIPS 2022 by Tian Zhou and co-authors (Zhou et al., 2022). It combines a Legendre polynomial projection of the history with frequency-domain filtering. It was developed as an alternative to attention-based long-horizon forecasters such as Autoformer and FEDformer.

When to use it

Choose FiLM for long-horizon forecasting of univariate or multivariate series that show trend and periodic structure, especially when the look-back window is long and full attention would be costly. It is a reasonable candidate when the dominant cycles are stable across the window. Avoid it for irregular or event-driven series, for series with abrupt regime changes, and for tasks where cross-variable interactions dominate; recurrent or diffusion-based approaches may fit those cases better. For short histories or short horizons, the efficiency advantage matters less and simpler baselines may be adequate.

Limitations and considerations

  • The polynomial order K is a sensitive hyperparameter: a small K cannot represent fine temporal detail, and a large K can fit noise present in the look-back window.
  • The forecast extends the frequency structure of the look-back window into the horizon, so if the cycle structure changes after the window, the forecast may carry forward the old cyclical pattern.
  • A smooth polynomial fitted to the history represents abrupt distributional shifts or regime changes poorly.
  • The mechanics described here contain no explicit cross-variable interaction term, so multivariate dependence must be captured through the MLP layers. This is a weaker basis for forecasting when cross-variable effects dominate.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Complexity is linear in sequence length, so very long look-back windows remain computationally manageable compared with full self-attention.
  • The memory size is set by the polynomial order K rather than by the look-back length, so the summary passed through the model has a fixed dimension.
  • The learned frequency weights are an inspectable parameter: they show how the model reweights each frequency component of the summary, although their magnitudes do not directly measure spectral importance (see pitfalls).
  • The architecture is built from projection, filtering and MLP blocks rather than attention layers, which keeps the number of distinct components small.

Applications

  • Long-horizon forecasting of series with trend and periodic structure, the setting addressed by the original paper

How it works

How it works

1

The look-back window is projected onto a truncated Legendre polynomial basis of order K. Each coefficient is an integral of the signal against one basis polynomial, so it summarises the whole window at one scale of variation. Keeping K terms gives a fixed-size summary whose dimension does not grow with the window length, but any structure beyond order K is lost, so the representation is an approximation.

Formula
\hat{x}(t) = \sum_{k=0}^{K-1} c_k P_k(t), \quad c_k = (2k+1) \int_{-1}^{1} x(t) P_k(t)\, dt
2

The K coefficients are transformed with a Fourier transform, multiplied element-wise by a learnable K x K weight matrix, and transformed back. This lets the model amplify or suppress particular frequency components of the coefficient sequence, so the learned weights determine which patterns in the summary carry into the forecast.

Formula
\tilde{C} = \mathcal{F}^{-1}\bigl(\mathbf{W} \odot \mathcal{F}(C)\bigr), \quad \mathbf{W} \in \mathbb{R}^{K \times K}
3

The filtered coefficients define a polynomial that is evaluated at normalised future times (t+h - t0)/L for h = 1, ..., H. All H forecast steps come from this single evaluation rather than from step-by-step autoregressive rollout. In this formula, K is the polynomial order (the number of retained coefficients), L is the look-back length used to scale time, t0 is the reference time origin, and H is the forecast horizon.

Formula
\hat{y}_{t+h} = \sum_{k=0}^{K-1} \tilde{c}_k P_k\!\left(\frac{t+h - t_0}{L}\right), \quad h = 1, \ldots, H
4

Frequency-filter operations are stacked in layers, each followed by an MLP and added back through a residual connection. The stacking allows the representation to be refined over several rounds of filtering and nonlinear transformation.

Formula
\mathbf{z}^{(\ell+1)} = \text{MLP}\!\left(\tilde{\mathbf{z}}^{(\ell)}\right) + \mathbf{z}^{(\ell)}, \quad \tilde{\mathbf{z}}^{(\ell)} = \text{FreqFilter}\!\left(\mathbf{z}^{(\ell)}\right)

Common pitfalls

  • Choosing K too small removes high-frequency variation from the history, so forecasts will be smoother than the observed series.
  • Input scaling affects the fit: every Legendre coefficient is an integral over the whole window, so outliers can have a disproportionate influence. Normalising the inputs before fitting is a sensible precaution.
  • Comparisons with other forecasters are sensitive to look-back length; results obtained with different window lengths are not directly comparable.
  • Filter weight magnitudes are not direct measures of spectral contribution, because the weights interact multiplicatively with the coefficient spectrum and then pass through the inverse transform. Reading the weights as importance scores needs care.

Frequently asked questions

How does FiLM differ from FEDformer and Autoformer?

FEDformer and Autoformer retain a Transformer backbone, using frequency-enhanced and autocorrelation-based attention respectively. FiLM replaces attention with Legendre polynomial projection and frequency-domain filtering, giving a simpler architecture whose complexity is linear in sequence length.

What is the role of Legendre polynomials in FiLM?

Legendre polynomials form an orthogonal basis on the interval [-1, 1]. Projecting the look-back window onto a truncated basis of order K compresses it into K coefficients that describe the window at different scales. Within that order the representation is an approximation, not a lossless copy, because components beyond order K are discarded. The resulting polynomial also gives an analytic form that can be evaluated at future time points.

Does FiLM require GPU acceleration for practical use?

The complexity is linear in sequence length, so the cost of longer look-back windows grows gently. Hardware needs depend on dataset size, look-back length and the polynomial order K. A small pilot run on the target data is the most reliable way to establish these requirements before choosing hardware.

Related methods

Sources

  1. Zhou, T., Ma, Z., Wen, Q., Sun, L., Yao, T., Yin, W., & Jin, R. (2022). FiLM: Frequency improved Legendre memory model for long-term time series forecasting. NeurIPS.

    Open publication reference