Residual inventory prediction model training method and device, equipment and medium

By combining an LSTM layer and a feature-guided attention processing layer in the inventory prediction model, the problem of low inventory prediction accuracy in existing technologies is solved, achieving more accurate and faster inventory prediction and improving the reliability and timeliness of inventory management.

CN121542734APending Publication Date: 2026-02-17CNOOC GAS & POWER GRP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511629512.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-07
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing statistical-based inventory forecasting models struggle to accurately capture the complex patterns and long-term dependencies in inventory data when faced with complex and ever-changing real-world inventory scenarios, resulting in low forecasting accuracy.

Method used

A combination of Long Short-Term Memory (LSTM) layers, feature-guided attention processing layers, and fully connected layers is employed. By creating a training dataset and using inventory change data for model training, the attention weight allocation is optimized using the feature-guided attention module, thereby enhancing the model's focus on key features and its predictive ability.

Benefits of technology

It significantly improves the accuracy and timeliness of inventory forecasting, can more accurately capture complex patterns and long-term dependencies in inventory data, reduces the convergence difficulty of model training, and enhances the robustness and prediction accuracy of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121542734A_ABST
    Figure CN121542734A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and discloses a residual inventory prediction model training method and device, equipment and a medium, and the method comprises the steps: creating a first training data set corresponding to a first prediction mode through employing inventory change data in each unit time length in a target time period, the first training data set comprises a plurality of inventory change data sequences for training the to-be-trained model. And inputting each inventory change data sequence into the to-be-trained model for residual inventory prediction to obtain each corresponding predicted residual inventory sequence. And updating parameters in the to-be-trained model according to each predicted residual inventory sequence to obtain a first residual inventory prediction model. The trained first remaining inventory prediction model faces complex and changeable real inventory scenes, complex rules and long-term dependency relationships in inventory data can be captured more accurately, and the remaining inventory prediction precision is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device and medium for training a surplus inventory prediction model. Background Technology

[0002] In supply chain management, inventory forecasting is a crucial element, and its accuracy directly impacts a company's operating costs and market responsiveness.

[0003] As the market environment becomes increasingly complex, inventory data exhibits characteristics of nonlinearity, high dimensionality, and strong time-series characteristics, and is affected by a combination of factors such as market promotions, seasonal changes, macroeconomic fluctuations, and supply chain disruptions.

[0004] Related techniques, based on statistical forecasting models, have shown some effectiveness in handling stationary time series. However, when faced with complex and ever-changing real-world inventory scenarios, their linear assumptions make it difficult to accurately capture the complex patterns and long-term dependencies in inventory data, resulting in low forecasting accuracy. Summary of the Invention

[0005] This invention provides a training method, apparatus, device, and medium for a remaining inventory prediction model, which addresses the shortcomings of related technologies in dealing with complex and ever-changing real-world inventory scenarios. The linear assumptions make it difficult to accurately capture the complex patterns and long-term dependencies in inventory data, resulting in low prediction accuracy. This invention aims to more accurately capture the complex patterns and long-term dependencies in inventory data and improve the accuracy of remaining inventory prediction.

[0006] In a first aspect, the present invention provides a method for training a surplus inventory prediction model, comprising: Using inventory change data within each unit of time in the target period, a first training dataset corresponding to the first prediction model is created. The first training dataset includes multiple inventory change data sequences for training the model to be trained. The model to be trained includes a first long short-term memory network (LSTM) layer, a feature-guided attention processing layer, a second LSTM layer, and a fully connected layer. Each of the inventory change data sequences is input into the first LSTM layer, so that the first LSTM layer generates a hidden state vector corresponding to each of the inventory change data sequences; Each of the hidden state vectors is input into the feature-guided attention processing layer for key feature weight correction, thereby obtaining the corrected state vector corresponding to each of the hidden state vectors. Each of the corrected state vectors is input into the second LSTM layer and the fully connected layer for forward propagation to obtain the predicted remaining inventory sequence corresponding to each inventory change data sequence. Based on the difference between each predicted remaining inventory sequence and the corresponding actual remaining inventory sequence, the parameters in the model to be trained are updated to obtain a first remaining inventory prediction model trained using the first training dataset.

[0007] Optionally, the first prediction mode is to use the inventory change data in each unit of time in the first N units of time to predict the remaining inventory in each unit of time in the next M units of time, where N and M are integers greater than 1. The process of creating a first training dataset corresponding to the first prediction model using inventory change data within each unit of time in the target period includes: Preprocess the inventory change data within each unit of time in the target time period to obtain the processed inventory change data within each unit of time. Sort each processed inventory change data within the first unit of time to the Nth unit of time in the target period according to the chronological order to obtain the inventory change data sequence; sort each processed inventory change data within the second unit of time to the N+1th unit of time in the target period according to the chronological order until each inventory change data sequence is obtained, and use each obtained inventory change data sequence as a whole as the first training dataset.

