GNBAN: Graph Neural Basis Attention Networks for Long-Horizon Forecasting over Large Entity Sets
Summary
GNBAN is a new graph-based neural architecture for long-horizon retail demand forecasting that combines heterogeneous graph learning with an interpretable basis-decomposition forecasting head, achieving 4-5% improvement on Walmart and Favorita benchmarks.
View Cached Full Text
Cached at: 06/29/26, 05:26 AM
# GNBAN: Graph Neural Basis Attention Networks for Long-Horizon Forecasting over Large Entity Sets
Source: [https://arxiv.org/html/2606.27863](https://arxiv.org/html/2606.27863)
Janak M\. Patel Phi Labs, Quantiphi Marlborough, MA 01752, USA &Anirudh Deodhar Phi Labs, Quantiphi Marlborough, MA 01752, USA &Dagnachew Birru Phi Labs, Quantiphi Marlborough, MA 01752, USA
###### Abstract
Demand forecasting at the lowest level of a retail hierarchy requires simultaneously predicting tens of thousands of correlated long\-horizon time series across products, stores, and regions\. This creates a fundamental challenge for modern forecasting systems: models must scale across massive retail catalogs while capturing shared demand dynamics and producing forecasts that practitioners can interpret and trust\. Classical statistical methods require maintaining separate models for each series, making them difficult to manage at production scale\. Deep auto\-regressive architectures struggle as the joint forecasting state grows to tens of thousands of dimensions\. More recently, graph\-based deep forecasting architectures have shown promise in modeling dependencies across entities and time\. However, many existing approaches remain difficult to scale for long\-horizon forecasting and often generate opaque forecasts that provide limited insight into underlying demand patterns\. To address these challenges, we proposeGNBAN \(Graph Neural Basis Attention Network\), an end\-to\-end forecasting architecture that combines heterogeneous graph representation learning with an interpretable basis\-decomposition forecasting head\. Retail data are represented directly as a heterogeneous graph derived from the underlying relational database schema, allowing a single model to learn across the entire catalog\. Instead of predicting forecast horizons directly, GNBAN decomposes each forecast into three semantically meaningful components: trend, seasonal, and generic\. The key innovation is a*per\-basis attention mechanism*in which each basis function maintains its own learnable query and retrieves information independently from the historical neighborhood of the forecast entity\. This enables different bases to specialize to distinct temporal patterns while preserving interpretability\. We evaluate GNBAN on two large\-scale retail forecasting benchmarks, M5 Walmart and Favorita Grocery Sales, under matched experimental protocols\. Compared with a baseline graph forecasting model, GNBAN improves volume\-weighted WRMSSE by approximately 4–5% across both datasets\. Qualitative analysis further shows that the learned decomposition produces interpretable forecasts that expose trend, seasonal, and residual demand drivers without requiring post\-hoc explanation methods\. These results demonstrate that scalable relational forecasting and interpretable forecast decomposition can be achieved simultaneously within a unified graph\-based forecasting framework\.
## 1Introduction
Retail demand forecasting at the lowest level of the merchandising hierarchy, where future demand must be predicted for every SKU at every store across multi\-week horizons, is one of the most challenging problems in large\-scale time\-series forecasting\. Modern retailers such as Corporación Favorita and Walmart must simultaneously forecast tens of thousands of correlated product\-store series within a single operational pipeline\[[8](https://arxiv.org/html/2606.27863#bib.bib25),[3](https://arxiv.org/html/2606.27863#bib.bib31)\]\. These forecasting systems must satisfy four competing requirements: they must scale across massive catalogs, capture shared demand dynamics across products and stores, support long\-horizon forecasting, and remain interpretable enough for operational decision\-making\.
Existing forecasting paradigms satisfy only subsets of these requirements\. Classical statistical methods such as Error\-Trend\-Seasonality \(ETS\) and ARIMA provide interpretable forecasts, but typically require maintaining separate models for every series, making deployment and monitoring difficult at catalog scale\[[5](https://arxiv.org/html/2606.27863#bib.bib22)\]\. Deep autoregressive architectures such as DeepAR and Temporal Fusion Transformers replace thousands of local models with a single global network\[[12](https://arxiv.org/html/2606.27863#bib.bib7),[6](https://arxiv.org/html/2606.27863#bib.bib10)\], enabling parameter sharing across series\. However, they do not explicitly model relational dependencies between entities such as products, stores, and categories when forecasting large retail panels\. Gradient\-boosted tree approaches, which dominated the M5 competition\[[8](https://arxiv.org/html/2606.27863#bib.bib25)\], improve scalability and predictive accuracy through extensive feature engineering, yet often flatten temporal and cross\-entity relationships into tabular representations, limiting their ability to naturally capture interactions across the retail ecosystem\.
More recently, graph\-based forecasting methods and relational deep learning approaches\[[4](https://arxiv.org/html/2606.27863#bib.bib2),[11](https://arxiv.org/html/2606.27863#bib.bib1)\]have emerged as a promising direction for large\-scale retail forecasting\. By representing products, stores, categories, and temporal events as nodes in a heterogeneous graph, these approaches naturally capture cross\-entity dependencies through message passing\. However, existing graph forecasting architectures typically attach a simple multi\-layer perceptron forecasting head to the learned graph embeddings, directly mapping latent representations to forecast vectors\. While effective for representation learning, these forecasting heads remain poorly suited for long\-horizon retail forecasting: they often produce opaque forecasts, provide little insight into trend or seasonal structure, and degrade as forecasting horizons grow longer\.
In parallel, long\-horizon forecasting research has shown that decomposition\-based architectures can significantly improve forecasting stability and interpretability by explicitly modeling low\-frequency structures such as trend and seasonality\[[10](https://arxiv.org/html/2606.27863#bib.bib5),[2](https://arxiv.org/html/2606.27863#bib.bib6),[16](https://arxiv.org/html/2606.27863#bib.bib13)\]\. However, these methods are primarily designed for independent time series and do not leverage the rich relational structure present in large retail systems\.
This work addresses the gap between scalable graph\-based forecasting and accurate, interpretable long\-horizon forecasting\. We proposeGNBAN \(Graph Neural Basis Attention Network\), a single global forecasting architecture that combines graph\-based representation learning with interpretable basis\-style forecast decomposition\. GNBAN couples a heterogeneous graph neural network backbone with a basis\-attention forecasting head that decomposes each forecast into three semantically meaningful components: a smooth trend component, a periodic seasonal component, and a residual generic component\. Each component is generated using a dedicated learnable attention query over the entity’s historical neighborhood, enabling the model to capture shared demand dynamics while improving long\-horizon forecasting performance and exposing the underlying structure of the forecast\. A single trained GNBAN model serves the entire retail catalog, eliminating the need for thousands of independently maintained forecasting models while simultaneously supporting scalable forecasting, interpretable forecast decomposition, and long\-horizon prediction within a unified end\-to\-end framework\. Our contributions are summarized as follows:
1. 1\.We introduce GNBAN, a single global forecasting architecture for large\-scale retail demand forecasting that combines graph\-based representation learning with basis\-style forecast decomposition\.
2. 2\.We propose a basis\-attention forecasting head that decomposes forecasts into interpretable trend, seasonal, and residual components while improving long\-horizon forecasting performance\.
3. 3\.We demonstrate that a single trained model can simultaneously achieve scalable forecasting, improved predictive accuracy, and interpretable forecast decomposition across large retail forecasting benchmarks\.
## 2Related Work
Large\-scale retail demand forecasting\.Retail forecasting has been extensively studied through the M\-series forecasting competitions, particularly M5, which focuses on hierarchical retail demand forecasting across thousands of product\-store combinations\[[8](https://arxiv.org/html/2606.27863#bib.bib25),[7](https://arxiv.org/html/2606.27863#bib.bib26)\]\. Classical statistical methods such as ARIMA, ETS, and Theta remain competitive for individual time series due to their simplicity and interpretability\[[5](https://arxiv.org/html/2606.27863#bib.bib22)\]\. However, maintaining separate models for tens of thousands of retail series becomes operationally challenging on a catalog scale\. Consequently, recent state\-of\-the\-art solutions increasingly rely on global learning approaches that share information across related series\.
Global forecasting models\.Global forecasting architectures learn a single model across all time series in a dataset\. DeepAR\[[12](https://arxiv.org/html/2606.27863#bib.bib7)\], DeepFactors\[[14](https://arxiv.org/html/2606.27863#bib.bib9)\], and Temporal Fusion Transformers\[[6](https://arxiv.org/html/2606.27863#bib.bib10)\]demonstrated that parameter sharing can significantly improve forecasting performance while reducing maintenance overhead\. More recently, long\-horizon forecasting architectures such as Informer\[[20](https://arxiv.org/html/2606.27863#bib.bib12)\], Autoformer\[[16](https://arxiv.org/html/2606.27863#bib.bib13)\], PatchTST\[[9](https://arxiv.org/html/2606.27863#bib.bib14)\], and TimesNet\[[15](https://arxiv.org/html/2606.27863#bib.bib15)\]have improved the modeling of long\-range temporal dependencies\. However, these approaches primarily focus on temporal dynamics and do not explicitly model relationships among products, stores, and other entities present in retail systems\.
Graph\-based forecasting\.Graph neural networks provide a natural mechanism for modeling dependencies across related entities\. Existing graph forecasting approaches such as STGCN\[[19](https://arxiv.org/html/2606.27863#bib.bib18)\], Graph WaveNet\[[18](https://arxiv.org/html/2606.27863#bib.bib19)\], MTGNN\[[17](https://arxiv.org/html/2606.27863#bib.bib20)\], and AGCRN\[[1](https://arxiv.org/html/2606.27863#bib.bib21)\]learn graph structures directly from correlated time series and have shown strong performance on traffic and sensor forecasting tasks\. More recently, graph\-based learning on relational databases has emerged as a promising framework for enterprise forecasting applications\[[4](https://arxiv.org/html/2606.27863#bib.bib2),[11](https://arxiv.org/html/2606.27863#bib.bib1)\], where products, stores, categories, and transactions can be represented as nodes connected through natural business relationships\. While these approaches effectively capture cross\-entity dependencies, forecasting is typically performed using simple MLP\-based prediction heads that directly map learned representations to future values\.
Forecast decomposition and interpretability\.Forecast decomposition has proven highly effective for long\-horizon forecasting\. N\-BEATS\[[10](https://arxiv.org/html/2606.27863#bib.bib5)\]introduced interpretable trend and seasonality bases, while N\-HiTS\[[2](https://arxiv.org/html/2606.27863#bib.bib6)\]extended this idea through hierarchical interpolation\. Similarly, decomposition\-based transformer architectures such as Autoformer\[[16](https://arxiv.org/html/2606.27863#bib.bib13)\]explicitly separate trend and seasonal patterns to improve long\-range forecasting performance\. Despite their success, these methods are primarily designed for independent time series and do not leverage the relational structure commonly found in large retail systems\.
Positioning of GNBAN\.GNBAN bridges these research directions by combining graph\-based forecasting with basis\-style forecast decomposition\. Unlike existing graph forecasting models that rely on black\-box prediction heads, GNBAN introduces a basis\-attention forecasting head that decomposes forecasts into interpretable trend, seasonal, and residual components while leveraging graph\-based representations to capture cross\-entity demand dynamics\.
## 3Method
GNBAN \(GraphNeuralBasisAttentionNetwork\) is a single global forecasting architecture designed for large\-scale retail demand forecasting\. The model combines a heterogeneous graph encoder that captures dependencies among retail entities with a basis\-attention forecasting head that produces interpretable long\-horizon forecasts\. Figure[1](https://arxiv.org/html/2606.27863#S3.F1)provides an overview of the architecture\.
The workflow consists of four stages\. First, the retail database is represented as a heterogeneous graph derived from the underlying relational schema\. Second, a heterogeneous graph neural network encodes each forecast entity and its historical context into latent representations\. Third, a basis\-attention forecasting head generates the forecast as an additive combination of trend, seasonal, and residual components\. Finally, the entire architecture is trained end\-to\-end using a normalized forecasting objective\.
Figure 1:Overview of GNBAN\. The retail database is represented as a heterogeneous graph where each forecast entity is connected to its historical sales observations\. A heterogeneous GraphSAGE produces an entity embedding and contextual neighborhood representations\. The basis\-attention forecasting head then generates three additive forecast components: trend, seasonal, and generic using dedicated learnable queries that attend to the historical neighborhood\. These components are combined to produce the final long\-horizon forecast\.### 3\.1Graph Representation
We represent the retail dataset as a heterogeneous graph constructed directly from the underlying relational schema\. The graph contains two node types:
- •itemstore: one node for each SKU\-store forecasting entity\.
- •sales: one node for each historical observation associated with an entity\.
Item\-store nodes contain static attributes such as product category, department, store identifier, and geographic information\. Sales nodes contain historical demand values and time\-varying covariates including price, promotions, holidays, and calendar features\.
Edges follow the natural foreign\-key relationship between sales observations and their corresponding item\-store entity\. For each forecast entity, we sample its historical sales neighborhood prior to the forecast origin, ensuring that no future information is available during training or inference\.
### 3\.2Heterogeneous Graph Encoder
Given a target item\-store entityvvand its sampled neighborhood𝒩\(v\)\\mathcal\{N\}\(v\), a heterogeneous GraphSAGE encoder aggregates information from neighboring sales observations to produce contextual representations\. Let𝐱v\\mathbf\{x\}\_\{v\}denote the feature vector of entityvvand𝐱u\\mathbf\{x\}\_\{u\}denote the feature vector of neighboring sales nodeuu\. The encoder computes
𝐳v=σ\(Wself𝐱v\+Meanu∈𝒩\(v\)Wnbr𝐱u\)\\mathbf\{z\}\_\{v\}=\\sigma\\left\(W\_\{\\mathrm\{self\}\}\\mathbf\{x\}\_\{v\}\+\\mathrm\{Mean\}\_\{u\\in\\mathcal\{N\}\(v\)\}W\_\{\\mathrm\{nbr\}\}\\mathbf\{x\}\_\{u\}\\right\)\(1\)
whereσ\(⋅\)\\sigma\(\\cdot\)denotes a non\-linear transformation followed by layer normalization\. The resulting embedding𝐳v∈ℝd\\mathbf\{z\}\_\{v\}\\in\\mathbb\{R\}^\{d\}captures both entity\-specific information and historical demand context\. In addition to the target embedding, the encoder produces contextual embeddings
𝐂v=\[𝐡1,…,𝐡N\]∈ℝN×d\\mathbf\{C\}\_\{v\}=\[\\mathbf\{h\}\_\{1\},\\ldots,\\mathbf\{h\}\_\{N\}\]\\in\\mathbb\{R\}^\{N\\times d\}
whereNNis the number of neighboring sales nodes andddis the hidden dimension\.
### 3\.3Basis\-Attention Forecasting Head
The basis\-attention forecasting head is the key contribution of GNBAN\. Rather than directly mapping latent representations to anHH\-step forecast vector through a multilayer perceptron, GNBAN represents forecasts as a weighted combination of interpretable basis functions\.
#### 3\.3\.1Forecast Decomposition
The forecasting horizon is represented using three groups of basis functions:
- •Trend basis: polynomial functions capturing long\-term demand evolution\.
- •Seasonal basis: sinusoidal functions capturing recurring demand cycles\.
- •Generic basis: learnable basis functions capturing residual structure\.
Let
𝐁=\[𝐁\(T\),𝐁\(S\),𝐁\(G\)\]\\mathbf\{B\}=\\left\[\\mathbf\{B\}^\{\(T\)\},\\mathbf\{B\}^\{\(S\)\},\\mathbf\{B\}^\{\(G\)\}\\right\]\(2\)
denote the complete basis dictionary defined over the forecasting horizon\. The final forecast is decomposed as
𝐲^v=𝐲^v\(T\)\+𝐲^v\(S\)\+𝐲^v\(G\)\\hat\{\\mathbf\{y\}\}\_\{v\}=\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(T\)\}\+\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(S\)\}\+\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(G\)\}\(3\)
where the three terms correspond to trend, seasonal, and generic contributions, respectively\.
#### 3\.3\.2Per\-Basis Attention
Unlike conventional attention mechanisms that use a shared query representation, GNBAN assigns a dedicated learnable query to each basis function\. This allows different basis functions to retrieve different aspects of the historical signal\. Let𝐪k∈ℝd\\mathbf\{q\}\_\{k\}\\in\\mathbb\{R\}^\{d\}denote the learnable query associated with basiskk\. To adapt the behavior of each basis to a specific forecast entity, the queries are conditioned on the entity embedding𝐳v\\mathbf\{z\}\_\{v\}produced by the graph encoder:
𝐂v\(q\)=reshape\(𝐖cond𝐳v\)∈ℝK×d\\mathbf\{C\}^\{\(q\)\}\_\{v\}=\\mathrm\{reshape\}\\left\(\\mathbf\{W\}\_\{\\mathrm\{cond\}\}\\mathbf\{z\}\_\{v\}\\right\)\\in\\mathbb\{R\}^\{K\\times d\}\(4\)
where rowkkcorresponds to the conditioning vector𝐜v,k\\mathbf\{c\}\_\{v,k\}\. The basis\-specific query is then
𝐪~v,k=𝐪k\+𝐜v,k\\tilde\{\\mathbf\{q\}\}\_\{v,k\}=\\mathbf\{q\}\_\{k\}\+\\mathbf\{c\}\_\{v,k\}\(5\)
Keys and values are generated from the neighborhood embeddings produced by the graph encoder:
𝐊v=𝐂v𝐖K,𝐕v=𝐂v𝐖V\\mathbf\{K\}\_\{v\}=\\mathbf\{C\}\_\{v\}\\mathbf\{W\}\_\{K\},\\qquad\\mathbf\{V\}\_\{v\}=\\mathbf\{C\}\_\{v\}\\mathbf\{W\}\_\{V\}\(6\)
The attention weights for basiskkare computed as
𝜶v,k=softmax\(𝐪~v,k⊤𝐊v⊤d\)\\bm\{\\alpha\}\_\{v,k\}=\\mathrm\{softmax\}\\left\(\\frac\{\\tilde\{\\mathbf\{q\}\}\_\{v,k\}^\{\\top\}\\mathbf\{K\}\_\{v\}^\{\\top\}\}\{\\sqrt\{d\}\}\\right\)\(7\)
where𝜶v,k∈ℝN\\bm\{\\alpha\}\_\{v,k\}\\in\\mathbb\{R\}^\{N\}assigns importance to each historical observation in the neighborhood\. The retrieved context vector is
𝐫v,k=𝜶v,k𝐕v\\mathbf\{r\}\_\{v,k\}=\\bm\{\\alpha\}\_\{v,k\}\\mathbf\{V\}\_\{v\}\(8\)
A scalar coefficient for basiskkis then obtained as
βv,k=𝐰k⊤LayerNorm\(𝐫v,k\)\+bk\\beta\_\{v,k\}=\\mathbf\{w\}\_\{k\}^\{\\top\}\\mathrm\{LayerNorm\}\(\\mathbf\{r\}\_\{v,k\}\)\+b\_\{k\}\(9\)
Because each basis maintains its own query, different basis functions can attend to different regions of the historical neighborhood\. Trend bases can focus on long\-term demand evolution, seasonal bases can attend to phase\-aligned historical observations, and generic bases can specialize to short\-term residual behavior\.
#### 3\.3\.3Forecast Reconstruction
The coefficients generated by the attention mechanism weight their corresponding basis functions to produce horizon\-level forecasts:
𝐲^v\(T\)\\displaystyle\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(T\)\}=∑k∈𝒯βv,k𝐛k\\displaystyle=\\sum\_\{k\\in\\mathcal\{T\}\}\\beta\_\{v,k\}\\mathbf\{b\}\_\{k\}\(10\)𝐲^v\(S\)\\displaystyle\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(S\)\}=∑k∈𝒮βv,k𝐛k\\displaystyle=\\sum\_\{k\\in\\mathcal\{S\}\}\\beta\_\{v,k\}\\mathbf\{b\}\_\{k\}\(11\)𝐲^v\(G\)\\displaystyle\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(G\)\}=∑k∈𝒢βv,k𝐛k\\displaystyle=\\sum\_\{k\\in\\mathcal\{G\}\}\\beta\_\{v,k\}\\mathbf\{b\}\_\{k\}\(12\)
The final forecast is obtained by applying a softplus activation to ensure non\-negative predictions:
𝐲^v=softplus\(𝐲^v\(T\)\+𝐲^v\(S\)\+𝐲^v\(G\)\)\.\\hat\{\\mathbf\{y\}\}\_\{v\}=\\mathrm\{softplus\}\\\!\\left\(\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(T\)\}\+\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(S\)\}\+\\hat\{\\mathbf\{y\}\}\_\{v\}^\{\(G\)\}\\right\)\.\(13\)This decomposition provides a direct interpretation of how trend, seasonality, and residual demand dynamics contribute to the prediction\.
## 4Experiments
### 4\.1Datasets
We evaluate GNBAN on two widely used retail demand forecasting benchmarks that differ substantially in scale, demand characteristics, and forecasting horizon\. Together, they provide complementary evaluation scenarios spanning intermittent count\-based demand and continuous, heavy\-tailed sales distributions\.
M5 Walmart Accuracy\[[13](https://arxiv.org/html/2606.27863#bib.bib32),[8](https://arxiv.org/html/2606.27863#bib.bib25)\]contains 30,490 item\-store time series collected from 10 Walmart stores across three U\.S\. states, spanning 1,941 days from January 2011 to June 2016\. The dataset exhibits highly intermittent demand, with a large fraction of zero\-sales observations and daily sales ranging from 0 to approximately 700 units\. In addition to historical sales, M5 provides a 12\-level product hierarchy, SNAP eligibility indicators, event calendars, and weekly selling prices\. We use data from 2014\-01\-01 onward \(≈\\approx26\.6M rows after filtering\) and evaluate 28\-day forecasts at the item\-store level using the full set of 30,490 series following the official public leaderboard protocol\.
Favorita Grocery Sales\[[3](https://arxiv.org/html/2606.27863#bib.bib31)\]contains sales records from 54 Corporación Favorita stores in Ecuador spanning approximately 1,680 days from January 2013 to August 2017\. Unlike M5, sales are continuous and span a substantially wider dynamic range, reaching approximately 44,000 units per day\. The dataset includes rich exogenous information such as promotions, holidays, crude oil prices, store transaction counts, and product metadata\. We use data from 2016\-01\-01 onward \(≈\\approx25\.9M rows\) and retain the 50,000 highest\-volume item\-store pairs after applying a minimum cumulative sales threshold\. We evaluate a 16\-day forecasting horizon\.
The two datasets differ not only in scale and horizon length, but also in their underlying demand distributions and exogenous drivers, providing a rigorous test of model robustness across diverse retail forecasting environments\.
### 4\.2Evaluation Protocol and Metrics
#### 4\.2\.1Forecast Origins and Data Splits
M5\.We follow the official M5 public leaderboard protocol, using 2016\-04\-24 as the forecast origin and generating forecasts for the subsequent 28 days\. Evaluation is performed at the bottom level of the hierarchy \(item\-store pairs\) using the complete set of 30,490 series\. Training forecast origins are sampled weekly prior to the validation and test periods, while preserving temporal ordering\.
Favorita\.Since the original competition provides labels for only a single forecasting window, we construct a reproducible evaluation protocol using the final 32 days of available data\. Weekly forecast origins are used for training, while non\-overlapping validation and test windows are created from the final two 16\-day periods\. This setup preserves the original forecasting horizon while enabling reliable model selection and evaluation\.
All baselines are trained and evaluated using identical data splits, preprocessing procedures, and forecasting horizons\. Consequently, performance differences reflect architectural choices rather than variations in experimental setup\.
#### 4\.2\.2Preprocessing
Retail demand spans several orders of magnitude across products and stores\. To stabilize optimization, all sales\-related numerical features are transformed using a log1p normalization prior to graph construction\. Model predictions are converted back to the original sales scale using the inverse transformation before evaluation\. Following common practice in large\-scale retail forecasting, training samples whose target windows contain more than 50% zero observations are removed to reduce the influence of extremely sparse demand patterns\.
#### 4\.2\.3Evaluation Metrics
We report the Weighted Root Mean Squared Scaled Error \(WRMSSE\), the primary M5 competition metric\. For seriesiiwith historical observationsyi,1,…,yi,Ty\_\{i,1\},\\ldots,y\_\{i,T\}andHH\-step forecastsy^i,1,…,y^i,H\\hat\{y\}\_\{i,1\},\\ldots,\\hat\{y\}\_\{i,H\}, the per\-series scaled error is
RMSSEi=1H∑t=1H\(yi,t−y^i,t\)21T−1∑t=2T\(yi,t−yi,t−1\)2\\mathrm\{RMSSE\}\_\{i\}=\\sqrt\{\\frac\{\\dfrac\{1\}\{H\}\\displaystyle\\sum\_\{t=1\}^\{H\}\\left\(y\_\{i,t\}\-\\hat\{y\}\_\{i,t\}\\right\)^\{2\}\}\{\\dfrac\{1\}\{T\-1\}\\displaystyle\\sum\_\{t=2\}^\{T\}\\left\(y\_\{i,t\}\-y\_\{i,t\-1\}\\right\)^\{2\}\}\}\(14\)
where the denominator is the mean squared one\-step naïve forecast error computed on the pretest period, serving as a scale normaliser across series with different sales magnitudes\.RMSSEi<1\\mathrm\{RMSSE\}\_\{i\}<1indicates the model outperforms the naïve last\-observed\-value baseline\. Ourprimary metricis the volume\-weighted aggregate
WRMSSEvol=∑i=1NwiRMSSEi,∑i=1Nwi=1,\\mathrm\{WRMSSE\}\_\{\\mathrm\{vol\}\}=\\sum\_\{i=1\}^\{N\}w\_\{i\}\\,\\mathrm\{RMSSE\}\_\{i\},\\qquad\\sum\_\{i=1\}^\{N\}w\_\{i\}=1,\(15\)
wherewiw\_\{i\}is proportional to seriesii’s total pretest sales volume, giving higher weight to economically significant high\-volume items\. We additionally report anunweighted mean
WRMSSEuw=1N∑i=1NRMSSEi\\mathrm\{WRMSSE\}\_\{\\mathrm\{uw\}\}=\\frac\{1\}\{N\}\\sum\_\{i=1\}^\{N\}\\mathrm\{RMSSE\}\_\{i\}\(16\)
which gives equal weight to every series and is therefore sensitive to performance on low\-volume and intermittent\-demand items\. Both metrics are computed in original sales units after reversing any training\-time normalisation; lower values indicate better performance, and 1\.0 corresponds to the naïve last\-day baseline by construction\.
### 4\.3Baselines
Our primary baseline is a heterogeneous graph neural network forecaster, referred to throughout the paper asBase Graph\. Base Graph uses the same graph construction, node features, neighborhood sampling strategy, GraphSAGE backbone, and training procedure as GNBAN\. The only difference is the forecasting head: the proposed basis\-attention module is replaced by a multi\-layer perceptron \(MLP\) that directly predicts theHH\-step forecast vector\. This controlled comparison isolates the contribution of the proposed basis\-attention forecasting head while keeping all other components identical\.
### 4\.4Implementation Details
All numerical sales features and forecasting targets are transformed usinglog\(1\+x\)\\log\(1\+x\)prior to training and inverted usingexp\(x\)−1\\exp\(x\)\-1during evaluation\. This normalization improves numerical stability and allows a single training configuration to generalize across datasets with widely different sales scales\. Following common practice in retail forecasting, training windows containing more than 50% zero\-valued targets are excluded to reduce the impact of highly sparse demand patterns\.
The graph encoder consists of a single\-layer heterogeneous GraphSAGE backbone with mean aggregation, hidden dimensiond=64d=64, and LayerNorm applied after message passing\. For each forecast entity, temporal neighborhood sampling retrieves up toK=256K=256historical sales nodes from the one\-hop neighborhood\. The forecasting head contains 22 basis functions: 4 polynomial trend bases, 10 sinusoidal seasonal bases corresponding to retail\-relevant periods, and 8 learnable generic bases\. Each basis is associated with an independent learnable attention query\.
Models are trained end\-to\-end using the Huber loss withδ=1\.0\\delta=1\.0on log\-transformed targets\. Optimization is performed using Adam with gradient clipping at‖g‖2≤1\.0\\\|g\\\|\_\{2\}\\leq 1\.0and early stopping based on validation loss with a patience of 10 epochs\. The batch size is fixed at 128 for both datasets, while the learning rate is set to10−310^\{\-3\}for M5 and10−410^\{\-4\}for Favorita\.
All experiments are conducted on a single NVIDIA V100 GPU \(16 GB\)\. The heterogeneous graph is stored in CPU memory and sampled on\-the\-fly, with only the sampled mini\-batch subgraphs transferred to the GPU during training\.
### 4\.5Forecasting Performance
Table[1](https://arxiv.org/html/2606.27863#S4.T1)reports the forecasting performance of GNBAN and the matchedBase Graphbaseline on the M5 and Favorita benchmarks\. The Base Graph model uses the same relational graph construction, node features, neighborhood sampling strategy, heterogeneous GraphSAGE backbone, and training procedure as GNBAN; the only difference is that the basis\-attention forecasting head is replaced with a standard multi\-layer perceptron that directly predicts the forecast horizon\. GNBAN improves volume\-weighted WRMSSE consistently across both datasets\. On Favorita, GNBAN reducesWRMSSEvol\\mathrm\{WRMSSE\}\_\{\\mathrm\{vol\}\}from 0\.6741 to 0\.6474 \(−4\.0%\-4\.0\\%\) andWRMSSEuw\\mathrm\{WRMSSE\}\_\{\\mathrm\{uw\}\}from 0\.7026 to 0\.6695 \(−4\.7%\-4\.7\\%\)\. On M5, GNBAN improvesWRMSSEvol\\mathrm\{WRMSSE\}\_\{\\mathrm\{vol\}\}from 0\.8689 to 0\.8372 \(−3\.6%\-3\.6\\%\); the unweighted metric shows no improvement \(0\.9053 vs\. 0\.9152\), as the basis\-attention head redistributes model capacity toward high\-volume items that dominate the volume\-weighted objective\. These improvements are particularly noteworthy because they arise solely from the forecasting head\. Both models share the same graph representation, message\-passing architecture, optimization procedure, and input features\. Consequently, the performance gains can be attributed directly to the proposed basis\-attention decomposition mechanism rather than increased model capacity or additional information\. The results suggest that decomposing forecasts into trend, seasonal, and generic components enables more effective utilization of the historical information encoded by the graph backbone\. Rather than predicting the entire forecast horizon through a single latent representation, GNBAN allows different basis functions to retrieve specialized information from the historical neighborhood through independent attention queries, leading to improved long\-horizon forecasting performance\.
Table 1:Bottom\-level forecasting performance on the M5 and Favorita benchmarks\. WRMSSEvoldenotes the volume\-weighted Weighted Root Mean Squared Scaled Error, while WRMSSEuwdenotes the unweighted mean RMSSE across all item\-store series\. Both models share identical graph construction, neighborhood sampling, node features, GNN backbone, and training procedure; only the forecasting head differs\. Lower values indicate better performance; best results per dataset in bold\.†GNBAN vol\-WRMSSE improves on M5; UW\-WRMSSE does not\.
### 4\.6Interpretability Analysis
A key advantage of GNBAN is that interpretability is built directly into the forecasting architecture\. Rather than producing a forecast through a black\-box latent representation, the model explicitly decomposes each prediction into trend, seasonal, and generic components\. These components are generated during the forward pass and therefore provide an intrinsic explanation of the forecast without requiring post\-hoc interpretation methods such as SHAP or LIME\. Figure[2](https://arxiv.org/html/2606.27863#S4.F2)presents forecasting results for three representative item\-store pairs from the Favorita dataset\. The top row compares the actual demand trajectory with the forecast generated by GNBAN over the 16\-day prediction horizon\. The model accurately captures both the overall demand level and the temporal evolution of each series despite substantial differences in sales magnitude and variability across items\. The bottom row shows the corresponding forecast decomposition obtained directly from the basis\-attention head:
𝐓v=𝜽v\(t\)𝐁\(t\),𝐒v=𝜽v\(s\)𝐁\(s\),𝐆v=𝜽v\(g\)𝐁\(g\)\.\\mathbf\{T\}\_\{v\}=\\bm\{\\theta\}^\{\(t\)\}\_\{v\}\\mathbf\{B\}^\{\(t\)\},\\qquad\\mathbf\{S\}\_\{v\}=\\bm\{\\theta\}^\{\(s\)\}\_\{v\}\\mathbf\{B\}^\{\(s\)\},\\qquad\\mathbf\{G\}\_\{v\}=\\bm\{\\theta\}^\{\(g\)\}\_\{v\}\\mathbf\{B\}^\{\(g\)\}\.\(17\)
where𝐓v\\mathbf\{T\}\_\{v\},𝐒v\\mathbf\{S\}\_\{v\}, and𝐆v\\mathbf\{G\}\_\{v\}denote the trend, seasonal, and generic forecast components, respectively\. Several observations emerge\. First, the trend component captures the long\-term demand trajectory and explains the majority of the forecast magnitude\. Second, the seasonal component clearly isolates recurring weekly demand patterns, with both amplitude and phase varying across items\. Finally, the generic component captures localized residual effects that cannot be explained by smooth trend or periodic seasonality, such as promotions, short\-lived demand spikes, or inventory\-related fluctuations\.
To quantify the relative importance of these components, Figure[3](https://arxiv.org/html/2606.27863#S4.F3)reports their average contribution magnitudes\. Across all three examples, the trend component contributes approximately 63–64% of the total forecast magnitude, the seasonal component contributes 20–21%, and the generic component contributes roughly 16%\. The consistency of these proportions across different products suggests that the model learns a stable and transferable decomposition of retail demand rather than relying on item\-specific memorization\.
From an operational perspective, the decomposition provides actionable insights in addition to accurate forecasts\. Trend components can support inventory planning and replenishment decisions, seasonal components reveal recurring demand cycles relevant for staffing and logistics, and generic components highlight unusual demand behavior that may warrant further investigation\. Consequently, GNBAN offers both improved forecasting performance and a transparent representation of the underlying factors driving each prediction\.
Figure 2:Forecast decomposition for three representative Favorita item\-store pairs\.Top:Actual demand \(black\) and GNBAN forecast \(orange\) in log1p space over the 16\-day forecasting horizon\. The close agreement between the two curves illustrates the forecasting accuracy of the model on these examples\.Bottom:Decomposition of the forecast into trend, seasonal, and generic components generated by the basis\-attention head\. The trend component captures long\-term demand evolution, the seasonal component captures recurring weekly patterns, and the generic component models residual effects not explained by trend or seasonality\. The decomposition is produced directly by the model and requires no post\-hoc explanation method\.Figure 3:Per\-item component contribution magnitudes\.Left:Mean absolute contribution per forecast day \(log1p units\)\.Right:Percentage share of total contribution\. The trend block contributes 63–64% across all three items; seasonal 20–21%; generic 16%\. The near\-identical proportions across distinct items indicate the model learned a stable, transferable demand structure rather than item\-specific noise\.
### 4\.7Ablation Studies
To isolate the contribution of the per\-basis attention mechanism, we compare GNBAN against a simplified variant that uses a single attention query per forecast block \(trend, seasonal, generic\) rather than one per basis function\. All other components remain identical\. Table[2](https://arxiv.org/html/2606.27863#S4.T2)summarizes the results\.
Table 2:Ablation on M5: effect of query granularity\.The single\-query variant performs substantially worse than the full GNBAN architecture and is even worse than the MLP baseline on both metrics, withWRMSSEuw=1\.2411\>1\.0\\mathrm\{WRMSSE\}\_\{\\mathrm\{uw\}\}=1\.2411\>1\.0indicating failure on intermittent\-demand items\. These results demonstrate that the performance gains are not due to the use of attention alone, but specifically to the ability of individual basis functions to retrieve specialized historical context through independent queries\. When all bases within a block share the same query, the retrieved context becomes a single averaged representation, reducing the model’s capacity to disentangle long\-term trends, recurring seasonal patterns, and residual demand fluctuations independently\.
## 5Conclusion
This paper introducesGNBAN \(Graph Neural Basis Attention Network\), a forecasting architecture for large\-scale retail demand forecasting that combines heterogeneous graph representation learning with interpretable basis\-based forecast decomposition\. GNBAN represents retail data as a heterogeneous graph and generates forecasts through a basis\-attention head that explicitly decomposes predictions into trend, seasonal, and generic components\. Experiments on the M5 Walmart and Favorita retail forecasting benchmarks demonstrate that GNBAN consistently improves forecasting accuracy over a matched graph\-based baseline while providing intrinsic interpretability\. The proposed per\-basis attention mechanism enables different forecast components to retrieve specialized information from historical observations, leading to improved long\-horizon forecasting performance\. Furthermore, the resulting decomposition provides a transparent view of the factors contributing to each prediction, eliminating the need for post\-hoc explanation methods\. Overall, our results show that accurate forecasting and interpretability need not be competing objectives\. By combining graph\-based representation learning with basis decomposition, GNBAN provides a unified framework capable of modeling complex retail demand dynamics while producing forecasts that remain understandable to practitioners\. Future work will explore larger\-scale evaluations against strong forecasting baselines, extensions to additional long\-horizon forecasting domains, and transfer\-learning settings where models are pre\-trained on one retail catalog and adapted to another\.
## References
- \[1\]L\. Bai, L\. Yao, C\. Li, X\. Wang, and C\. Wang\(2020\)Adaptive graph convolutional recurrent network for traffic forecasting\.InAdvances in Neural Information Processing Systems \(NeurIPS\),Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p3.1)\.
- \[2\]C\. Challu, K\. G\. Olivares, B\. N\. Oreshkin, F\. Garza, M\. Mergenthaler, and A\. Dubrawski\(2023\)N\-HiTS: neural hierarchical interpolation for time series forecasting\.InProceedings of the AAAI Conference on Artificial Intelligence,Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p4.1),[§2](https://arxiv.org/html/2606.27863#S2.p4.1)\.
- \[3\]Corporación Favorita and Kaggle\(2018\)Corporación favorita grocery sales forecasting\.Note:Kaggle competitionExternal Links:[Link](https://www.kaggle.com/c/favorita-grocery-sales-forecasting)Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p1.1),[§4\.1](https://arxiv.org/html/2606.27863#S4.SS1.p3.1)\.
- \[4\]M\. Fey, W\. Hu, K\. Huang, J\. E\. Lenssen, R\. Ranjan, J\. Robinson, R\. Ying, J\. You, and J\. Leskovec\(2023\)Relational deep learning: graph representation learning on relational tables\.arXiv preprint arXiv:2312\.04615\.Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p3.1),[§2](https://arxiv.org/html/2606.27863#S2.p3.1)\.
- \[5\]R\. J\. Hyndman and G\. Athanasopoulos\(2021\)Forecasting: principles and practice\.3rd edition,OTexts\.External Links:[Link](https://otexts.com/fpp3/)Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p2.1),[§2](https://arxiv.org/html/2606.27863#S2.p1.1)\.
- \[6\]B\. Lim, S\. Ö\. Arık, N\. Loeff, and T\. Pfister\(2021\)Temporal fusion transformers for interpretable multi\-horizon time series forecasting\.International Journal of Forecasting37\(4\),pp\. 1748–1764\.Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p2.1),[§2](https://arxiv.org/html/2606.27863#S2.p2.1)\.
- \[7\]S\. Makridakis, E\. Spiliotis, and V\. Assimakopoulos\(2020\)The M4 competition: 100,000 time series and 61 forecasting methods\.International Journal of Forecasting36\(1\),pp\. 54–74\.Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p1.1)\.
- \[8\]S\. Makridakis, E\. Spiliotis, and V\. Assimakopoulos\(2022\)M5 accuracy competition: results, findings, and conclusions\.International Journal of Forecasting38\(4\),pp\. 1346–1364\.Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p1.1),[§1](https://arxiv.org/html/2606.27863#S1.p2.1),[§2](https://arxiv.org/html/2606.27863#S2.p1.1),[§4\.1](https://arxiv.org/html/2606.27863#S4.SS1.p2.1)\.
- \[9\]Y\. Nie, N\. H\. Nguyen, P\. Sinthong, and J\. Kalagnanam\(2023\)A time series is worth 64 words: long\-term forecasting with transformers\.InInternational Conference on Learning Representations \(ICLR\),Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p2.1)\.
- \[10\]B\. N\. Oreshkin, D\. Carpov, N\. Chapados, and Y\. Bengio\(2020\)N\-BEATS: neural basis expansion analysis for interpretable time series forecasting\.InInternational Conference on Learning Representations \(ICLR\),Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p4.1),[§2](https://arxiv.org/html/2606.27863#S2.p4.1)\.
- \[11\]J\. Robinson, R\. Ranjan, W\. Hu, K\. Huang, J\. Han, A\. Dobles, M\. Fey, J\. E\. Lenssen, Y\. Yuan, Z\. Zhang, X\. He, and J\. Leskovec\(2024\)RelBench: a benchmark for deep learning on relational databases\.InAdvances in Neural Information Processing Systems \(NeurIPS\) Datasets and Benchmarks Track,Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p3.1),[§2](https://arxiv.org/html/2606.27863#S2.p3.1)\.
- \[12\]D\. Salinas, V\. Flunkert, J\. Gasthaus, and T\. Januschowski\(2020\)DeepAR: probabilistic forecasting with autoregressive recurrent networks\.International Journal of Forecasting36\(3\),pp\. 1181–1191\.Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p2.1),[§2](https://arxiv.org/html/2606.27863#S2.p2.1)\.
- \[13\]Walmart, University of Nicosia, and Kaggle\(2020\)M5 Forecasting – Accuracy: estimate the unit sales of walmart retail goods\.Note:Kaggle competitionExternal Links:[Link](https://www.kaggle.com/c/m5-forecasting-accuracy)Cited by:[§4\.1](https://arxiv.org/html/2606.27863#S4.SS1.p2.1)\.
- \[14\]Y\. Wang, A\. Smola, D\. Maddix, J\. Gasthaus, D\. Foster, and T\. Januschowski\(2019\)Deep factors for forecasting\.InInternational Conference on Machine Learning \(ICML\),Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p2.1)\.
- \[15\]H\. Wu, T\. Hu, Y\. Liu, H\. Zhou, J\. Wang, and M\. Long\(2022\)TimesNet: temporal 2D\-variation modeling for general time series analysis\.InInternational Conference on Learning Representations \(ICLR\),Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p2.1)\.
- \[16\]H\. Wu, J\. Xu, J\. Wang, and M\. Long\(2021\)Autoformer: decomposition transformers with auto\-correlation for long\-term series forecasting\.InAdvances in Neural Information Processing Systems \(NeurIPS\),Cited by:[§1](https://arxiv.org/html/2606.27863#S1.p4.1),[§2](https://arxiv.org/html/2606.27863#S2.p2.1),[§2](https://arxiv.org/html/2606.27863#S2.p4.1)\.
- \[17\]Z\. Wu, S\. Pan, G\. Long, J\. Jiang, X\. Chang, and C\. Zhang\(2020\)Connecting the dots: multivariate time series forecasting with graph neural networks\.InProceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining \(KDD\),Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p3.1)\.
- \[18\]Z\. Wu, S\. Pan, G\. Long, J\. Jiang, and C\. Zhang\(2019\)Graph wavenet for deep spatial\-temporal graph modeling\.InInternational Joint Conference on Artificial Intelligence \(IJCAI\),Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p3.1)\.
- \[19\]B\. Yu, H\. Yin, and Z\. Zhu\(2018\)Spatio\-temporal graph convolutional networks: a deep learning framework for traffic forecasting\.InInternational Joint Conference on Artificial Intelligence \(IJCAI\),Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p3.1)\.
- \[20\]H\. Zhou, S\. Zhang, J\. Peng, S\. Zhang, J\. Li, H\. Xiong, and W\. Zhang\(2021\)Informer: beyond efficient transformer for long sequence time\-series forecasting\.InProceedings of the AAAI Conference on Artificial Intelligence,Cited by:[§2](https://arxiv.org/html/2606.27863#S2.p2.1)\.
## Appendix AFull Hyperparameters
Table[3](https://arxiv.org/html/2606.27863#A1.T3)lists all architecture, training, sampling, and preprocessing hyperparameters used in the reported experiments\. Unless otherwise noted, the same configuration is used for both M5 and Favorita\.
Table 3:Full hyperparameter specification for all reported runs\.Similar Articles
A Global-Local Graph Attention Network for Traffic Forecasting
Proposes a Global-Local Graph Attention Network (GLGAT) with pairwise encoding and event-based adjacency matrix for traffic forecasting, effectively capturing spatio-temporal correlations and achieving competitive performance on real-world datasets.
EMAGN: Efficient Multi-Attention Graph Network via Learned Clustering for Scalable Traffic Forecasting
EMAGN is a new efficient multi-attention graph network for traffic forecasting that linearizes self-attention via learned clustering, reducing complexity from quadratic to linear while maintaining accuracy close to full-attention models, with significant reductions in training time, inference time, and GPU memory.
A Temporally Augmented Graph Attention Network for Affordance Classification
EEG-tGAT is a temporally augmented Graph Attention Network that improves affordance classification from interaction sequences by incorporating temporal attention and dropout mechanisms. The model enhances GATv2 for sequential data where temporal dimensions are semantically non-uniform.
Graph-Conditioned Mixture of Graph Neural Network Experts for Traffic Forecasting
Proposes GC-MoE, a graph-conditioned mixture of experts framework for traffic forecasting that assigns each node a personalized combination of frozen pretrained spatio-temporal GNN experts based on graph topology and recent input, training only a lightweight routing module (∼17K parameters) and achieving competitive performance on four benchmarks.
TA-SparseMG: Trend-Aware Sparse Forecasting via Multi-Scale Gating for Long-Term Time Series
This paper proposes TA-SparseMG, a lightweight cross-period forecasting model for long-term time series that incorporates trend-aware reversible instance normalization, scale-adaptive gated denoising, and a multiscale gated-attention MLP module to address nonstationarity and high-frequency disturbances.