Sequence recommendation method and device based on bidirectional encoder representation of transformer

Through the bidirectional encoder and mask language model training method based on the self-attention mechanism, the problem of insufficient bidirectional dependence of recurrent neural networks in sequence modeling is solved, and the accuracy of sequence recommendation and system recommendation performance are improved.

CN115757865BActive Publication Date: 2025-08-12WUHAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211359879.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-02
Publication Date
2025-08-12
Estimated Expiration
2042-11-02

AI Technical Summary

Technical Problem

In the prior art, recurrent neural networks lack a two-way modeling dependency modeling modeling in sequence modeling, resulting in insufficient long-term behavioral sequence modeling and inability to effectively perform sequence recommendations.

Method used

A bidirectional encoder based on a self-attention mechanism is used to capture the bidirectional dependencies and project co-occurrence characteristics in the user's historical behavior sequence, and self-supervised training is performed through the mask language model of the bidirectional encoder, and fine-tune it in combination with the user's historical behavior sequence data to ensure the balance of the target item label.

Benefits of technology

It effectively alleviates the system cold start problem, improves the recommendation performance of the recommendation platform, and fully learns the two-way dependence and co-occurrence characteristics of the project in the user behavior sequence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115757865B_ABST
    Figure CN115757865B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for sequential recommendation based on a transformer-based bidirectional encoder representation. The method comprises: Step 1: Using a bidirectional encoder based on a self-attention mechanism to capture the bidirectional dependencies and co-occurrence characteristics of items in a user's historical behavior sequence; Step 2: Using the bidirectional dependencies and co-occurrence characteristics of the items obtained in Step 1, in a pre-training phase, a masked language model of the bidirectional encoder is used to train the model in a self-supervised manner to address the disparity in the ratio of positive and negative samples caused by data sparsity; Step 3: Using the model training parameters in Step 2, in a fine-tuning phase, the network is trained using user historical behavior sequence data to ensure balanced target item labels. This invention can effectively alleviate the system cold start problem and effectively improve the recommendation performance of the target platform.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of sequence recommendation, and more particularly to a method and device for sequence recommendation based on bidirectional encoder representation of a transformer. Background Art

[0002] Sequential Recommendation (SR) refers to predicting the items that a user is most likely to engage in next based on the user's historical behavior information. In recent years, due to the powerful capabilities of recurrent neural networks in sequence modeling, deep networks have been widely used in the problem of user behavior sequence modeling in video recommendation scenarios. The basic paradigm of these RNN-based methods is to use a left-to-right pattern to transform the sequence into a vector, and to make recommendations by calculating the similarity between the target video and the sequence. When processing sequences, recurrent neural networks use a unidirectional modeling method from front to back. This modeling method from front to back is lacking in the problem of modeling long and short-term behavior sequences and lacks a bidirectional modeling dependency model. Therefore, the development of a sequence recommendation method and device based on a bidirectional encoder representation of a transformer can effectively overcome the defects in the above-mentioned related technologies, which has become a technical problem that needs to be solved urgently in the industry. Summary of the Invention

[0003] In response to the above-mentioned problems in the prior art, embodiments of the present invention provide a sequence recommendation method and device based on bidirectional encoder representation of a transformer.

[0004] In the first aspect, an embodiment of the present invention provides a sequence recommendation method based on a transformer-based bidirectional encoder representation, including: step 1: using a bidirectional encoder based on a self-attention mechanism to capture the bidirectional dependency relationship and co-occurrence characteristics of items in the user's historical behavior sequence; step 2: using the bidirectional dependency relationship and co-occurrence characteristic relationship of the items obtained in step 1, in the pre-training stage, in view of the large disparity in the ratio of positive and negative samples caused by data sparsity, the masked language model of the bidirectional encoder is used to train the model in a self-supervised manner; step 3: using the model training parameters in step 2, and using the user's historical behavior sequence data to train the network in the fine-tuning stage to ensure that the target item labels are balanced.

