liveBook · Manning

FLAN-T5

As explained in Time Series Forecasting Using Foundation Models

Flan-T5 is an instruction-tuned text-to-text transformer model designed to follow natural-language instructions across tasks.

FLAN-T5 is an instruction-tuned version of T5, fine-tuned on more than 1,800 tasks including question answering, arithmetic reasoning, and text categorization. It is open source, ranges from flan-t5-small to flan-t5-xxl, and generally responds better to questions than direct forecasting instructions. section 8.1.1

For time-series forecasting, frame the task as asking what future values will be rather than instructing the model to forecast. A practical pipeline scales the context, uses few-shot examples, generates text, parses numeric predictions, adjusts the horizon, and inverse-transforms the values. section 8.2.1

A local forecasting workflow typically includes:

  • Load the model and tokenizer with the Transformers library; flan-t5-base contains 278 million parameters. section 8.2
  • Scale values between 0 and 1 with MinMaxScaler to reduce errors when generating numeric tokens. section 8.2.1
  • Control output length with max_new_tokens and reduce variability with a low temperature. section 8.2.1
  • Inspect raw output because the model may produce too few or repeated predictions; extend or truncate the sequence before evaluation. section 8.2.2

Weekly sales forecasting

Applied to eight-week forecasts for individual stores, FLAN-T5 often generated constant values or only six predictions instead of eight, requiring repetition of the last value. Its MAE was 83,721 and sMAPE was 2.62% in one four-window evaluation, comparable to Moirai with exogenous features but not representative of general performance. section 8.2.2 section 8.3.2

Prompting can also request anomaly labels using statistics and chain-of-thought examples, but the demonstrated method labeled every value normal and produced zero precision, recall, and F1. FLAN-T5 is not specifically trained for time-series data. section 8.5 section 8.5.2

How Time Series Forecasting Using Foundation Models covers it

How deep it goes
Details local loading, scaling, prompting, parsing, horizon correction, and evaluation, but stops short of specialized time-series training.
Examples
Uses weekly store sales, eight-week horizons, few-shot numeric prompts, cross-validation metrics, and anomaly-label sequences.
What it assumes
Assumes a time-series dataset and basic model-loading, scaling, parsing, and forecast-evaluation workflows.
What you can do after
Apply it via Transformers to build prompt-based forecasts and evaluate their numeric outputs, while recognizing unreliable anomaly detection.
How it connects
Connects T5, Transformers, few-shot prompting, zero-shot forecasting, anomaly detection, and exogenous features.

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.