Model training method, distribution duration estimation method, equipment, product and medium
By introducing a time series forecasting model into the delivery time prediction model and utilizing self-attention and cross-attention mechanisms, the problem that existing models cannot capture long-term dependencies and dynamic responses to sudden changes is solved, thus achieving more accurate and flexible delivery time prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-10
AI Technical Summary
Existing delivery time prediction models cannot effectively capture the long-term dependence and complex patterns of historical data, cannot dynamically respond to sudden changes, rely on manual parameter tuning, and are slow to react.
A time series prediction model is introduced, which captures the long-term dependence and change patterns of historical delivery time series through a self-attention mechanism. The interaction between multi-source external dynamic series and historical delivery time series is modeled by a cross-attention mechanism to generate a global representation vector to predict delivery time.
It breaks through the limitations of traditional static statistical features, and can automatically learn the dependencies between multiple historical time points, capture long-term time series patterns and multivariate interaction relationships, thereby improving the accuracy of delivery time prediction and dynamic response capability.
Smart Images

Figure CN121835959A_ABST
Abstract
Description
Technical Field
[0001] This manual relates to the field of on-demand delivery technology, and in particular to model training methods, delivery time prediction methods, equipment, products and media. Background Technology
[0002] In logistics and delivery, order delivery times can typically be predicted. Delivery times play a crucial role in supporting operational decisions. For example, orders can be rationally allocated and scheduled based on their delivery times to improve delivery efficiency; delivery times can also be used to characterize order difficulty, thus influencing pricing; or delivery times can be sent to user clients so they know when their goods will arrive in advance, reducing waiting anxiety. Therefore, developing a model that can accurately predict delivery times has become a pressing technical challenge. Summary of the Invention
[0003] To overcome the problems existing in related technologies, this manual provides model training methods, delivery time prediction methods, equipment, products and media.
[0004] According to a first aspect of the embodiments of this specification, a model training method is provided, the model including a time series prediction model and a delivery time estimation model; the method includes: The system acquires historical delivery time sequences, historical external dynamic sequences, and historical external static features of historical orders. The historical delivery time sequences include statistical information on historical delivery times at multiple historical time points. The historical external dynamic sequences include historical external dynamic information on the impact of these multiple historical time points on the historical delivery times. The time series prediction model generates a context vector from the historical delivery time sequence through a self-attention mechanism, and fuses the context vector with the historical external dynamic sequence through a cross-attention mechanism to obtain a global representation vector. The delivery time statistics for subsequent historical time points are then predicted based on the global representation vector. Obtain the estimated delivery time of the historical order from the global representation vector and the external static features predicted by the delivery time prediction model; The model is trained based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model.
[0005] According to a second aspect of the embodiments of this specification, a method for estimating delivery time is provided, the method comprising: Obtain the current delivery time sequence, current external dynamic sequence, and external static features of the orders to be delivered; The current delivery time sequence and the current external dynamic sequence are input into the time series prediction model trained by the method described in the first aspect; The fused global representation vector obtained from the time series prediction model and the external static features are input into the delivery time estimation model so that the delivery time estimation model outputs the estimated delivery time of the order to be delivered.
[0006] According to a third aspect of the embodiments of this specification, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method embodiments described in the first or second aspects above.
[0007] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method embodiments described in the first or second aspect above.
[0008] According to a fifth aspect of the embodiments of this specification, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the method embodiments described in the first or second aspect above.
[0009] The technical solutions provided in the embodiments of this specification may include the following beneficial effects: In the embodiments of this specification, in addition to the delivery time prediction model, a time series prediction model is also introduced. The design involves the time series prediction model first capturing the long-term dependencies and change patterns of historical delivery time sequences through a self-attention mechanism, and then modeling the interaction relationships between multi-source historical external dynamic sequences and historical delivery time sequences through a cross-attention mechanism. The context vector and external static features output by the time series prediction model can then be used as new inputs to the delivery time prediction model, which learns the actual delivery time. Through this design, the time series prediction model can automatically learn the dependencies between multiple historical time points without manually pre-setting time windows or statistical rules, and can effectively capture long-term time series patterns, overcoming the limitations of traditional static statistical features. This provides the delivery time prediction model with richer context-aware information, capturing the long-term dependencies and multi-variable interactions of historical data, enabling the training of an accurate delivery time prediction model.
[0010] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description
[0011] Figure 1This is a schematic diagram illustrating an instant delivery scenario according to an exemplary embodiment of this specification.
[0012] Figure 2A This is a flowchart illustrating a model training method according to an exemplary embodiment of this specification.
[0013] Figure 2B This is a schematic diagram of a self-attention module in a time series prediction model according to an exemplary embodiment of this specification.
[0014] Figure 2C This is a schematic diagram of a cross-attention module in a time series prediction model according to an exemplary embodiment of this specification.
[0015] Figure 2D This is a schematic diagram illustrating a model training method according to an exemplary embodiment of this specification.
[0016] Figure 3 This is a flowchart illustrating a delivery time estimation method according to an exemplary embodiment of this specification.
[0017] Figure 4 This specification is a hardware structure diagram of a computer device containing a model training device / delivery time estimation device according to an exemplary embodiment.
[0018] Figure 5 This is a block diagram illustrating a model training apparatus according to an exemplary embodiment of this specification.
[0019] Figure 6 This is a block diagram illustrating a delivery time estimation device according to an exemplary embodiment of this specification. Detailed Implementation
[0020] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed in the appended claims.
[0021] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0022] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0023] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals shall be provided for users to choose to authorize or refuse.
[0024] The accuracy of delivery time prediction models directly impacts the user's shopping experience and the delivery team's work experience. With the continuous growth of order volume and business scale, the complexity of delivery time prediction tasks is also constantly increasing. Faced with sustained business growth, order surges during peak hours, and traffic delays caused by weather changes, delivery time prediction models based on real-time statistical features cannot capture long-term historical dependencies and trends, react slowly to emergencies, and lack the ability to dynamically adjust to changes in external factors. To ensure user experience and improve delivery efficiency, the platform has placed higher demands on current delivery time prediction models based on real-time statistical features.
[0025] The features of a delivery time prediction model can include real-time statistical features (such as the average delivery time over a 30-minute period in a given area), external static features (such as merchant location), and external dynamic features (such as weather changes). By implicitly modeling the cross-relationships between features using deep neural networks, a regression model is used to learn the actual delivery time. This approach has significant limitations in the following aspects: 1. The model cannot capture the long-term dependencies and complex patterns in historical data, such as the periodicity (midday peak, evening peak) and trends (long-term growth trend of orders). 2. The response to sudden changes is lagging, and the statistical characteristics of fixed time windows are slow to react to sudden events (such as traffic control and extreme weather); 3. Real-time statistical features rely on expert knowledge and manual parameter tuning. The size of the time window for statistical features (30 minutes, 1 hour, etc.) and the calculation method of statistical values (mean, maximum, minimum, etc.) all require a lot of experiments and analysis to obtain the optimal solution.
[0026] Based on this, the embodiments of this specification provide a model training method that can construct a model that accurately estimates delivery time. The embodiments of this specification will be described in detail below.
[0027] like Figure 1 The diagram illustrates an instant delivery scenario according to an embodiment of this specification. Delivery services are widely used in online shopping, food delivery, and errand services, involving multi-party interactions between the service provider, merchants, delivery capacity, and users. The service platform provides a server-side application and a user client for users to access services. In addition to the user client, the platform also provides a merchant client for merchants to use. Delivery capacity refers to entities with delivery capabilities, including but not limited to delivery personnel, such as delivery riders. Delivery capacity communicates with the server through a delivery capacity client. In other examples, delivery capacity may also include unmanned delivery equipment, such as drones and unmanned vehicles. Users can transact with merchants and initiate delivery orders through their user clients; the service provider can allocate delivery capacity for these instant delivery orders.
[0028] For example, a user selects a target product on their client and places an order, generating a target order on their client. The client then sends this order to the server, which can then forward it to the merchant's client for inventory preparation. Simultaneously, the server can schedule the order to suitable delivery capacity. After the user completes the order placement on their client, the server can estimate the delivery time and send this estimate to the user's client, allowing the user to access the delivery time for their order. The server can also send this delivery time to the scheduling system, which can then allocate tasks to delivery capacity based on the estimated delivery time, ensuring a reasonable workload for delivery personnel.
[0029] like Figure 2A As shown, Figure 2A This is a flowchart illustrating a model training method according to an exemplary embodiment. The model in this embodiment may include a time series prediction model and a delivery time estimation model. The model training method may include the following steps: In step 202, the historical delivery time sequence, historical external dynamic sequence, and historical external static features of historical orders are obtained.
[0030] The historical delivery time sequence includes: historical delivery time statistics for multiple historical time points; the historical external dynamic sequence includes: historical external dynamic information affecting the historical delivery time for the multiple historical time points.
[0031] In step 204, the time series prediction model generates a context vector from the historical delivery time sequence through a self-attention mechanism, and fuses the context vector with the historical external dynamic sequence through a cross-attention mechanism to obtain a global representation vector, and predicts the delivery time statistics of subsequent historical time points based on the global representation vector.
[0032] In step 206, the estimated delivery time of the historical order is obtained by the delivery time estimation model based on the global representation vector and the external static features.
[0033] In step 208, the model is trained based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model.
[0034] The embodiments in this specification can be applied to... Figure 1 The server shown can be a program installed on a backend device to provide services to users. The backend device can be a server, which can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, and big data and artificial intelligence platforms.
[0035] In the embodiments of this specification, in addition to the delivery time prediction model, a time series prediction model is also introduced. The design involves the time series prediction model first capturing the long-term dependencies and change patterns of historical delivery time sequences through a self-attention mechanism, and then modeling the interaction relationships between multi-source historical external dynamic sequences and historical delivery time sequences through a cross-attention mechanism. The context vector and external static features output by the time series prediction model can then be used as new inputs to the delivery time prediction model, which learns the actual delivery time. Through this design, the time series prediction model can automatically learn the dependencies between multiple historical time points without manually pre-setting time windows or statistical rules, and can effectively capture long-term time series patterns, overcoming the limitations of traditional static statistical features. This provides the delivery time prediction model with richer context-aware information, capturing the long-term dependencies and multi-variable interactions of historical data, enabling the training of an accurate delivery time prediction model.
[0036] In some examples, the time series prediction model can include any model capable of processing time series data, such as a Transformer-based model. The time series prediction model can incorporate self-attention and cross-attention mechanisms. In practical applications, the specific structure of the time series prediction model can be configured according to actual needs; this embodiment does not impose any limitations on this.
[0037] In some examples, the delivery time prediction model can be any model capable of predicting delivery time, or an existing delivery time prediction model, such as a deep learning model or a progressive layered extraction (PLE) model. This embodiment does not limit this.
[0038] In some cases, samples for training the model can be constructed in advance using order data from historical orders. For example, the samples may include: historical delivery time sequences of historical orders, historical external dynamic sequences, and historical external static features. Historical orders also have actual delivery times.
[0039] As an example, the historical delivery time sequence may include: statistical information on historical delivery times at multiple historical time points. In practical applications: The duration of the historical delivery time sequence can be configured according to actual needs. For example, it can be a one-hour data sequence, a two-hour data sequence, a four-hour data sequence, an eight-hour data sequence, etc. This embodiment does not limit this.
[0040] The number of historical time points contained in the sequence can also be configured according to actual needs. For example, the number of historical time points contained in the sequence can be any custom number, such as 12, 16, or 24.
[0041] The time interval between two adjacent time points can also be configured according to actual needs. For example, the time interval between two adjacent time points in the sequence can be a custom duration such as 5 minutes, 10 minutes, or 15 minutes. Alternatively, the number of historical time points and / or the time interval between two adjacent time points can be flexibly set according to the length of the historical delivery time sequence.
[0042] Specific delivery time statistics can also be configured according to actual needs. For example, they can include average delivery time, delivery time variance, etc. The statistics can be calculated from different dimensions, but this embodiment does not limit this.
[0043] The historical delivery time series input into the time series prediction model can be one or more, and the specific number can be set according to actual needs; this embodiment does not limit this. For example, one or more historical delivery time series can be constructed from different dimensions (such as different regions) and statistical indicators, including: the historical delivery time series includes: the business district where the historical order is located, and the historical delivery time statistics at each historical time point; and / or, the merchant where the historical order is located, and the historical delivery time statistics at each historical time point. As an example, any of the following sequences can be included: Sequence 1: Based on the business district where the order is located, the average historical delivery time within a fixed time window (such as the time window between two adjacent time points) can be calculated to form a delivery time sequence S[S¹,S²,…,Sᵗ] (t is the number of time points); if some time points have missing values, they can be filled in various ways; for example, forward filling can be used, that is, filling with the value of the most recent time point.
[0044] Sequence 2: Based on the merchant of the order, calculate the average of the historical actual delivery times within a fixed time window, forming a delivery time sequence T[T¹, T²,…, T]. t If there are missing values at certain time points, they can be filled in using various methods, such as the forward filling method mentioned above.
[0045] Sequence 3: Based on the business district where the order is located, calculate the variance of the historical actual delivery time within a fixed time window, forming a delivery time sequence P[P¹, P², ..., P]. t If there are missing values at certain time points, they can be filled in using various methods, such as the forward filling method mentioned above.
[0046] Sequence 4: Based on the merchant of the order, calculate the variance of the historical actual delivery time within a fixed time window, forming a delivery time sequence K[K¹, K²,…,K]. t If there are missing values at certain time points, they can be filled in using various methods, such as the forward filling method mentioned above.
[0047] As an example, if each time point in the sequence is spaced 10 minutes apart, taking 12 time points as an example, it can correspond to the historical data of the most recent 2 hours; if 24 time points are selected in the sequence, it can cover the data of the most recent 4 hours. By adjusting the number and interval of time points, it can flexibly adapt to the historical dependency modeling needs of different time scales (such as short-term fluctuations or medium-term trends).
[0048] In practical applications, when using multiple historical delivery time series, multiple time points in different series can remain consistent, or multiple series can use the same dimension or statistical indicator but different time intervals. For example, multiple series can also include the following: historical delivery time statistics for multiple time points (with an interval of A between adjacent time points) in the same dimension (merchant dimension or business district dimension), and historical delivery time statistics for multiple time points (with an interval of B between adjacent time points) in the same dimension (merchant dimension or business district dimension), where A and B are different, for example, A is 10 minutes and B is 30 minutes.
[0049] In practical applications, if a delivery time series is used as an example, the time series prediction model can employ a single-head attention mechanism to generate context vectors for the historical delivery time series. Single-head attention can generate query, key, and value vectors, calculate attention scores and normalize them, and finally weight and sum the value vectors to generate a weighted representation of each position in the input sequence. Alternatively, a multi-head attention mechanism can be used, which is not limited in this embodiment. For example, a multi-head attention mechanism can map the input sequence to multiple different subspaces, independently calculate attention scores in each subspace, and thus capture various interaction relationships between different positions in the input sequence. Through the multi-head attention mechanism, the time series prediction model can more comprehensively capture long-term dependencies and complex patterns in the historical delivery time series, such as periodic changes and trend features within different time periods. In specific implementation, the multi-head attention mechanism divides the historical delivery time series into multiple subsequences, each subsequence is processed by an independent attention head, and finally the processing results of all subsequences are concatenated to form a richer context vector representation. This design not only enhances the model's ability to model historical data but also strengthens its adaptability to changes in external dynamic factors, such as sudden weather changes or traffic control measures. Furthermore, the computation of the multi-head attention mechanism can be parallelized, thereby improving training efficiency while maintaining model accuracy.
[0050] In an embodiment employing multiple delivery time sequences, the historical time points within each delivery time sequence can remain consistent. For example, the historical time points within each sequence can be aligned, such as maintaining the same number and duration of time points. For this embodiment with multiple sequences, self-attention can be calculated separately for each delivery time sequence, and a context vector can be obtained based on the self-attention calculation results for each delivery time sequence. In practical applications, for embodiments with multiple delivery time sequences, the generated context vector can be set according to actual needs. For example, multiple delivery time sequences can ultimately generate a single context vector, or multiple delivery time sequences can generate multiple context vectors. The number of context vectors can be the same as or different from the number of delivery time sequences; this embodiment does not impose any limitations on this.
[0051] As an example, the historical external dynamic sequence may include: historical external dynamic information about the influence of the multiple historical time points on the historical delivery duration. In practical applications, similar to the historical delivery duration sequence, the sequence length of the historical external dynamic sequence, the number of historical time points included in the sequence, the time interval between two adjacent time points, and the specific external dynamic information can all be configured according to actual needs, and this embodiment does not limit this.
[0052] As an example, the time points in the historical external dynamic sequence can be different from the time points in the historical delivery time sequence, or the two sequences can be consistent. For example, the historical time points in the two sequences can be aligned, such as keeping the number of time points and the time of the time consistent.
[0053] As an example, each time point in the historical external dynamic sequence has corresponding external dynamic information. This external dynamic information can include information affecting delivery time, and can include information that changes dynamically over time, including but not limited to: historical weather information, historical traffic information, and historical supply and demand pressure information representing the supply and demand relationship between delivery orders and delivery capacity. This embodiment does not limit this. As an example, historical traffic information can represent delivery difficulty; for example, traffic congestion or complex road conditions can affect the delivery efficiency of delivery capacity. Supply and demand pressure information can be determined by the ratio of the number of orders in the business district to the number of active delivery capacity in that business district, and it is used to represent the supply and demand situation of dispatchable delivery capacity and order quantity in that business district.
[0054] As an example, in practical applications, one or more types of external dynamic information as described above can be used. When using multiple types of external dynamic information, there can be multiple historical external dynamic sequences, each containing one type of external dynamic information from multiple historical time points. For example, taking weather information and traffic information as examples, historical external dynamic sequences can include sequences containing weather information from multiple historical time points, and sequences containing traffic information from multiple historical time points. In practical applications, with m historical delivery time sequences and / or n historical external dynamic sequences, any two historical delivery time sequences and historical external dynamic sequences can interact. Furthermore, as in the aforementioned embodiments, the context vector can be one or more, and this embodiment does not limit this.
[0055] As an example, historical external static features can include a variety of external static information, such as information that remains basically static over time, including but not limited to static information such as merchant location or merchant identification. In practical applications, they can be configured as needed, and this embodiment does not limit them.
[0056] In step 204, historical delivery time sequences and historical external dynamic sequences can be input into the time series prediction model, so that the time series prediction model generates a context vector for the historical delivery time sequence through a self-attention mechanism, and fuses the context vector with the historical external dynamic sequence through a cross-attention mechanism to obtain a global representation vector, and predicts the delivery time statistics of subsequent historical time points based on the global representation vector.
[0057] As an example, subsequent time points can be time points input after the last historical time point in the historical delivery time sequence. There can be one or more subsequent time points. For example, it can be the time point after the last historical time point in the historical delivery time sequence, or it can be multiple consecutive time points after the last historical time point in the historical delivery time sequence. The specific number can be set according to actual needs, and this embodiment does not limit it.
[0058] Traditional real-time statistical features (such as the average of the past 30 minutes) can only capture short-term information and cannot model long-term dependencies. This embodiment, however, designs a self-attention mechanism to generate context vectors for historical delivery time sequences. Through global computation, the self-attention mechanism can automatically learn complex patterns in historical sequences (such as order growth trends and cyclical fluctuations) without requiring manual setting of time windows or statistical methods. For example, by calculating the correlation between any two time points in the historical delivery time sequence using the self-attention mechanism, long-term patterns (such as periodicity and trends) can be identified, replacing fixed-time-window statistical features and eliminating the need for manual setting of time windows or statistical methods (such as mean and variance), thus reducing maintenance costs.
[0059] In traditional methods, external dynamic features (such as weather information) are typically simply concatenated with statistical features, failing to enable dynamic interaction. This embodiment utilizes cross-attention, allowing external dynamic variables to directly perform attention calculations with historical delivery time sequences, thereby modeling dynamic relationships. For example, heavy rain may suddenly affect delivery times, and cross-attention can capture this sudden impact. This embodiment innovatively designs the application of cross-attention to the interaction between time series forecasting and external dynamic variables in the field of delivery time prediction, solving the problem that traditional models cannot dynamically respond to sudden changes (such as traffic control or extreme weather).
[0060] Cross-attention mechanisms allow external dynamic variables (such as weather and other dynamic information) to interact with time series data in real time, enabling models to quickly adjust their predictions. For example, sudden weather changes can influence the representation of historical delivery time series through attention weights, thereby reducing delays.
[0061] In step 206, after obtaining the global representation vector generated by the time series prediction model, the delivery time estimation model can be used to estimate the estimated delivery time of historical orders based on the global representation vector and external static features. For example, the global representation vector and external static features can be input into the delivery time estimation model, or the two can be concatenated and input into the delivery time estimation model.
[0062] In step 208, the prediction loss of the time series prediction model can be determined based on the difference between the delivery time statistics predicted by the time series prediction model for subsequent historical time points and the actual delivery time statistics for subsequent historical time points. The prediction loss of the delivery time estimation model can be determined based on the difference between the estimated delivery time of historical orders estimated by the delivery time estimation model and the actual delivery time of historical orders. The specific loss calculation method can be set according to actual needs, and this embodiment does not limit it. In this way, the models (time series prediction model and delivery time estimation model) can be trained based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model.
[0063] In some examples, generating a context vector from the historical delivery duration sequence using a self-attention mechanism may include: The historical delivery time sequence data is embedded and mapped, and location encoding is added to obtain a sequence embedding vector containing the sequential information of the multiple historical time points; After calculating the self-attention weights between the multiple time points for the sequence embedding vector, the context vector is generated using the self-attention weights.
[0064] As an example, historical delivery time sequence data can first be embedded and mapped (converting the original delivery time statistics into a high-dimensional vector), and then location encoding can be added to inject time sequence information, such as the location index of each time point, ultimately resulting in a sequence embedding vector. In practical applications, the specific implementation of location encoding can be set as needed, for example, it can be the location encoding method in Transformer; this embodiment does not limit this.
[0065] Next, the self-attention weights between multiple time points can be calculated on the sequence embedding vector (by performing Query, Key, and Value matrix operations to quantify the correlation between any two time points), and then these weights can be used to perform a weighted summation on the sequence embedding vector to generate a context vector.
[0066] As can be seen from the above embodiments, by embedding and mapping historical delivery time sequence data and adding location encoding, the original delivery time statistics can be converted into a high-dimensional vector while explicitly injecting sequential features (such as chronological relationships) from multiple historical time points. This solves the problem of traditional statistical features (such as fixed window mean) losing temporal location information, and provides basic information for subsequently capturing the dynamic changes of time series (such as short-term fluctuations and medium-term trends).
[0067] In practical applications, the internal structure of the time series forecasting model can be flexibly implemented according to the above processing steps; as an example, the time series forecasting model may include: The first Embedding layer is used to: perform embedding mapping on the historical delivery time sequence data and add location encoding to obtain a sequence embedding vector containing the sequential information of the multiple historical time points; A self-attention layer is used to: calculate the self-attention weights between the plurality of time points from the sequence embedding vector; The first residual connection and layer normalization network is used to: perform a residual connection on the sequence embedding vector and the correlation coefficient, and then perform layer normalization on the residual connection result to obtain the context vector.
[0068] like Figure 2B The diagram shown is a schematic of a self-attention module implementing the self-attention mechanism in the time series prediction model in the embodiments of this specification. It may include the first Embedding layer, the self-attention layer, and the first residual connection and layer normalization network mentioned above.
[0069] like Figure 2B As shown, the sequence input to the first Embedding layer is the historical delivery time sequence. This network layer can map the features of the input sequence to a high-dimensional space (Embedding) and add positional encoding.
[0070] Self-attention layers can calculate the correlation between each time point and other time points, capturing global dependencies.
[0071] The first residual connection and layer normalization (Add & LayerNorm) layer performs residual connections on the sequence embedding vector and correlation coefficients, and then performs layer normalization on the residual connection result to obtain the context vector. The residual processing can be implemented as "Residual Output = Self-Attention Output + Embedding Input," which prevents gradient vanishing, meaning that gradients in deep networks can be backpropagated to shallower layers. The LayerNorm (layer normalization) layer prevents certain dimensions from becoming too large or too small, stabilizing the training process and accelerating model training.
[0072] In some examples, the fusion of the context vector and the historical external dynamic sequence through a cross-attention mechanism to obtain a global representation vector may include: The historical external dynamic sequence is embedded and mapped to obtain a dynamic feature embedding vector; Using the dynamic feature embedding vector as the query vector and key vector, and the context vector as the value vector, cross-attention calculation is performed to generate a global representation vector containing the interaction relationship between the historical delivery time sequence and the external dynamic feature data.
[0073] As an example, the historical external dynamic sequence can be transformed into a high-dimensional vector through embedding layers or other means, so that it is in the same feature space as the context vector (a representation from the historical delivery time sequence), which facilitates the subsequent calculation of interaction relationships.
[0074] Cross Attention is a "cross" attention mechanism. Unlike Self-Attention, which allows elements within a sequence to pay attention to each other, Cross Attention establishes an attention relationship between two different sequences (or data sources). In other words, the core of Cross Attention is that it allows one sequence (called the Query) to pay attention to another sequence (called the Key and Value), thereby achieving information fusion.
[0075] In the cross-attention calculation of this embodiment, the following is designed: Query vector: An embedded vector of historical external dynamic sequences (a high-dimensional representation of external dynamic information, such as weather, traffic, etc.); Key vector: The embedding vector of the historical external dynamic sequence (same as Query).
[0076] Value vector: Context vector (capturing long-term dependencies, etc., in the historical delivery time sequence).
[0077] By employing a cross-attention mechanism, the attention weights between the dynamic feature embedding vector (as the Query and Key) and the context vector (as the Value) are calculated to model the multivariate correlation between internal variables (historical delivery time series) and external variables, quantifying the influence of external dynamic features on the historical delivery time series. Ultimately, a global representation vector that integrates the long-term dependencies of the time series and the interaction with external dynamic features can be obtained.
[0078] In traditional Transformer cross-attention, the typical setup is: Query (Q) comes from the "target sequence" (such as the current state of the decoder), and Key (K) and Value (V) come from the "source sequence" (such as the output of the encoder). The core idea is to let the target query the source and extract relevant information from the source.
[0079] The goal of this embodiment is not to generate new sequences, but to allow external dynamic features (such as weather and traffic) to "pay attention" to the contextual information contained in the historical delivery time sequence. Therefore, this embodiment is designed as follows: Query is a dynamic feature embedding vector (from the external dynamic sequence), Key is a dynamic feature embedding vector (same as above), and Value is a context vector (from the self-attention output of the historical delivery time sequence). Thus, the external dynamic features act as "questioners" to "extract" the part most relevant to the current dynamic conditions from the context of the historical delivery time.
[0080] The reason for the above design is: This embodiment aims to model "how external dynamic information adjusts historical patterns." Specifically, historical patterns of delivery times (such as midday peak and weekend effects) are relatively stable, but sudden external factors (such as heavy rain and traffic control) can temporarily change the weighting of these patterns. For example, the average delivery time in a business district is usually 30 minutes, but it may become 50 minutes on a rainy day. The model needs to know: "How should the historical 30-minute data be reweighted under the current weather conditions?" Therefore, by using weather as the query to query the historical context (Value), the attention mechanism automatically learns: which historical delivery statuses are more relevant under the current weather conditions.
[0081] Furthermore, to avoid incorrect information flow, it's semantically unreasonable to reverse the process, using the context vector as the query and dynamic features as the key / value pair. This would be equivalent to "using historical patterns to query the weather," as historical data cannot actively "choose" which weather conditions to focus on. In reality, the current weather / traffic conditions "determine" which parts of historical data are more valuable. Therefore, a query based on external dynamic features was designed.
[0082] Furthermore, the above design maintains the semantic consistency of Value; Value represents the "source of extracted information". This embodiment aims to ensure that the final global representation remains centered on the historical context of delivery time, only "modulated" by external dynamic information. Therefore, Value is designed as a context vector, rather than external dynamic features. Otherwise, the fused representation would be biased towards external dynamic features (weather / traffic), thus losing the core information of delivery time.
[0083] In implementing the cross-attention calculation described above, optionally, the historical delivery time sequence and the historical external dynamic sequence can contain the same historical time point, i.e., the time points of the two sequences are aligned, enabling the Query (external dynamic information at time t) and Value (delivery time statistics at time t) to be associated. Optionally, although the dynamic feature embedding vector (Q / K) and the context vector (V) come from different sources, they can be mapped to a vector space of the same dimension through the embedding layer. Optionally, the context vector already contains rich temporal information; the context vector generated by self-attention can effectively encode long-term dependencies, periodic patterns, etc., of historical delivery times, thus supporting the extraction of "high-quality information" during cross-attention calculation. This is also one of the purposes of performing self-attention calculation before cross-attention calculation.
[0084] As can be seen from the above embodiments, this embodiment uses the steps of "embedding mapping → cross-attention calculation → global representation generation" to deeply interact and fuse the temporal features of historical delivery time sequences with external dynamic features (weather, traffic, etc.), replacing the traditional static splicing method. This enables the model to dynamically capture the complex impact of external factors on delivery time (such as sudden weather or time-related traffic congestion), providing a more robust and context-aware feature foundation for the final delivery time prediction.
[0085] In practical applications, the internal structure of the time series forecasting model can be flexibly implemented according to the above processing steps; in some examples, the time series forecasting model may include: The second Embedding layer is used to: perform embedding mapping on the historical external dynamic sequence to obtain an external dynamic feature embedding vector; The cross-attention layer is used to: perform cross-attention calculation using the dynamic feature embedding vector as the query vector and the key vector, and the context vector as the value vector, to obtain cross-attention weights that characterize the interaction relationship between the historical delivery time sequence and the external dynamic feature data. The second residual connection and layer normalization network is used to: perform a residual connection on the context vector and the cross-attention weights, and then perform layer normalization on the residual connection result to obtain the global representation vector.
[0086] like Figure 2C The diagram shown is a schematic of the cross-attention module implementing the cross-attention mechanism in the time series prediction model in the embodiments of this specification. It may include the second Embedding layer, the cross-attention layer, and the second residual connection and layer normalization network mentioned above.
[0087] like Figure 2C As shown, the sequence input to the second Embedding layer is the historical external dynamic sequence, which can map the external dynamic features to a high-dimensional space (Embedding).
[0088] The cross-attention layer can model the feature interaction between external dynamic information (such as weather, supply and demand pressure, traffic conditions, etc., which are also sequences) and context vectors.
[0089] The input to the second residual connection and layer normalization (Add&LayerNorm) includes the context vector and the output of the cross-attention layer. After residually connecting the context vector and the cross-attention weights, layer normalization is applied to the residual connection result to obtain the global representation vector. The residual processing can be implemented as "Residual Output = Cross-Attention Output + Context Vector," which prevents gradient vanishing, meaning that gradients in deep networks can be backpropagated to shallower layers. LayerNorm (layer normalization) prevents certain dimensions from becoming too large or too small, stabilizing the training process and accelerating model training.
[0090] In some cases, when there are multiple historical delivery duration sequences, one or more context vectors may be generated; for example, self-attention may be calculated for each delivery duration sequence (such as S, T, P, K) to generate a context vector for each.
[0091] For example: the average value sequence of the business district corresponds to the context vector C1, the average value sequence of the merchant corresponds to the context vector C2, and so on; thus, m context vectors are obtained (m = the number of delivery time sequences).
[0092] When generating multiple context vectors, optionally, the multiple context vectors can be merged first before performing cross-attention calculation; for example, multiple context vectors (C1, C2, ..., Cm) can be concatenated or weighted averaged to obtain a unified context vector C. Then, cross-attention calculation is performed using dynamic feature embedding (Q / K) and C (as V).
[0093] Alternatively, the context vector generated for each delivery time sequence can be cross-attention calculated with the external dynamic sequence (dynamic feature embedding vector), and then fused according to the cross-attention calculation result; for example, for each Ci, cross-attention is calculated with the dynamic feature embedding vector to obtain Gi; then G1, G2, ..., Gm are concatenated or weighted and fused into the final global representation vector.
[0094] Alternatively, dynamic feature embedding vectors can be used as the Query and Key, and all context vectors can be concatenated as the Value; for example, C1, C2, ..., Cm can be concatenated along the time or feature dimension into a large Value matrix, and then the Query, Key and Value matrices can be cross-attention calculated.
[0095] In cases where there are multiple historical external dynamic sequences, multiple dynamic sequence embedding vectors can be concatenated to form a Query / Key, ultimately resulting in a global representation vector.
[0096] In some examples, obtaining the estimated delivery time of the historical order from the global representation vector and the external static features predicted by the delivery time estimation model may include: The global representation vector is concatenated with the external static features to form an enhanced feature vector, which is then input into the delivery time prediction model so that the delivery time prediction model outputs the estimated delivery time of the historical order based on the enhanced feature vector.
[0097] As an example, external static information such as business district ID and merchant type code can first be embedded and mapped into vectors to obtain external static features. The global representation vector (high-dimensional temporal dynamic features) can then be concatenated with the external static features, for example, by concatenating along feature dimensions to form a longer enhanced feature vector. This concatenation allows the enhanced feature vector to simultaneously contain dynamic contextual information and static attribute information, providing more comprehensive input features for the delivery time prediction model.
[0098] In some examples, training the model based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model may include: Calculate the squared error between the statistical information of delivery time at subsequent historical time points predicted by the time series prediction model and the statistical information of actual delivery time at the subsequent time points; Calculate the absolute error between the estimated delivery time of the historical order predicted by the delivery time prediction model and the actual delivery time of the historical order; The total loss is calculated based on the squared error and the absolute error, and the time series prediction model and the delivery time estimation model are jointly trained based on the total loss.
[0099] like Figure 2D As shown, as an example, this embodiment takes a historical delivery time series as the input of the time series prediction model. The global representation vector output by the time series prediction model and the external static variables are concatenated as the features of the delivery time estimation model (PLE model). At the same time, the value of the next moment of the historical delivery time series is used as the true label of the time series prediction model. The difference between the prediction result of the time series prediction model and the true label is constrained by the mean squared error loss.
[0100] As an example, it can be represented by the following formula: Total_Loss: Total loss, consisting of two parts: and .
[0101] The number of sample data.
[0102] : No. Each sample at time point The true value of the delivery time sequence.
[0103] : No. Each sample at time point The predicted value of the delivery time sequence.
[0104] : No. The actual delivery time for each sample.
[0105] : No. Estimated delivery time for each sample.
[0106] : A hyperparameter used to adjust the weights of the time series loss term.
[0107] The loss function designed in this embodiment is a weighted sum of the following two losses: Loss term of time series prediction model: The squared error is used to measure the accuracy of time series forecasts.
[0108] Loss term in the delivery time prediction model: The accuracy of delivery time predictions is measured using absolute error.
[0109] Therefore, in this embodiment, the total loss function can be calculated by averaging the loss of all samples. By weighted fusion of the two losses, the optimization objectives of the time series prediction model and the delivery time estimation model are aligned: the former provides high-quality global time series features, and the latter outputs accurate estimated delivery times for a single order based on these features.
[0110] The above embodiment uses a historical delivery time series input into the time series prediction model as an example, that is, the predicted delivery time statistics for subsequent historical time points are a single data set. Examples.
[0111] In practical applications, as mentioned in the preceding embodiments, the historical delivery time series input to the time series prediction model can be multiple (corresponding to series with different dimensions and / or different statistical indicators). Therefore, the predicted values output by the time series prediction model can also be multiple (corresponding to different input series). Thus, the total loss can also be designed based on multiple different predicted values from the time series prediction model. For example, the prediction loss of the time series prediction model is determined by the difference between the predicted value and the actual value at subsequent time points in each historical delivery time series, such as the sum of the absolute values of these differences for each series. For example, if the delivery time series includes series S, and also includes series P and K, the loss term can be modified to " + + "and other calculation methods, among which" and Let represent the actual values of delivery time series P and K at subsequent time point t+1, respectively. and These represent the predicted values of the subsequent time point t+1 for the delivery duration sequences P and K, respectively. This embodiment does not impose any limitations on these values.
[0112] As can be seen from the above embodiments, this embodiment employs a dual-loss function joint optimization mechanism during model training. By simultaneously constraining the errors of the time series prediction model and the delivery time estimation model, it achieves collaborative learning between the two models. If the two models are trained separately, the time series prediction model may over-optimize statistical regularities and neglect support for single order estimation. Joint training binds the goals of both models through the total loss, improving end-to-end prediction performance.
[0113] like Figure 3The diagram illustrates a delivery time estimation method according to an exemplary embodiment of this specification. The method may include: In step 302, the current delivery time sequence, current external dynamic sequence, and external static features of the orders to be delivered are obtained.
[0114] In step 304, the current delivery time sequence and the current external dynamic sequence are input into the time series prediction model trained by the aforementioned model training method.
[0115] In step 306, the fused global representation vector obtained from the time series prediction model and the external static features are input into the delivery time estimation model so that the delivery time estimation model outputs the estimated delivery time of the order to be delivered.
[0116] The method described in this embodiment can be used to estimate delivery time. As an example, the method described in this embodiment can be derived from... Figure 1 The server-side execution shown allows it to predict the delivery time for each order and send that estimated time to the user client, enabling the client to display the predicted delivery time. Simultaneously, the server can allocate and schedule orders based on the estimated delivery time, improving operational efficiency.
[0117] In this embodiment, the current delivery time sequence corresponds to the historical delivery time sequence of the aforementioned embodiment, and may include: historical delivery time statistics for multiple historical time points prior to the current moment (such as the order time). The current external dynamic sequence corresponds to the historical external dynamic sequence of the aforementioned embodiment, and may include: historical external dynamic information affecting delivery time for multiple historical time points prior to the current moment (such as the order time). Similarly, the external static features here may be the same as the historical external static features of the aforementioned embodiment.
[0118] The current delivery time sequence and the current external dynamic sequence are input into the time series prediction model trained by the aforementioned model training method. In this way, the time series prediction model can generate a context vector for the current delivery time sequence through a self-attention mechanism, and fuse the context vector with the current external dynamic sequence through a cross-attention mechanism to obtain a global representation vector.
[0119] Next, the fused global representation vector obtained from the time series prediction model and the external static features can be input into the delivery time prediction model. For example, the enhanced feature vector obtained by concatenating the two can be input into the model so that the delivery time prediction model can output the estimated delivery time of the order to be delivered.
[0120] As can be seen from the above embodiments, this method introduces time series modeling technology to construct a new generation of delivery time prediction models. The core advantages of this solution are reflected in the following aspects: a. This embodiment can capture complex dynamic change patterns in historical data, learn the impact of periodicity and trends on delivery time, and improve the accuracy of prediction.
[0121] b. This embodiment integrates multi-source external dynamic information such as weather, traffic, and supply and demand pressure by introducing a cross-attention mechanism to form a more comprehensive forecast in order to cope with emergencies caused by changes in the external environment.
[0122] c. Compared to real-time statistical features that rely on expert knowledge and manual parameter tuning, this solution directly learns from the raw data through model adaptive learning, improving iteration efficiency and reducing maintenance costs.
[0123] In practical applications, the prediction accuracy of the delivery time estimation model is improved by 3.3%, and the follow-up delay in sudden weather and traffic congestion scenarios is reduced by 37%.
[0124] This embodiment transforms the real-time statistical features in the delivery time prediction model into a dynamic time series modeling approach. This not only reduces the manual development cost of real-time statistical features but also captures the long-term dependencies and change patterns of historical time series through sequence modeling, thereby improving the prediction accuracy of the delivery time prediction model.
[0125] By incorporating external dynamic variables such as weather and supply and demand pressures into time series modeling, and using a cross-attention mechanism to realize the dynamic interaction between external information and time series, we can comprehensively model the changing patterns of historical information and improve the interpretability of the model.
[0126] Sequence modeling techniques are applied to time prediction models to achieve joint training of time prediction models and sequence modeling.
[0127] Corresponding to the embodiments of the aforementioned model training method / delivery time prediction method, this specification also provides embodiments of the model training device / delivery time prediction device and the computer equipment used thereon.
[0128] The embodiments of the model training device / delivery time estimation device described in this specification can be applied to computer equipment, such as servers or terminal devices. The device embodiments can be implemented through software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by its processor reading the corresponding computer program instructions from non-volatile memory into memory for execution. From a hardware perspective, such as... Figure 4 The diagram shown is a hardware structure diagram of the computer equipment containing the model training device / delivery time prediction device of this specification, except for... Figure 4In addition to the processor 410, memory 430, network interface 420, and non-volatile memory 440 shown, the electronic device in which the model training device / delivery time estimation device 431 is located in the embodiment may also include other hardware depending on the actual function of the electronic device, which will not be described in detail here.
[0129] like Figure 5 As shown, Figure 5 This is a block diagram illustrating a model training apparatus according to an exemplary embodiment of this specification. The model includes a time series prediction model and a delivery time estimation model; the apparatus includes: The data acquisition module 51 is used to: acquire historical delivery time sequences, historical external dynamic sequences, and historical external static features of historical orders; wherein, the historical delivery time sequence includes: historical delivery time statistics for multiple historical time points; the historical external dynamic sequence includes: historical external dynamic information affecting the historical delivery time for the multiple historical time points; Prediction module 52 is used to: obtain the context vector generated by the time series prediction model from the historical delivery time sequence through the self-attention mechanism, and fuse the context vector with the historical external dynamic sequence through the cross-attention mechanism to obtain the global representation vector, and predict the delivery time statistics of subsequent historical time points based on the global representation vector; The estimation module 53 is used to: obtain the estimated delivery time of the historical order estimated by the delivery time estimation model based on the global representation vector and the external static features; Training module 54 is used to train the model based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model.
[0130] In some examples, the generation of context vectors from the historical delivery duration sequence via a self-attention mechanism, as described in prediction module 52, includes: The historical delivery time sequence data is embedded and mapped, and location encoding is added to obtain a sequence embedding vector containing the sequential information of the multiple historical time points; After calculating the self-attention weights between the multiple time points for the sequence embedding vector, the context vector is generated using the self-attention weights.
[0131] In some examples, the time series prediction model includes: The first Embedding layer is used to: perform embedding mapping on the historical delivery time sequence data and add location encoding to obtain a sequence embedding vector containing the sequential information of the multiple historical time points; A self-attention layer is used to: calculate the self-attention weights between the plurality of time points from the sequence embedding vector; The first residual connection and layer normalization network is used to: perform a residual connection on the sequence embedding vector and the correlation coefficient, and then perform layer normalization on the residual connection result to obtain the context vector.
[0132] In some examples, the prediction module 52 uses a cross-attention mechanism to fuse the context vector with the historical external dynamic sequence to obtain a global representation vector, including: The historical external dynamic sequence is embedded and mapped to obtain a dynamic feature embedding vector; Using the dynamic feature embedding vector as the query vector and key vector, and the context vector as the value vector, cross-attention calculation is performed to generate a global representation vector containing the interaction relationship between the historical delivery time sequence and the external dynamic feature data.
[0133] In some examples, the time series prediction model includes: The second Embedding layer is used to: perform embedding mapping on the historical external dynamic sequence to obtain an external dynamic feature embedding vector; The cross-attention layer is used to: perform cross-attention calculation using the dynamic feature embedding vector as the query vector and the key vector, and the context vector as the value vector, to obtain cross-attention weights that characterize the interaction relationship between the historical delivery time sequence and the external dynamic feature data. The second residual connection and layer normalization network is used to: perform a residual connection on the context vector and the cross-attention weights, and then perform layer normalization on the residual connection result to obtain the global representation vector.
[0134] In some examples, in training module 54, training the model based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model includes: Calculate the squared error between the statistical information of delivery time at subsequent historical time points predicted by the time series prediction model and the statistical information of actual delivery time at the subsequent time points; Calculate the absolute error between the estimated delivery time of the historical order predicted by the delivery time prediction model and the actual delivery time of the historical order; The total loss is calculated based on the squared error and the absolute error, and the time series prediction model and the delivery time estimation model are jointly trained based on the total loss.
[0135] In some examples, in the estimation module 53, obtaining the estimated delivery time of the historical order estimated by the delivery time estimation model based on the global representation vector and the external static features includes: The global representation vector is concatenated with the external static features to form an enhanced feature vector, which is then input into the delivery time prediction model so that the delivery time prediction model outputs the estimated delivery time of the historical order based on the enhanced feature vector.
[0136] In some examples, the historical delivery time sequence includes: the business district where the historical order is located, and the historical delivery time statistics at each historical point in time; and / or, the merchant where the historical order is located, and the historical delivery time statistics at each historical point in time; And / or, the historical external dynamic information affecting the historical delivery time at the multiple historical time points includes a combination of one or more of the following: historical weather information, historical traffic information, and historical supply and demand pressure information characterizing the supply and demand relationship between delivery orders and delivery capacity.
[0137] like Figure 6 As shown, Figure 6 This specification illustrates a delivery time estimation device according to an exemplary embodiment, the device comprising: The acquisition module 61 is used to: acquire the current delivery time sequence, current external dynamic sequence, and external static features of the orders to be delivered; Input module 62 is used to: input the current delivery time sequence and the current external dynamic sequence into the time series prediction model trained by the aforementioned model training method embodiment; Output module 63 is used to: input the fused global representation vector obtained by the time series prediction model and the external static features into the delivery time estimation model, so that the delivery time estimation model outputs the estimated delivery time of the order to be delivered.
[0138] The specific implementation process of the functions and roles of each module in the above-mentioned model training device / delivery time prediction device can be found in the implementation process of the corresponding steps in the above-mentioned model training method / delivery time prediction method, and will not be repeated here.
[0139] Accordingly, embodiments of this specification also provide a computer program product, including a computer program that, when executed by a processor, implements the steps of the aforementioned model training method / delivery time estimation method embodiments.
[0140] Accordingly, embodiments of this specification also provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the model training method / delivery time estimation method embodiment.
[0141] Accordingly, embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the model training method / delivery time estimation method embodiments.
[0142] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0143] The above embodiments can be applied to one or more computer devices. The computer device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. The hardware of the computer device includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0144] The computer device can be any electronic product that can interact with the user, such as a personal computer, tablet computer, smartphone, personal digital assistant (PDA), game console, interactive network television (IPTV), smart wearable device, etc.
[0145] The computer equipment may also include network equipment and / or user equipment. The network equipment includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.
[0146] The network in which the computer device is located includes, but is not limited to, the Internet, wide area network, metropolitan area network, local area network, and virtual private network (VPN).
[0147] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0148] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this application.
[0149] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.
[0150] The terms "specific example" or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with the embodiments or examples, which are included in at least one embodiment or example of this specification. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0151] Other embodiments of this specification will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This specification is intended to cover any variations, uses, or adaptations that follow the general principles of this specification and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this specification are indicated by the following claims.
[0152] It should be understood that this specification is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this specification is limited only by the appended claims.
[0153] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.
Claims
1. A model training method, wherein the model includes a time series prediction model and a delivery time estimation model; the method includes: The system acquires historical delivery time sequences, historical external dynamic sequences, and historical external static features of historical orders. The historical delivery time sequences include statistical information on historical delivery times at multiple historical time points. The historical external dynamic sequences include historical external dynamic information on the impact of these multiple historical time points on the historical delivery times. The time series prediction model generates a context vector from the historical delivery time sequence through a self-attention mechanism, and fuses the context vector with the historical external dynamic sequence through a cross-attention mechanism to obtain a global representation vector. The delivery time statistics for subsequent historical time points are then predicted based on the global representation vector. Obtain the estimated delivery time of the historical order from the global representation vector and the external static features predicted by the delivery time prediction model; The model is trained based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model.
2. The method according to claim 1, wherein generating a context vector from the historical delivery time sequence using a self-attention mechanism comprises: The historical delivery time sequence data is embedded and mapped, and location encoding is added to obtain a sequence embedding vector containing the sequential information of the multiple historical time points; After calculating the self-attention weights between the multiple time points for the sequence embedding vector, the context vector is generated using the self-attention weights.
3. The method according to claim 2, wherein the time series prediction model comprises: The first Embedding layer is used to: perform embedding mapping on the historical delivery time sequence data and add location encoding to obtain a sequence embedding vector containing the sequential information of the multiple historical time points; A self-attention layer is used to: calculate the self-attention weights between the plurality of time points from the sequence embedding vector; The first residual connection and layer normalization network is used to: perform a residual connection on the sequence embedding vector and the self-attention weights, and then perform layer normalization on the residual connection result to obtain the context vector.
4. The method according to claim 1, wherein fusing the context vector with the historical external dynamic sequence through a cross-attention mechanism to obtain a global representation vector comprises: The historical external dynamic sequence is embedded and mapped to obtain a dynamic feature embedding vector; Using the dynamic feature embedding vector as the query vector and key vector, and the context vector as the value vector, cross-attention calculation is performed to generate a global representation vector containing the interaction relationship between the historical delivery time sequence and the external dynamic feature data.
5. The method according to claim 4, wherein the time series prediction model comprises: The second Embedding layer is used to: perform embedding mapping on the historical external dynamic sequence to obtain an external dynamic feature embedding vector; The cross-attention layer is used to: perform cross-attention calculation using the dynamic feature embedding vector as the query vector and the key vector, and the context vector as the value vector, to obtain cross-attention weights that characterize the interaction relationship between the historical delivery time sequence and the external dynamic feature data. The second residual connection and layer normalization network is used to: perform a residual connection on the context vector and the cross-attention weights, and then perform layer normalization on the residual connection result to obtain the global representation vector.
6. The method according to claim 1, wherein training the model based on the prediction loss of the time series prediction model and the prediction loss of the delivery time estimation model comprises: Calculate the squared error between the statistical information of delivery time at subsequent historical time points predicted by the time series prediction model and the statistical information of actual delivery time at those subsequent historical time points; Calculate the absolute error between the estimated delivery time of the historical order predicted by the delivery time prediction model and the actual delivery time of the historical order; The total loss is calculated based on the squared error and the absolute error, and the time series prediction model and the delivery time estimation model are jointly trained based on the total loss.
7. A method for estimating delivery time, the method comprising: Obtain the current delivery time sequence, current external dynamic sequence, and external static features of the orders to be delivered; The current delivery time sequence and the current external dynamic sequence are input into the time series prediction model trained by the method of any one of claims 1 to 6; The fused global representation vector obtained from the time series prediction model and the external static features are input into the delivery time estimation model so that the delivery time estimation model outputs the estimated delivery time of the order to be delivered.
8. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
9. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.