[0005] Based on the content of the above method embodiment, the sequence recommendation method based on bidirectional encoder representation of the transformer provided in the embodiment of the present invention, step 1 specifically includes: step 1.1: in the input layer, prepare the initial representation of the video and send it to the sequence encoder. The sequence encoder of the model is composed of multiple self-attention layers stacked together to obtain the initial embedding vector representation of the video in the user behavior sequence; step 1.2: based on the initial embedding vector representation of the video in the user behavior sequence obtained in step 1.1, in the sequence encoding layer, use the sequence encoder to initialize the parameters of the corresponding part, without starting training from scratch, to obtain the corresponding part of the model parameters; step 1.3: based on the corresponding part of the model parameters obtained in step 1.2, in the model pre-training stage, use the negative log-likelihood function as the loss function optimization method to obtain better model training parameters; step 1.4: for the better model training parameters obtained in step 1.3, in the model fine-tuning stage, use the pre-trained input layer and sequence encoder parameters to initialize the corresponding part of the model parameters, and use average pooling to aggregate the hidden layer embedding vector table of all videos in the user behavior sequence. Characteristic, obtain the hidden layer embedding vector representation of the masked video; Step 1.5: For the hidden layer embedding vector representation of the masked video obtained in step 1.4, in the output layer, obtain the hidden layer representation of the masked video, and use it to predict the classification probability to obtain the probability of the target video being clicked; Step 1.2 includes sub-steps: Step 1.2.1: The multi-head attention mechanism applies the scaled dot product multiplication attention mechanism multiple times in parallel, and the independent attention mechanism outputs are connected in series and linearly converted to the expected dimension to obtain different space vector representations under linear mapping; Step 1.2.2: Based on the different space vector representations under linear mapping obtained in step 1.2.1, in order to ensure that the model has nonlinear expression ability and that features of different dimensions interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, and the representation of the position feedforward network is obtained; Step 1.2.3: Based on the representation of the position feedforward network obtained in step 1.2.2, a multi-layer transformer stack is used to consider capturing more complex bidirectional dependencies to obtain a hidden layer video embedding vector representation; In step 1.1, element addition is used to form the video s i The initial embedding representation vector Calculations include:

[0006]

[0007] Among them, p i represents the position embedding vector, Indicates video i The feature vector of , the initial representation vector of the user behavior sequence s is obtained, Among them, H 0 ∈R L×d, set a user behavior sequence S = {s1,s2,...,s L}, by taking the i-th video s in the user behavior sequence i Convert to a relatively low-dimensional space and convert it to a d-dimensional vector.

[0008] Based on the content of the above method embodiment, the sequence recommendation method based on bidirectional encoder representation of transformer provided in the embodiment of the present invention, in step 1.2.1, the multi-head attention mechanism does not calculate the attention weight only once, but applies the scaled dot product multiplication attention mechanism h times in parallel. The independent attention mechanism outputs are concatenated and linearly converted to the expected dimension. The input is linearly mapped to different spaces respectively. The calculation includes:

[0009]

[0010]

[0011] in, W i C ∈R d×d are all parameter matrices to be learned, and h is set to 4. is the representation vector matrix of the video sequence S at the mth layer, Attention(·) is the attention score, head i is the multi-head attention score, and MH(·) is the multi-head attention map.

[0012] Based on the content of the above method embodiment, the sequence recommendation method based on bidirectional encoder representation of transformer provided in the embodiment of the present invention, in step 1.2.2, to enable the model to have nonlinear expression capabilities and allow features of different dimensions to interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, including two linear transformations, with a Gaussian error linear unit activation function in the middle. The calculation includes:

[0013] FFN(x)=GELU(xW1+b1)W2+b2

[0014] Where W1∈R d×4d ,W2∈R 4d×d ,b1∈R 4d and b2∈R d It is the parameter to be learned, and each video shares the parameter to be learned

[0015] Based on the content of the above method embodiment, the sequence recommendation method based on bidirectional encoder representation of transformer provided in the embodiment of the present invention, in step 1.2.3, to better train the model, residual connections and layer normalization are added between the multi-layer transformers. The model iteratively stacks M layers of transformers to obtain a modified hidden layer representation of each video sequence, where the calculation of the hidden layer video representation of the mth layer includes:

[0016]

[0017]

[0018]

[0019] Where, LN(·) represents layer normalization; is the representation vector matrix of the video sequence S at the mth layer

[0020] Based on the content of the above method embodiment, the sequence recommendation method based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention, in step 2, the M-th hidden layer representation of the position i is Send it to the fully connected layer to perform softmax function classification operation to determine whether it is the video s that was originally covered i , calculation methods include:

[0021]

[0022] in, is the parameter matrix to be learned, b3 and b0 are bias vectors, c f is the feature matrix defined in the input layer section; when using ID class embedding features, c f Then it contains all embedded feature vectors, is the mask video s in sequence S i The predicted probability distribution of ; softmax(·) represents the activation function; GELU(·) represents the Gaussian error linear unit; Represents the Mth hidden layer representation of position i in the video sequence.

[0023] Based on the content of the above method embodiment, the sequence recommendation method based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention, in step 3, the user interest representation h s and target video representation h t Spliced together and sent to the interaction layer to predict the user click probability The interaction layer is an inner product operation. The interaction layer is implemented using a multi-layer perceptron. The number of neurons in the multi-layer perceptron is set to 128→64→1. In the fine-tuning stage, the objective function used is the sigmoid cross entropy loss function, which is defined as follows:

[0024]

[0025] Where y∈{0,1} is the label, 0 means the user did not click on the video, 1 means the user clicked on the video, σ(·) is the sigmoid function; Indicates the predicted user click rate; L F represents the loss function.

