A sequence recommendation method based on bidirectional encoding and state reuse

Through the sequence recommendation method of bidirectional encoding and state multiplexing, the problem of CNN-based sequence recommendation algorithm in unidirectional modeling and failure to establish adjacent subsequence connections is solved, and the effect of capturing more complex dependencies and dependencies beyond the subsequence length is achieved.

CN114780852BActive Publication Date: 2025-04-15NORTHWEST UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210474168.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-29
Publication Date
2025-04-15
Estimated Expiration
2042-04-29

AI Technical Summary

Technical Problem

The CNN-based sequence recommendation algorithm has limitations in the unidirectional modeling of user-project interaction sequences and failure to establish adjacent subsequence links, resulting in the model being unable to capture dependencies beyond the length of the subsequence.

Method used

Using the sequence recommendation method of bidirectional encoding and state multiplexing, the project context features are extracted through a non-causal convolution bidirectional encoder and fused with the project embedding sequence, and the relationship between subsequences is established using the causal convolution decoder and memory module.

Benefits of technology

This method can capture more complex dependencies between projects and establish dependencies beyond the length of the sub-sequence, improving the recommendation capabilities of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114780852B_ABST
    Figure CN114780852B_ABST
Patent Text Reader

Abstract

The present invention discloses a sequence recommendation method based on bidirectional encoding and state reuse. The method first extracts project context features through a bidirectional encoder of non-causal convolution and merges it with the project embedding sequence. Then, during the convolution of the causal convolution decoder, the hidden state sequence of the previous subsequence cached in the memory module is taken as the padding content to establish the connection between subsequences. Finally, the hidden state output by the causal convolution decoder is used to predict the project that the user may interact with next time. The method mines the front-to-back dependency relationship of projects in the sequence by bidirectionally encoding project features. The traditional model training methods, namely data enhancement and autoregressive models, are unidirectional modeling from left to right, which limits the prediction ability of the model. Compared with the traditional method, it can capture more complex dependencies between projects. Compared with the traditional model that can only mine the project dependencies within the subsequence, this method can capture longer-distance project dependencies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer recommendation systems, and in particular relates to a sequence recommendation method based on bidirectional coding and state multiplexing. Background Art

[0002] In daily life, whether users buy goods, watch videos or read news online, their historical behavior is a sequence sorted over time. There is a certain dependency between the behavior sequence, so mining such sequence patterns is valuable for recommendation systems.

[0003] Traditional recommendation algorithms mine users' general preferences by statically modeling user historical data, but such methods are not suitable for sequential recommendation. In recent years, researchers have applied deep learning methods to sequential recommendation, mining project dependencies and users' long-term and short-term interests by modeling users' historical behavior sequences, and have achieved good recommendation results. Among them, convolutional neural networks are usually used to process time series data and are suitable for capturing the dependencies of local information in sequences, so they are applied to sequential recommendation. For example, Tang et al. proposed the Caser model, which regards multiple adjacent items in the user behavior sequence as "images" and captures point-like, set-like, and sequence patterns that allow skipping behaviors through horizontal and vertical filters, thereby mining users' short-term preferences. Yuan et al. improved the Caser model and proposed the NextItNet model. The model replaces the standard convolution with stacked dilated convolutions, which increases the receptive field and alleviates the problem that the CNN-based sequential recommendation algorithm can only capture users' short-term interests.

[0004] Although the CNN-based sequence recommendation algorithm has achieved certain results, it is still in its infancy and has some problems. First, most CNN-based sequence recommendation algorithms model the user-item interaction sequence from left to right in a unidirectional manner. For example, the Caser model uses data augmentation to train the model, and the NextItNet model uses autoregression to train the model. Both training methods are unidirectional modeling from left to right, which limits the recommendation ability of the model. Second, the length of user historical behavior sequences varies, and the model usually requires the input sequence length to be consistent. Therefore, it is necessary to divide the complete user behavior sequence into multiple subsequences of equal length and input them into the model for training. Although the model can mine the project dependencies within the subsequence, it does not establish connections between adjacent subsequences, resulting in the model being unable to capture dependencies beyond the length of the subsequence. Summary of the invention

[0005] In view of the technical problems that the CNN-based sequence recommendation algorithm unidirectionally models the user-item interaction sequence and fails to establish connections between adjacent subsequences, the purpose of the present invention is to provide a sequence recommendation method based on bidirectional encoding and state multiplexing.

[0006] In order to achieve the above tasks, the present invention adopts the following technical solutions:

[0007] A sequence recommendation method based on bidirectional encoding and state reuse first extracts item context features through a non-causal convolutional bidirectional encoder and merges them with the item embedding sequence. Then, during the convolution of the causal convolutional decoder, the hidden state sequence of the previous subsequence cached in the memory module is taken as the padding content to establish the connection between subsequences. Finally, the hidden state output by the causal convolutional decoder is used to predict the item that the user may interact with next.

