liveBook · Manning

Transformer architecture

As explained in Time Series Forecasting Using Foundation Models

A neural-network architecture built from stacked attention and feed-forward processing components, typically organized into encoder and decoder parts.

A transformer architecture processes sequences through learned attention and feed-forward components, typically separating representation learning in an encoder from prediction in a decoder. In time-series forecasting, embeddings represent the data, positional encoding preserves time order, and stacked layers learn dependencies before generating future values. section 1.2 section 1.2.3

Follow the forecasting path:

  • Embed the input series into a representation the model can process, then add positional encoding so time-step order remains available. section 1.2
  • Pass the representation through stacked encoder layers, where self-attention learns relationships among tokens and feed-forward layers transform the result. section 1.2.2
  • Use multiheaded attention to learn different representations, such as trend-related and seasonal relationships. section 1.2.2
  • Generate predictions with decoder layers: masked attention blocks access to future values, cross-attention uses encoder output, and linear projection returns the forecast dimension. section 1.2.3
  • Feed each prediction back into the decoder until the complete forecast horizon is produced. section 1.2.3

Electricity demand and temperature

A transformer-based forecaster can use historical electricity demand together with temperature as an exogenous feature. Forecasting the next 24 hours requires the next 24 hours of temperature as well as past demand. section 3.2

Figure 1.2 Simplified transformer architecture from a time-series perspective. The raw series enters at the bottom-left portion of the figure and flows through an embedding layer and positional encoding before going into the decoder. Then the output comes from the decoder one value at a time until the entire horizon is predicted.
A diagram of a process

Description automatically generated

Trace the simplified time-series architecture from the raw series through embedding and positional encoding, then through prediction one value at a time. section 1.2

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Explains embeddings, positional encoding, encoder-decoder flow, attention variants, masking, and projection, but defers attention mathematics.
Examples
Uses electricity-demand forecasting with temperature, plus trend and seasonal patterns as attention-learning examples.
What it assumes
Assumes basic neural-network familiarity while introducing transformer components and their forecasting roles from first principles.
What you can do after
Evaluate transformer-based forecasters and diagnose architectural limitations involving exogenous features, multiple series, and fine-tuning.
How it connects
Connects foundation models, time-series forecasting, self-attention, positional encoding, multiheaded attention, encoder-decoder models, and exogenous features.

Also explained in

Compare how 28 books explain transformer architecture →

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.