[0026] In the second aspect, an embodiment of the present invention provides a sequence recommendation device based on a bidirectional encoder representation of a transformer, including: a first main module, used to implement step 1: using a bidirectional encoder based on a self-attention mechanism to capture the bidirectional dependency relationship and co-occurrence characteristics of items in the user's historical behavior sequence; a second main module, used to implement step 2: using the bidirectional dependency and co-occurrence characteristic relationship of the items obtained in step 1, in the pre-training stage, in view of the disparity in the ratio of positive and negative samples caused by data sparsity, the masked language model of the bidirectional encoder is used to train the model in a self-supervised manner; a third main module, used to implement step 3: using the model training parameters in step 2, and using the user historical behavior sequence data to train the network in the fine-tuning stage to ensure that the target item labels are balanced.

[0027] In a third aspect, an embodiment of the present invention provides an electronic device, including:

[0028] at least one processor; and

[0029] at least one memory communicatively coupled to the processor, wherein:

[0030] The memory stores program instructions that can be executed by the processor. The processor calls the program instructions to execute the sequence recommendation method based on bidirectional encoder representation of the transformer provided by any one of the various implementations of the first aspect.

[0031] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable a computer to execute the sequence recommendation method based on transformer-based bidirectional encoder representation provided by any one of the various implementation methods of the first aspect.

[0032] The sequence recommendation method and device based on the transformer-based bidirectional encoder representation provided by the embodiment of the present invention can fully learn the bidirectional dependencies and item co-occurrence characteristics of items in the user behavior sequence, characterize the item co-occurrence characteristics and bidirectional dependencies in the user's long-term and short-term behavior sequences, and can effectively alleviate the system cold start problem and effectively improve the recommendation performance of the target platform. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0034] Figure 1 A flow chart of a sequence recommendation method based on a transformer-based bidirectional encoder representation according to an embodiment of the present invention;

[0035] Figure 2 A schematic diagram of the structure of a sequence recommendation device based on a bidirectional encoder representation of a transformer according to an embodiment of the present invention;

[0036] Figure 3 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. In addition, the technical features in the various embodiments or single embodiments provided by the present invention can be arbitrarily combined with each other to form a feasible technical solution. This combination is not restricted by the sequence of steps and / or structural composition mode, but must be based on the ability of ordinary technicians in this field to implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.

[0038] Based on the user historical behavior sequence modeling algorithm, the user's historical interaction items are arranged into a sequence in order of time, and the user's long-term and short-term interests are characterized by considering the temporal dependency of items in the sequence. The device adopts a bidirectional encoder (Bidirectional Encoder) based on the self-attention mechanism to capture the bidirectional dependency of items in the user's historical behavior sequence and the co-occurrence characteristics of items, thereby improving the recommendation performance of sequence recommendation. A bidirectional encoder (Bidirectional Encoder) based on the self-attention mechanism is adopted to capture the bidirectional dependency of items in the user's historical behavior sequence and the co-occurrence characteristics of items; in the pre-training stage, in order to cope with the problem of a large disparity in the ratio of positive and negative samples caused by data sparsity, the method adopts the masked language model of the bidirectional encoder to train the model in a self-supervised manner; in the fine-tuning stage, the user's historical behavior sequence data is used to train the network, which effectively solves the problem of imbalanced target item labels and better improves the recommendation performance of the recommendation platform. Based on this idea, an embodiment of the present invention provides a sequence recommendation method represented by a bidirectional encoder based on a transformer, see. Figure 1 The method includes: step 1: using a bidirectional encoder based on a self-attention mechanism to capture the bidirectional dependency relationship and co-occurrence characteristics of items in the user's historical behavior sequence; step 2: using the bidirectional dependency relationship and co-occurrence characteristic relationship of the items obtained in step 1, in the pre-training stage, to address the large disparity in the ratio of positive and negative samples caused by data sparsity, a masked language model of the bidirectional encoder is used to train the model in a self-supervised manner; step 3: using the model training parameters in step 2 to train the network using user historical behavior sequence data in the fine-tuning stage to ensure that the target item labels are balanced.

[0039] Based on the content of the above method embodiment, as an optional embodiment, the sequence recommendation method based on bidirectional encoder representation of the transformer provided in the embodiment of the present invention, step 1 specifically includes: step 1.1: in the input layer, prepare the initial representation of the video and send it to the sequence encoder. The sequence encoder of the model is composed of multiple self-attention layers stacked together to obtain the initial embedding vector representation of the video in the user behavior sequence; step 1.2: based on the initial embedding vector representation of the video in the user behavior sequence obtained in step 1.1, in the sequence encoding layer, use the sequence encoder to initialize the parameters of the corresponding part, without starting training from the beginning, to obtain the corresponding part of the model parameters; step 1.3: based on the corresponding part of the model parameters obtained in step 1.2, in the model pre-training stage, use the negative log-likelihood function as the loss function optimization method to obtain better model training parameters; step 1.4: for the better model training parameters obtained in step 1.3, in the model fine-tuning stage, use the pre-trained input layer and sequence encoder parameters to initialize the corresponding part of the model parameters, and use average pooling to aggregate the hidden layer of all videos in the user behavior sequence. Embed vector representation to obtain the hidden layer embedding vector representation of the masked video; Step 1.5: For the hidden layer embedding vector representation of the masked video obtained in Step 1.4, in the output layer, obtain the hidden layer representation of the masked video and use it to predict the classification probability to obtain the probability of the target video being clicked; Step 1.2 includes sub-steps: Step 1.2.1: The multi-head attention mechanism applies the scaled dot product multiplication attention mechanism multiple times in parallel, and the independent attention mechanism outputs are connected in series and linearly converted to the expected dimension to obtain different space vector representations under linear mapping; Step 1.2.2: Based on the different space vector representations under linear mapping obtained in Step 1.2.1, in order to ensure that the model has nonlinear expression capabilities and that features of different dimensions interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, and the representation of the position feedforward network is obtained; Step 1.2.3: Based on the representation of the position feedforward network obtained in Step 1.2.2, a multi-layer transformer stack is used to consider capturing more complex bidirectional dependencies to obtain a hidden layer video embedding vector representation; In step 1.1, element addition is used to form the video s i The initial embedding representation vector Calculations include:

[0040]

[0041] Among them, p i represents the position embedding vector, Indicates video i The feature vector of , the initial representation vector of the user behavior sequence s is obtained, Among them, H 0 ∈R L×d, set a user behavior sequence S = {s1,s2,...,s L}, by taking the i-th video s in the user behavior sequence i Convert to a relatively low-dimensional space and convert it to a d-dimensional vector.

[0042] Based on the content of the above method embodiment, as an optional embodiment, the sequence recommendation method based on bidirectional encoder representation of transformer provided in the embodiment of the present invention, in step 1.2.1, the multi-head attention mechanism does not calculate the attention weight only once, but applies the scaled dot product multiplication attention mechanism h times in parallel. The independent attention mechanism outputs are concatenated and linearly converted to the expected dimension, and the inputs are linearly mapped to different spaces respectively. The calculation includes:

[0043]

[0044]

[0045] in, W i C ∈R d×d are all parameter matrices to be learned, and h is set to 4. is the representation vector matrix of the video sequence S at the mth layer, Attention(·) is the attention score, head i is the multi-head attention score, and MH(·) is the multi-head attention map.

[0046] Based on the content of the above method embodiment, as an optional embodiment, the sequence recommendation method based on bidirectional encoder representation of transformer provided in the embodiment of the present invention, in step 1.2.2, in order to enable the model to have nonlinear expression capabilities and allow features of different dimensions to interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, including two linear transformations, with an activation function of Gaussian error linear unit in the middle. The calculation includes:

[0047] FFN(x)=GELU(xW1+b1)W2+b2

[0048] Where W1∈R d×4d ,W2∈R 4d×d ,b1∈R 4d and b2∈R d It is the parameter to be learned, and each video shares the parameter to be learned

[0049] Based on the content of the above method embodiment, as an optional embodiment, the sequence recommendation method based on bidirectional encoder representation of transformer provided in the embodiment of the present invention, in step 1.2.3, to better train the model, residual connections and layer normalization are added between the multi-layer transformers. The model iteratively stacks M layers of transformers to obtain a modified hidden layer representation of each video sequence, where the calculation of the hidden layer video representation of the mth layer includes:

[0050]

[0051]

[0052]

[0053] Where, LN(·) represents layer normalization; is the representation vector matrix of the video sequence S at the mth layer

[0054] Based on the content of the above method embodiment, as an optional embodiment, the sequence recommendation method based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention, in step 2, the M-th hidden layer representation of the position i is Send it to the fully connected layer to perform softmax function classification operation to determine whether it is the video s that was originally covered i , calculation methods include:

[0055]

[0056] in, is the parameter matrix to be learned, b3 and b0 are bias vectors, c f is the feature matrix defined in the input layer section; when using ID class embedding features, c f Then it contains all embedded feature vectors, is the mask video s in sequence S i The predicted probability distribution of ; softmax(·) represents the activation function; GELU(·) represents the Gaussian error linear unit; Represents the Mth hidden layer representation of position i in the video sequence.

[0057] Based on the content of the above method embodiment, as an optional embodiment, the sequence recommendation method based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention, in step 3, the user interest representation h s and target video representation h t Spliced together and sent to the interaction layer to predict the user click probability The interaction layer is an inner product operation. The interaction layer is implemented using a multi-layer perceptron. The number of neurons in the multi-layer perceptron is set to 128→64→1. In the fine-tuning stage, the objective function used is the sigmoid cross entropy loss function, which is defined as follows:

[0058]

[0059] Where y∈{0,1} is the label, 0 means the user did not click on the video, 1 means the user clicked on the video, σ(·) is the sigmoid function; Indicates the predicted user click rate; L F represents the loss function.

[0060] The sequence recommendation method based on the transformer-based bidirectional encoder representation provided by the embodiment of the present invention can fully learn the bidirectional dependencies and item co-occurrence characteristics of items in the user behavior sequence, characterize the item co-occurrence characteristics and bidirectional dependencies in the user's long-term and short-term behavior sequences, and can effectively alleviate the system cold start problem and effectively improve the recommendation performance of the target platform.