[0008] Optionally, the inventory change data includes the parameter values ​​of I inventory change parameters, where I is an integer greater than 1, and the feature-guided attention processing layer includes an attention weight calculation layer, an attention weight correction layer, a fusion layer, and a residual connection layer. The step of inputting each of the hidden state vectors into the feature-guided attention processing layer for key feature weight correction to obtain the corrected state vector corresponding to each hidden state vector includes: For any of the hidden state vectors, the hidden state vectors are input to the attention weight calculation layer for linear transformation and attention weight calculation to obtain the linear transformation vector and initial attention weight corresponding to each inventory change parameter. The initial attention weight corresponding to each inventory change parameter is input to the attention weight correction layer, so that the attention weight correction layer multiplies each initial attention weight by the corresponding preset guidance importance coefficient to obtain the corrected attention weight corresponding to each inventory change parameter. The corrected attention weight and linear transformation vector corresponding to each inventory change parameter are input to the fusion layer, so that the fusion layer performs weighted fusion on each linear transformation vector based on each corrected attention weight to obtain a fusion vector. The fusion vector and the hidden state vector are input to the residual connection layer for residual connection to obtain the corrected state vector corresponding to the hidden state vector.

[0009] Optionally, the attention weight calculation layer includes a linear transformation layer, a feature mapping layer, a similarity calculation layer, and a normalization layer; The step of inputting the hidden state vector into the attention weight calculation layer for linear transformation and attention weight calculation to obtain the linear transformation vector and initial attention weight corresponding to each inventory change parameter includes: The hidden state vector is input into the linear transformation layer for linear transformation to obtain the linear transformation vector corresponding to each inventory change parameter; The hidden state vector is input into the feature mapping layer so that the feature mapping layer maps the hidden state vector into a target feature vector with a feature dimension of I; The target feature vector and each of the linear transformation vectors are input into the similarity calculation layer, so that the similarity calculation layer calculates the similarity between the target feature vector and each of the linear transformation vectors respectively; The similarity between the target feature vector and each of the linear transformation vectors is input into the normalization layer for normalization to obtain the normalized similarity corresponding to each similarity, and is used as the initial attention weight corresponding to each of the inventory change parameters.

[0010] Optionally, the unit duration is one full day, and the I inventory change parameters include date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status identifier.

[0011] Optionally, when the first forecasting mode uses the daily inventory change data of the previous 30 days to forecast the remaining inventory for each of the next 7 days, the second forecasting mode uses the daily inventory change data of the previous 30 days to forecast the remaining inventory for each of the next 15 days, and the third forecasting mode uses the daily inventory change data of the previous 60 days to forecast the remaining inventory for each of the next 30 days.

[0012] Optionally, after obtaining the first remaining inventory prediction model trained using the first training dataset, the method further includes: Using the inventory change data within each unit of time in the target period, create a second training dataset corresponding to the second prediction mode and a third training dataset corresponding to the third prediction mode; The first remaining inventory prediction model is trained using the second training dataset to obtain a trained second remaining inventory prediction model. The second remaining inventory prediction model is trained using the third training dataset to obtain a trained third remaining inventory prediction model, which serves as the final remaining inventory prediction model.

[0013] Secondly, the present invention provides a training apparatus for a residual inventory prediction model, comprising: A creation unit is used to create a first training dataset corresponding to a first prediction model using inventory change data within each unit of time in the target time period. The first training dataset includes multiple inventory change data sequences for training the model to be trained. The model to be trained includes a first long short-term memory network (LSTM) layer, a feature-guided attention processing layer, a second LSTM layer, and a fully connected layer. A generation unit is used to input each of the inventory change data sequences into the first LSTM layer, so that the first LSTM layer generates a hidden state vector corresponding to each of the inventory change data sequences; The correction unit is used to input each of the hidden state vectors into the feature-guided attention processing layer to correct the key feature weights, so as to obtain the corrected state vector corresponding to each of the hidden state vectors. A propagation unit is used to input each of the corrected state vectors into the second LSTM layer and the fully connected layer for forward propagation, so as to obtain the predicted remaining inventory sequence corresponding to each inventory change data sequence; An update unit is used to update the parameters in the model to be trained based on the difference between each predicted remaining inventory sequence and the corresponding actual remaining inventory sequence, so as to obtain a first remaining inventory prediction model trained using the first training dataset.

[0014] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the remaining inventory prediction model training method of the first aspect or any corresponding embodiment described above.

[0015] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the remaining inventory prediction model training method of the first aspect or any corresponding embodiment described above.

[0016] The present invention provides a method, apparatus, device, and medium for training a remaining inventory prediction model. It uses inventory change data within each unit of time in a target period to create a first training dataset corresponding to a first prediction model. The first training dataset includes multiple inventory change data sequences used to train the model. The model includes a first Long Short-Term Memory (LSTM) layer, a feature-guided attention processing layer, a second LSTM layer, and a fully connected layer. Each inventory change data sequence is input into the first LSTM layer to generate a hidden state vector corresponding to each sequence. Each hidden state vector is then input into the feature-guided attention processing layer for key feature weight correction, resulting in a corrected state vector. Each corrected state vector is then input into the second LSTM layer and the fully connected layer for forward propagation, yielding a predicted remaining inventory sequence for each inventory change data sequence. Based on the difference between each predicted remaining inventory sequence and its corresponding actual remaining inventory sequence, the parameters in the model are updated to obtain a first remaining inventory prediction model trained using the first training dataset. The first remaining inventory prediction model trained by this invention can more accurately capture the complex patterns and long-term dependencies in inventory data when facing complex and ever-changing real-world inventory scenarios, thus effectively improving the accuracy of remaining inventory prediction. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A flowchart illustrating a method for training a remaining inventory prediction model, as provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a training device for a remaining inventory prediction model provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0020] The following is combined Figure 1 The present invention describes the training method for the remaining inventory prediction model.

