Training method and device for cycle prediction model, cycle prediction method and equipment
By considering historical order behavior sequences during the training of the periodic prediction model, building a data set and training the model, the problem of low model accuracy in the existing technology is solved, and higher fitting ability and prediction accuracy are achieved.
Patent Information
- Application Number
- CN202111272810.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2041-10-29
AI Technical Summary
The existing cycle prediction model does not consider the user's historical order behavior sequence during the training process, resulting in a low accuracy of the output results of the repurchase cycle model, which in turn affects the accuracy of the model.
By calculating the historical order behavior sequence and actual repurchase cycle of historical users, a data set is constructed, and historical items, historical order behavior sequence and user portrait are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle. Then, based on the actual and predicted repurchase cycles, the model is trained, and the trained period prediction model is obtained.
By considering the historical order behavior sequence, the fitting ability and accuracy of the periodic prediction model are improved, and the problem of low model accuracy in the existing technology is solved.
Smart Images

Figure CN113780479B_ABST
Abstract
Description
Background Art
[0002] In the existing cycle prediction model, it can be implemented by using a DNN (Deep Neural Networks) model with a three-layer fully connected neural network structure. Specifically, during the training process, user information features and corresponding item information features (such as item identification, item price, and item quantity) can be used as inputs to the DNN model, and the user's repurchase cycle for the item can be obtained through calculation of the neural network.
[0003] At the same time, when training the DNN model, a loss function can be constructed based on the output results of the user-product repurchase cycle model and the true value of the repurchase cycle, and the loss function can be optimized to minimize the value to update the network weight parameters, thereby obtaining a trained cycle prediction model.
[0004] However, in the training method of the above-mentioned cycle prediction model, the user's historical order behavior sequence is not taken into account, which makes the accuracy of the output result of the repurchase cycle model low, thereby resulting in low precision of the model.
[0005] Therefore, it is necessary to provide a new training method and device for a cycle prediction model.
[0006] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0007] The purpose of the present disclosure is to provide a training method for a period prediction model, a training device for a period prediction model, a period prediction method, a computer-readable storage medium and an electronic device, thereby at least to a certain extent overcoming the problem of low accuracy of the period prediction model caused by the limitations and defects of the relevant technology.
[0008] According to one aspect of the present disclosure, a training method for a period prediction model is provided, comprising:
[0009] Calculate the historical order behavior sequence of historical users and the actual repurchase cycle of historical items included in the historical orders based on historical user data;
[0010] Constructing a data set based on the historical items, the actual repurchase cycle, the historical order behavior sequence, and the historical user portraits in the historical user data;
[0011] Inputting the historical items, historical order behavior sequences, and historical user portraits included in the data set into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items;
[0012] A first loss function is constructed according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and the cycle prediction model to be trained is trained using the first loss function to obtain a trained cycle prediction model.
[0013] In an exemplary embodiment of the present disclosure, calculating the historical order behavior sequence of the historical user according to the historical user data includes:
[0014] Acquire historical user data of the historical user within a first preset time period according to the user identifier of the historical user;
[0015] Extracting historical items included in the historical user data, and aggregating the historical items according to the category identifications to which the historical items belong, to obtain categories of different levels to which the historical items belong;
[0016] Performing a sum operation on the quantity of the historical items to obtain the purchase quantity of the historical items, and calculating the time location feature of the historical items according to the start purchase time and the end purchase time of the historical items;
[0017] The historical order behavior sequence is generated according to the categories of different levels to which the historical items belong, the purchase quantity, and the time and location characteristics.
[0018] In an exemplary embodiment of the present disclosure, calculating the actual repurchase period of historical items included in historical orders according to historical user data includes:
[0019] Extracting the first purchase time node of the historical items included in the historical orders and the previous purchase time node corresponding to the first purchase time node from the historical user data;
[0020] Calculating a current purchase cycle of the historical item according to the first purchase time node and a previous purchase time node corresponding to the first purchase time node;
[0021] The current purchase cycle is normalized to obtain the actual repurchase cycle of the historical item.
[0022] In an exemplary embodiment of the present disclosure, the period prediction model to be trained includes a first word embedding layer, a second word embedding layer, an attention mechanism layer, and a logistic regression layer;
[0023] The historical items, historical order behavior sequences and historical user portraits included in the data set are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items, including:
[0024] Using the first word embedding layer to encode the historical items and historical order behavior sequences to obtain item features and behavior sequence features, and using the second word embedding layer to encode the historical user portraits to obtain user features;
[0025] Using the attention mechanism layer to process the behavior sequence features and the item features, obtaining a repurchase behavior vector of the historical user for the historical item;
[0026] The logistic regression layer is used to perform logistic regression processing on the repurchase behavior vector, item features, and user features to obtain the predicted repurchase cycle.
[0027] In an exemplary embodiment of the present disclosure, the behavior sequence feature and the item feature are processed to obtain a repurchase behavior vector of the historical user for the historical item, including:
[0028] Performing a first operation on the behavior sequence feature and the item feature to obtain a first output result; wherein the first operation includes an inner product operation and a subtraction operation;
[0029] splicing the first output result, the behavior sequence feature, and the item feature to obtain a first splicing result;
[0030] Processing the first splicing result using a first multi-layer fully connected neural network included in the attention mechanism layer to obtain an attention weight of the historical item;
[0031] The attention weight and the item feature are weightedly summed to obtain the repurchase behavior vector.
[0032] In an exemplary embodiment of the present disclosure, the training method of the period prediction model further includes:
[0033] Based on Word2vec, the categories of different levels, the purchase quantity, and the time location features to which the historical items belong are encoded to obtain a first sub-vector, a second sub-vector, and a third sub-vector;
[0034] Perform feature concatenation on the first sub-vector, the second sub-vector, and the third sub-vector to obtain the order sequence of the historical user, and perform masking on any sub-vector in the order sequence to obtain a sequence to be processed;
[0035] Predicting the sequence to be processed by using the Bert model to be trained to obtain a first prediction result, and constructing a second loss function for the Bert model by using the first prediction result and the masked sub-vector;
[0036] The Bert model to be trained is trained using the second loss function, and the trained Bert model is integrated into the second word embedding layer to obtain the first word embedding layer.
[0037] In an exemplary embodiment of the present disclosure, the Bert model includes a plurality of Transformer models;
[0038] The sequence to be processed is predicted by the Bert model to be trained to obtain a first prediction result, including:
[0039] Input the sequence to be processed into a first Transformer model to generate a first text semantic vector, and input the first text semantic vector into other Transformer models to obtain text semantic vectors corresponding to the other Transformer models; wherein, in the other Transformer models, the output of the previous Transformer model is the input of the next Transformer model corresponding thereto;
[0040] The importance of each Transformer model to the sequence to be processed is calculated, and the first prediction result is obtained according to each importance and each text semantic vector.
[0041] In an exemplary embodiment of the present disclosure, performing logistic regression processing on the repurchase behavior vector, item features, and user features to obtain the predicted repurchase cycle includes:
[0042] The repurchase behavior vector, item features, and user features are spliced and tiled to obtain a second splicing result;
[0043] Projecting the second concatenation result into a high-dimensional space using a second multi-layer fully connected neural network included in the logistic regression layer to obtain a high-dimensional projection result;
[0044] Nonlinear activation is performed on the high-dimensional projection result to obtain the predicted repurchase cycle.
[0045] According to one aspect of the present disclosure, a period prediction method is provided, comprising:
[0046] According to the user identifier of the target user, target user data of the target user is acquired, and a target order behavior sequence of the target user is calculated according to the target user data;
[0047] Determine a target item from the target order, and input the target item, the target order behavior sequence, and the target user portrait included in the target user data into the trained cycle prediction model to obtain the target user's repurchase cycle for the target item; wherein the trained cycle prediction model is obtained by training the cycle prediction model to be trained using any one of the cycle prediction model training methods described above;
[0048] Based on the repurchase cycle and the last purchase time of the target item by the target user, the next recommendation time of the target item is calculated, and the target item is recommended based on the next recommendation time.
[0049] According to one aspect of the present disclosure, a training device for a period prediction model is provided, comprising:
[0050] A first calculation module is used to calculate the historical order behavior sequence of the historical user and the actual repurchase cycle of the historical items included in the historical order according to the historical user data;
[0051] A data set construction module, used to construct a data set based on the historical items, actual repurchase cycles, historical order behavior sequences, and historical user portraits in the historical user data;
[0052] A repurchase cycle prediction module is used to input the historical items, historical order behavior sequences and historical user portraits included in the data set into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items;
[0053] The cycle prediction model training module is used to construct a first loss function according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and use the first loss function to train the cycle prediction model to be trained to obtain a trained cycle prediction model.
[0054] According to one aspect of the present disclosure, there is provided a period prediction device, comprising:
[0055] A second calculation module is used to obtain target user data of the target user according to the user identifier of the target user, and calculate the target order behavior sequence of the target user according to the target user data;
[0056] a repurchase cycle prediction module, used to determine a target item from the target order, and input the target item, the target order behavior sequence, and the target user portrait included in the target user data into a trained cycle prediction model to obtain the target user's repurchase cycle for the target item; wherein the trained cycle prediction model is obtained by training the cycle prediction model to be trained using any of the cycle prediction model training methods described above;
[0057] The item recommendation module is used to calculate the next recommendation time of the target item based on the repurchase cycle and the last purchase time of the target item by the target user, and recommend the target item based on the next recommendation time.
[0058] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the training method of the period prediction model described in any one of the above and the period prediction method described in the above are implemented.
[0059] According to one aspect of the present disclosure, there is provided an electronic device, including:
[0060] Processor; and
[0061] A memory, configured to store executable instructions of the processor;
[0062] Wherein, the processor is configured to execute any one of the above-mentioned period prediction model training methods and the above-mentioned period prediction methods by executing the executable instructions.
[0063] A training method for a cycle prediction model provided by an embodiment of the present disclosure, on the one hand, takes into account the historical order behavior sequence in the training process of the cycle prediction model, thereby solving the problem in the prior art that the historical order behavior sequence of the user is not taken into account, resulting in low accuracy of the output result of the repurchase cycle model, thereby leading to low precision of the model; on the other hand, the historical order behavior sequence of the historical user and the actual repurchase cycle of the historical items included in the historical order are calculated according to the historical user data; and a data set is constructed according to the historical items, the actual repurchase cycle, the historical order behavior sequence and the historical user portraits in the historical user data; and the historical items, the historical order behavior sequence and the historical user portraits included in the data set are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items; finally, a first loss function is constructed according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and the cycle prediction model to be trained is trained using the first loss function to obtain a trained cycle prediction model, thereby improving the fitting ability of the cycle prediction model, and further improving the precision of the cycle prediction model.
[0064] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0066] Figure 1 A flowchart of a method for training a period prediction model according to an example embodiment of the present disclosure is schematically shown.
[0067] Figure 2 A schematic diagram of an exemplary structure of a period prediction model according to an exemplary embodiment of the present disclosure is shown.
[0068] Figure 3 A flowchart schematically illustrates a method for inputting historical items, historical order behavior sequences, and historical user portraits included in the data set into a cycle prediction model to be trained to obtain a predicted repurchase cycle of the historical items according to an example embodiment of the present disclosure.
[0069] Figure 4 A flowchart of a method for generating a first word embedding layer according to an exemplary embodiment of the present disclosure is schematically shown.
[0070] Figure 5A diagram schematically illustrates a structural example of a Bert model according to an exemplary embodiment of the present disclosure.
[0071] Figure 6 A flowchart of another method for training a period prediction model according to an example embodiment of the present disclosure is schematically shown.
[0072] Figure 7 The flowchart of a period prediction method according to an exemplary embodiment of the present disclosure is schematically shown.
[0073] Figure 8 A block diagram schematically illustrates a training device for a period prediction model according to an example embodiment of the present disclosure.
[0074] Fig. 9 A block diagram of a period prediction device according to an exemplary embodiment of the present disclosure is schematically shown.
[0075] Fig.10 An electronic device for implementing the training method of the period prediction model and the period prediction method according to an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0076] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0077] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0078] As e-commerce becomes more mature, e-commerce pays more and more attention to the refined operation of each customer. The method of enhancing the stickiness of old users and tapping new users as a supplement has gradually become a necessary condition for the sustained and stable growth of e-commerce platforms. Therefore, accurately recommending products to users and enhancing user experience are indispensable means to achieve this condition. The repurchase problem, as one of the user experience problems in the recommendation system, needs to be solved urgently.
[0079] Specifically, the repeat purchase problem refers to the fact that in the e-commerce scenario, the recommendation system tends to recommend similar products that the user has recently purchased. For example, when shopping on an e-commerce platform, users often report that they have recently purchased products such as "range hoods" and "electric cars", but the e-commerce platform continues to recommend "range hoods" and "electric cars" related products, and can reproduce them stably, which seriously affects the user experience and easily causes user loss.
[0080] A common method to solve the repurchase problem is to build a user's repurchase cycle profile. The repurchase cycle refers to the time interval between users' repurchases of a certain type of goods. For example, if a user buys milk every 30 days, then the user's repurchase cycle for milk is 30 days. The recommendation system solves the repurchase problem in two stages: recall and sorting. In the recall stage, the user's repurchase cycle is used to filter recently purchased goods; in the sorting stage, the repurchase cycle is used as a feature of the refined ranking model and input into the machine learning model for training. The repurchase cycle is used to increase the weight of goods with a close repurchase date, and the weight of recently purchased goods is reduced, thereby affecting the sorting results and improving the user experience.
[0081] The existing repurchase cycle portraits may include: calculating the user repurchase cycle based on normal distribution. Specifically, the method first arranges the historical order information of the user's repurchased goods in descending order, calculates the time difference between each two adjacent purchases of the user's repurchased goods; calculates the mean and variance of the time difference according to the purchase interval; calculates the screening interval through the mean and variance of the time difference, and the screening interval is [mean-variance, mean+variance]; removes the data whose time difference does not belong to the screening interval to obtain the time difference after screening; obtains the user's repurchase cycle for the repurchased goods by averaging the time difference.
[0082] However, although the solution based on normal distribution takes into account the historical order interval, it is limited by the statistical model and cannot count similar products. For example, if the products are washing powder and laundry detergent, they will be regarded as two types of products in the statistical model, which makes the statistical model's expressive power relatively lacking; moreover, the existing solutions use the time interval as the basic data when calculating the user's actual repurchase cycle, and do not consider the user's purchase quantity, which can easily lead to inaccurate prediction results. Taking milk as an example, if the time interval between buying two boxes of milk and buying five boxes of milk is used as the user's single repurchase interval for milk, the basic data will be inaccurate. At the same time, the user's stockpiling behavior has a great impact on the user's next purchase time, and not considering it will cause deviations in the prediction results.
[0083] Based on this, this exemplary embodiment first provides a training method for a period prediction model, which can be run on a server, a server cluster or a cloud server, etc. Of course, those skilled in the art can also run the method disclosed in this disclosure on other platforms as required, and this exemplary embodiment does not specifically limit this. Figure 1 As shown, the training method of the cycle prediction model may include the following steps:
[0084] Step S110. Calculate the historical order behavior sequence of the historical user and the actual repurchase cycle of the historical items included in the historical orders according to the historical user data;
[0085] Step S120. Construct a data set based on the historical items, actual repurchase cycles, historical order behavior sequences, and historical user portraits in the historical user data;
[0086] Step S130. Input the historical items, historical order behavior sequences and historical user portraits included in the data set into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items;
[0087] Step S140. Construct a first loss function according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and use the first loss function to train the cycle prediction model to be trained to obtain a trained cycle prediction model.
[0088] In the training method of the above-mentioned cycle prediction model, on the one hand, since the historical order behavior sequence is taken into account during the training process of the cycle prediction model, the problem that the output result of the repurchase cycle model is low in accuracy due to the failure to consider the historical order behavior sequence of the user in the prior art is solved, which leads to low accuracy of the model; on the other hand, the historical order behavior sequence of historical users and the actual repurchase cycle of historical items included in the historical orders are calculated according to the historical user data; and a data set is constructed according to the historical items, the actual repurchase cycle, the historical order behavior sequence and the historical user portraits in the historical user data; the historical items, the historical order behavior sequence and the historical user portraits included in the data set are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items; finally, a first loss function is constructed according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and the cycle prediction model to be trained is trained using the first loss function to obtain a trained cycle prediction model, thereby improving the fitting ability of the cycle prediction model and further improving the accuracy of the cycle prediction model.
[0089] Hereinafter, the training method of the period prediction model according to the exemplary embodiment of the present disclosure will be explained and illustrated in detail with reference to the accompanying drawings.
[0090] First, the purpose of the invention of the exemplary embodiment of the present disclosure is explained and illustrated. Specifically, in order to solve the deficiencies of the prior art, the present disclosure proposes an implementation scheme for a user repurchase cycle prediction method based on the Attention mechanism, which finely predicts the user-product repurchase cycle, thereby solving the user experience problem caused by recommending products that users have recently purchased in the recommendation system. This technical solution is characterized by the user's historical order product sequence, purchase quantity sequence, and purchase time sequence in the past three years. First, feature semantic information such as products, purchase quantities, and purchase time is extracted based on a pre-training method; then, in the overall model, the user's personalized repurchase habits are first learned based on the Self-attention mechanism, and then the purchase information related to the target product in the user's historical purchase sequence is extracted based on the Attention mechanism, and then the user portrait and the target product are input into the MLP network together, thereby predicting the user's repurchase cycle. On the basis of improving the accuracy of the cycle prediction model, the user experience is improved.
[0091] In a training method for a period prediction model provided in an exemplary embodiment of the present disclosure:
[0092] In step S110, the historical order behavior sequence of the historical user and the actual repurchase cycle of the historical items included in the historical orders are calculated based on the historical user data.
[0093] In this example embodiment, first, a historical order behavior sequence of a historical user is calculated based on historical user data. Specifically, it may include: first, based on the user identifier of the historical user, the historical user data of the historical user within a first preset time period is obtained; second, the historical items included in the historical user data are extracted, and according to the category identifier to which the historical items belong, the historical items are aggregated to obtain the categories of different levels to which the historical items belong; then, the quantity of the historical items is summed to obtain the purchase quantity of the historical items, and the time location characteristics of the historical items are calculated based on the start purchase time and the end purchase time of the historical items; finally, the historical order behavior sequence is generated based on the categories of different levels to which the historical items belong, the purchase quantity and the time location characteristics.
[0094] For example, the historical user data of the historical user in the past three years (1095 days) can be obtained based on the user ID of the historical user (the user ID can be a phone number, email address or name, etc., and this example does not impose special restrictions on this); then, the historical items included in the historical user data are extracted, that is, the historical items purchased by the historical user in the past three years, and the user purchase sequence is constructed based on the day dimension, and the product data of the same category purchased by the user on the same day is aggregated. The specific method is to aggregate (group by) the products purchased by the user on the same day with cid4, cid3, cid2, and cid1 as the aggregation fields, and then obtain the categories of different levels to which the historical items belong. Among them, cid4, cid3, cid2, and cid1 are the category identifiers to which the products belong, corresponding to the fourth-level category, the third-level category, the second-level category, and the first-level category respectively; for example, taking a hairpin as an example, the cid4, cid3, cid2, and cid1 corresponding to the item are broken hairpins, hairpins, hair accessories, and jewelry respectively. Furthermore, the quantity of historical items is summed to obtain the purchase quantity of the historical items; at the same time, for the time position feature (that is, the purchase time feature), the current purchase date can be subtracted from the minimum purchase date of the training data to obtain the time position (position) feature, ranging from [0,1095]; finally, the historical order behavior sequence can be generated according to the categories of different levels to which the historical items belong, the purchase quantity and the time position features.
[0095] Secondly, the actual repurchase cycle of the historical items included in the historical orders is calculated based on the historical user data. Specifically, it may include: first, extracting the first purchase time node and the previous purchase time node corresponding to the first purchase time node of the historical items included in the historical orders from the historical user data; secondly, calculating the current purchase cycle of the historical items based on the first purchase time node and the previous purchase time node corresponding to the first purchase time node; finally, normalizing the current purchase cycle to obtain the actual repurchase cycle of the historical items. Specifically, in the model training process, the goal may be to randomly predict the next repurchase interval in the historical user purchase sequence, and the training sample extraction rule is to randomly select a repurchased commodity in the historical user purchase sequence as a historical item (targetitem), and the time interval between the repurchase time (repruchase_day) and the last purchase of the cid4 category historical item as the real repurchase interval (label), and the user purchase sequence is truncated to before pruchase_day; then, the real repurchase interval is normalized to obtain the real value of the training sample (actual repurchase cycle) y. Among them, the specific normalization processing formula can be shown as the following formula (1):
[0096]
[0097] Among them, max is the maximum value in label and min is the minimum value in label.
[0098] In step S120, a data set is constructed based on the historical items, the actual repurchase cycle, the historical order behavior sequence, and the historical user portraits in the historical user data.
[0099] Specifically, after obtaining the actual repurchase cycle and historical order behavior sequence, a data set can be constructed based on historical items, actual repurchase cycle, historical order behavior sequence, and user portraits; and the data samples in the data set are divided into 8:1:1 ratios, of which 8 are used for model training, 1 for model verification, and 1 for model testing and evaluation. The user portrait can include the gender, age, occupation, etc. of the historical user.
[0100] In step S130, the historical items, historical order behavior sequences and historical user portraits included in the data set are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items.
[0101] In this example embodiment, first, the cycle prediction model is explained and illustrated. Specifically, refer to Figure 2 As shown, the period prediction model may include an input layer 210, a first word embedding layer 220, a second word embedding layer 230, an attention mechanism layer 240, a logistic regression layer 250 and an output layer 260; wherein the input layer is connected to the first word embedding layer and the second word embedding layer, the first word embedding layer is connected to the logistic regression layer through the attention mechanism layer, and the second word embedding layer is connected to the output layer through the logistic regression layer.
[0102] Secondly, refer to Figure 3 As shown, the historical items, historical order behavior sequences and historical user portraits included in the data set are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items, which may include the following steps:
[0103] Step S310, using the first word embedding layer to encode the historical items and historical order behavior sequences to obtain item features and behavior sequence features, and using the second word embedding layer to encode the historical user portraits to obtain user features.
[0104] In this example embodiment, first, the generation process of the first word embedding layer is explained and illustrated. Figure 4 As shown, the generation process of the first word embedding layer may include the following steps:
[0105] Step S410, encoding the categories of different levels, purchase quantity, and time location features of the historical items based on Word2vec to obtain a first sub-vector, a second sub-vector, and a third sub-vector;
[0106] Step S420, performing feature concatenation on the first sub-vector, the second sub-vector and the third sub-vector to obtain the order sequence of the historical user, and performing masking on any sub-vector in the order sequence to obtain a sequence to be processed;
[0107] Step S430, predicting the sequence to be processed by using the Bert model to be trained to obtain a first prediction result, and constructing a second loss function for the Bert model by using the first prediction result and the masked sub-vector; wherein the Bert model includes multiple Transformer models;
[0108] Specifically, predicting the sequence to be processed by the Bert model to be trained to obtain a first prediction result can include: first, inputting the sequence to be processed into the first Transformer model to generate a first text semantic vector, and inputting the first text semantic vector into other Transformer models to obtain text semantic vectors corresponding to the other Transformer models; wherein, in the other Transformer models, the output of the previous Transformer model is the input of the next Transformer model corresponding to it; secondly, calculating the importance of each Transformer model to the sequence to be processed, and obtaining the first prediction result based on each importance and each text semantic vector.
[0109] Step S440: Use the second loss function to train the Bert model to be trained, and integrate the trained Bert model into the second word embedding layer to obtain the first word embedding layer.
[0110] In the following, steps S410 to S440 will be explained and illustrated. Specifically, pre-training refers to obtaining a pre-training model that is not related to a specific task from large-scale data through a self-supervised learning method. Introducing pre-training can better obtain the embedding vectors of the semantic representation of features such as cid4, cid3, cid2, cid1, purchase quantity, purchase time position, etc. In this example embodiment, pre-training can be completed based on a Bert model including multiple Transformer models, where the architecture diagram of the Bert model can refer to Figure 5As shown, in the Bert model, 12 Transformer models may be included, for example, Transformer 1, Transformer 2, ..., Transformer Encoder L, and so on.
[0111] Furthermore, since cid4 is relatively sparse and the amount of data is as high as hundreds of thousands, it is difficult for Transformer to complete pre-training under the existing machine conditions (4 GPU cards). Therefore, in this example embodiment, the Transformer is pre-trained using the two-stage pre-training method of word2Vec+Transformer to alleviate the sparsity problem of cid4 and speed up the pre-training speed. Specifically, first, based on Word2vec, the cid4 sequence, cid3 sequence, cid2 sequence, cid1 sequence, purchase quantity sequence, and purchase time position sequence of the items purchased by the user are trained to obtain the first sub-vector corresponding to cid4, cid3, cid2, and cid1, the second sub-vector corresponding to the purchase quantity, and the third sub-vector corresponding to the time position; secondly, since the embedding based on Word2vec training can only aggregate similar features within the limited window size, it lacks more contextual information, and does not use the product attributes for prediction, lacking its own attribute information; therefore, the embedding vector obtained by Word2vec can be used as the initial input embedding in the Transformer model, and then the second stage of pre-training is performed to obtain a better feature semantic representation (embedding).
[0112] For example, the first subvector corresponding to the cid4 sequence, cid3 sequence, cid2 sequence, and cid1 sequence, the second subvector corresponding to the purchase quantity sequence, and the third subvector corresponding to the time position sequence can be feature concatenated to obtain the order sequence of the historical user, wherein each purchase record of the user will include cid1, cid2, cid3, cid4, purchase quantity, and purchase time features; further, the model is trained using the MLM training method. The specific principle of MLM is as follows: the user order sequence is input into the Transformer model, and the MLM training method randomly masks any features of the purchase record (features include cid1, cid2, cid3, cid4, purchase quantity, and time position features, etc.) to obtain the sequence to be processed, and then the model is used to predict the masked features in the sequence to be processed to obtain the first prediction result; then a loss function is constructed based on the prediction result and the actual masked features to complete the training of the Bert model to be trained; finally, the trained Bert model can be fused into the second word embedding layer to obtain the first word embedding layer.
[0113] It should be noted here that this training method can not only use the most recent purchase records for prediction, but also use other features of the current purchase records for prediction (cid1, cid2, cid3, cid4, etc.), so that the embeddings of different features can be aligned in the semantic space, thereby improving the accuracy of the behavior sequence features, thereby improving the accuracy of the cycle prediction model. In addition, this example introduces the pre-trained Bert model into the first word embedding layer obtained by integrating it into the second word embedding layer, which can act on each item in the historical purchase sequence of the historical user. For example, for the commodity "shirt" in the sequence, when learning the embedding representation of the shirt, the features of the purchased T-shirts, vests and other related categories should be weighted, so that the semantic information of "shirt" can be better learned, and due to the addition of purchase time and purchase quantity features, the personalized repurchase habit information of the user for the "shirt" item can be learned, enhancing the learning ability of the model.
[0114] Finally, after obtaining the first word embedding layer, the first word embedding layer can be used to encode the historical items and historical order behavior sequences to obtain item features and behavior sequence features, and then the second word embedding layer can be used to encode historical user portraits to obtain user features. It should be noted that the second word embedding layer recorded here can be a commonly used word embedding layer, that is, a conventional Embedding layer.
[0115] Step S320: Use the attention mechanism layer to process the behavior sequence features and the item features to obtain a repurchase behavior vector of the historical user for the historical item.
[0116] In an exemplary embodiment of the present disclosure, first, a first operation is performed on the behavior sequence features and the item features to obtain a first output result; wherein the first operation includes an inner product operation and a subtraction operation; secondly, the first output result, the behavior sequence features and the item features are concatenated to obtain a first concatenated result; then, the first concatenated result is processed using a first multi-layer fully connected neural network included in the attention mechanism layer to obtain an attention weight of the historical item; finally, a weighted sum is performed on the attention weight and the item features to obtain the repurchase behavior vector.
[0117] Specifically, first, inner product and subtraction operations are performed on the behavior sequence features and item features to obtain the first output result; the first output result is concatenated with the behavior sequence features and item features, and input into the first multi-layer fully connected neural network (MLP) to learn the attention weight w, and finally weighted sum pooling is used to obtain the repurchase behavior vector related to the current product in the purchase sequence. The weighted sum pooling formula can be shown as follows (2):
[0118]
[0119] Among them, v a Represents the embedding vector (item features) of historical items, e 1 ,e 2 ,...,e n represents the item embedding vector (behavior sequence feature) output by the second word embedding layer, a(e j ,v a ) represents the attention operation of the attention mechanism layer, w j represents the learned attention weight, and U(A) represents the repurchase behavior vector of historical users for historical items.
[0120] It should be noted that the attention mechanism layer can well focus on the products that the user has purchased in the past that are related to the current product. For example, when calculating the repurchase cycle of the user's "computer" product, the features of related categories such as laptops and desktops that the user has purchased before should be weighted; while purchases such as clothes and snacks should be relatively downgraded. The Attention mechanism is to focus on historical purchase behaviors related to the target product.
[0121] Step S330, using the logistic regression layer to perform logistic regression processing on the repurchase behavior vector, item features, and user features to obtain the predicted repurchase cycle.
[0122] In this example embodiment, first, the repurchase behavior vector, item features, and user features are spliced and tiled to obtain a second splicing result; secondly, the second splicing result is projected into a high-dimensional space using a second multi-layer fully connected neural network included in the logistic regression layer to obtain a high-dimensional projection result; finally, the high-dimensional projection result is nonlinearly activated to obtain the predicted repurchase cycle.
[0123] Specifically, the logistic regression Regressor layer outputs the repurchase behavior vector U(A) of the Attention layer and the embedding vector (item feature) v of the historical item. a The user portrait vector (user features) is spliced and tiled, and then projected into a high-dimensional space through the second multi-layer fully connected neural network MLP, and nonlinearly activated through the activation function relu, and finally the model output result y is obtained through the Sigmoid function pred , that is, predicting the repurchase cycle.
[0124] In step S140, a first loss function is constructed according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and the cycle prediction model to be trained is trained using the first loss function to obtain a trained cycle prediction model.
[0125] Specifically, a first MAPE loss function can be constructed according to the actual repurchase cycle and the predicted repurchase cycle, and then the cycle prediction model to be trained is trained by the first MAPE loss function. The loss function can be shown in the following formula (3):
[0126]
[0127] Among them, L is the first MAPE loss function, y i is the true value of the i-th training sample, that is, the actual repurchase cycle, is the model prediction value of the i-th training sample, that is, the predicted repurchase cycle, and N is the total number of samples, that is, the number of historical items.
[0128] Furthermore, after the trained cycle prediction model is obtained, it is necessary to evaluate the effect of the trained cycle prediction model. Specifically, in the effect evaluation stage, y pred First, we need to perform denormalization to get the final repurchase period prediction result period. The denormalization formula is y pred *(max-min)+min, where max is the maximum value in label and min is the minimum value in label. pred It is the output of the Rgressor layer in step D, i.e., the predicted repurchase cycle.
[0129] At the same time, after predicting and denormalizing the model on the test set, the MAPE, SMAPE and other indicators are used to comprehensively evaluate the effect of the model. Accumulate multiple model evaluation results and calculate the average indicators of the model. In the offline experiment of the repurchase cycle, the SMAPE of the test set evaluation was 0.198 and the MAPE was 0.1392, and the effect was very obvious. In actual online use, when the model's indicators are at the average level or above the average level, the model file can be updated to the online model library regularly. If the model evaluation indicators are lower than the average level of the model, it will not be updated. The training and evaluation cycle of the offline model is weekly, that is, the model effect is trained and evaluated every week.
[0130] The following, combined Figure 6 The training method of the cycle prediction model of the exemplary embodiment of the present disclosure is further explained and illustrated. Figure 6 As shown, the training method of the cycle prediction model may include the following steps:
[0131] Step S601, the Embedding layer first converts the input historical items, user historical purchase sequence (including features such as products, purchase time, purchase quantity, etc.), and user portrait (gender, age, etc.) into embedding vectors;
[0132] Step S602: Input the embedding vector of the target product and the embedding vector of the user's historical purchase sequence into the attention network to obtain the historical user's repurchase habits for historical items.
[0133] Step S603: concatenate the embedding vectors of historical items, repurchase habits, and user portraits, and input them into the Regressor layer together to obtain the user's predicted repurchase cycle;
[0134] Step S604, constructing a first loss function according to the predicted repurchase cycle and the actual repurchase cycle, and training the cycle prediction model to be trained based on the first loss function, thereby obtaining a trained cycle prediction model.
[0135] The example embodiments of the present disclosure provide a training method for a cycle prediction model based on an Attention mechanism. On the one hand, the method is designed for the unique features of the repurchase cycle portrait: in addition to conventional features such as cid4 sequence, cid3 sequence, cid2 sequence, cid1 sequence and user portrait features, purchase quantity sequence and time position sequence are also added to accurately predict the repurchase interval and solve the impact of similar products and stockpiling problems on the repurchase cycle; on the other hand, in order to enhance the generalization ability, a training method is also adopted in which the next repurchase interval is randomly predicted in the user's historical purchase sequence as the training target, thereby improving the fitting ability of the model.
[0136] The exemplary embodiment of the present disclosure also provides a cycle prediction method. Figure 7 As shown, the cycle prediction method may include the following steps:
[0137] Step S710, acquiring target user data of the target user according to the user identifier of the target user, and calculating the target order behavior sequence of the target user according to the target user data;
[0138] Step S720, determining a target item from the target order, and inputting the target item, the target order behavior sequence, and the target user portrait included in the target user data into the trained cycle prediction model to obtain the target user's repurchase cycle for the target item; wherein the trained cycle prediction model is obtained by training the cycle prediction model to be trained using the aforementioned cycle prediction model training method;
[0139] Step S730, based on the repurchase cycle and the last purchase time of the target item by the target user, calculate the next recommendation time of the target item, and recommend the target item based on the next recommendation time.
[0140] Figure 7 In the cycle prediction method shown, on the one hand, since the target order behavior sequence is taken into account in the cycle prediction process, the problem of low accuracy of the prediction result of the repurchase cycle in the prior art due to not taking the user's target order behavior sequence into consideration is solved; on the other hand, the next recommendation time of the target item can be calculated based on the repurchase cycle and the target user's last purchase time and purchase quantity of the target item, and the target item can be recommended based on the next recommendation time, thereby improving the accuracy of the recommendation results and enhancing the user experience.
[0141] The exemplary embodiment of the present disclosure also provides a training device for a period prediction model. Figure 8 As shown, the training device of the cycle prediction model may include a first calculation module 810, a data set construction module 820, a repurchase cycle prediction module 830 and a cycle prediction model training module 840. Among them:
[0142] The first calculation module 810 may be used to calculate the historical order behavior sequence of the historical user and the actual repurchase cycle of the historical items included in the historical order according to the historical user data;
[0143] The data set construction module 820 may be used to construct a data set according to the historical items, the actual repurchase cycle, the historical order behavior sequence, and the historical user portraits in the historical user data;
[0144] The repurchase cycle prediction module 830 may be used to input the historical items, historical order behavior sequences, and historical user portraits included in the data set into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items;
[0145] The cycle prediction model training module 840 can be used to construct a first loss function based on the actual repurchase cycle and the predicted repurchase cycle in the data set, and use the first loss function to train the cycle prediction model to be trained to obtain a trained cycle prediction model.
[0146] In an exemplary embodiment of the present disclosure, calculating the historical order behavior sequence of the historical user according to the historical user data includes:
[0147] Acquire historical user data of the historical user within a first preset time period according to the user identifier of the historical user;
[0148] Extracting historical items included in the historical user data, and aggregating the historical items according to the category identifications to which the historical items belong, to obtain categories of different levels to which the historical items belong;
[0149] Performing a sum operation on the quantity of the historical items to obtain the purchase quantity of the historical items, and calculating the time location feature of the historical items according to the start purchase time and the end purchase time of the historical items;
[0150] The historical order behavior sequence is generated according to the categories of different levels to which the historical items belong, the purchase quantity, and the time and location characteristics.
[0151] In an exemplary embodiment of the present disclosure, calculating the actual repurchase period of historical items included in historical orders according to historical user data includes:
[0152] Extracting the first purchase time node of the historical items included in the historical orders and the previous purchase time node corresponding to the first purchase time node from the historical user data;
[0153] Calculating a current purchase cycle of the historical item according to the first purchase time node and a previous purchase time node corresponding to the first purchase time node;
[0154] The current purchase cycle is normalized to obtain the actual repurchase cycle of the historical item.
[0155] In an exemplary embodiment of the present disclosure, the period prediction model to be trained includes a first word embedding layer, a second word embedding layer, an attention mechanism layer, and a logistic regression layer;
[0156] The historical items, historical order behavior sequences and historical user portraits included in the data set are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items, including:
[0157] Using the first word embedding layer to encode the historical items and historical order behavior sequences to obtain item features and behavior sequence features, and using the second word embedding layer to encode the historical user portraits to obtain user features;
[0158] Using the attention mechanism layer to process the behavior sequence features and the item features, obtaining a repurchase behavior vector of the historical user for the historical item;
[0159] The logistic regression layer is used to perform logistic regression processing on the repurchase behavior vector, item features, and user features to obtain the predicted repurchase cycle.
[0160] In an exemplary embodiment of the present disclosure, the behavior sequence feature and the item feature are processed to obtain a repurchase behavior vector of the historical user for the historical item, including:
[0161] Performing a first operation on the behavior sequence feature and the item feature to obtain a first output result; wherein the first operation includes an inner product operation and a subtraction operation;
[0162] splicing the first output result, the behavior sequence feature, and the item feature to obtain a first splicing result;
[0163] Processing the first splicing result using a first multi-layer fully connected neural network included in the attention mechanism layer to obtain an attention weight of the historical item;
[0164] The attention weight and the item feature are weightedly summed to obtain the repurchase behavior vector.
[0165] In an exemplary embodiment of the present disclosure, the training device of the period prediction model may further include:
[0166] The encoding module can be used to encode the categories of different levels, purchase quantities and time location features of the historical items based on Word2vec to obtain a first sub-vector, a second sub-vector and a third sub-vector;
[0167] A feature concatenation module may be used to concatenate the first sub-vector, the second sub-vector and the third sub-vector to obtain the order sequence of the historical user, and to mask any sub-vector in the order sequence to obtain a sequence to be processed;
[0168] A loss function construction module can be used to predict the sequence to be processed by using the Bert model to be trained to obtain a first prediction result, and construct a second loss function for the Bert model by using the first prediction result and the masked sub-vector;
[0169] The Bert model training module can be used to train the Bert model to be trained using the second loss function, and integrate the trained Bert model into the second word embedding layer to obtain the first word embedding layer.
[0170] In an exemplary embodiment of the present disclosure, the Bert model includes a plurality of Transformer models;
[0171] The sequence to be processed is predicted by the Bert model to be trained to obtain a first prediction result, including:
[0172] Input the sequence to be processed into a first Transformer model to generate a first text semantic vector, and input the first text semantic vector into other Transformer models to obtain text semantic vectors corresponding to the other Transformer models; wherein, in the other Transformer models, the output of the previous Transformer model is the input of the next Transformer model corresponding thereto;
[0173] The importance of each Transformer model to the sequence to be processed is calculated, and the first prediction result is obtained according to each importance and each text semantic vector.
[0174] In an exemplary embodiment of the present disclosure, performing logistic regression processing on the repurchase behavior vector, item features, and user features to obtain the predicted repurchase cycle includes:
[0175] The repurchase behavior vector, item features, and user features are spliced and tiled to obtain a second splicing result;
[0176] Projecting the second concatenation result into a high-dimensional space using a second multi-layer fully connected neural network included in the logistic regression layer to obtain a high-dimensional projection result;
[0177] Nonlinear activation is performed on the high-dimensional projection result to obtain the predicted repurchase cycle.
[0178] The exemplary embodiment of the present disclosure also provides a period prediction device. Fig. 9 As shown, the cycle prediction device may include a second calculation module 910, a repurchase cycle prediction module 920, and an item recommendation module 930. Among them:
[0179] The second calculation module 910 may be used to obtain target user data of the target user according to the user identifier of the target user, and calculate the target order behavior sequence of the target user according to the target user data;
[0180] The repurchase cycle prediction module 920 may be used to determine a target item from the target order, and input the target item, the target order behavior sequence, and the target user portrait included in the target user data into a trained cycle prediction model to obtain the target user's repurchase cycle for the target item; wherein the trained cycle prediction model is obtained by training the cycle prediction model to be trained using any of the cycle prediction model training methods described above;
[0181] The item recommendation module 930 may be used to calculate the next recommendation time of the target item based on the repurchase cycle and the last purchase time of the target item by the target user, and recommend the target item based on the next recommendation time.
[0182] The specific details of the training device of the above-mentioned period prediction model and each module in the period prediction device have been described in detail in the corresponding training method of the period prediction model and the period prediction method, so they will not be repeated here.
[0183] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0184] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0185] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0186] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0187] Refer to the following Fig.10 The electronic device 1000 according to this embodiment of the present disclosure is described. Fig.10 The electronic device 1000 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0188] like Fig.10 As shown, the electronic device 1000 is in the form of a general computing device. The components of the electronic device 1000 may include, but are not limited to: the at least one processing unit 1010, the at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), and a display unit 1040.
[0189] The storage unit stores program codes, which can be executed by the processing unit 1010, so that the processing unit 1010 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 1010 can perform the following steps: Figure 1 Step S110 shown in: Calculate the historical order behavior sequence of historical users and the actual repurchase cycle of historical items included in the historical orders based on historical user data; Step S120: Construct a data set based on the historical items, the actual repurchase cycle, the historical order behavior sequence and the historical user portraits in the historical user data; Step S130: Input the historical items, historical order behavior sequence and historical user portraits included in the data set into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items; Step S140: Construct a first loss function based on the actual repurchase cycle and the predicted repurchase cycle in the data set, and use the first loss function to train the cycle prediction model to be trained to obtain a trained cycle prediction model.
[0190] The processing unit 1010 may perform the following operations: Figure 7Step S710 shown in: acquiring target user data of the target user according to the user identifier of the target user, and calculating the target order behavior sequence of the target user according to the target user data; Step S720: determining the target item from the target order, and inputting the target item, the target order behavior sequence and the target user portrait included in the target user data into the trained cycle prediction model to obtain the repurchase cycle of the target user for the target item; wherein the trained cycle prediction model is obtained by training the cycle prediction model to be trained using the training method of the cycle prediction model described above; Step S730: calculating the next recommendation time of the target item based on the repurchase cycle and the last purchase time of the target user for the target item, and recommending the target item based on the next recommendation time.
[0191] The storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 10201 and / or a cache storage unit 10202 , and may further include a read-only storage unit (ROM) 10203 .
[0192] The storage unit 1020 may also include a program / utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0193] Bus 1030 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0194] The electronic device 1000 may also communicate with one or more external devices 1100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or may communicate with any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1050. Furthermore, the electronic device 1000 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1060. As shown, the network adapter 1060 communicates with other modules of the electronic device 1000 via a bus 1030. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0195] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0196] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of the present specification.
[0197] According to the program product for implementing the above method in the embodiment of the present disclosure, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0198] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0199] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0200] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0201] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0202] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0203] Other embodiments of the present disclosure will be readily apparent to those skilled in the art after considering the specification and practicing the inventions invented herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not invented by the present disclosure. The specification and examples are to be considered merely exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A training method for a period prediction model, It is characterized in that include: Calculating the historical order behavior sequence of the historical user and the actual repurchase cycle of the historical items included in the historical orders according to the historical user data; wherein the historical order behavior sequence is obtained according to the category, purchase quantity, and purchase time characteristics of the historical items in the historical user data; Constructing a data set based on the historical items, the actual repurchase cycle, the historical order behavior sequence, and the historical user portraits in the historical user data; Inputting the historical items, historical order behavior sequences, and historical user portraits included in the data set into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items; A first loss function is constructed according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and the cycle prediction model to be trained is trained using the first loss function to obtain a trained cycle prediction model.
2. The training method of the cycle prediction model according to claim 1, It is characterized in that Calculate the historical order behavior sequence of historical users based on historical user data, including: Acquire historical user data of the historical user within a first preset time period according to the user identifier of the historical user; Extracting historical items included in the historical user data, and aggregating the historical items according to the category identifications to which the historical items belong, to obtain categories of different levels to which the historical items belong; Performing a sum operation on the quantity of the historical items to obtain the purchase quantity of the historical items, and calculating the time location feature of the historical items according to the start purchase time and the end purchase time of the historical items; The historical order behavior sequence is generated according to the categories of different levels to which the historical items belong, the purchase quantity, and the time and location characteristics.
3. The training method of the cycle prediction model according to claim 1, It is characterized in that The actual repurchase cycle of historical items included in historical orders is calculated based on historical user data, including: Extracting the first purchase time node of the historical items included in the historical orders and the previous purchase time node corresponding to the first purchase time node from the historical user data; Calculating a current purchase cycle of the historical item according to the first purchase time node and a previous purchase time node corresponding to the first purchase time node; The current purchase cycle is normalized to obtain the actual repurchase cycle of the historical item.
4. The training method of the cycle prediction model according to claim 1, It is characterized in that The cycle prediction model to be trained includes a first word embedding layer, a second word embedding layer, an attention mechanism layer and a logistic regression layer; The historical items, historical order behavior sequences and historical user portraits included in the data set are input into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items, including: Using the first word embedding layer to encode the historical items and historical order behavior sequences to obtain item features and behavior sequence features, and using the second word embedding layer to encode the historical user portraits to obtain user features; Using the attention mechanism layer to process the behavior sequence features and the item features, obtaining a repurchase behavior vector of the historical user for the historical item; The logistic regression layer is used to perform logistic regression processing on the repurchase behavior vector, item features, and user features to obtain the predicted repurchase cycle.
5. The training method of the cycle prediction model according to claim 4, It is characterized in that Processing the behavior sequence features and the item features to obtain a repurchase behavior vector of the historical user for the historical item includes: Performing a first operation on the behavior sequence feature and the item feature to obtain a first output result; wherein the first operation includes an inner product operation and a subtraction operation; splicing the first output result, the behavior sequence feature, and the item feature to obtain a first splicing result; Processing the first splicing result using a first multi-layer fully connected neural network included in the attention mechanism layer to obtain an attention weight of the historical item; The attention weight and the item feature are weightedly summed to obtain the repurchase behavior vector.
6. The training method of the cycle prediction model according to claim 4, It is characterized in that The training method of the cycle prediction model also includes: Based on Word2vec, the categories of different levels, the purchase quantity, and the time location features of the historical items are encoded to obtain a first sub-vector, a second sub-vector, and a third sub-vector; Perform feature concatenation on the first sub-vector, the second sub-vector, and the third sub-vector to obtain the order sequence of the historical user, and perform masking on any sub-vector in the order sequence to obtain a sequence to be processed; Predicting the sequence to be processed by using the Bert model to be trained to obtain a first prediction result, and constructing a second loss function for the Bert model by using the first prediction result and the masked sub-vector; The Bert model to be trained is trained using the second loss function, and the trained Bert model is integrated into the second word embedding layer to obtain the first word embedding layer.
7. The training method of the period prediction model according to claim 6, It is characterized in that The Bert model includes multiple Transformer models; The sequence to be processed is predicted by the Bert model to be trained to obtain a first prediction result, including: Input the sequence to be processed into a first Transformer model to generate a first text semantic vector, and input the first text semantic vector into other Transformer models to obtain text semantic vectors corresponding to the other Transformer models; wherein, in the other Transformer models, the output of the previous Transformer model is the input of the next Transformer model corresponding thereto; The importance of each Transformer model to the sequence to be processed is calculated, and the first prediction result is obtained according to each importance and each text semantic vector.
8. The training method of the cycle prediction model according to claim 4, It is characterized in that Performing logistic regression processing on the repurchase behavior vector, item features, and user features to obtain the predicted repurchase cycle includes: The repurchase behavior vector, item features, and user features are spliced and tiled to obtain a second splicing result; Projecting the second concatenation result into a high-dimensional space using a second multi-layer fully connected neural network included in the logistic regression layer to obtain a high-dimensional projection result; Nonlinear activation is performed on the high-dimensional projection result to obtain the predicted repurchase cycle.
9. A cycle prediction method, It is characterized in that include: According to the user identifier of the target user, target user data of the target user is acquired, and a target order behavior sequence of the target user is calculated according to the target user data; Determine a target item from the target order, and input the target item, the target order behavior sequence, and the target user portrait included in the target user data into a trained cycle prediction model to obtain a repurchase cycle of the target user for the target item; wherein the trained cycle prediction model is obtained by training the cycle prediction model to be trained using the cycle prediction model training method according to any one of claims 1 to 8; Based on the repurchase cycle and the last purchase time of the target item by the target user, the next recommendation time of the target item is calculated, and the target item is recommended based on the next recommendation time.
10. A training device for a cycle prediction model, It is characterized in that include: A first calculation module is used to calculate the historical order behavior sequence of the historical user and the actual repurchase cycle of the historical items included in the historical order according to the historical user data; wherein the historical order behavior sequence is obtained according to the category, purchase quantity, and purchase time characteristics of the historical items in the historical user data; A data set construction module, used to construct a data set based on the historical items, actual repurchase cycles, historical order behavior sequences, and historical user portraits in the historical user data; A repurchase cycle prediction module is used to input the historical items, historical order behavior sequences and historical user portraits included in the data set into the cycle prediction model to be trained to obtain the predicted repurchase cycle of the historical items; The cycle prediction model training module is used to construct a first loss function according to the actual repurchase cycle and the predicted repurchase cycle in the data set, and use the first loss function to train the cycle prediction model to be trained to obtain a trained cycle prediction model.
11. A cycle prediction device, It is characterized in that include: A second calculation module is used to obtain target user data of the target user according to the user identifier of the target user, and calculate the target order behavior sequence of the target user according to the target user data; A repurchase cycle prediction module, used to determine a target item from the target order, and input the target item, the target order behavior sequence, and the target user portrait included in the target user data into a trained cycle prediction model to obtain the target user's repurchase cycle for the target item; wherein the trained cycle prediction model is obtained by training the cycle prediction model to be trained using the cycle prediction model training method according to any one of claims 1 to 8; The item recommendation module is used to calculate the next recommendation time of the target item based on the repurchase cycle and the last purchase time of the target item by the target user, and recommend the target item based on the next recommendation time.
12. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the training method of the period prediction model described in any one of claims 1 to 8 and the period prediction method described in claim 9 are implemented.
13. An electronic device, It is characterized in that include: processor; as well as A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the training method of the period prediction model described in any one of claims 1-8 and the period prediction method described in claim 9 by executing the executable instructions.
Citation Information
Patent Citations
Commodity recommendation list pushing method and a commodity recommendation list pushing system
CN109872220A
E-commerce platform user repeated purchase behavior prediction method
CN110956497A