liveBook · Manning

Multi-head attention

As explained in Time Series Forecasting Using Foundation Models

An attention mechanism with multiple parallel attention heads that combines information from different representation subspaces.

Multi-head attention runs several attention mechanisms in parallel, allowing a model to learn different relationships and representations from the same sequence. In time-series forecasting, one head might emphasize trends while another identifies seasonal patterns. The mechanism is described conceptually rather than mathematically. section 1.2.2

Within transformer forecasting architectures, multi-head attention supports several distinct operations:

  • Encoder heads relate the current token to other tokens in the known historical sequence, potentially assigning greater weight to nearby time steps. section 1.2.2
  • Decoder self-attention is masked so predictions use previous data without accessing future values. section 1.2.3
  • A decoder's second attention layer uses the encoder representation, after which projections convert the deep representation into forecast values. section 1.2.3
  • Decoder-only forecasting models can stack many layers using multi-head attention; TimesFM also masks input patches during training. section 7.1.1
Figure 1.8 Visualizing the decoder in detail. We see that the output of the encoder is fed to the second attention layer of the decoder; the decoder generates predictions using information learned from the encoder.

Trace how encoder output enters the decoder's second attention layer and contributes to prediction generation. section 1.2.3

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Explains roles, masking, and architecture connections, but defers the mechanism's mathematical details.
Examples
Illustrates trend and seasonal heads, nearer historical tokens, masked decoder inputs, and TimesFM input patches.
What it assumes
Assumes familiarity with tokens, embeddings, and basic transformer structure while explaining attention roles conceptually.
What you can do after
Evaluate/understand how attention heads, causal masks, and encoder representations support transformer forecasts.
How it connects
Connects self-attention, transformers, encoders, decoders, positional encoding, masking, and time-series forecasting.

Also explained in

Compare how 14 books explain multi-head attention →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Time Series Forecasting Using Foundation Models. The section links point to the parts of the book it draws on.