Temporal Fusion Transformer

Also known as: TFT

On this page 7

The Temporal Fusion Transformer (TFT) is a deep learning architecture for multi-horizon time series forecasting that combines recurrent layers, gating mechanisms and interpretable self-attention to predict several future steps at once, together with quantile prediction intervals. In artificial intelligence, it is one of the best-known neural forecasters designed to use static metadata, past observations and known future inputs in a single model.

TFT was introduced by researchers from Google Cloud AI and the University of Oxford in 2019 and published in the International Journal of Forecasting in 2021. Its distinguishing aim is accuracy with explanation: besides forecasts, it reports which variables and which past time steps mattered most.

How the Temporal Fusion Transformer processes inputs

TFT separates its inputs into three kinds of variables and treats each kind differently, which is the core idea behind the word fusion. Static covariates describe a series and do not change over time, past-observed inputs are known only up to the forecast origin, and known future inputs such as calendar features or planned promotions are available for the whole forecast horizon.

Input typeExamplesAvailable for
Static covariatesStore identifier, product category, regionEntire series, constant
Past-observed inputsSales, sensor readings, observed weatherLookback window only
Known future inputsDay of week, holidays, planned pricesLookback window and horizon
Target variableThe quantity being forecastLookback window only
Input types accepted by TFT

The data flow has a clear order. Variable selection networks weight each input at every time step, an LSTM encoder-decoder processes the lookback window and the horizon to capture local patterns, and a multi-head attention layer then links each future step to relevant earlier steps. Finally, a dense output layer produces several quantiles per future step.

Key building blocks of the architecture

TFT is assembled from a small set of reusable components. The most frequent is the gated residual network (GRN), a feedforward block with a skip connection and a gated linear unit that can suppress the block entirely, so the model applies nonlinear processing only where the data supports it.

ComponentFunctionBenefit
Gated residual networkNonlinear transformation with gatingSkips unnecessary complexity
Variable selection networkSoftmax weights over inputsRemoves noisy features, shows importance
Static covariate encodersFour context vectors from metadataConditions every later stage on the series
LSTM encoder-decoderSequence-to-sequence local processingCaptures short-range patterns and order
Interpretable multi-head attentionShared value weights across headsYields one readable attention pattern
Quantile output layerPredicts chosen percentilesProvides prediction intervals
Main components of the Temporal Fusion Transformer

The static covariate encoders deserve emphasis. They produce four separate context vectors that steer variable selection, initialize the LSTM states and enrich the temporal features, so one global model can behave differently for a large store and a small kiosk.

Training minimizes the quantile loss, also called pinball loss, summed over typical quantiles such as the 10th, 50th and 90th percentiles. The result is a probabilistic forecast without assuming any specific output distribution.

Interpretability in TFT

TFT offers built-in interpretability at three levels, which distinguishes it from most deep forecasters. Aggregated variable selection weights show global feature importance, attention weights over past time steps reveal persistent patterns such as weekly seasonality, and spikes in attention can highlight regime changes such as a sudden shift in demand.

These explanations are useful but not causal. Attention and selection weights describe what the trained model relied on, not why the target behaves as it does. Correlated covariates can share or swap importance between training runs, so practitioners should check stability across random seeds before drawing business conclusions.

TFT compared with other forecasting models

TFT sits among global deep forecasting models that learn from many related series at once. The comparison below places it next to classical statistical models and other neural forecasters from the same Topic.

ModelCore mechanismCovariatesProbabilistic output
ARIMA or ETSStatistical model per seriesLimitedYes, parametric
DeepARAutoregressive recurrent networkYesYes, likelihood-based
N-BEATS and N-HiTSStacked fully connected blocksLimited in base formNot by default
PatchTSTTransformer over series patchesLimitedNot by default
Temporal Fusion TransformerLSTM, gating and attentionStatic, past and futureYes, quantiles
TFT and related forecasting approaches

Compared with the Informer and PatchTST, TFT is less focused on very long input sequences and more focused on heterogeneous covariates. Compared with DeepAR, it predicts the whole horizon directly rather than recursively, which avoids the accumulation of errors in recursive forecasting.

When to use TFT and its limitations

TFT is most effective when a problem has many related series, rich covariates and a need for explanations, as in retail demand, electricity load or traffic planning. It is available in common libraries such as PyTorch Forecasting, Darts and NeuralForecast, which handle data encoding and quantile training.

SituationRecommendationReason
Thousands of series with metadataStrong candidateGlobal learning and static context pay off
Important known future eventsStrong candidateKnown inputs enter the decoder directly
A single short seriesPrefer ETS or ARIMAToo little data for many parameters
Strict latency or compute budgetPrefer simpler modelsTraining and tuning are costly
Deciding whether TFT fits a forecasting task

Its main limitations are high computational cost, sensitivity to hyperparameters such as hidden size, dropout and lookback length, and a tendency to overfit small datasets. Results should always be compared with a seasonal naive forecast and a tuned gradient boosting model, because in several published comparisons simpler baselines remain competitive.

Stripped to the essentials

The Temporal Fusion Transformer is a forecasting program that learns from history. It predicts values for many days or hours ahead in a single step.

It uses three kinds of clues. Some clues never change, such as the type of shop. Some clues are known only from the past, such as last week’s sales. Some clues are known in advance, such as holidays. The model decides which clues matter at each moment.

It does not give just one number. It gives a likely value and a realistic range around it. It also shows which clues it relied on most, so people can check its reasoning.

Where it is applied

A grocery chain with 300 stores needs daily demand forecasts for 14 days ahead for about 5,000 products. Its planners train one TFT model on three years of sales. Static inputs include store size, region and product category. Known future inputs include the calendar, public holidays and planned promotions, while past inputs include sales and local weather observations.

The model returns the 10th, 50th and 90th percentiles for every product, store and day. Replenishment uses the 90th percentile for perishable best sellers and the median for slow movers. The variable selection weights show that promotions and day of week dominate most categories, which the planners confirm against their experience. After several months of parallel testing against the previous statistical system, the chain adopts TFT for categories with frequent promotions, where its accuracy gain is largest.