[0061] Based on the above method, in another embodiment, a recommendation device of a sequence recommendation platform that can automatically implement the method is also provided. The device includes an input layer module, a sequence encoding layer module, a model training layer module, a model fine-tuning layer module, an output layer module, an input display unit, and a control unit.

[0062] The input layer module prepares the initial representation of the video and feeds it into the sequence encoder. The model's sequence encoder is composed of multiple stacked self-attention layers, also known as Transformer layers, which produce the initial embedding vector representation of the video in the user behavior sequence.

[0063] The sequence encoding layer module uses the initial embedding vector representation of the video in the user behavior sequence. In the sequence encoding layer, the sequence encoder is used to initialize the corresponding parameters instead of training from scratch to obtain the corresponding parameters of the model.

[0064] The model training layer module uses some parameters corresponding to the obtained model. In the model pre-training stage, the negative log-likelihood function is used as the loss function optimization method to obtain better model training parameters;

[0065] The model fine-tuning layer module uses the optimized model training parameters obtained according to the content described in step A4 above. During the model fine-tuning phase, the pre-trained input layer and sequence encoder parameters are directly used to initialize the corresponding model parameters. Then, average pooling is used to aggregate the hidden layer embedding vector representations of all videos in the user behavior sequence to obtain the hidden layer embedding vector representation of the masked video.

[0066] The output layer module uses the obtained hidden layer embedding vector representation of the masked video. At the output layer, the hidden layer representation of the masked video is obtained and used to predict the classification probability to obtain the probability of the target video being clicked.

[0067] The input display unit is communicatively connected to the input layer module, sequence encoding layer module, model training layer module, model fine-tuning layer module, and output layer module, allowing the user to input control instructions and display accordingly.

[0068] The control unit is communicatively connected with the input layer module, sequence encoding layer module, model training layer module, model fine-tuning layer module, output layer module, and input display unit to control their operation.

[0069] The implementation basis of each embodiment of the present invention is to implement it through programmed processing by a device with processor functions. Therefore, in engineering practice, the technical solutions and functions of each embodiment of the present invention can be encapsulated into various modules. Based on this reality, on the basis of the above embodiments, an embodiment of the present invention provides a sequence recommendation device based on a bidirectional encoder representation of a transformer, which is used to execute the sequence recommendation method based on a bidirectional encoder representation of a transformer in the above method embodiment. Figure 2 The device includes: a first main module, used to implement step 1: using a bidirectional encoder based on a self-attention mechanism to capture the bidirectional dependency relationship and co-occurrence characteristics of items in the user's historical behavior sequence; a second main module, used to implement step 2: using the bidirectional dependency relationship and co-occurrence characteristic relationship of the items obtained in step 1, in the pre-training stage, in view of the large disparity in the ratio of positive and negative samples caused by data sparsity, a masked language model of the bidirectional encoder is used to train the model in a self-supervised manner; a third main module, used to implement step 3: using the model training parameters in step 2 to train the network using user historical behavior sequence data in the fine-tuning stage to ensure that the target item labels are balanced.

[0070] The embodiment of the present invention provides a sequence recommendation device based on a bidirectional encoder representation of a transformer, which adopts Figure 2 Several modules in it can fully learn the bidirectional dependencies and item co-occurrence characteristics of items in user behavior sequences, characterize the item co-occurrence characteristics and bidirectional dependencies in users' long-term and short-term behavior sequences, and can effectively alleviate the system cold start problem and effectively improve the recommendation performance of the target platform.

[0071] It should be noted that the device in the device embodiment provided by the present invention can be used to implement the method in the above-mentioned method embodiment as well as the method in other method embodiments provided by the present invention. The only difference is that the corresponding functional modules are set. The principle is basically the same as the principle of the above-mentioned device embodiment provided by the present invention. As long as those skilled in the art refer to the specific technical solutions in other method embodiments on the basis of the above-mentioned device embodiment, obtain the corresponding technical means and the technical solutions composed of these technical means by combining technical features, and ensure the practicality of the technical solutions, they can improve the device in the above-mentioned device embodiment to obtain the corresponding device class embodiment, thereby obtaining the corresponding device class embodiment for implementing the methods in other method class embodiments. For example:

[0072] Based on the content of the above-mentioned device embodiment, as an optional embodiment, the sequence recommendation device based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention further includes: a first submodule, which is used to implement step 1, specifically including: step 1.1: in the input layer, prepare the initial representation of the video and send it to the sequence encoder. The sequence encoder of the model is composed of multiple self-attention layers stacked together to obtain the initial embedding vector representation of the video in the user behavior sequence; step 1.2: based on the initial embedding vector representation of the video in the user behavior sequence obtained in step 1.1, in the sequence encoding layer, use the sequence encoder to initialize the parameters of the corresponding part, without starting training from scratch, to obtain the corresponding part of the model parameters; step 1.3: based on the corresponding part of the model parameters obtained in step 1.2, in the model pre-training stage, use the negative log-likelihood function as the loss function optimization method to obtain better model training parameters; step 1.4: for the better model training parameters obtained in step 1.3, in the model fine-tuning stage, use the pre-trained input layer and sequence encoder parameters to initialize the corresponding part of the model parameters, and use average pooling to aggregate the user behavior sequence. The hidden layer embedding vector representation of all videos is used to obtain the hidden layer embedding vector representation of the masked video; Step 1.5: For the hidden layer embedding vector representation of the masked video obtained in Step 1.4, at the output layer, the hidden layer representation of the masked video is obtained and used to predict the classification probability to obtain the probability of the target video being clicked; Step 1.2 includes the following sub-steps: Step 1.2.1: The multi-head attention mechanism applies the scaled dot product multiplication attention mechanism multiple times in parallel, and the independent attention mechanism outputs are connected in series and linearly transformed into the expected dimension to obtain different space vectors under the linear mapping Representation; Step 1.2.2: Based on step 1.2.1, different spatial vector representations under linear mapping are obtained. To ensure that the model has nonlinear expression capabilities and that features of different dimensions interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, and the representation of the position feedforward network is obtained; Step 1.2.3: Based on the representation of the position feedforward network obtained in step 1.2.2, a multi-layer transformer stack is used to consider capturing more complex bidirectional dependencies and obtain the hidden layer video embedding vector representation; In step 1.1, element addition is used to form the video s i The initial embedding representation vector Calculations include:

[0073]

[0074] Among them, p i represents the position embedding vector, Indicates video i The feature vector of , the initial representation vector of the user behavior sequence s is obtained, Among them, H 0 ∈R L×d, set a user behavior sequence S = {s1,s2,...,s L}, by taking the i-th video s in the user behavior sequence i Convert to a relatively low-dimensional space and convert it to a d-dimensional vector.

[0075] Based on the content of the above device embodiment, as an optional embodiment, the sequence recommendation device based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention further includes: a second submodule, which is used to implement that in step 1.2.1, the multi-head attention mechanism does not calculate the attention weight only once, but applies the scaled dot product multiplication attention mechanism h times in parallel, and the independent attention mechanism outputs are connected in series and linearly converted to the expected dimension, and the inputs are linearly mapped to different spaces respectively. The calculation includes:

[0076]

[0077]

[0078] in, W i C ∈R d×d are all parameter matrices to be learned, and h is set to 4. is the representation vector matrix of the video sequence S at the mth layer, Attention(·) is the attention score, head i is the multi-head attention score, and MH(·) is the multi-head attention map.

[0079] Based on the content of the above device embodiment, as an optional embodiment, the sequence recommendation device based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention further includes: a third submodule, which is used to implement in step 1.2.2 that, in order to enable the model to have nonlinear expression capabilities and allow features of different dimensions to interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, including two linear transformations, with an activation function of a Gaussian error linear unit in the middle, and the calculation includes:

[0080] FFN(x)=GELU(xW1+b1)W2+b2

[0081] Where W1∈R d×4d ,W2∈R 4d×d ,b1∈R 4d and b2∈R d It is the parameter to be learned, and each video shares the parameter to be learned

[0082] Based on the content of the above device embodiment, as an optional embodiment, the sequence recommendation device based on bidirectional encoder representation of transformer provided in the embodiment of the present invention further includes: a fourth submodule, which is used to implement in step 1.2.3, to better train the model, adding residual connections and layer normalization in the middle of the multi-layer transformer, and iteratively stacking M layers of transformer layers to obtain a modified hidden layer representation of each video sequence, wherein the calculation of the hidden layer video representation of the mth layer includes:

[0083]

[0084]

[0085]

[0086] Where, LN(·) represents layer normalization; is the representation vector matrix of the video sequence S at the mth layer

[0087] Based on the content of the above device embodiment, as an optional embodiment, the sequence recommendation device based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention further includes: a fifth submodule for implementing in step 2, the Mth hidden layer representation of the position i Send it to the fully connected layer to perform softmax function classification operation to determine whether it is the video s that was originally covered i , calculation methods include:

[0088]

[0089] in, is the parameter matrix to be learned, b3 and b0 are bias vectors, c f is the feature matrix defined in the input layer section; when using ID class embedding features, c f Then it contains all embedded feature vectors, is the mask video s in sequence S i The predicted probability distribution of ; softmax(·) represents the activation function; GELU(·) represents the Gaussian error linear unit; Represents the Mth hidden layer representation of position i in the video sequence.

[0090] Based on the content of the above device embodiment, as an optional embodiment, the sequence recommendation device based on the bidirectional encoder representation of the transformer provided in the embodiment of the present invention further includes: a sixth submodule for implementing in step 3, the user interest representation h s and target video representation h t Spliced together and sent to the interaction layer to predict the user click probability The interaction layer is an inner product operation. The interaction layer is implemented using a multi-layer perceptron. The number of neurons in the multi-layer perceptron is set to 128→64→1. In the fine-tuning stage, the objective function used is the sigmoid cross entropy loss function, which is defined as follows:

