Training method and device of recommendation model based on bidirectional transformers and recommendation method

By using a bidirectional Transformers-based recommendation model and employing a training method based on masked sequences and loss functions, the performance limitations of unidirectional Transformers in sequence recommendation models are addressed, resulting in more efficient user behavior modeling and accurate object recommendation.

CN115221960BActive Publication Date: 2026-01-02JIANGSU YEYOO E-CLOUD SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210843571.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-18
Publication Date
2026-01-02
Estimated Expiration
2042-07-18

AI Technical Summary

Technical Problem

Existing recommendation methods based on one-way Transformers cannot effectively handle the uncertainty of user behavior and the perturbation of sequence order in sequence recommendation models, resulting in insufficient model performance.

Method used

A recommendation model based on bidirectional Transformers is adopted. Multiple occlusion sequences are generated by randomly occluding the user's historical interaction sequences. The model is trained by combining the loss function of the cloze test task and the contrastive learning loss function. The attention mechanism of bidirectional Transformers is used to model from two directions and fuse contextual information.

Benefits of technology

This improved the robustness and noise resistance of the recommendation model, and enhanced the accuracy of recommendations for target users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115221960B_ABST
    Figure CN115221960B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a training method and device of a recommendation model based on bidirectional Transformers and a recommendation method. The training method comprises: obtaining historical interaction sequences of a plurality of users; randomly masking objects in the historical interaction sequence of each user to generate a plurality of different masked sequences; inputting the masked sequences of the plurality of users into the recommendation model for processing to obtain a predicted vector representation of each masked object and each masked sequence of each user; determining completion of a fill-in-the-blank task loss information according to the vector representations of all the masked objects in the masked sequences of the plurality of users; determining a contrastive learning loss information according to the vector representations of the masked sequences of the plurality of users; and training the recommendation model according to the completion of the fill-in-the-blank task loss information and the contrastive learning loss information. Based on the training method, the accuracy of the recommendation model in recommending objects to a target user can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of computer technology, and in particular to a training method of a recommendation model based on bidirectional Transformers, a training device and a recommendation method. BACKGROUND

[0002] Sequence recommendation methods aim to study the dynamic interest of users in historical interaction sequences and predict the items that users may be interested in the future. Traditional methods based on Markov chain assumption believe that the next item of interest of a user is only related to the previous few items. With the advancement of deep learning technology, convolutional neural networks and recurrent neural networks are also used as sequence encoders to generate sequence representations. The limitation of these methods is that convolutional neural networks can only capture local features, while recurrent neural networks are difficult to parallelize. Recently, the powerful architecture of Transformers model has been widely used in many research fields. Unlike convolutional neural networks and recurrent neural networks, Transformers model can automatically assign different attention weights to items at different positions, which enables Transformers to capture global and local information and parallelize computation. Therefore, many sequence recommendation models use Transformers as sequence encoders to capture the association between items through self-attention mechanism and obtain high-quality sequence representations.

[0003] Existing works are all based on unidirectional Transformers to design recommendation models. The limitation of unidirectional Transformers is that it can only consider information in user historical sequences from left to right. However, in the real world, user behavior does not necessarily follow a strict left-to-right sequence. Many external factors can disturb the original sequence order, and there are also skip behaviors in sequence patterns. Therefore, the recommendation model based on unidirectional Transformers still needs to be improved in terms of model performance. SUMMARY

[0004] An object of embodiments of the present application is to address at least the above problems and / or disadvantages and provide at least the advantages described later.

[0005] Embodiments of the present application provide a training method of a recommendation model based on bidirectional Transformers, a training device and a recommendation method, which can improve the performance of the recommendation model and improve the accuracy of the recommendation model in recommending objects to target users.

[0006] In a first aspect, a training method of a recommendation model based on bidirectional Transformers is provided, comprising:

[0007] obtaining historical interaction sequences of a plurality of users, wherein each historical interaction sequence of each user comprises a sequence of objects interacted by each user;

[0008] randomly masking the objects in each historical interaction sequence of each user to generate a plurality of different masked sequences for each user;

[0009] inputting the masked sequences of the plurality of users into a recommendation model based on bidirectional Transformers for processing, to predict the masked objects in each masked sequence of each user from all the objects interacted by the plurality of users, and to obtain vector representations of each masked object in each masked sequence of each user and vector representations of each masked sequence of each user;

[0010] determining completion task loss information based on the vector representations of all the masked objects in the masked sequences of the plurality of users according to a preset completion task loss function;

[0011] determining contrastive learning loss information based on the vector representations of the masked sequences of the plurality of users according to a preset contrastive learning loss function;

[0012] training the recommendation model according to the completion task loss information and the contrastive learning loss information.

[0013] Optionally, the randomly masking the objects in each historical interaction sequence of each user to generate a plurality of different masked sequences for each user comprises:

[0014] if the length of the historical interaction sequence of any one of the plurality of users exceeds a first preset length, scanning the historical interaction sequence of the corresponding user using a sliding window of the first preset length to divide the historical interaction sequence of the corresponding user into a plurality of subsequences;

[0015] randomly masking the objects in each subsequence of the corresponding user to generate a plurality of different masked sequences for each subsequence of the corresponding user.

[0016] Optionally, the determining completion task loss information based on the vector representations of all the masked objects in the masked sequences of the plurality of users according to a preset completion task loss function comprises:

[0017] determining a probability of each masked object in each masked sequence of each user according to the vector representation of each masked object in each masked sequence of each user, wherein the probability of each masked object in each masked sequence of each user is a probability that each masked object in each masked sequence of each user belongs to a real object in each masked sequence of each user;

[0018] The complete-type fill-in-the-blank task loss information is determined based on a preset complete-type fill-in-the-blank task loss function according to probabilities of all the hidden objects in the hidden sequences of the multiple users.

[0019] Optionally, the contrastive learning loss information is determined based on the vector representations of the hidden sequences of the multiple users according to a preset contrastive learning loss function, including:

[0020] The contrastive learning loss information is determined according to differences between the vector representations of different hidden sequences with the same sequence source of the same user in the multiple users and differences between the vector representations of different hidden sequences of different users.

[0021] Optionally, the recommendation model is trained according to the complete-type fill-in-the-blank task loss information and the contrastive learning loss information, including:

[0022] The weights of the complete-type fill-in-the-blank task loss information and the contrastive learning loss information are updated in each iteration based on a preset weight dynamic re-estimation strategy;

[0023] In each iteration, the complete-type fill-in-the-blank task loss information and the contrastive learning loss information determined in each iteration are weighted and summed to obtain joint loss information in each iteration according to the updated weights of the complete-type fill-in-the-blank task loss information and the contrastive learning loss information;

[0024] The parameters of the recommendation model are adjusted according to the joint loss information of each iteration.

[0025] Optionally, the weights of the complete-type fill-in-the-blank task loss information and the contrastive learning loss information are updated in each iteration based on a preset weight dynamic re-estimation strategy, including:

[0026] The weights of the complete-type fill-in-the-blank task loss information and the contrastive learning loss information are updated in each iteration according to the following formula:

[0027]

[0028]

[0029] wherein θ n+1 is the weight of the contrastive learning loss information in the n+1th iteration, θ n is the weight of the contrastive learning loss information in the nth iteration, the initial value of θ is set to 0, α is a learning rate hyperparameter, λ is a proportional conversion factor, and respectively represent the complete-type fill-in-the-blank task loss information and the contrastive learning loss information determined in the n+1th iteration;

[0030] In each iteration, the complete blank task loss information and the contrastive learning loss information determined in each iteration are weighted and summed according to the updated weights of the complete blank task loss information and the contrastive learning loss information, to obtain the joint loss information in each iteration, comprising:

[0031] In each iteration, the complete blank task loss information and the contrastive learning loss information determined in each iteration are weighted and summed according to the updated weights of the complete blank task loss information and the contrastive learning loss information, to obtain the joint loss information in each iteration, according to the following formula:

[0032]

[0033] Wherein, The joint loss information in the n+1 iteration is represented.

