نوع مقاله : مقاله پژوهشی
نویسنده
گروه مهندسی صنایع، دانشکده فنی و مهندسی، دانشگاه اردکان، اردکان، ایران
کلیدواژهها
عنوان مقاله English
نویسنده English
Accurate demand forecasting in online retail is a fundamental challenge in supply chain management, as demand patterns are typically influenced by complex temporal relationships, cross-product network interactions, and item-specific semantic features. To address this challenge, this study introduced a novel forecasting framework based on a Transformer architecture, capable of modeling long-lag temporal dependencies, cross-product network effects, and item semantic information. This empirical-computational research evaluated the proposed model using online retail II datasets. The proposed model was subsequently trained utilizing a multi-head attention mechanism within the Transformer framework, incorporating semantic representations extracted from product descriptions. The results demonstrated that the model achieved a Mean Absolute Error (MAE) of 2.68 and a Root Mean Square Error (RMSE) of 3.85, outperforming both the Autoregressive Integrated Moving Average model (MAE: 4.37, RMSE: 5.96) and the Gradient Boosting algorithm (MAE: 3.91, RMSE: 5.12). This improvement indicated that the framework effectively identifies complex demand patterns and cross-product relationships.
Introduction
Precise and adaptive demand forecasting is paramount in the digitally transformed retail landscape. Online platforms generate vast data, presenting opportunities and challenges. Demand is shaped by trends, seasonality, promotions, network externalities (influences between complementary/substitute products), and product characteristics. Traditional models like ARIMA capture linear temporal dependencies but often miss nonlinear relationships and external factors. While advanced machine learning models handle nonlinearity, they may not adequately integrate diverse data types (time series, network structures, textual semantics). This study proposed a unified deep learning framework, the Transformer, excelling at capturing long-range dependencies via its attention mechanism. By explicitly modeling temporal lags, product network effects, and semantic features, our approach aimed for a more comprehensive and accurate representation of demand generation in online retail, pushing forecasting boundaries.
Literature Review
Demand forecasting in online retail is vital for supply chain and inventory management. Traditional time-series models like ARIMA and Exponential Smoothing capture linear temporal dependencies but are limited by the increasing complexity of modern online retail environments, characterized by intricate temporal relationships, inter-product network effects, and rich semantic item characteristics (Tiwari, 2025; Chowdhury et al., 2025). Contemporary deep learning architectures, including RNNs (LSTMs, GRUs), model complex temporal patterns but may struggle with long-range dependencies or nuanced interactions (Cai et al., 2021).
The Transformer architecture, with its self-attention mechanism, excels at capturing long-range and context-dependent relationships, revolutionizing sequence modeling (Rahman et al., 2025). Its adoption in time-series forecasting, including retail demand prediction, is growing (Wang, 2025; Li, 2023). However, existing Transformer-based research often focuses primarily on historical sales data (temporal lags) in isolation. A significant gap remains in simultaneously modeling the multifaceted influences on demand, specifically the interplay of:
Network Effects: Product demand is interdependent; influenced by complements and substitutes (Caetano et al., 2025). Capturing these structural interdependencies is crucial for dynamic patterns, especially in large catalogs.
Temporal Lags: The impact of events or changes may not be immediate. Accurately modeling these varied time delays is vital for precise forecasting (Tarighat et al., 2025).
Product Semantics: Product characteristics and descriptions significantly influence consumer choice. Leveraging semantic information can uncover hidden relationships and improve accuracy (Rahikka & Mikkola, 2025).
While studies have explored these factors individually or in limited combinations (e.g., Cai et al., 2021; Wang, 2025), a comprehensive framework integrating temporal dependencies, network effects, and product semantics within a single Transformer architecture remains an active research area. This study bridged this gap by proposing a novel Transformer-based framework to jointly model these dimensions for a more accurate and holistic approach to dynamic retail demand forecasting.
Method
This study employed an empirical-computational approach using the Online Retail II dataset. Data preprocessing involved handling missing values, correcting errors, and removing irrelevant transactions. The dataset was split chronologically into an 80% training set and a 20% testing set.
Our core forecasting model was the Transformer architecture, utilizing its self-attention mechanism to weigh historical time steps for predicting future demand, thus capturing complex temporal patterns and long-range dependencies. Positional encodings were added to input embeddings for sequence information.
Our framework innovatively integrated three key information sources:
Temporal Lags: Explicitly accounts for lagged demand patterns. While attention captures temporal relationships, features representing past demand values at different lags can be incorporated.
Network Effects: Models product interdependencies through a product interaction graph (nodes=products, edges=relationships like co-purchase frequency). Graph-derived features (e.g., centrality) processed by techniques like Graph Convolutional Networks (GCNs) are integrated.
Product Semantics: Extracts rich semantic embeddings from product descriptions using NLP techniques (e.g., pre-trained models). These capture nuanced characteristics and are integrated alongside temporal and network features.
The model was trained end-to-end using Mean Squared Error (MSE) or Mean Absolute Error (MAE), optimized via an Adam optimizer. Hyperparameters were tuned for optimal performance. Final evaluation used MAE and RMSE on the test set.
Results
The empirical evaluation on the Online Retail II dataset showed the superiority of our proposed Transformer-based framework. On the test set, the model achieved an MAE of 2.68 and an RMSE of 3.85. This substantially outperformed baseline models: ARIMA yielded MAE 4.37, RMSE 5.96; XG-Boost achieved MAE 3.91, RMSE 5.12. These quantitative results highlighted the enhanced predictive accuracy of our integrated approach, attributed to its ability to capture the complex interplay of temporal, network, and semantic factors. Visualizations of predicted versus actual demand confirmed the model’s superior tracking of demand fluctuations. Analysis of attention weights also provided insights into influential historical periods and product relationships, offering a degree of interpretability.
Discussion
The findings underscored the advantages of a Transformer-based architecture for dynamic retail demand forecasting when augmented with explicit modeling of temporal lags, network effects, and product semantics. The accuracy improvements over ARIMA and XG-Boost highlighted the limitations of models neglecting the interconnected nature of retail demand. Our approach achieved a more comprehensive representation by jointly considering these factors. The attention mechanism effectively captured long-range temporal dependencies and contextual relationships. Explicit incorporation of network effects revealed the critical influence of product interdependencies, often overlooked in single-item forecasting. Leveraging product semantics allowed deeper understanding of demand drivers beyond historical sales. This integrated approach offered retailers enhanced capabilities for inventory management, demand planning, and strategic decision-making, potentially reducing costs and stockouts while improving customer satisfaction. Attention weight analysis offered valuable insights for model trust and adoption.
Conclusion
This research successfully developed and validated a novel Transformer-based framework for dynamic retail demand forecasting, integrating temporal lags, network effects, and product semantics. Empirical results on the Online Retail II dataset demonstrated the model’s superiority, achieving significantly lower error metrics (MAE: 2.68, RMSE: 3.85) compared to ARIMA (MAE: 4.37, RMSE: 5.96) and XG-Boost (MAE: 3.91, RMSE: 5.12). This work contributed a unified and highly accurate methodology for forecasting in complex retail environments, offering substantial practical implications for inventory management and strategic decision-making. Future research could incorporate additional external factors, explore advanced GNN architectures, and develop more sophisticated interpretability methods for real-world adoption.
کلیدواژهها English