[0021] like Figure 1 As shown, this embodiment proposes a first method for training a remaining inventory prediction model, which may include the following steps: S101. Using the inventory change data within each unit of time in the target period, create the first training dataset corresponding to the first prediction model. The first training dataset includes multiple inventory change data sequences used to train the model to be trained. The model to be trained includes a first Long Short-Term Memory (LSTM) network layer, a feature-guided attention processing layer, a second LSTM layer, and a fully connected layer.

[0022] The target period can be the company's historical operating period, such as the previous 10 years.

[0023] Specifically, the unit duration can be two days, one day, or 12 hours within the target time period. This embodiment does not limit the specific size of the unit duration.

[0024] Inventory change data reflects changes in inventory over a given period of time. This data may include values ​​for multiple inventory change parameters, such as date, quantity changed, and remaining inventory.

[0025] Specifically, the first forecasting model uses inventory change data for each unit of time within a certain historical period to predict the remaining inventory for each unit of time within a specific period. For example, the first forecasting model could use daily inventory change data from the previous 30 days to predict the remaining inventory for each of the following 7 days.

[0026] The inventory change data sequence may include preprocessed inventory change data for each unit of time span.

[0027] Optionally, the first forecasting mode uses inventory change data from each of the first N time units to forecast the remaining inventory for each of the next M time units, where N and M are integers greater than 1. In this case, step S101 includes: Preprocess the inventory change data for each unit of time within the target period to obtain the processed inventory change data for each unit of time. Sort each processed inventory change data within the first unit to the Nth unit of the target time period in chronological order to obtain an inventory change data sequence; sort each processed inventory change data within the second unit to the N+1th unit of the target time period in chronological order until each inventory change data sequence is obtained, and use each obtained inventory change data sequence as a whole as the first training dataset.

[0028] Specifically, preprocessing can include missing value handling, outlier handling, and data standardization.

[0029] Regarding the handling of missing values, if the target period is 10 years and the unit duration is one day, and there are 128 missing records in the 10-year data (mostly due to system failures causing the data not to be uploaded on the current day), the 7-day moving average method can be used to fill them in: if the remaining inventory is missing, the average of the remaining inventory for the 3 days before and after the missing date can be taken; if the inventory change quantity and estimated unit price are missing, they can be filled in based on the corresponding equipment maintenance records for the current day (such as whether there was maintenance) and the historical purchase unit price of the same model of spare parts to ensure the continuity of time sequence.

[0030] Regarding outlier handling, this embodiment can identify outliers using the 3σ principle. For example, if the remaining inventory on a certain day is -50 (spare parts do not have negative inventory logic, this is determined to be an input error), or if the estimated unit price on a certain day is 100,000 yuan (far exceeding the historical average price of 20,000 yuan for the same model of spare parts, this is determined to be a data misalignment), this embodiment can first check the original documents in the enterprise system. After confirming the error, the negative inventory is replaced with the remaining inventory of the previous day, and the misaligned unit price is corrected with the average unit price of the spare part over the past three months.

[0031] Regarding data standardization, this embodiment can use Z-score standardization to eliminate dimensional differences for numerical parameters such as inventory change quantity, estimated unit price, estimated total price, and remaining inventory in inventory change data.

[0032] S102. Input each inventory change data sequence into the first LSTM layer so that the first LSTM layer generates the hidden state vector corresponding to each inventory change data sequence.

[0033] The first LSTM layer can have two hidden layers, with 128 neurons per layer (higher than in conventional scenarios, as it is necessary to capture long-term dependencies in long-term inventory change data for the target period, such as the impact of equipment overhaul every three years on spare parts inventory).

[0034] Specifically, in this embodiment, the gating unit parameters can be set in the first LSTM layer. The forget gate activation function is sigmoid (with a threshold set to 0.6 to prioritize the retention of inventory patterns related to long-term maintenance cycles), and the cell state update is tanh (to enhance the fitting ability to large fluctuations in inventory, such as a surge in outbound volume during major repairs).

[0035] It should be noted that the output of the first LSTM is the hidden state vector corresponding to each time step (one time step is one unit of time) t. (t=1,2,...T, where T represents the time step). Hidden state vector This represents the model's internal representation of the dynamic characteristics and temporal dependencies of the entire inventory change data sequence up to the current time step after processing the input data at that time step. It is the implicit representation of the inventory change data sequence of the model at time step t, reflecting the model's memory state at that moment. Importance analysis can reveal the degree of attention the model pays to different features in the time dimension, providing support for model interpretability and decision-making basis. This vector contains the model's temporal memory and internal representation of inventory change data sequences.

[0036] S103. Input each hidden state vector into the feature-guided attention processing layer to correct the key feature weights, and obtain the corrected state vector corresponding to each hidden state vector. Optionally, the inventory change data includes parameter values ​​for I inventory change parameters, where I is an integer greater than 1. The feature-guided attention processing layer includes an attention weight calculation layer, an attention weight correction layer, a fusion layer, and a residual connection layer. Step S102 includes: For any hidden state vector, the hidden state vector is input into the attention weight calculation layer for linear transformation and attention weight calculation to obtain the linear transformation vector and initial attention weight corresponding to each inventory change parameter. The initial attention weight corresponding to each inventory change parameter is input into the attention weight correction layer, so that the attention weight correction layer multiplies each initial attention weight by the corresponding preset guidance importance coefficient to obtain the corrected attention weight corresponding to each inventory change parameter. The corrected attention weight and linear transformation vector corresponding to each inventory change parameter are input into the fusion layer, so that the fusion layer performs weighted fusion on each linear transformation vector based on each corrected attention weight to obtain the fusion vector. The fusion vector and the hidden state vector are input into the residual connection layer for residual connection to obtain the corrected state vector corresponding to the hidden state vector.