[0034] In a second aspect, a training device of a bidirectional Transformers-based recommendation model is provided, characterized in that it comprises:

[0035] A user sequence acquisition module is configured to acquire historical interaction sequences of a plurality of users, wherein each user's historical interaction sequence comprises a sequence of objects interacted by each user.

[0036] A masking sequence generation module is configured to randomly mask the objects in each user's historical interaction sequence to generate a plurality of different masking sequences for each user.

[0037] A vector representation generation module is configured to input all masking sequences of the plurality of users into a bidirectional Transformers-based recommendation model for processing, to predict the masked objects in each masking sequence of each user from all objects interacted by the plurality of users, to obtain the vector representation of each masked object in each masking sequence of each user and the vector representation of each masking sequence of each user.

[0038] A complete blank task loss information determination module is configured to determine the complete blank task loss information based on the vector representation of all masked objects in the plurality of masking sequences of each user according to a preset complete blank task loss function.

[0039] A contrastive learning loss information determination module is configured to determine the contrastive learning loss information based on the vector representation of all masking sequences of the plurality of users according to a preset contrastive learning loss function.

[0040] A recommendation model training module is configured to train the recommendation model according to the complete blank task loss information and the contrastive learning loss information.

[0041] In a third aspect, a recommendation method of a bidirectional Transformers-based recommendation model is provided, comprising:

[0042] obtaining a historical interaction sequence of a target user from the historical interaction sequences of the plurality of users;

[0043] inputting the historical interaction sequence of the target user into the trained recommendation model for processing, and predicting at least one target object from all objects interacted by the plurality of users for recommendation to the target user.

[0044] Optionally, the method further comprises:

[0045] if the length of the historical interaction sequence of the target user exceeds a second preset length, scanning the historical interaction sequence of the target user using a sliding window of the second preset length, and selecting a last target sub-sequence from the historical interaction sequence of the target user;

[0046] the inputting the historical interaction sequence of the target user into the trained recommendation model for processing, and predicting at least one target object from all objects interacted by the plurality of users for recommendation to the target user, comprises:

[0047] inputting the last target sub-sequence of the target user into the trained recommendation model for processing, and predicting at least one target object from all objects interacted by the plurality of users for recommendation to the target user.

[0048] In a fourth aspect, a recommendation device based on a bidirectional Transformers-based recommendation model is provided, comprising:

[0049] a target user sequence acquisition module configured to obtain a historical interaction sequence of a target user from the historical interaction sequences of the plurality of users;

[0050] a target object recommendation module configured to input the historical interaction sequence of the target user into the trained recommendation model for processing, and predict at least one target object from all objects interacted by the plurality of users for recommendation to the target user.

[0051] In a fifth aspect, an electronic device is provided, comprising at least one processor and a memory connected to the at least one processor in communication, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to cause the at least one processor to perform the method.

[0052] In a sixth aspect, a storage medium is provided, and the storage medium has stored thereon a computer program, and the computer program is executed by a processor to implement the method.

[0053] The embodiments of the present application at least have the following beneficial effects:

[0054] The training method of the recommendation model based on the bidirectional Transformers, the training device and the recommendation method are provided. The training method comprises the following steps: first, obtaining historical interaction sequences of a plurality of users; wherein, the historical interaction sequence of each user comprises a sequence of objects interacted by each user, randomly masking the objects in the historical interaction sequence of each user to generate a plurality of different masked sequences of each user, then inputting the masked sequences of the plurality of users into the recommendation model based on the bidirectional Transformers for processing, predicting the masked objects in each masked sequence of each user from all the objects interacted by each user, obtaining the vector representation of each masked object in each masked sequence of each user predicted and the vector representation of each masked sequence of each user, then determining the fill-in-the-blank task loss information according to the vector representation of all the masked objects in the masked sequences of the plurality of users based on the preset fill-in-the-blank task loss function, determining the contrast learning loss information according to the vector representation of the masked sequences of the plurality of users based on the preset contrast learning loss function, and finally training the recommendation model according to the fill-in-the-blank task loss information and the contrast learning loss information. Based on the training method, the objects in the historical interaction sequence of each user are randomly masked to generate a masked sequence, and the masked sequences of a plurality of users are input into the recommendation model based on the bidirectional Transformers for processing. The recommendation model based on the bidirectional Transformers can model the objects in the sequence from two directions, and can fuse the context information from two directions. The recommendation model is trained by combining the fill-in-the-blank task and the contrast learning method, which can improve the robustness and noise resistance performance of the recommendation model, and improve the accuracy of object recommendation for target users.

[0055] Other advantages, objects, and features of the embodiments of the present application will be understood by those skilled in the art from the following description in conjunction with the accompanying drawings. Some of the advantages, objects, and features will also be understood by those skilled in the art from the study and practice of the embodiments of the present application. BRIEF DESCRIPTION OF DRAWINGS

[0056] Figure 1 A flowchart of the training method of the recommendation model based on the bidirectional Transformers provided by an embodiment of the present application is shown in the figure;

[0057] Figure 2 A schematic diagram of the recommendation model based on the bidirectional Transformers provided by another embodiment of the present application is shown in the figure;

[0058] Figure 3 A flowchart of a recommendation method of a bidirectional Transformers-based recommendation model provided for an embodiment of the present application;

[0059] Figure 4 A structural schematic diagram of a training device of a bidirectional Transformers-based recommendation model provided for an embodiment of the present application;

[0060] Figure 5 A structural schematic diagram of a recommendation device of a bidirectional Transformers-based recommendation model provided for an embodiment of the present application;

[0061] Figure 6 A structural schematic diagram of an electronic device provided for an embodiment of the present application. DETAILED DESCRIPTION

[0062] The embodiments of the present application will be further described in detail below with reference to the accompanying drawings, so that those skilled in the art can implement the embodiments according to the description in the specification.

[0063] Figure 1 A flowchart of a training method of a bidirectional Transformers-based recommendation model provided for an embodiment of the present application, executed by a system having processing capability, a server device or a recommendation device based on a quaternion graph convolutional neural network. The method comprises:

[0064] Step 110, obtaining a plurality of historical interaction sequences of users; wherein the historical interaction sequence of each user comprises a sequence of objects interacted by each user.

[0065] Here, the historical interaction sequence of each user can include at least one object that has an interaction relationship with each user, and accordingly, the historical interaction sequence of a plurality of users can include all objects that have an interaction relationship with a plurality of users. The objects corresponding to different users can be completely the same, partially the same or completely different. The interaction relationship between the user and the object is the relationship generated based on the interaction behavior of the user to the object. The interaction behavior can be the purchase behavior of the user to a certain commodity, the reading behavior of the user to a certain news, the dining behavior of the user in a certain restaurant, etc.

[0066] Specifically, in the sequence recommendation, define for a user set, for an item (i.e. object) set, for an interaction sequence of the user sorted according to the interaction time, wherein The items that the user interacts at the first timestamp. The task of sequential recommendation is to predict the next item that the user is likely to be interested in, and can be formally defined as the probability that the user generates all the items that the user is likely to interact at the next timestamp:

[0067] In actual applications, the interactions of different users with the same object can reflect that there can be the same preferences between different users. Therefore, in the embodiments of the present application, based on the interactions of different users with the same object, the preferences of different users for the same object can be captured, and the accuracy of the recommendation model for object recommendation for a target user is improved.

[0068] In step 120, the objects in the historical interaction sequence of each user are randomly masked to generate a plurality of different masked sequences for each user.

[0069] In this step, the objects in the historical interaction sequence of each user can be masked at a preset proportion, that is, the proportion of the masked objects in each masked sequence of different users and each masked sequence of the same user is the same. For different masked sequences of the same user, the masked objects are different, thereby generating a plurality of different masked sequences.

[0070] In some embodiments, the objects in the historical interaction sequence of each user can be randomly masked in each iteration to generate a plurality of different masked sequences for each user.

