End-to-End Modeling Hierarchical Time Series Using Autoregressive Transformer and Conditional Normalizing Flow based Reconciliation

Shiyu Wang, Fan Zhou, Yinbo Sun, Lintao Ma, James Zhang, Yangfei Zheng, Lei Lei, Yun Hu · DOI

Introduction

In many real-world applications, time series data is organized into hierarchical structures where lower-level series aggregate into higher-level totals. For instance, national retail sales are the sum of regional sales, which in turn are the sum of individual store sales. Forecasting these series requires not only accuracy but also "coherency"—ensuring that the forecasts at different levels of the hierarchy satisfy the same aggregation constraints as the historical data.

Traditional forecasting pipelines typically employ a two-stage "forecast-then-reconcile" approach. These methods first generate independent "base forecasts" for each level and subsequently apply a reconciliation algorithm (such as Minimum Trace or Empirical Risk Minimization) to force the results into alignment. However, these methods often rely on rigid Gaussian assumptions and fail to share information between the forecasting and reconciliation steps. This paper introduces Hier-Transformer-CNF, an end-to-end framework that integrates forecasting and reconciliation into a single differentiable architecture.

The Challenges of Hierarchical Forecasting

Forecasting hierarchical data presents two primary difficulties:

  1. Coherency Constraints: The sum of the forecasts for sub-categories must equal the forecast for the parent category. Failing to maintain this leads to inconsistent decision-making across different levels of an organization.
  2. Statistical Complexity: Real-world data is frequently non-Gaussian, exhibiting heavy tails, skewness, and non-linear correlations. Traditional reconciliation methods often struggle with these "ill-behaved" distributions.

Proposed Methodology: Hier-Transformer-CNF

The proposed model replaces the disjointed two-stage pipeline with a unified architecture consisting of three core components:

1. Multivariate Autoregressive Transformer

Instead of treating each series in the hierarchy as an isolated unit, the model employs a Transformer with globally shared parameters. This allows the network to capture long-range dependencies and learn common patterns—such as seasonal trends or macro-economic cycles—across all levels of the hierarchy simultaneously. The Transformer outputs latent states that serve as conditions for the subsequent probabilistic modeling step.

2. Conditional Normalizing Flow (CNF)

To move beyond the limitations of Gaussian assumptions, the authors utilize Normalizing Flows. This class of deep learning models transforms a simple base distribution (like a standard Gaussian) into a complex, multi-modal distribution through a sequence of invertible, differentiable mappings. By conditioning this flow on the Transformer’s output, the model can represent the intricate joint distributions of the time series data.

3. End-to-End Reconciliation

The framework integrates reconciliation directly into the training process using a "bottom-up" projection. The CNF models the joint distribution of the bottom-level series. An aggregation matrix ($S$) is then applied within the network to derive the upper-level forecasts. Because this process is fully integrated, the model learns to generate base forecasts that are inherently easier to reconcile, optimizing for both accuracy and coherency simultaneously.

Experimental Evaluation

The model was evaluated on four diverse hierarchical datasets:

  • Traffic: Occupancy rates of 963 car lanes in the SF Bay Area (207-series hierarchy).
  • Tourism & Tourism-L: Quarterly Australian tourism flows (89 and 555 series, respectively).
  • Server-traffic: A proprietary dataset from Alipay application servers (39 series), where the model is currently deployed in production.

Key Results

Performance was measured using the Continuous Ranked Probability Score (CRPS), which evaluates the accuracy of the entire predictive distribution. Lower CRPS values indicate better performance.

  • State-of-the-Art Performance: Hier-Transformer-CNF outperformed all major baselines, including MinT, ERM, and Hier-E2E, across every dataset.
  • Significant Accuracy Gains: On the Traffic dataset, the model achieved a CRPS of 0.0217, representing a nearly 40% improvement over the next best end-to-end model (Hier-E2E at 0.0376).
  • Ablation Insights: Ablation studies revealed that the Transformer was most effective at improving macro-level (upper) forecasts, while the CNF was the primary driver for improving the accuracy of highly fluctuant bottom-level data.

Discussion and Future Work

By breaking the "Gaussian habit" and treating reconciliation as a learnable part of the network, Hier-Transformer-CNF provides a robust solution for complex hierarchical forecasting. The model’s ability to generate full predictive distributions makes it particularly valuable for risk management and resource allocation.

However, some challenges remain. The computational intensity of Transformers and Normalizing Flows may limit scalability for hierarchies with tens of thousands of nodes. Additionally, the current framework assumes a fixed hierarchy; future research could explore dynamic hierarchies where the aggregation structure changes over time (e.g., as new products are launched or regional boundaries are redefined). Finally, addressing error accumulation in long-horizon autoregressive forecasting remains a general area for improvement.

Summary updated

BibTeX
@inproceedings{wang2022end,
  author = {Shiyu Wang and Fan Zhou and Yinbo Sun and Lintao Ma and James Zhang and Yangfei Zheng and Lei Lei and Yun Hu},
  title = {{End-to-End Modeling Hierarchical Time Series Using Autoregressive Transformer and Conditional Normalizing Flow based Reconciliation}},
  booktitle = {Workshops @ ICDM},
  year = {2022},
  url = {https://openreview.net/forum?id=4Vn7ZjFmKL},
}
Figure