[0037] Optionally, the attention weight calculation layer includes a linear transformation layer, a feature mapping layer, a similarity calculation layer, and a normalization layer. The hidden state vector is input into the attention weight calculation layer for linear transformation and attention weight calculation, yielding the linear transformation vector and initial attention weights corresponding to each inventory change parameter, including: The hidden state vector is input into the linear transformation layer for linear transformation to obtain the linear transformation vector corresponding to each inventory change parameter; The hidden state vector is input into the feature mapping layer so that the feature mapping layer maps the hidden state vector into a target feature vector with a feature dimension of I; The target feature vector and each linear transformation vector are input into the similarity calculation layer, so that the similarity calculation layer calculates the similarity between the target feature vector and each linear transformation vector respectively; The similarity between the target feature vector and each linear transformation vector is input into the normalization layer for normalization, resulting in the normalized similarity corresponding to each similarity, which is then used as the initial attention weight for each inventory change parameter.

[0038] Optionally, the unit duration is one full day, and the I inventory change parameters include date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status indicator. In this case, the inventory change data includes 6-dimensional feature data. Among them, the equipment maintenance status indicator can be used to indicate whether the current unit duration is within a scheduled maintenance window. The equipment maintenance status indicator can be 1 or 0, where 1 indicates that it is within a scheduled maintenance window and 0 indicates that it is not within a scheduled maintenance window.

[0039] It should be noted that at the output of the hidden layer of the first LSTM, a corresponding hidden state necklace is generated at each time step t. This embodiment can calculate the importance of each hidden state input feature.

[0040] Specifically, in this embodiment, the hidden state vector can be input into the linear transformation layer for linear transformation to obtain the linear transformation vector corresponding to each inventory change parameter. ,in, This represents the normalized value of the six input features (date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status). and For trainable parameters, each For the first i The representation vector of each feature in the feature embedding space.

[0041] Specifically, this embodiment can use a feature mapping layer to... Mapped to a vector with the same feature dimension (6 dimensions) The role of mapping here is to... The high-dimensional space is mapped to the same dimension as the input feature space to facilitate the next step of feature similarity.