[0091]

[0092] Where y∈{0,1} is the label, 0 means the user did not click on the video, 1 means the user clicked on the video, σ(·) is the sigmoid function; Indicates the predicted user click rate; L F represents the loss function.

[0093] The method of the embodiment of the present invention is implemented by electronic devices, so it is necessary to introduce the relevant electronic devices. Based on this purpose, the embodiment of the present invention provides an electronic device, such as Figure 3 As shown, the electronic device includes: at least one processor, a communications interface, at least one memory, and a communications bus, wherein the at least one processor, the communications interface, and the at least one memory communicate with each other via the communications bus. The at least one processor can call logic instructions in the at least one memory to execute all or part of the steps of the methods provided in the aforementioned method embodiments.

[0094] In addition, the logic instructions in the at least one memory mentioned above can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each method embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0095] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0096] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0097] The flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. Based on this understanding, each box in the flowchart or block diagram can represent a module, program segment or part of the code, and the module, program segment or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, or sometimes in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0098] It should be noted that the terms "comprise," "include," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, the elements defined by the phrase "comprise..." do not preclude the presence of additional identical elements in the process, method, article, or apparatus comprising the elements.

[0099] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A sequence recommendation method based on bidirectional encoder representation of transformer, characterized in that include: Step 1: A bidirectional encoder based on a self-attention mechanism is used to capture the bidirectional dependencies and co-occurrence characteristics of items in the user's historical behavior sequence. Step 2: Using the bidirectional dependencies and co-occurrence characteristics of the items obtained in Step 1, in the pre-training phase, a masked language model of the bidirectional encoder is used to train the model in a self-supervised manner to address the large disparity in the ratio of positive and negative samples caused by data sparsity. Step 3: The model training parameters in Step 2 are used to train the network using user historical behavior sequence data in the fine-tuning phase to ensure balanced target item labels. Step 1 specifically includes: Step 1.1: In the input layer, prepare the initial representation of the video and send it to the sequence encoder. The sequence encoder of the model is composed of multiple self-attention layers stacked together to obtain the initial embedding vector representation of the video in the user behavior sequence; In step 1.1, the video is formed by element addition. The initial embedding representation vector , the calculation includes: in, represents the position embedding vector, Represents a video The feature vector of , the initial representation vector of the user behavior sequence s is obtained, ,in, , set a user behavior sequence of length L , by taking the i-th video in the user behavior sequence Convert to a relatively low-dimensional space and convert it to a d-dimensional vector; Step 1.2: Based on the initial embedding vector representation of the video in the user behavior sequence obtained in step 1.1, in the sequence encoding layer, the sequence encoder is used to initialize the parameters of the corresponding part, without starting training from scratch, to obtain the corresponding parameters of the model; Step 1.2 includes sub-steps: Step 1.2.1: The multi-head attention mechanism applies the scaled dot product multiplication attention mechanism multiple times in parallel, and the independent attention mechanism outputs are connected in series and linearly converted into the expected dimension to obtain different space vector representations under linear mapping; Step 1.2.2: Based on the different space vector representations under linear mapping obtained in step 1.2.1, to ensure that the model has nonlinear expression capabilities and that features of different dimensions interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, and the representation of the position feedforward network is obtained; Step 1.2.3: Based on the representation of the position feedforward network obtained in step 1.2.2, a multi-layer transformer stack is used to consider capturing more complex bidirectional dependencies to obtain a hidden layer video embedding vector representation.

2. The sequence recommendation method based on bidirectional encoder representation of transformer according to claim 1, characterized in that Step 1 specifically also includes: Step 1.3: Based on the partial parameters corresponding to the model obtained in Step 1.2, in the model pre-training stage, the negative log-likelihood function is used as the loss function optimization method to obtain better model training parameters; Step 1.4: For the better model training parameters obtained in Step 1.3, in the model fine-tuning stage, the pre-trained input layer and sequence encoder parameters are used to initialize the partial parameters corresponding to the model, and average pooling is used to aggregate the hidden layer embedding vector representations of all videos in the user behavior sequence to obtain the hidden layer embedding vector representation of the masked video; Step 1.5: For the hidden layer embedding vector representation of the masked video obtained in Step 1.4, at the output layer, the hidden layer representation of the masked video is obtained, and used to predict the classification probability to obtain the probability of the target video being clicked.

3. The sequence recommendation method based on bidirectional encoder representation of transformer according to claim 1, characterized in that In step 1.2.1, the multi-head attention mechanism does not calculate the attention weights only once. Instead, it applies the scaled dot product attention mechanism h times in parallel. The independent attention mechanism outputs are concatenated and linearly transformed to the expected dimensions. The input is linearly mapped into different spaces. The calculation includes: in, , , , are all parameter matrices to be learned, and h is set to 4. is the representation vector matrix of the video sequence S at the mth layer, is the attention score, is the multi-head attention score, is a multi-head attention map.