[0008] The specific steps include:

[0009] Step 1: Divide the user behavior sequence into multiple subsequences of equal length and create training sets, validation sets, and test sets;

[0010] Step 2: Establish a relationship dictionary between subsequences;

[0011] Step 3: Mask the input sequence and encode it using Embedding technology;

[0012] Step 4: Obtain the item context feature sequence through a non-causal convolutional encoder;

[0013] Step 5: Encode the input sequence through the Embedding technology to obtain the item embedding sequence;

[0014] Step 6: The item context feature sequence and the item embedding sequence are fused through feature addition operation to obtain a feature sequence;

[0015] Step 7: Read the hidden state sequence of the previous subsequence from the memory module as the padding content during the convolution operation of the causal convolution decoder;

[0016] Step 8: Decode using the causal convolutional decoder;

[0017] Step 9: Calculate the probability of each item using the softmax function;

[0018] Step 10: Use the cross entropy loss function to calculate the loss value of the model and update the model parameters through back propagation.

[0019] According to the present invention, the implementation of step 1 includes:

[0020] In the data preprocessing stage, the user-item interaction items in the dataset are sorted by timestamp to obtain the historical behavior sequence of each user; the lengths of the user's historical behavior sequences are not consistent and vary greatly, so the user behavior sequence is divided into multiple subsequences of equal length and input into the model for training respectively.

[0021] Furthermore, the non-causal convolutional bidirectional encoder is composed of a plurality of non-causal convolutional layers stacked together, each of which is composed of two non-causal dilated convolution operations and a residual connection, and is calculated as follows:

[0022]

[0023] in, represents the input sequence of the non-causal convolutional layer, and represents the non-causal hole convolution, σ represents the ReLU activation function, and the expression is as follows:

[0024] f ( x ) = max(0, x )

[0025] LN stands for layer normalization, which normalizes all neurons in an intermediate layer;

[0026] No. l The input of the layer is denoted as Z (l) , its mean and variance are calculated as follows:

[0027]

[0028]

[0029] where n (l) For the l The number of neurons in the layer;

[0030] Layer normalization is defined as:

[0031]

[0032] in, γ and β The parameter vector representing the scale and translation, and Z (l) The dimensions are the same.

[0033] The sequence recommendation algorithm based on bidirectional coding and state multiplexing of the present invention has the following beneficial effects:

[0034] By bidirectionally encoding project features, the dependencies between items in the sequence are mined. The traditional model training methods, namely data enhancement and autoregressive models, are unidirectional modeling from left to right, which limits the prediction ability of the model. Therefore, compared with traditional methods, the present invention can capture more complex dependencies between items. The hidden state sequence of the previous subsequence is reused through the memory module as the extended context of the current subsequence, thereby establishing a connection between subsequences. Compared with traditional models that can only mine project dependencies within subsequences, the present invention can capture project dependencies over longer distances. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 It is a model diagram of the sequence recommendation method based on bidirectional coding and state multiplexing of the present invention;

[0036] Figure 2 This is a diagram of the non-causal convolutional layer structure;

[0037] Figure 3 It is the NextItNet model training graph;

[0038] Figure 4 It is a diagram of the memory module structure;

[0039] Figure 5 is the model training graph;

[0040] Figure 6 It is a diagram of the causal convolutional layer structure.

[0041] The present invention is further described in detail below with reference to the accompanying drawings and embodiments. DETAILED DESCRIPTION

[0042] See also Figure 1 This embodiment provides a sequence recommendation method based on bidirectional encoding and state reuse. First, the item context features are extracted through a non-causal convolutional bidirectional encoder and merged with the item embedding sequence. Then, during the convolution of the causal convolution decoder, the hidden state sequence of the previous subsequence cached in the memory module is taken as the padding content to establish the connection between subsequences. Finally, the hidden state output by the causal convolution decoder is used to predict the item that the user may interact with next time.

[0043] In this embodiment, the inventors construct a non-causal convolutional bidirectional encoder based on the NextItNet model, which performs well in the current CNN sequence recommendation model, and reuse the hidden state of the previous subsequence as the extended context of the current subsequence.

[0044] The specific steps include:

[0045] Step 1: Divide the user behavior sequence into multiple subsequences of equal length and create training sets, validation sets, and test sets.

[0046] In the data preprocessing stage, the user-item interaction items in the dataset are sorted by timestamp to obtain each user's historical behavior sequence. The lengths of the user's historical behavior sequences are not consistent and vary greatly, so the user behavior sequence is divided into multiple subsequences of equal length and input into the model for training.