[0071] Figure 2 A schematic diagram of a recommendation model based on bidirectional Transformers in an embodiment of the present application is shown. Specifically, for each iteration step, given a sequence s u m masked sequences are generated using different random seeds In each masked sequence, a proportion ρ of all items in the sequence will be randomly replaced with a masking flag [masking], and the set of masked item position indices is denoted as

[0072] In some embodiments, the random masking of the objects in the historical interaction sequence of each user to generate a plurality of different masked sequences for each user comprises: if the length of the historical interaction sequence of any one of the plurality of users exceeds a first preset length, a sliding window of the first preset length is used to scan the historical interaction sequence of the corresponding user, and the historical interaction sequence of the corresponding user is divided into a plurality of subsequences; the objects in each subsequence of the corresponding user are randomly masked to generate a plurality of different masked sequences for each subsequence of the corresponding user.

[0073] Due to limitations in the recommendation model's structure, in some cases, when a user's historical interaction sequence exceeds a first preset length, the masking sequence generated from the historical interaction sequence cannot be directly input into the recommendation model for processing. To retain all of the user's training data and improve the recommendation model's performance, a sliding window can be used to divide the user's historical interaction sequence into several sub-sequences, and then multiple different masking sequences can be generated based on these sub-sequences. Specifically, the first preset length can be set according to the maximum sequence length of the recommendation model. Specifically, if the maximum sequence length of the recommendation model is set to T, then the first preset length can be set to T. For any long sequence s... u If the sequence length |s u |>T, for s u A sliding window of size T is used to further divide the user sequence into finer-grained parts in order to preserve all training data.

[0074] In other cases, if the target user's historical interaction sequence is shorter than the first preset length, instead of using a sliding window to divide the historical interaction sequence, "0"s can be added to the beginning of the historical interaction sequence to make its length reach the first preset length. If the target user's historical interaction sequence is equal to the first preset length, then there is no need to divide or pad the historical interaction sequence; multiple occlusion sequences can be generated directly from the historical interaction sequence.

[0075] Here, each subsequence of a user can be considered an independent historical interaction sequence for that user. When training the recommendation model, masking sequences generated from different subsequences of the same user are not compared and learned. Specifically, when training the recommendation model based on the historical interaction sequences of all users, the masking sequences generated from different subsequences of the same user can be separated into different training batches.

[0076] Step 130: Input the occlusion sequences of the multiple users into the recommendation model based on bidirectional Transformers for processing. Predict the occluded object in each occlusion sequence of each user from all objects interacted by the multiple users, and obtain the vector representation of each occluded object in each occlusion sequence of each user and the vector representation of each occlusion sequence of each user.

[0077] Existing works are all based on unidirectional Transformers to design recommendation models. The limitation of unidirectional Transformers is that it can only consider the information in the user history sequence from left to right. But in the real world, user behavior does not necessarily follow a strict left-to-right sequence. Many external factors can disturb the original sequence order, and there are also skip behaviors in the sequence pattern. Therefore, the recommendation model based on unidirectional Transformers still needs to be improved in terms of model performance. Compared with unidirectional Transformers, the attention mechanism of bidirectional Transformers can model objects from two directions and fuse context information from two directions, which makes bidirectional Transformers have better performance than unidirectional Transformers.

[0078] Through the processing of the recommendation model based on bidirectional Transformers, the masked objects in each masking sequence of each user can be predicted from all the objects interacted by multiple users, and the vector representation of each masked object in each masking sequence of each user and the vector representation of each masking sequence of each user are obtained. Figure 2 In the middle, for each masking sequence , the vector representation of the masked object is given by the L-layer bidirectional Transformers module, for example, the vector representation of the masked object in the 2nd masking sequence h 2,2 and h T,2 . After that, the vector representations of the objects in each masking sequence (including the unmasked objects and the predicted masked objects) can be spliced to obtain the vector representation of the m masking sequences

[0079] Specifically, Figure 3 The structure of the recommendation model based on bidirectional Transformers is shown. The recommendation model based on bidirectional Transformers includes two parts: a basic module and a bidirectional Transformers module.

[0080] In the basic module, its embedding layer is composed of an item embedding matrix and a position embedding matrix . For an item in any masking sequence, its embedding vector is calculated as follows:

[0081]

[0082] Where e i ∈E, p t ∈P represent the initial vector of the item and the position of the item in the user's history interaction sequence s uembedding vectors of the items in the sequence, where i represents the item in the item set of all users .

[0083] After the embedding layer, for any masking sequence, the embedding vectors of all items in the masking sequence are stacked to form a matrix as the representation of the entire masking sequence, that is, H 0 is input to the bidirectional Transformers module with L layers for processing, and the calculation formula is as follows:

[0084]

[0085] After the processing of the bidirectional Transformers module with L layers, the item hidden vector representation h t of the position t of any masking sequence in the user is output. For any masking sequence, the masked object in the masking sequence can be predicted, and the probability that the predicted masked object belongs to the real object can be calculated according to the hidden vector representation of the predicted masked object, which can be called a candidate item from the item set.

[0086] The hidden vector representation h t of the item in any masking sequence is converted into the probability distribution P(v) that the item belongs to the real item, and the calculation formula is as follows:

[0087] P(v)=W P h t +b P

[0088] wherein, is a weight matrix, is a bias matrix.

[0089] The bidirectional Transformers module is stacked by multiple Transformer modules, each of which includes a multi-head self-attention module and a forward propagation network, and the multiple Transformer modules are stacked to form a deep network. The number of layers of the bidirectional Transformers module can be determined according to the data amount of the training data and the sequence recommendation task, and the embodiments of the present application do not make specific limitations thereto.

[0090] The multi-head self-attention module can capture context information from multiple different subspaces. Given the hidden vector representation of the l-th layer and the maximum sequence length T. The calculation formula of the multi-head self-attention module is as follows:

[0091] MH(H l) = concat(head1; head2;... ; head h )W O

[0092]

[0093] wherein, MH(H l ) represents the output of the multi-head self-attention module in the lth bidirectional Transformers module, head i represents the output of the i-th multi-head self-attention module in the lth bidirectional Transformers module, are learnable parameters.

[0094] wherein, the attention mechanism of the multi-head self-attention module is realized by dot product and softmax operation:

[0095]

[0096] wherein, Q, K, and V represent query, key and value, is a scaling coefficient to avoid the value of inner product being too large.

[0097] The calculation formula of the forward propagation network is as follows:

[0098]

[0099]

[0100] wherein, PFFN(H l ) represents the output of the forward propagation network in the lth bidirectional Transformers module, is the hidden vector representation of the item in any masking sequence after being processed by the lth bidirectional Transformers module, are learnable parameters. Here, when the length |S u of the user's historical interaction sequence is exactly equal to the maximum sequence length T given by the recommendation model, a plurality of masking sequences can be directly generated according to the user's historical interaction sequence, and the masking sequences are input into the recommendation model for processing. When the length |S u of the user's historical interaction sequence is greater than the maximum sequence length T given by the recommendation model, a sliding window with a size of T is used to divide the user's historical interaction sequence into a plurality of sub-sequences with a length of T, and a plurality of masking sequences generated by each sub-sequence are input into the recommendation model for processing.

[0101] In the recommendation model based on multiple Transformer modules, residual connection, layer normalization and Dropout mechanism are also introduced to avoid model overfitting. The Transformer encoder Trm is defined as follows:

[0102] Trm(H l )=LayerNorm(F l +Dropout(PFFN(F l )))

[0103] F l =LayerNorm(H l +Dropout(MH(H l )))。

[0104] In step 140, based on the preset cloze task loss function, the vector representation of all the hidden objects in the mask sequence of the plurality of users is determined to obtain the cloze task loss information.

[0105] In some embodiments, based on the preset cloze task loss function, the vector representation of all the hidden objects in the mask sequence of the plurality of users is determined to obtain the cloze task loss information, including: determining the probability of each hidden object in each mask sequence of each user according to the vector representation of each hidden object in each mask sequence of each user, wherein the probability of each hidden object in each mask sequence of each user is the probability of each hidden object in each mask sequence of each user belonging to the real object in each mask sequence of each user; based on the preset cloze task loss function, the probability of all hidden objects in the mask sequence of the plurality of users is determined to obtain the cloze task loss information.