4. The sequence recommendation method based on bidirectional encoder representation of transformer according to claim 1, characterized in that In step 1.2.2, to enable the model to have nonlinear expression capabilities and allow features of different dimensions to interact, the positional feedforward layer applied to the representation of each video in the sequence representation is the same, consisting of two linear transformations with a Gaussian error linear unit activation function in the middle. The calculation includes: in, , , and are the parameters to be learned, and each video shares the parameters to be learned; represents the Gaussian error linear unit; represents the activation function; x represents the video item variable.

5. The sequence recommendation method based on bidirectional encoder representation of transformer according to claim 4, characterized in that In step 1.2.3, to better train the model, residual connections and layer normalization are added between the multi-layer transformers. The model iteratively stacks M layers of transformers to obtain the modified hidden layer representation of each video sequence. The calculation of the hidden layer video representation of the mth layer includes: in, Representation layer normalization; is the representation vector matrix of the video sequence S at the mth layer; represents the video conversion function, represents the hidden layer video representation of the mth layer; For multi-head attention mapping; Represents the activation function.

6. The sequence recommendation method based on bidirectional encoder representation of transformer according to claim 5, characterized in that In step 2, the Mth hidden layer at position i is represented Send it to the fully connected layer to perform softmax function classification operation to determine whether it is the video that was originally covered. , calculation methods include: in, is the parameter matrix to be learned, and is the bias vector, is the feature matrix defined in the input layer section; when using ID class embedding features, Then it contains all embedded feature vectors, is the mask video in sequence S The predicted probability distribution of represents the activation function; represents the Gaussian error linear unit; Represents the Mth hidden layer representation of position i in the video sequence.

7. The sequence recommendation method based on bidirectional encoder representation of transformer according to claim 6, characterized in that In step 3, user interest representation and target video representation Spliced together and sent to the interaction layer to predict the user click probability , where the interaction layer is an inner product operation. The interaction layer is implemented using a multi-layer perceptron. The number of neurons in the multi-layer perceptron is set to 128→64→1. In the fine-tuning stage, the objective function used is the sigmoid cross entropy loss function, which is defined as follows: in, is a label, 0 means the user did not click on the video, 1 means the user clicked on the video, is the sigmoid function; Represents the predicted user click rate; represents the loss function.

8. A sequence recommendation device based on bidirectional encoder representation of transformer, characterized in that include: The first main module is used to implement step 1: using a bidirectional encoder based on the self-attention mechanism to capture the bidirectional dependencies and co-occurrence characteristics of items in the user's historical behavior sequence; step 1 specifically includes: step 1.1: in the input layer, prepare the initial representation of the video and send it to the sequence encoder. The sequence encoder of the model is composed of multiple stacked self-attention layers to obtain the initial embedding vector representation of the video in the user behavior sequence; in step 1.1, the video is formed by element addition. The initial embedding representation vector , the calculation includes: in, represents the position embedding vector, Represents a video The feature vector of , the initial representation vector of the user behavior sequence s is obtained, ,in, , set a user behavior sequence of length L , by taking the i-th video in the user behavior sequence Convert to a relatively low-dimensional space and convert it to a d-dimensional vector; Step 1.2: Based on the initial embedding vector representation of the video in the user behavior sequence obtained in step 1.1, in the sequence encoding layer, the sequence encoder is used to initialize the corresponding part of the parameters, without starting training from scratch, to obtain the corresponding part of the model parameters; Step 1.2 includes sub-steps: Step 1.2.1: The multi-head attention mechanism applies the scaled dot product multiplication attention mechanism multiple times in parallel, and the independent attention mechanism outputs are connected in series and linearly converted to the expected dimension to obtain different space vector representations under linear mapping; Step 1.2.2: Based on the different space vector representations under linear mapping obtained in step 1.2.1, to ensure that the model has nonlinear expression capabilities and that features of different dimensions interact, the position feedforward layer applied to the representation of each video in the sequence representation is the same, and the representation of the position feedforward network is obtained; Step 1.2.3: Based on the representation of the position feedforward network obtained in step 1.2.2, a multi-layer transformer stack is used to consider capturing more complex bidirectional dependencies to obtain the hidden layer video embedding vector representation; The second main module is used to implement step 2: using the bidirectional dependency and co-occurrence feature relationships of the items obtained in step 1, in the pre-training phase, to address the large disparity in the ratio of positive and negative samples caused by data sparsity, a masked language model with a bidirectional encoder is used to train the model in a self-supervised manner; The third main module is used to implement step 3: the model training parameters in step 2 are used to train the network using user historical behavior sequence data in the fine-tuning phase to ensure that the target item labels are balanced.

9. An electronic device, characterized in that: include: At least one processor, at least one memory and a communication interface; wherein, The processor, memory and communication interface communicate with each other; The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the method according to any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores computer instructions, which cause the computer to execute the method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Commodity sequence recommendation method based on deep learning

    CN111429234A

  • Sequence recommendation method, system and device and medium

    CN114897145A