[0047] Given a historical behavior sequence {X1, X2, ..., X n}, set the subsequence length to K, then the subsequence {X n-k+1 , …, X n} is added to the test set, and the subsequence {X n-k , …, X n-1} to the validation set, and {X1,…,X n-2} is divided into multiple subsequences of length K and added to the training set, thereby producing a training set, a validation set, and a test set with a subsequence length of K. Different K values ​​can be set to obtain training sets, validation sets, and test sets with different subsequence lengths. When dividing the subsequence, if the subsequence length is less than K but greater than L, zero is added. When the subsequence length is less than L, the subsequence is discarded.

[0048] Step 2: Create a dictionary of relationships between subsequences

[0049] In order to establish the relationship between user behavior subsequences, a unique subsequence id number is assigned to each subsequence in the data preprocessing stage, denoted as S i For example, a user's behavior sequence is divided into four subsequences, which are recorded as subsequences S i , S i+1 , S i+2 and S i+3 . subsequence S i yes S i+1 The previous subsequence of S i+1 The expansion context, therefore, converts the subsequence S i and subsequences S i+1 The relationship is stored in the dictionary and recorded as , so that the subsequence id number can be S i+1 Find the previous subsequence id number S i . And so on, generate a relational dictionary containing 3 key-value pairs dic = {Si+1 :S i , S i+2 :S i+1 , S i+3 :S i+2}.

[0050] Step 3: Mask the input sequence and encode it using Embedding technology

[0051] The non-causal convolutional encoder randomly masks 50% of the items in the sequence. If an item is selected to be masked, the id value of the item is replaced with n+1 (the total number of items is n).

[0052] Assume that the input user behavior subsequence is { x 1, x 2, x 3, ..., x 10}, through the mask mechanism becomes { x 1, n+1, x 4, n+1, x 6. x 7, n+1, n+1, x 10}, through the Embedding matrix Encode the sequence of item ids into a sequence of item embeddings { }, as the input to the non-causal convolutional encoder.

[0053] When training the model, the selection of which items to mask is dynamic and random. In different epochs of training, items at different positions in the item sequence are randomly masked, so that the model can be better trained.

[0054] Step 4: Obtain item context feature sequence through non-causal convolutional encoder

[0055] Non-causal convolution is a common convolution, which performs convolution operations on the left and right item data in the sequence to mine the bidirectional dependency relationship between items. The non-causal convolution encoder is composed of multiple non-causal convolution layers stacked together, as shown in the attached figure. Figure 2 As shown in Figure 1, each non-causal convolutional layer consists of two non-causal dilated convolution operations and a residual connection, which is calculated as follows:

[0056]

[0057] in represents the input sequence of the non-causal convolutional layer, and represents the non-causal hole convolution, σ represents the ReLU activation function, and the expression is as follows:

[0058] f ( x ) = max(0, x )

[0059] LN stands for layer normalization, which normalizes all neurons in an intermediate layer.

[0060] No. l The input of the layer is denoted as Z (l) , its mean and variance are calculated as follows:

[0061]

[0062]

[0063] where n (l) For the l The number of neurons in a layer.

[0064] Layer normalization is defined as:

[0065]

[0066] in, γ and β The parameter vector representing the scale and translation, and Z (l) The dimensions are the same.

[0067] By stacking non-causal convolutional layers multiple times, the item features output by the non-causal convolutional encoder can contain the unmasked item information on its left and right, thereby mining the bidirectional dependencies between items. As the number of non-causal convolutional layers increases, the gradient disappearance phenomenon is prone to occur. To alleviate this problem, the non-causal convolutional layer adds a residual connection after two non-causal convolution operations.

[0068] Step 5: Perform Embedding encoding on the input sequence to obtain the item embedding sequence.

[0069] For the input sequence { x 1, x 2, x 3, ..., x 10}, through the Embedding matrix Encode the sequence of item ids into a sequence of item embeddings { }.

[0070] Step 6: The item context feature sequence and the item embedding sequence are fused through feature addition operation to obtain a feature sequence.

[0071] Step 7: Read the hidden state sequence of the previous subsequence from the memory module as the padding content during the convolution operation of the causal convolution decoder.

[0072] Since convolutional neural networks cannot process sequences of varying lengths, a common method is to divide the sequence into multiple subsequences of equal length and input them into the model for training. However, this approach ignores the relationship between subsequences. Figure 3 As shown in the figure, when the NextItNet model is trained, adjacent subsequences 1 and 2 cannot communicate with each other. The model can only mine the item dependencies within the subsequences, but cannot capture the item dependencies beyond the subsequence length.

[0073] The memory module caches the hidden state sequence of the subsequence in memory in a dictionary structure, as shown in the attached figure. Figure 4 As shown, the key of the dictionary is the subsequence id number, and the value is the hidden state sequence calculated by the subsequence in the decoder.