[0106] The recommendation model can convert the hidden vector representation h t of any item in the mask sequence into the probability distribution P(v) of the item belonging to the real item, and the calculation formula is as follows:

[0107] P(υ)=W P h t +b P

[0108] wherein, is a weight matrix, is a bias matrix.

[0109] When there are N users, the cloze task loss function of any user is defined as follows:

[0110]

[0111] wherein the predicted masked object v t negative samples randomly sampled from the item set pairing. denotes the cloze task loss information for the u-th user, denotes the sigmoid function, and P(·) denotes the probability, denotes the predicted masked object v t probability of belonging to a real object, negative samples randomly sampled from the item set probability of belonging to a real object, and m denotes the number of masked sequences of the u-th user. Based on the above-mentioned cloze task loss function, through the training of the recommendation model, it is expected to increase the probability of the masked object belonging to a real object, and to decrease the probability of the negative sample belonging to a real object.

[0112] The cloze task loss function of N users is defined as follows:

[0113]

[0114] In addition, when the number of users in the user set is greater than N, the users in the user set can be divided into several batches, and the users in the user set can be divided into several batches. The training of the recommendation model is input into the recommendation model. When the length of the historical interaction sequence of a user is greater than the first preset length, the historical sequence length of the user is divided into several subsequences by a sliding window, and the different subsequences of the user are respectively divided into different batches for training the recommendation model.

[0115] Step 150, based on the preset contrast learning loss function, determining the contrast learning loss information according to the vector representation of the masked sequence of the plurality of users.

[0116] Although the Transformers model is very effective, it cannot solve the noise and sparsity problems caused by the sparsity of user interactions. To solve these problems, contrast learning is introduced into the bidirectional Transformers-based recommendation model. As a paradigm of self-supervised learning, contrast learning maximizes the similarity between positive samples and distinguishes positive samples from negative samples. Contrast learning can demonstrate strong ability to generate embedding layer representations from unlabeled data, and can improve model robustness and noise resistance.

[0117] In some embodiments, the preset contrast learning loss function is used to determine the contrast learning loss information according to the vector representations of the multiple users' mask sequences, including: determining the contrast learning loss information according to the difference between the vector representations of different mask sequences with the same sequence source of the same user in the multiple users, and the difference between the vector representations of different mask sequences of different users. The embodiment of the application extrapolates the traditional one-sample pair contrast learning to multi-sample pair contrast learning, which can provide more difficult samples compared with one-sample pair contrast learning, which is conducive to capturing higher-order information by the recommendation model. Multi-sample pair contrast learning alleviates the impact of false negative samples by increasing more positive samples.

[0118] Specifically, for any user, the hidden vector representations of a pair of mask sequences of the user are regarded as a pair of positive samples, and the hidden vector representations of other 2(N-1) mask sequences from other users are regarded as negative samples. Based on the above setting, the one-sample pair contrast learning loss function of the user is defined as follows:

[0119]

[0120] Where τ is a temperature hyperparameter, and the cosine similarity function <φ1, φ2> = φ1 T ·φ2 / ||φ1||·||φ2|| is used to calculate the similarity between two vector representations.

[0121] Then, the one-sample pair contrast learning is extrapolated to multi-sample pair contrast learning using the m mask sequences generated by the previous fill-in-the-blank task. Given m hidden representations corresponding to the mask sequences These hidden representations can be combined together as positive samples for multi-sample pair contrast learning. The multi-sample pair contrast learning loss function is defined as follows:

[0122]

[0123] Where, is an indicator function that takes the value 1 if and only if x≠y.

[0124] The multi-sample pair contrast learning loss function of the N users is defined as follows:

[0125]

[0126] Further, when the number of users in the user set is greater than N, the users in the user set can be divided into batches, and the users in each batch are input into the recommendation model for training. When the length of the historical interaction sequence of a user is greater than the first preset length, the historical sequence length of the user is divided into a plurality of sub-sequences by a sliding window, and the different sub-sequences of the user are respectively divided into different batches for training the recommendation model.

[0127] In step 160, the recommendation model is trained according to the completion task loss information and the contrastive learning loss information.

[0128] In some embodiments, the training of the recommendation model according to the completion task loss information and the contrastive learning loss information includes: updating the weights of the completion task loss information and the contrastive learning loss information in each iteration based on a preset weight dynamic re-estimation strategy; in each iteration, performing weighted summation on the completion task loss information and the contrastive learning loss information determined in each iteration according to the updated weights of the completion task loss information and the contrastive learning loss information to obtain joint loss information in each iteration; and adjusting the parameters of the recommendation model according to the joint loss information of each iteration. The weight dynamic re-estimation strategy can dynamically calculate the weights of the completion task loss information and the contrastive learning loss information to accelerate the convergence speed of the recommendation model and improve the performance of the recommendation model.

[0129] Further, the updating of the weights of the completion task loss information and the contrastive learning loss information in each iteration based on the preset weight dynamic re-estimation strategy includes: updating the weights of the completion task loss information and the contrastive learning loss information in each iteration according to the following formula:

[0130]

[0131]

[0132] wherein θ n+1 is the weight of the contrastive learning loss information in the n+1th iteration, θ n is the weight of the contrastive learning loss information in the nth iteration, the initial value of θ is 0, a is a learning rate hyperparameter, and λ is a proportional conversion factor. and respectively represent the completion task loss information and the contrastive learning loss information determined in the n+1th iteration.

[0133] When θ n+1 is calculated, θ and θ to avoid affecting the normal back propagation process. Based on this, in each iteration, the complete fill-in-the-blank task loss information and the contrastive learning loss information determined in each iteration are weighted and summed according to the updated weights of the complete fill-in-the-blank task loss information and the contrastive learning loss information, to obtain the joint loss information in each iteration, including: in each iteration, the complete fill-in-the-blank task loss information and the contrastive learning loss information determined in each iteration are weighted and summed according to the updated weights of the complete fill-in-the-blank task loss information and the contrastive learning loss information, to obtain the joint loss information in each iteration according to the following formula:

[0134]

[0135] wherein, denotes the joint loss information in the n+1th iteration.

[0136] A termination condition can be set for the training process, and when the termination condition is reached, the training process can be ended. The termination condition can be that the training reaches a maximum number of iterations, or the prediction accuracy of the training set reaches a set threshold. The embodiments of the present application do not make specific limitations on this.

[0137] The trained recommendation model can be used to recommend target objects to target users.

[0138] To sum up, the embodiment of the application provides a training method of a recommendation model based on bidirectional Transformers, first, the historical interaction sequences of a plurality of users are acquired; wherein the historical interaction sequence of each user includes the object sequence interacted by each user, the objects in the historical interaction sequence of each user are randomly masked to generate a plurality of different masked sequences of each user, then the masked sequences of the plurality of users are input into the recommendation model based on bidirectional Transformers for processing, the masked objects in each masked sequence of each user are predicted from all the objects interacted by the plurality of users, the vector representation of each masked object in each masked sequence of each user and the vector representation of each masked sequence of each user are obtained, then based on the preset fill-in-the-blank task loss function, the fill-in-the-blank task loss information is determined according to the vector representation of all the masked objects in the masked sequences of the plurality of users, based on the preset contrast learning loss function, the contrast learning loss information is determined according to the vector representation of the masked sequences of the plurality of users, and finally, the recommendation model is trained according to the fill-in-the-blank task loss information and the contrast learning loss information. Based on the training method, the objects in the historical interaction sequence of each user are randomly masked to generate a masked sequence, the masked sequences of a plurality of users are input into the recommendation model based on bidirectional Transformers for processing, the recommendation model based on bidirectional Transformers can model the objects in the sequence from two directions and can fuse the context information from two directions, the recommendation model is trained in combination with the fill-in-the-blank task and the contrast learning method, the robustness and noise resistance performance of the recommendation model can be improved, and the accuracy of object recommendation for a target user can be improved.

