liveBook · Manning

Token

As explained in Time Series Forecasting Using Foundation Models

A token is a discrete representation of a sequence segment, including a fixed-length set of past time steps and associated features.

A token is a discrete representation of part of a time series. Depending on the model, it may represent a unique value, a window or patch of values, or fixed-context past time steps combined with date-time features. section 1.2.1 section 4.1.1

Common token construction strategies include:

  • Represent raw observations as individual values or windows of values before learning an embedding. section 1.2.1
  • Combine lagged values over a fixed context length with date-time features such as hour-of-day, day-of-week, and quarter-of-year. section 4.1.1
  • Convert continuous values into a finite vocabulary through mean scaling and quantization. section 5.2 section 5.3
  • Treat a token as a patch containing several time steps, so autoregressive decoding can forecast groups rather than individual observations. section 6.2.2

After tokenization, transformer models commonly project tokens into hidden dimensions and add positional encoding so attention can distinguish order and repeated values. Some models instead train on finite discrete tokens, then dequantize and unscale generated tokens back into predictions. section 1.2.1 section 4.1.1 section 5.2

Hourly forecasting token

For hourly data, a token can contain a fixed history of lagged observations plus calendar features. Hour-of-day changes at every step, while day-of-week and day-of-month change less often, giving the model clues about the series frequency. section 4.1.1

Figure 4.2 Tokenization process in Lag-Llama. Here, the token of the current time step includes lagged values of the series over a certain context length, as well as date-time features.
A diagram of a cell phone

Description automatically generated

Visualizes how a current-time-step token combines lagged values over a context window with date-time features. section 4.1.1

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Explains token construction, embeddings, positional encoding, lagged features, scaling, quantization, and patch-based decoding.
Examples
Uses hourly lagged histories, calendar features, time-series patches, mean-scaled values, and quantization bins as concrete token examples.
What it assumes
Assumes familiarity with time series and transformer forecasting while explaining tokenization from raw values and fixed contexts.
What you can do after
Evaluate tokenization choices by considering feature richness, quantization precision, context size, and inference cost.
How it connects
Connects tokens to embeddings, positional encoding, attention, lagged features, quantization, and autoregressive forecasting.

Also explained in

Compare how 31 books explain token →

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.