[0042] Specifically, this embodiment can calculate With each feature vector ( i The similarity score between the groups (=1,2,......,6) is calculated using the following formula: The similarity scores are normalized using the Softmax function to obtain the similarity weights, which are the initial attention weights. , As a bias term, where quantity and remaining inventory correspond to Initially high (because it directly reflects inventory changes).

[0043] To reflect the degree of dependence of enterprises on key features under the first prediction model, a 1×6-dimensional feature guidance matrix is ​​constructed by combining the enterprise's production and business knowledge. . Each element In the first prediction mode, the feature i The guiding importance coefficient is assigned to key features with a higher guiding importance coefficient. This coefficient is determined by two parts: (1) business knowledge weight, which is based on enterprise experts and inventory management logic, such as the fact that equipment maintenance cycle has the greatest impact on spare parts consumption, and therefore a high weight of 0.9~1.0 is given; (2) data sensitivity correction, which is to linearly scale the empirical coefficient by calculating the Pearson correlation coefficient or mutual information of each feature and the target variable (such as remaining inventory), so that it takes into account both prior knowledge and data statistical characteristics.

[0044] Specifically, in the first prediction mode, this embodiment can respectively assign the features corresponding to date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status.i The preset importance coefficients for guidance are set to 0.2, 0.8, 0.3, 0.4, 0.9 and 0.9.

[0045] It should be noted that in this embodiment, the guiding importance coefficient of the feature guiding matrix can be used. With initial attention weights Multiplying these together yields the corrected attention weights, which are then adjusted... The scale allows the model to automatically bias towards key features (such as equipment maintenance status indicators and inventory change counts) when calculating the attention distribution; subsequently, this embodiment can perform weighted fusion to obtain a fusion vector. Finally, the hidden state vector output by the first LSTM layer is connected via residual connections. and The sum is used as the input to the second LSTM layer. This context vector is obtained through modified attention weights, which already incorporate the influence of the feature guidance matrix. This allows the vector to assign higher weights to key features (such as equipment maintenance status indicators). During training, backpropagation further strengthens the gradient updates of these features, thus reflecting the model's prioritization of these key features in the prediction results. This context vector is the result of information convergence after the model reweights the features; it includes not only temporal features... The model incorporates memory information and feature attention distribution adjusted based on business knowledge to ensure that the model prioritizes key features such as maintenance cycle and season during training, ultimately improving the model's sensitivity to key drivers of inventory fluctuations and its prediction accuracy.

[0046] S104. Input each corrected state vector into the second LSTM layer and the fully connected layer for forward propagation to obtain the predicted remaining inventory sequence corresponding to each inventory change data sequence.

[0047] Specifically, the input to the second LSTM layer is the corrected state vector. The second LSTM layer can continue to process time series information and enhance the sensitivity to key features by utilizing the corrected state vector, thereby affecting the prediction results of subsequent models.

[0048] Specifically, the input to the fully connected layer is the sequence vector output by the second LSTM layer. The fully connected layer can map the sequence vector to the prediction dimension (the number of days to be predicted in the future), and the final output is the multi-step inventory prediction result (such as the remaining inventory in the next 7 / 15 / 30 days).

[0049] S105. Based on the difference between each predicted remaining inventory sequence and the corresponding actual remaining inventory sequence, update the parameters in the model to be trained to obtain the first remaining inventory prediction model trained using the first training dataset.

[0050] Specifically, in this embodiment, the model to be trained can be updated and optimized based on the difference between each predicted remaining inventory sequence and the corresponding actual remaining inventory sequence.

[0051] Specifically, this embodiment can set a loss function and an optimizer, using weighted mean squared error as the loss function, and assigning higher weights to samples with low inventory, thereby achieving business-oriented training optimization. Specifically, for samples... a Real inventory With forecast inventory The sample weights are defined as follows: .

[0052] The formula for calculating the weight-based loss function is: .

[0053] Where Z is the total number of training samples. Samples with remaining inventory below the safety threshold are given higher weights (e.g., weight 2, because spare parts shortages will cause downtime losses, so they need to be optimized).

[0054] Optionally, in other remaining inventory prediction model training methods proposed in this embodiment, when the first prediction mode uses daily inventory change data from the previous 30 days to predict the remaining inventory for each of the next 7 days, the second prediction mode uses daily inventory change data from the previous 30 days to predict the remaining inventory for each of the next 15 days, and the third prediction mode uses daily inventory change data from the previous 60 days to predict the remaining inventory for each of the next 30 days. After step S105 above, this method may further include: Using inventory change data within each unit of time in the target period, create a second training dataset for the second prediction model and a third training dataset for the third prediction model. The first remaining inventory prediction model is trained using the second training dataset to obtain the trained second remaining inventory prediction model. The second remaining inventory prediction model is trained using the third training dataset to obtain the trained third remaining inventory prediction model, which is then used as the final remaining inventory prediction model.

[0055] Specifically, this embodiment can set a training strategy and adopt iterative training with different modes. First, train the first prediction mode. After the loss on the validation set decreases to a stable level, use its parameters as the initial parameters for the second prediction mode. Similarly, use the model parameters of the second prediction mode as the initial parameters for the third prediction mode to reduce the training convergence time. The number of training epochs can be set to 100. When the loss on the validation set does not decrease for 8 consecutive training epochs, early stopping is triggered to save the optimal model parameters.

[0056] Among them, the feature guidance matrix corresponding to the second prediction mode In this embodiment, the features corresponding to date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status can be respectively identified. i The preset guidance importance coefficients are set to 0.2, 0.7, 0.3, 0.4, 1, and 0.9. The feature guidance matrix corresponding to the third prediction mode... In this embodiment, the features corresponding to date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status can be respectively identified. i The preset importance coefficients for guidance are set to 0.2, 0.6, 0.4, 0.5, 1, and 1.

[0057] Specifically, this embodiment can also perform hyperparameter tuning, optimize key hyperparameters through grid search, and finally determine that the random dropout rate of the LSTM hidden layer for the first and second prediction modes is 0.2, and the dropout rate for the third prediction mode is 0.3 (stronger regularization is needed for long-term prediction); the bias term of the attention mechanism is equal to 0.1; and the activation function of the fully connected layer is ReLU6 (to prevent gradient explosion).

[0058] Current statistical prediction models, while based on existing technologies, suffer from limitations in accurately capturing complex patterns and long-term dependencies in inventory data due to their linear assumptions in the face of complex and ever-changing real-world inventory scenarios. For example, they often fail to provide accurate inventory warnings when dealing with sudden sales surges during promotional events or seasonal demand fluctuations, leading to inventory buildup or stockouts and resulting in economic losses for businesses. With the rapid development of artificial intelligence, machine learning and deep learning technologies are increasingly being applied to inventory management. Some studies have attempted to use neural networks to process inventory time-series data, but standard neural network models have limitations when handling multivariate input problems such as inventory warnings. For instance, the standard LSTM model treats all input features equally when fusing multidimensional features, failing to effectively distinguish the degree of influence of different features on inventory levels at different times, thus limiting the model's prediction accuracy. While attention mechanisms can improve the model's focus on key features to some extent, they remain insufficient when dealing with complex interactions between features, and the model's convergence speed and prediction accuracy need further improvement.

[0059] This embodiment can address the problem that related inventory forecasting methods struggle to accurately capture the temporal patterns and dynamic correlations between multidimensional features in complex inventory data. It improves the accuracy and timeliness of inventory early warning, provides enterprises with more reliable inventory decision support, avoids inventory backlogs or stockouts, and reduces enterprise operating costs.

[0060] To optimize the efficiency and accuracy of attention weight allocation, this embodiment innovatively proposes a feature-guided attention module based on the standard attention mechanism. When calculating attention weights, this module not only relies on the temporal evolution state of the LSTM model itself, but also explicitly incorporates prior knowledge of the static and dynamic attributes of the features themselves for guidance.

[0061] The remaining inventory prediction model in this embodiment can pre-analyze the intrinsic importance of different features and the strength of their interrelationships to form a feature guidance matrix. This matrix serves as a guiding signal in the calculation of attention weights, enabling the model to more quickly and accurately identify high-information features. For example, when predicting promotional item inventory, the model can pre-assign very high initial weights to holiday features through guidance. Compared to data-driven attention mechanisms in related technologies, this feature-guided attention allocation method can more robustly handle complex interactions between features, reduce the convergence difficulty of model training, and construct a remaining inventory prediction model that is more sensitive to dynamic changes in inventory, provides more accurate predictions, and is more interpretable.

[0062] This embodiment achieves the following technical effects: improved prediction accuracy. Through the effective capture of long-term dependencies in inventory data using an LSTM network, and the precise identification and weight optimization of key features by an attention mechanism and feature-guided attention module, this embodiment can more accurately uncover the patterns behind inventory data, thereby significantly improving the accuracy of inventory early warning. Experiments show that compared to benchmark models in related technologies, this invention significantly reduces key evaluation indicators such as root mean square error and mean absolute error, enabling more accurate prediction of changes in inventory levels and providing enterprises with a more reliable basis for inventory decision-making.

[0063] This embodiment also enhances model robustness. The feature-guided attention module utilizes prior knowledge to guide the calculation of attention weights, enabling the model to better cope with complex interactions between features and data noise, thus enhancing its robustness in different scenarios. Even when faced with sudden changes in the market environment or data anomalies, the model in this embodiment can still maintain relatively stable predictive performance, providing enterprises with continuous and reliable inventory early warning services.

[0064] This embodiment can also improve model training efficiency. Because the feature-guided attention module helps the model quickly identify key features, it reduces unnecessary computation and training time, thereby accelerating model convergence and improving training efficiency. This means that enterprises can complete model training and updates in a shorter time, adapting to market changes promptly and improving the timeliness of inventory management.

[0065] The proposed method for training a remaining inventory prediction model in this embodiment uses inventory change data within each unit of time in the target period to create a first training dataset corresponding to a first prediction model. The first training dataset includes multiple inventory change data sequences used to train the model. The model includes a first Long Short-Term Memory (LSTM) layer, a feature-guided attention layer, a second LSTM layer, and a fully connected layer. Each inventory change data sequence is input into the first LSTM layer to generate a hidden state vector corresponding to each sequence. Each hidden state vector is then input into the feature-guided attention layer for key feature weight correction, resulting in a corrected state vector. Each corrected state vector is then input into the second LSTM layer and the fully connected layer for forward propagation, yielding a predicted remaining inventory sequence for each inventory change data sequence. Based on the difference between each predicted remaining inventory sequence and its corresponding actual remaining inventory sequence, the parameters in the model are updated to obtain the first remaining inventory prediction model trained using the first training dataset. The first remaining inventory prediction model trained in this embodiment can more accurately capture the complex patterns and long-term dependencies in inventory data when facing complex and ever-changing real-world inventory scenarios, thus effectively improving the accuracy of remaining inventory prediction.

[0066] like Figure 2 As shown in the figure, this embodiment proposes a training device for a remaining inventory prediction model, which may include: Create unit 201 to create a first training dataset corresponding to the first prediction model using inventory change data within each unit of time in the target period. The first training dataset includes multiple inventory change data sequences for training the model to be trained. The model to be trained includes a first long short-term memory network LSTM layer, a feature-guided attention processing layer, a second LSTM layer, and a fully connected layer. The generation unit 202 is used to input each inventory change data sequence into the first LSTM layer, so that the first LSTM layer generates a hidden state vector corresponding to each inventory change data sequence. The correction unit 203 is used to input each hidden state vector into the feature-guided attention processing layer to correct the key feature weights, so as to obtain the corrected state vector corresponding to each hidden state vector. The propagation unit 204 is used to input each corrected state vector into the second LSTM layer and the fully connected layer for forward propagation, respectively, to obtain the predicted remaining inventory sequence corresponding to each inventory change data sequence; The update unit 205 is used to update the parameters in the model to be trained based on the difference between each predicted remaining inventory sequence and the corresponding actual remaining inventory sequence, so as to obtain the first remaining inventory prediction model trained using the first training dataset.

[0067] It should be noted that the processing procedures of creation unit 201, generation unit 202, correction unit 203, propagation unit 204, and update unit 205, and their beneficial effects, can be referred to respectively. Figure 1 Steps S101 to S105 are not described in detail here.

[0068] Optionally, the first forecasting mode is to use the inventory change data in each unit of time in the first N units of time to forecast the remaining inventory in each unit of time in the next M units of time, where N and M are integers greater than 1. Unit 201 is also used for: Preprocess the inventory change data for each unit of time within the target period to obtain the processed inventory change data for each unit of time. Sort each processed inventory change data within the first unit to the Nth unit of the target time period in chronological order to obtain an inventory change data sequence; sort each processed inventory change data within the second unit to the N+1th unit of the target time period in chronological order until each inventory change data sequence is obtained, and use each obtained inventory change data sequence as a whole as the first training dataset.

[0069] Optionally, the inventory change data includes the parameter values ​​of I inventory change parameters, where I is an integer greater than 1. The feature-guided attention processing layer includes an attention weight calculation layer, an attention weight correction layer, a fusion layer, and a residual connection layer. The correction unit 203 is also used for: For any hidden state vector, the hidden state vector is input into the attention weight calculation layer for linear transformation and attention weight calculation to obtain the linear transformation vector and initial attention weight corresponding to each inventory change parameter. The initial attention weight corresponding to each inventory change parameter is input into the attention weight correction layer, so that the attention weight correction layer multiplies each initial attention weight by the corresponding preset guidance importance coefficient to obtain the corrected attention weight corresponding to each inventory change parameter. The corrected attention weight and linear transformation vector corresponding to each inventory change parameter are input into the fusion layer, so that the fusion layer performs weighted fusion on each linear transformation vector based on each corrected attention weight to obtain the fusion vector. The fusion vector and the hidden state vector are input into the residual connection layer for residual connection to obtain the corrected state vector corresponding to the hidden state vector.

[0070] Optionally, the attention weight calculation layer includes a linear transformation layer, a feature mapping layer, a similarity calculation layer, and a normalization layer; The correction unit 203 is also used for: The hidden state vector is input into the linear transformation layer for linear transformation to obtain the linear transformation vector corresponding to each inventory change parameter; The hidden state vector is input into the feature mapping layer so that the feature mapping layer maps the hidden state vector into a target feature vector with a feature dimension of I; The target feature vector and each linear transformation vector are input into the similarity calculation layer, so that the similarity calculation layer calculates the similarity between the target feature vector and each linear transformation vector respectively; The similarity between the target feature vector and each linear transformation vector is input into the normalization layer for normalization, resulting in the normalized similarity corresponding to each similarity, which is then used as the initial attention weight for each inventory change parameter.

[0071] Optionally, the unit duration is a full day, and the I inventory change parameters include date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status indicator.

[0072] Optionally, when the first forecasting mode uses the daily inventory change data of the previous 30 days to forecast the remaining inventory for each of the next 7 days, the second forecasting mode uses the daily inventory change data of the previous 30 days to forecast the remaining inventory for each of the next 15 days, and the third forecasting mode uses the daily inventory change data of the previous 60 days to forecast the remaining inventory for each of the next 30 days.

[0073] Optionally, the above-mentioned device further includes a training unit for: After obtaining the first remaining inventory prediction model trained using the first training dataset, the second training dataset corresponding to the second prediction model and the third training dataset corresponding to the third prediction model are created using inventory change data within each unit of time in the target period. The first remaining inventory prediction model is trained using the second training dataset to obtain the trained second remaining inventory prediction model. The second remaining inventory prediction model is trained using the third training dataset to obtain the trained third remaining inventory prediction model, which is then used as the final remaining inventory prediction model.

[0074] The remaining inventory prediction model training device proposed in this embodiment uses inventory change data within each unit of time in the target period to create a first training dataset corresponding to the first prediction mode. The first training dataset includes multiple inventory change data sequences used to train the model to be trained. The model to be trained includes a first Long Short-Term Memory (LSTM) layer, a feature-guided attention processing layer, a second LSTM layer, and a fully connected layer. Each inventory change data sequence is input into the first LSTM layer to generate a hidden state vector corresponding to each inventory change data sequence. Each hidden state vector is then input into the feature-guided attention processing layer for key feature weight correction to obtain a corrected state vector corresponding to each hidden state vector. Each corrected state vector is then input into the second LSTM layer and the fully connected layer for forward propagation to obtain a predicted remaining inventory sequence corresponding to each inventory change data sequence. Based on the difference between each predicted remaining inventory sequence and the corresponding actual remaining inventory sequence, the parameters in the model to be trained are updated to obtain the first remaining inventory prediction model trained using the first training dataset. The first remaining inventory prediction model trained in this embodiment can more accurately capture the complex patterns and long-term dependencies in inventory data when facing complex and ever-changing real-world inventory scenarios, thus effectively improving the accuracy of remaining inventory prediction.

[0075] In this embodiment, the remaining inventory prediction model training device is presented in the form of functional units. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0076] This invention also provides a computer device having the above-described features. Figure 2 The training device for the remaining inventory prediction model is shown.