[0139] Figure 3 The flowchart of the recommendation method of the recommendation model based on bidirectional Transformers provided by an embodiment of the application is executed by a system, a server device or a recommendation device based on a quaternion graph convolutional neural network having processing capability. The method comprises:

[0140] Step 310, the historical interaction sequence of a target user is acquired from the historical interaction sequences of the plurality of users.

[0141] The embodiment of the application selects a user as a target user from the user set in the foregoing embodiment and recommends a target object to the target user.

[0142] Step 320, the historical interaction sequence of the target user is input into the trained recommendation model for processing, and at least one target object is predicted from all the objects interacted by the plurality of users to recommend to the target user.

[0143] Here, the trained recommendation model is a recommendation model trained according to the training method provided in the foregoing embodiments.

[0144] Specifically, a masking mark [MASK] can be added at the end of the historical interaction sequence of the target user, and the sequence after the masking mark is added is:

[0145]

[0146] The sequence is then input into the trained recommendation model, and the next item of the sequence is predicted by the recommendation model, and the item is recommended to the target user as the target object.

[0147] In some embodiments, if the historical interaction sequence of the target user is equal to the second preset length, the historical interaction sequence of the target user can not be divided by using a sliding window, and after a masking mark [MASK] is added at the last position of the historical interaction sequence, the historical interaction sequence is input into the recommendation model to predict and recommend the next target object interacted by the target user.

[0148] In some embodiments, if the historical interaction sequence of the target user is less than the second preset length, the historical interaction sequence of the target user can not be divided by using a sliding window, and “0” is added at a plurality of positions in front of the historical interaction sequence to make the length of the historical interaction sequence reach the second preset length, and then a masking mark [MASK] is added at the last position, and the historical interaction sequence is input into the recommendation model to predict and recommend the next target object interacted by the target user.

[0149] In other embodiments, if the length of the historical interaction sequence of the target user exceeds the second preset length, a sliding window of the second preset length is used to scan the historical interaction sequence of the target user, and the last target sub-sequence is selected from the historical interaction sequence of the target user; then, the last target sub-sequence of the target user is input into the trained recommendation model for processing to predict at least one target object from all objects interacted by the plurality of users to recommend to the target user.

[0150] Here, the second preset length can be set according to the maximum sequence length of the recommendation model. Specifically, the maximum sequence length of the recommendation model is set to T, and the second preset length can be set to T-1. That is, when the length of the historical interaction sequence of the target user exceeds T-1, the last target sub-sequence with a length of T-1 in the historical interaction sequence is selected by using a sliding window. Here, before the target sub-sequence is input into the trained recommendation model, a masking mark [MASK] is also added at the last position of the target sub-sequence, and therefore, the actual length of the sequence input into the trained recommendation model is still T.

[0151] It should be noted that when the next target object interacted by the target user needs to be predicted, the number of masking marks can be set according to the number of target objects to be predicted. However, overall, the sequence length input to the trained recommendation model must be consistent with the maximum sequence length of the recommendation model.

[0152] To sum up, the embodiment of the application provides a recommendation method of a recommendation model based on bidirectional Transformers, which first acquires a historical interaction sequence of a target user from historical interaction sequences of a plurality of users, then inputs the historical interaction sequence of the target user into a trained recommendation model for processing, and predicts at least one target object from all objects interacted by the plurality of users to recommend to the target user. Based on this method, the accuracy of recommending target objects to target users can be improved.

[0153] A specific implementation scenario is provided below to further illustrate the training method of the recommendation model based on bidirectional Transformers provided by the embodiment of the application.

[0154] Figure 2 The schematic diagram of the recommendation model based on bidirectional Transformers provided by the embodiment of the application is shown in FIG. 1. The training method of the recommendation model based on bidirectional Transformers in the embodiment of the application is described in combination with FIG. 1. Figure 2 The training method of the recommendation model based on bidirectional Transformers in the embodiment of the application is described.

[0155] Definitions A set of users is denoted as V = {v1, v2, v3, … vn}, where n is the number of users. A set of items is denoted as I = {i1, i2, i3, … in}, where n is the number of items. A sequence of interactions of users is denoted as S = {s1, s2, s3, … sn}, where n is the number of sequences, and each sequence is sorted by interaction time. The item interacted by the user at the i-th timestamp is denoted as si. The task of sequence recommendation is to predict the next item that the user may be interested in, and can be formally defined as the probability that the user generates all items that may be interacted at the next timestamp:

[0156] The historical interaction sequence of the user in the set of users is input into the recommendation model based on bidirectional Transformers, and the recommendation model is trained. For each step of iteration, given the sequence s u , the random cloze task masking is performed, and m masking sequences are generated using different random seeds In each masking sequence, a proportion of ρ of all items in the sequence will be randomly replaced with a masking mark [masking], and the set of item position indexes of the masking is denoted as Figure 2 In the above formula, the historical interaction sequence of the user is denoted as {v1, v2, v3, … vn}, where n is the number of users. TThe system performs a random cloze test to mask the user's historical interaction sequences, generating m masking sequences. For example, in the second occlusion sequence, the second item and the Tth item are occluded.

[0157] The recommendation model based on bidirectional Transformers used in this embodiment of the invention consists of two parts: a basic module and a bidirectional Transformers module.

[0158] In the basic module, its embedding layer consists of an item embedding matrix. and position embedding matrix It is composed of multiple parts. For any item in the occlusion sequence, its embedding vector is... The calculation method is as follows:

[0159]

[0160] Where e i ∈E, p t Let P represent the initial vector of the item and the item's historical interaction sequence in the user's data, respectively. u The embedding vector at position t in the set of items for all users, where i represents the item in the set of items for all users. The number in the middle.

[0161] After the embedding layer, for any occlusion sequence, the embedding vectors of all items in the occlusion sequence are stacked to form a matrix. As a representation of the entire masking sequence, i.e. H 0 The input is processed by the bidirectional Transformers module at layer L, and the calculation formula is as follows:

[0162]

[0163] The bidirectional Transformers module is composed of multiple stacked Transformers modules. Each Transformer module includes a multi-head self-attention module and a forward propagation network. Multiple stacked Transformers modules form a deep network.

[0164] Multi-head self-attention modules can capture contextual information from multiple different subspaces. Given the l-th layer hidden vector representation... And the maximum sequence length T. The calculation formula for the multi-head self-attention module is as follows:

[0165] MH(H l )=concat(head1;head2;…;head h W O

[0166]

[0167] where MH(H l ) denotes the output of the multi-head self-attention module in the first layer bidirectional Transformers module, head i denotes the output of the i-th multi-head self-attention module in the first layer bidirectional Transformers module, are learnable parameters.

[0168] where the attention mechanism of the multi-head self-attention module is realized by dot product and softmax operation:

[0169]

[0170] where Q, K, V represent query, key and value, respectively, is a scaling factor to avoid the value of inner product being too large.

[0171] The calculation formula of the forward propagation network is as follows:

[0172]

[0173]

[0174] where PFFN(H l ) denotes the output of the forward propagation network in the first layer bidirectional Transformers module, is the hidden vector representation of the item in any masking sequence after being processed by the first layer bidirectional Transformers module, are learnable parameters.

[0175] In the recommendation model based on multiple Transformers modules provided in the embodiments of the present application, residual connection, layer regularization and Dropout mechanism are also introduced to avoid model overfitting. The Transformer encoder Trm is defined as follows:

[0176] Trm(H l ) = LayerNorm(F l + Dropout(PFFN(F l )))

[0177] F l = LayerNorm(H l + Dropout(MH(H l ))).

[0178] After being processed by the bidirectional Transformers module of the L-th layer, the output is the item hidden vector representation of the position t of any one of the user's masking sequences t . Here, the hidden vector representation of each item in each masking sequence can be obtained, including the hidden vector representation of the masked item and the hidden vector representation of the unmasked item. For any one masking sequence, the masked item in the masking sequence can be predicted, and the probability that the masked item belongs to the real item can be calculated according to the hidden vector representation of the predicted masked item, which can be referred to as a candidate item from the item set. As shown in Figure 2 , after being processed by the bidirectional Transformers module of the L-th layer, the vector representation of the masked item is given, for example, the vector representation of the 2nd and T-th masked items in the 2nd masking sequence is obtained 2,2 and T,2 .

[0179] The hidden vector representation of the item in any one masking sequence is converted into P(v) that the item belongs to the real item by using a linear layer, and the calculation formula is as follows:

[0180] P(v) = W t h P + b t P

[0181] wherein, is a weight matrix, is a bias matrix. As shown in Figure 2 , the hidden vector representation of the predicted masked item is input into the prediction layer, so as to calculate the probability that each predicted masked item belongs to the real item. For example, the vector representation of the 2nd and T-th masked items in the 2nd masking sequence is input into the prediction layer, and the probability of the 2nd and T-th masked items can be obtained. 2,2 and T,2 .

[0182] After that, the vector representation of the item in each masking sequence of the user (including the unmasked item and the predicted masked item) can be spliced together to obtain the vector representation of each masking sequence as shown in Figure 2 The vector representation of the item in each masking sequence of the user is spliced to obtain the vector representation of the m masking sequences

[0183] Next, the cloze task loss information and the contrastive learning loss information are determined.

[0184] When there are N users, the cloze task loss function of any one user is defined as follows:

[0185]

[0186] Among them, the predicted occluded object v t Negative samples randomly sampled from the set of items pair. This represents the loss information for the cloze test task for the u-th user, where σ represents the sigmoid function and P(·) represents the probability. This represents the occluded item v in the j-th occlusion sequence for the predicted u-th user. t The probability that it is a real item. Negative samples are randomly sampled from a set of items. The probability that it belongs to a real item, where m represents the number of occlusion sequences for the u-th user.

[0187] The loss function for a cloze test task with N users is defined as follows:

[0188]

[0189] For any user, the hidden vector of that user's pair of masking sequences can be represented. The hidden vector representations of the other 2(N-1) masking sequences from other users are considered as a pair of positive samples, while the hidden vector representations of these other 2(N-1) masking sequences are considered as negative samples. Based on the above settings, the user's pair-sample contrastive learning loss function is defined as follows:

[0190]

[0191] Where τ is the temperature hyperparameter, and the cosine similarity function <φ1, φ2> = φ1 T ·φ2 / ||φ1||·||φ2|| is used to calculate the similarity between two vector representations.

[0192] Given m corresponding to the masking sequence Hidden representation These hidden representations can be combined and used as positive samples for multi-pair comparison learning. The loss function for multi-pair comparison learning is defined as follows:

[0193]

[0194] in, It is an indicator function whose value is 1 if and only if x ≠ y.

[0195] The loss function for multi-pair comparison learning of N users is defined as follows:

[0196]

[0197] According to the following formula, in each round of iteration, the weight of the fill-in-the-blank task loss information and the contrastive learning loss information is updated:

[0198]

[0199]

[0200] wherein θ n+1 is the weight of the contrastive learning loss information in the n+1th round of iteration, θ n is the weight of the contrastive learning loss information in the nth round of iteration, the initial value of θ is set to 0, α is a learning rate hyperparameter, λ is a proportional conversion factor, and respectively represent the fill-in-the-blank task loss information and the contrastive learning loss information determined in the n+1th round of iteration.

[0201] Next, according to the following formula, in each round of iteration, the fill-in-the-blank task loss information and the contrastive learning loss information determined in each round of iteration are weighted and summed according to the updated weights of the fill-in-the-blank task loss information and the contrastive learning loss information to obtain the joint loss information in each round of iteration:

[0202]

[0203] wherein, represents the joint loss information in the n+1th round of iteration.

[0204] When the termination condition is reached, the training process can be ended. The termination condition can be that the training reaches the maximum number of iterations, or the prediction accuracy of the training set reaches the set threshold.

[0205] In the above training process of the recommendation model, when the number of users in the user set is greater than N, the users in the user set can be divided into batches and input into the recommendation model for training. When the length of the historical interaction sequence of a user is greater than the first preset length, the historical sequence length of the user is divided into a plurality of subsequences by a sliding window, a plurality of masked sequences are generated according to each subsequence of the user, and then the different subsequences of the user and the corresponding masked sequences are divided into different batches for training the recommendation model.

[0206] Finally, a user is selected from the user set as a target user, and a mask flag [mask] is added at the end of the historical interaction sequence of the target user. The sequence after adding the mask flag is:

[0207]

[0208] The sequence is input into the trained recommendation model, the next item of the sequence is predicted by the recommendation model, and the item is recommended to the target user as a target object. If the length of the historical interaction sequence of the target user exceeds the second preset length, the historical interaction sequence of the target user is scanned by using a sliding window with the second preset length, the last target subsequence is selected from the historical interaction sequence of the target user, the last target subsequence of the target user is input into the trained recommendation model for processing, and at least one target object is predicted from all objects interacted by the plurality of users and recommended to the target user.

[0209] The following provides a specific implementation scenario to further illustrate the recommendation performance of the recommendation model trained by the training method of the recommendation model based on bidirectional Transformers provided by the embodiments of the present application.

[0210] To evaluate the model performance, experiments are conducted on three widely used data sets for recommendation. The data sets are Beauty, Toys, and ML-1M, respectively. The detailed data of the data sets is shown in Table 1.

[0211] Table 1 Data set

[0212]

[0213] The training method provided in the previous embodiment is used to train the recommendation model. In the recommendation model, the number of hidden layers is 256, the number of bidirectional Transformers modules is 2, and the number of heads in the multi-head self-attention module in each Transformers module is 2. During training, the training data is input into the recommendation model in batches, and each batch of training data is 256 sequences. After training, target users are selected from the three data sets, and the target objects are recommended to the target users by the recommendation model.

[0214] Two indicators are used to evaluate the performance of the trained recommendation model, which are HR@K and NDCG@K, K∈{5, 10, 20}. The latest contrast learning sequence recommendation model is selected as the benchmark model. The specific recommendation performance is shown in Table 2.

[0215] Table 2 Recommendation performance of the trained recommendation model and the comparative model of the embodiments of the present application

[0216]

[0217] Table 2 is a recommendation model based on bidirectional Transformers provided by the embodiment of the application, referred to as CBiT, and other models as comparative models. Column 1 of Table 2 is the name of the index, and the last column is the recommendation performance improvement percentage of the recommendation model provided by the embodiment of the application compared with the selected comparative model, wherein one of the comparative models is selected from all the comparative models as the comparative model for calculating the recommendation performance improvement percentage (indicated by an underline in Table 2) in the corresponding index. For example, for the Beauty data set, the HR@5 of the recommendation model based on bidirectional Transformers provided by the embodiment of the application is 0.0637, and the HR@5 of DuoRec in the comparative model is optimal, which is 0.0559, and then the HR@5 of the recommendation model provided by the embodiment of the application and DuoRec is calculated to be 13.95% of the recommendation performance improvement percentage. According to Table 2, the recommendation performance of the recommendation model based on bidirectional Transformers provided by the embodiment of the application is greatly improved compared with the optimal comparative model.

[0218] In the above comparative model, SGL is a recommendation model of graph self-supervised learning. According to Table 2, the recommendation performance of the recommendation model provided by the embodiment of the application is greatly improved compared with each comparative model in the recommendation performance of the three data sets; and the recommendation performance of the recommendation model provided by the embodiment of the application is also significantly improved compared with SGL.

[0219] In summary, the training method of the recommendation model based on bidirectional Transformers provided by the embodiment of the application randomly masks the objects in the historical interaction sequence of each user, generates a masked sequence, inputs the masked sequences of multiple users into the recommendation model based on bidirectional Transformers for processing, the recommendation model based on bidirectional Transformers can model the objects in the sequence from two directions, and can fuse the context information from two directions, and the recommendation model is trained by combining the cloze task and the multiple sample comparison learning method, which can improve the robustness and noise resistance performance of the recommendation model, and improve the accuracy of object recommendation for the target user.

[0220] Figure 4 The structure schematic diagram of the training device of the recommendation model based on bidirectional Transformers provided by the embodiment of the application is shown. As Figure 4As shown, the training device of the bidirectional Transformer-based recommendation model comprises: a user sequence acquisition module 410 configured to acquire historical interaction sequences of a plurality of users; wherein each historical interaction sequence of each user comprises a sequence of objects interacted by each user; a masked sequence generation module 420 configured to randomly mask the objects in each historical interaction sequence of each user to generate a plurality of different masked sequences of each user; a vector representation generation module 430 configured to input all the masked sequences of the plurality of users into the bidirectional Transformer-based recommendation model for processing, to predict the masked objects in each masked sequence of each user from all the objects interacted by each user, and to obtain the vector representation of each masked object in each masked sequence of each user and the vector representation of each masked sequence of each user; a fill-in-the-blank task loss information determination module 440 configured to determine fill-in-the-blank task loss information based on a preset fill-in-the-blank task loss function and according to the vector representation of all the masked objects in the plurality of masked sequences of each user; a contrastive learning loss information determination module 450 configured to determine contrastive learning loss information based on a preset contrastive learning loss function and according to the vector representation of all the masked sequences of the plurality of users; and a recommendation model training module 460 configured to train the recommendation model according to the fill-in-the-blank task loss information and the contrastive learning loss information.

[0221] In some embodiments, the masked sequence generation module comprises:

[0222] a subsequence division unit configured to, if the length of the historical interaction sequence of any one of the plurality of users exceeds a first preset length, scan the historical interaction sequence of the corresponding user by using a sliding window of the first preset length, and divide the historical interaction sequence of the corresponding user into a plurality of sub-sequences;

[0223] a masked sequence generation unit configured to randomly mask the objects in each sub-sequence of the corresponding user to generate a plurality of different masked sequences of each sub-sequence of the corresponding user.

[0224] In some embodiments, the fill-in-the-blank task loss information determination module comprises:

[0225] a probability determination unit configured to determine the probability of each masked object in each masked sequence of each user according to the vector representation of each masked object in each masked sequence of each user, wherein the probability of each masked object in each masked sequence of each user is the probability that each predicted masked object in each masked sequence of each user belongs to the real object in each masked sequence of each user.

[0226] The complete-type fill-in-the-blank task loss information determination unit is configured to determine complete-type fill-in-the-blank task loss information based on a preset complete-type fill-in-the-blank task loss function and probabilities of all masked objects in the masking sequences of the plurality of users.

[0227] In some embodiments, the contrastive learning loss information determination module is specifically configured to:

[0228] determine the contrastive learning loss information based on differences between vector representations of different masking sequences with the same sequence source of the same user in the plurality of users and differences between vector representations of different masking sequences of different users.

[0229] In some embodiments, the recommendation model training module includes:

[0230] The weight dynamic re-estimation unit is configured to update weights of the complete-type fill-in-the-blank task loss information and the contrastive learning loss information in each iteration based on a preset weight dynamic re-estimation strategy.

[0231] The joint loss information determination unit is configured to, in each iteration, weight-sum the complete-type fill-in-the-blank task loss information and the contrastive learning loss information determined in each iteration based on the updated weights of the complete-type fill-in-the-blank task loss information and the contrastive learning loss information to obtain joint loss information in each iteration.

[0232] The parameter adjustment unit is configured to adjust parameters of the recommendation model based on the joint loss information of each iteration.

[0233] In some embodiments, the weight dynamic re-estimation unit is specifically configured to:

[0234] update the weights of the complete-type fill-in-the-blank task loss information and the contrastive learning loss information in each iteration according to the following formula:

[0235]

[0236]

[0237] wherein θ n+1 is the weight of the contrastive learning loss information in the n+1th iteration, θ n is the weight of the contrastive learning loss information in the nth iteration, the initial value of θ is set to 0, α is a learning rate hyperparameter, λ is a proportional conversion factor, and respectively represent the complete-type fill-in-the-blank task loss information and the contrastive learning loss information determined in the n+1th iteration;

[0238] The joint loss information determination unit is specifically configured to:

[0239] According to the following formula, in each iteration, the cloze test loss information and the contrastive learning loss information determined in each iteration are weighted and summed based on the updated weights of the cloze test loss information and the contrastive learning loss information to obtain the joint loss information in each iteration:

[0240]

[0241] in, This represents the joint loss information in the (n+1)th iteration.

[0242] Figure 5 A schematic diagram of the structure of a recommendation device based on a bidirectional Transformers recommendation model provided in an embodiment of the present invention is shown. Figure 5 As shown, the recommendation device based on the bidirectional Transformers recommendation model includes: a target user sequence acquisition module 510, used to acquire the historical interaction sequence of a target user from the historical interaction sequences of the multiple users; and a target object recommendation module 520, used to input the historical interaction sequence of the target user into the trained recommendation model for processing, and predict at least one target object from all objects interacted by the multiple users to recommend to the target user.

[0243] In some embodiments, the apparatus further includes:

[0244] The target subsequence selection module is used to scan the target user's historical interaction sequence using a sliding window of the second preset length if the length of the target user's historical interaction sequence exceeds a second preset length, and select the last target subsequence from the target user's historical interaction sequence.

[0245] The target object recommendation module is specifically used for:

[0246] The last target subsequence of the target user is input into the trained recommendation model for processing, and at least one target object is predicted from all objects interacted with by the multiple users and recommended to the target user.

[0247] Figure 6 An electronic device according to an embodiment of the present invention is shown. For example... Figure 6 As shown, the electronic device 600 includes: at least one processor 610, and a memory 620 communicatively connected to the at least one processor 610, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to cause the at least one processor to perform a method.

[0248] In particular, the memory 620 and the processor 610 are connected together via the bus 630, and can be general memory and processor, which are not limited here, and when the processor 610 runs the computer program stored in the memory 620, the operations and functions described in the embodiments of the present application can be implemented. Figures 1 to 3 The operations and functions described.

[0249] In the embodiments of the present application, the electronic device 600 can include, but is not limited to, a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile computing device, a smart phone, a tablet computer, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable computing device, and the like.

[0250] The embodiments of the present application also provide a storage medium having a computer program stored thereon, which is executed by a processor to implement the method. The specific implementation can be referred to the method embodiments, which will not be described here. Specifically, a system or device equipped with a storage medium can be provided, and the storage medium has a software program code for implementing the functions of any of the above embodiments, and the computer or processor of the system or device reads and executes the instructions stored in the storage medium. The program code read from the storage medium can itself implement the functions of any of the above embodiments, so the machine-readable code and the storage medium storing the machine-readable code constitute a part of the present application.

[0251] The storage medium includes, but is not limited to, a floppy disk, a hard disk, a magneto-optical disk, an optical disk, a magnetic tape, a nonvolatile memory card, and a ROM. The program code can also be downloaded from a server computer or the cloud over a communication network.

[0252] It should be noted that not all steps and modules are necessary in the above processes and system structures, and some steps and units can be omitted according to actual needs. The execution order of each step is not fixed and can be determined as needed. The device structure described in each of the above embodiments can be a physical structure or a logical structure. A certain module or unit can be implemented by the same physical entity, a certain module or unit can be implemented by multiple physical entities respectively, and a certain module or unit can also be implemented by multiple components in multiple independent devices.

[0253] Although the embodiments of the present application have been disclosed as above, they are not limited to the applications listed in the specification and embodiments. They can be fully applied to various fields suitable for the embodiments of the present application. Additional modifications can be easily implemented by those skilled in the art. Therefore, the embodiments of the present application are not limited to specific details and figures shown and described herein, without departing from the general concept defined by the claims and their equivalent scope.

Claims

1. A method for training a bidirectional Transformers-based recommendation model, characterized in that, The method comprises the following steps: Obtain a plurality of historical interaction sequences of users; wherein the historical interaction sequence of each user includes the sequence of objects interacted by each user; the historical interaction sequence of each user includes at least one object having an interaction relationship with each user; the interaction relationship between the user and the object is the relationship generated based on the interaction behavior of the user to the object, and the interaction behavior includes the purchase behavior of the user to the commodity, the reading behavior of the user to the news, and the dining behavior of the user in the restaurant; in sequence recommendation, define for a user set, for an item set, for an interaction sequence of the user sorted according to the interaction time, wherein is the item interacted by the user at the i-th timestamp; the task of sequence recommendation is to predict the item that the user is likely to be interested in next, and is formally defined as generating the probability of all items that the user is likely to interact at the next timestamp: , the item is an object; randomly masking objects in a historical interaction sequence of each user to generate a plurality of different masked sequences for each user; inputting the masked sequences of the plurality of users into a recommendation model based on bidirectional Transformers for processing, predicting the masked objects in each masked sequence of each user from all objects interacted by the plurality of users, obtaining vector representations of each masked object in each masked sequence of each user and vector representations of each masked sequence of each user; determining completion task loss information according to the vector representations of all masked objects in the masked sequences of the plurality of users based on a preset completion task loss function; determining contrast learning loss information according to the vector representations of the masked sequences of the plurality of users based on a preset contrast learning loss function; training the recommendation model according to the completion task loss information and the contrast learning loss information; the training of the recommendation model according to the completion task loss information and the contrast learning loss information comprises the following steps: updating the weights of the completion task loss information and the contrast learning loss information in each iteration based on a preset weight dynamic re-estimation strategy; in each iteration, performing weighted summation on the completion task loss information and the contrast learning loss information determined in each iteration according to the updated weights of the completion task loss information and the contrast learning loss information to obtain joint loss information in each iteration; adjusting parameters of the recommendation model according to the joint loss information of each iteration; the trained recommendation model is used to recommend target objects to a target user. 2.The method of Claim 1, wherein, The method comprises the following steps: if the length of the historical interaction sequence of any one of the plurality of users exceeds a first preset length, scanning the historical interaction sequence of the corresponding user by using a sliding window with the first preset length to divide the historical interaction sequence of the corresponding user into a plurality of subsequences; randomly masking objects in each subsequence of the corresponding user to generate a plurality of different masked sequences for each subsequence of the corresponding user. 3.The method of Claim 1, wherein, The method comprises the following steps: determining the probability of each masked object in each masked sequence of each user according to the vector representation of each masked object in each masked sequence of each user, wherein the probability of each masked object in each masked sequence of each user is the probability that each predicted masked object in each masked sequence of each user belongs to the real object in each masked sequence of each user; determining the completion task loss information according to the probabilities of all masked objects in the masked sequences of the plurality of users based on the preset completion task loss function. 4.The method of Claim 1, wherein, The contrastive learning loss information, determined based on a preset contrastive learning loss function and the vector representations of the masking sequences of the multiple users, includes: The contrastive learning loss information is determined based on the differences between the vector representations of different masking sequences from the same user with the same sequence source, and the differences between the vector representations of different masking sequences from different users. 5.The method of Claim 1, wherein, The preset weight-based dynamic re-evaluation strategy updates the weights of the cloze test loss information and the contrastive learning loss information in each iteration, including: In each iteration, the weights of the cloze test loss information and the contrastive learning loss information are updated according to the following formula: wherein, is a weight of the contrastive learning loss information in the n+1th iteration, is a weight of the contrastive learning loss information in the n iteration, is set to 0, is a learning rate hyperparameter, is a scaling factor, and respectively represent the determined gap fill task loss information and the contrastive learning loss information in the n+1th iteration. In each iteration, based on the updated weights of the cloze test loss information and the contrastive learning loss information, a weighted sum is performed on the cloze test loss information and the contrastive learning loss information determined in each iteration to obtain the joint loss information in each iteration, including: According to the following formula, in each iteration, the cloze test loss information and the contrastive learning loss information determined in each iteration are weighted and summed based on the updated weights of the cloze test loss information and the contrastive learning loss information to obtain the joint loss information in each iteration: wherein, represents the joint loss information in the n+1th round of iteration.

6. An apparatus for training a bidirectional Transformers-based recommendation model, comprising: include: A user sequence acquisition module is configured to acquire historical interaction sequences of a plurality of users; wherein the historical interaction sequence of each user comprises an object sequence interacted by each user; the historical interaction sequence of each user comprises at least one object having an interaction relationship with each user; the interaction relationship between the user and the object is a relationship generated based on an interaction behavior of the user to the object, and the interaction behavior comprises a purchase behavior of the user to a commodity, a reading behavior of the user to news, and a dining behavior of the user in a restaurant; in sequence recommendation, define as a user set, as an item set, as an interaction sequence of the user sorted according to an interaction time, wherein as an item interacted by the user at the i th time stamp; the task of sequence recommendation is to predict an item that is likely to be interested by the user next, and is defined as a probability that the user generates all items that are likely to be interacted at a next time stamp: , the item is an object; The occlusion sequence generation module is used to randomly occlude objects in each user's historical interaction sequence, generating multiple different occlusion sequences for each user. The vector representation generation module is used to input all the occlusion sequences of the multiple users into the recommendation model based on bidirectional Transformers for processing, predict the occluded object in each occlusion sequence of each user from all the objects interacted by the multiple users, and obtain the vector representation of each occluded object in each occlusion sequence of each user and the vector representation of each occlusion sequence of each user. The cloze test task loss information determination module is used to determine the cloze test task loss information based on the preset cloze test task loss function and the vector representation of all occluded objects in multiple occlusion sequences for each user. The contrastive learning loss information determination module is used to determine the contrastive learning loss information based on a preset contrastive learning loss function and the vector representation of all occlusion sequences of the multiple users. The recommendation model training module is used to train the recommendation model based on the cloze test task loss information and the contrastive learning loss information. The recommendation model training module includes: The weight dynamic re-evaluation unit is used to update the weights of the cloze test loss information and the contrastive learning loss information in each iteration based on a preset weight dynamic re-evaluation strategy. The joint loss information determination unit is used to, in each iteration, perform a weighted summation of the cloze task loss information and the contrastive learning loss information determined in each iteration according to the updated weights of the cloze task loss information and the contrastive learning loss information, to obtain the joint loss information in each iteration. The parameter adjustment unit is configured to adjust the parameters of the recommendation model according to the joint loss information of each round of iteration. The trained recommendation model is used to recommend target objects to a target user.

7. A recommendation method of a bidirectional Transformers-based recommendation model, characterized in that, The method comprises: obtaining a historical interaction sequence of a target user from the historical interaction sequences of the plurality of users according to any one of claims 1 to 5; processing the historical interaction sequence of the target user in the trained recommendation model according to any one of claims 1 to 5 to predict at least one target object for recommendation to the target user from all objects interacted by the plurality of users. 8.The recommendation method of the bidirectional Transformers-based recommendation model according to claim 7, wherein, The method further comprises: if the length of the historical interaction sequence of the target user exceeds a second preset length, scanning the historical interaction sequence of the target user using a sliding window of the second preset length, and selecting a last target sub-sequence from the historical interaction sequence of the target user; processing the last target sub-sequence of the target user in the trained recommendation model according to any one of claims 1 to 5 to predict at least one target object for recommendation to the target user from all objects interacted by the plurality of users. The method comprises: 9.A recommendation device of a bidirectional Transformers-based recommendation model, characterized in that, a target user sequence acquisition module configured to obtain a historical interaction sequence of a target user from the historical interaction sequences of the plurality of users according to any one of claims 1 to 5; a target object recommendation module configured to process the historical interaction sequence of the target user in the trained recommendation model according to any one of claims 1 to 5 to predict at least one target object for recommendation to the target user from all objects interacted by the plurality of users. ​

Citation Information

Patent Citations

  • Recommendation method based on self-attention mechanism

    CN113822742A

  • Self-supervised recommendation method combined with contrast learning method

    CN114564651A