[0074] The causal convolution decoder of the model is composed of multiple stacked causal convolution layers. Before each convolution, the causal convolution layer queries the relationship dictionary between subsequences to see whether the previous adjacent subsequence of the current subsequence exists. If it exists, as shown in the attached Figure 5 As shown, the corresponding hidden state sequence is read from the memory module through the ID number of the previous subsequence for filling; if it does not exist, it is filled with all zeros. By reusing the state sequence of the previous subsequence, the connection between subsequences is established.

[0075] Step 8: Decode using the causal convolutional decoder.

[0076] The causal convolutional decoder of the model is composed of multiple causal convolutional layers stacked together, as shown in the attached figure. Figure 6 As shown in the figure, each causal convolution layer consists of two causal hole convolution operations and one residual connection, and the calculation formula is as follows:

[0077]

[0078]

[0079]

[0080] in, Represent the model as a subsequence S T is the input, the hidden state sequence output by the nth causal convolutional layer of the causal convolutional decoder, Represents the padding operation before convolution, using subsequence S T The hidden state sequence of De-fill subsequence S T+1 The hidden state sequence of , establish the connection between subsequences. σ represents the ReLU activation function, LN represents layer normalization, and Represents causal atrous convolution.

[0081] After causal convolution decoding, the current subsequence ID is used as the key and the hidden state sequence of all causal convolutional layers is used as the value and saved in the memory module for easy reading during the training of the next adjacent subsequence.

[0082] Step 9: Calculate the probability of each item using the softmax function.

[0083] The item latent vector is mapped to n dimensions (n ​​is the total number of items) through a fully connected layer and the softmax function is used to calculate the probability of each item to generate a Top-K recommendation list.

[0084] Step 10: Use cross entropy loss as the loss function of the model and update the model parameters through back propagation.

[0085] The present invention uses the cross entropy loss function CrossEntropyLoss() in Pytorch to calculate the loss value of the model. This loss function combines the two functions nn.LogSoftmax() and nn.NLLLoss(), which is very useful when doing classification training.

[0086] The above is only a preferred specific embodiment of the present invention, but the present invention is not limited to the above embodiment. Any technician familiar with the technical field, based on the technical solution disclosed by the present invention, shall add or replace the technical features of the technical solution of the present invention, which shall fall within the protection scope of the present invention.

Claims

1. A sequence recommendation method based on bidirectional coding and state multiplexing, characterized in that: First, the non-causal convolutional bidirectional encoder extracts the item context features and merges them with the item embedding sequence. Then, during the convolution of the causal convolution decoder, the hidden state sequence of the previous subsequence cached in the memory module is taken as the padding content to establish the connection between subsequences. Finally, the hidden state output by the causal convolution decoder is used to predict the item that the user may interact with next. The specific steps include: Step 1: Divide the user behavior sequence into multiple subsequences of equal length and create training sets, validation sets, and test sets; Step 2: Establish a relationship dictionary between subsequences; Step 3: Mask the input sequence and encode it using Embedding technology; Step 4: Obtain the item context feature sequence through a non-causal convolutional encoder; Step 5: Encode the input sequence through the Embedding technology to obtain the item embedding sequence; Step 6: The item context feature sequence and the item embedding sequence are fused through feature addition operation to obtain a feature sequence; Step 7: Read the hidden state sequence of the previous subsequence from the memory module as the padding content during the convolution operation of the causal convolution decoder; Step 8: Decode using the causal convolutional decoder; Step 9: Calculate the probability of each item using the softmax function; Step 10: Use the cross entropy loss function to calculate the loss value of the model and update the model parameters through back propagation; The implementation of step 1 includes: In the data preprocessing stage, the user-item interaction items in the data set are sorted by timestamp to obtain the historical behavior sequence of each user. The lengths of the user's historical behavior sequences are not consistent and vary greatly, so the user behavior sequence is divided into multiple subsequences of equal length and input into the model for training respectively. The non-causal convolutional bidirectional encoder is composed of multiple non-causal convolutional layers stacked together, each of which consists of two non-causal dilated convolution operations and a residual connection, and is calculated as follows: in, represents the input sequence of the non-causal convolutional layer, and represents the non-causal hole convolution, σ represents the ReLU activation function, and the expression is as follows: f ( x )=max(0, x ) LN stands for layer normalization, which normalizes all neurons in an intermediate layer; No. l The input of the layer is denoted as Z (l) , its mean and variance are calculated as follows: Where n (l) For the l The number of neurons in the layer; Layer normalization is defined as: in, γ and β a parameter vector representing scaling and translation, and The dimensions are the same.

Citation Information

Patent Citations

  • Sequence recommendation list generation method based on improved time sequence convolution network

    CN111753209A

  • Sequence recommendation method fusing dynamic knowledge graph

    CN113590900A