[0077] Please see Figure 3The present invention provides a schematic diagram of the structure of a computer device according to an optional embodiment. The computer device includes one or more processors 10, a memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, multiple processors and / or multiple buses can be used with multiple memories, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 3 Take a processor 10 as an example.

[0078] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GPA), or any combination thereof.

[0079] The memory 20 stores instructions executable by at least one processor 10 to cause at least one processor 10 to perform the method shown in the above embodiments.

[0080] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function. The data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, which can be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0081] Memory 20 may include volatile memory, such as random access memory. Memory may also include non-volatile memory, such as flash memory, hard disk, or solid-state drive. Memory 20 may also include combinations of the above types of memory.

[0082] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.

[0083] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.

[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for training a surplus inventory prediction model, characterized in that, The application comprises: using inventory change data in each unit time period in a target period to create a first training data set corresponding to a first prediction mode, the first training data set including a plurality of inventory change data sequences for training a to-be-trained model, the to-be-trained model including a first long short-term memory (LSTM) layer, a feature-guided attention processing layer, a second LSTM layer, and a fully connected layer; inputting each of the inventory change data sequences into the first LSTM layer to make the first LSTM layer generate a hidden state vector corresponding to each of the inventory change data sequences; inputting each of the hidden state vectors into the feature-guided attention processing layer to correct the key feature weight and obtain a corrected state vector corresponding to each of the hidden state vectors; inputting each of the corrected state vectors into the second LSTM layer and the fully connected layer to perform forward propagation and obtain a predicted remaining inventory sequence corresponding to each of the inventory change data sequences; updating parameters in the to-be-trained model according to the difference between each of the predicted remaining inventory sequences and a corresponding actual remaining inventory sequence to obtain a first remaining inventory prediction model trained by the first training data set.

2. The method of claim 1, wherein, The first prediction mode is to predict remaining inventory in each unit time period in the next M unit time periods using inventory change data in each unit time period in the previous N unit time periods, where N and M are integers greater than 1. The first prediction mode is to predict remaining inventory in each unit time period in the next M unit time periods using inventory change data in each unit time period in the previous N unit time periods, where N and M are integers greater than 1. The first prediction mode is to predict remaining inventory in each unit time period in the next M unit time periods using inventory change data in each unit time period in the previous N unit time periods, where N and M are integers greater than 1. The first prediction mode is to predict remaining inventory in each unit time period in the next M unit time periods using inventory change data in each unit time period in the previous N unit time periods, where N and M are integers greater than 1.

3. The method of claim 1, wherein, The inventory change data includes parameter values of I inventory change parameters, where I is an integer greater than 1, and the feature-guided attention processing layer includes an attention weight calculation layer, an attention weight correction layer, a fusion layer, and a residual connection layer. The first prediction mode is to predict remaining inventory in each unit time period in the next M unit time periods using inventory change data in each unit time period in the previous N unit time periods, where N and M are integers greater than 1. For any of the hidden state vectors, the hidden state vectors are input to the attention weight calculation layer for linear transformation and attention weight calculation to obtain the linear transformation vector and initial attention weight corresponding to each inventory change parameter. The initial attention weight corresponding to each inventory change parameter is input to the attention weight correction layer, so that the attention weight correction layer multiplies each initial attention weight by the corresponding preset guidance importance coefficient to obtain the corrected attention weight corresponding to each inventory change parameter. The corrected attention weight and linear transformation vector corresponding to each inventory change parameter are input to the fusion layer, so that the fusion layer performs weighted fusion on each linear transformation vector based on each corrected attention weight to obtain a fusion vector. The fusion vector and the hidden state vector are input to the residual connection layer for residual connection to obtain the corrected state vector corresponding to the hidden state vector.

4. The method of claim 3, wherein, The attention weight calculation layer includes a linear transformation layer, a feature mapping layer, a similarity calculation layer, and a normalization layer; The step of inputting the hidden state vector into the attention weight calculation layer for linear transformation and attention weight calculation to obtain the linear transformation vector and initial attention weight corresponding to each inventory change parameter includes: The hidden state vector is input into the linear transformation layer for linear transformation to obtain the linear transformation vector corresponding to each inventory change parameter; The hidden state vector is input into the feature mapping layer so that the feature mapping layer maps the hidden state vector into a target feature vector with a feature dimension of I; The target feature vector and each of the linear transformation vectors are input into the similarity calculation layer, so that the similarity calculation layer calculates the similarity between the target feature vector and each of the linear transformation vectors respectively; The similarity between the target feature vector and each of the linear transformation vectors is input into the normalization layer for normalization to obtain the normalized similarity corresponding to each similarity, and is used as the initial attention weight corresponding to each of the inventory change parameters.

5. The method according to claim 3 or 4, characterized in that, The unit duration is one full day, and the I inventory change parameters include date, inventory change quantity, estimated unit price, estimated total price, remaining inventory, and equipment maintenance status identifier.

6. The method of claim 5, wherein, When the first forecasting mode uses the daily inventory change data of the previous 30 days to forecast the remaining inventory for each of the next 7 days, the second forecasting mode uses the daily inventory change data of the previous 30 days to forecast the remaining inventory for each of the next 15 days, and the third forecasting mode uses the daily inventory change data of the previous 60 days to forecast the remaining inventory for each of the next 30 days.

7. The method of claim 6, wherein, After obtaining the first remaining inventory prediction model trained using the first training dataset, the method further includes: Using the inventory change data within each unit of time in the target period, create a second training dataset corresponding to the second prediction mode and a third training dataset corresponding to the third prediction mode; training the first remaining inventory prediction model by using the second training data set to obtain a trained second remaining inventory prediction model; training the second remaining inventory prediction model by using the third training data set to obtain a trained third remaining inventory prediction model as a final remaining inventory prediction model. 8.A remaining inventory prediction model training apparatus comprising: The method comprises the following steps: The creating unit is configured to create a first training data set corresponding to a first prediction model by using inventory change data in each unit length in a target period, wherein the first training data set comprises a plurality of inventory change data sequences used for training a to-be-trained model, and the to-be-trained model comprises a first long short-term memory (LSTM) layer, a feature-guided attention processing layer, a second LSTM layer, and a full connection layer. The generating unit is configured to input each inventory change data sequence into the first LSTM layer to enable the first LSTM layer to generate a hidden state vector corresponding to each inventory change data sequence. The correcting unit is configured to input each hidden state vector into the feature-guided attention processing layer to obtain a corrected state vector corresponding to each hidden state vector. The propagating unit is configured to input each corrected state vector into the second LSTM layer and the full connection layer to perform forward propagation to obtain a predicted remaining inventory sequence corresponding to each inventory change data sequence. The updating unit is configured to update parameters in the to-be-trained model according to a difference between each predicted remaining inventory sequence and a corresponding real remaining inventory sequence to obtain a first remaining inventory prediction model trained by using the first training data set.

9. A computer device, comprising: The method comprises the following steps: The memory and the processor are communicatively connected, and the memory stores computer instructions. The processor executes the computer instructions to perform the method of any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling a computer to perform the method of any one of claims 1 to 7.