Sequence recommendation method based on global information and mixed time query attention mechanism

By introducing global information and mixed time query attention mechanism into the recommendation system, combined with multi-dimensional elliptical Gaussian distribution and sliding window mechanism, the problem of insufficient inter-item correlation and user collaboration signals is solved, the performance and accuracy of the recommendation system are improved, and the system is provided Personalized recommendations.

CN118568301AActive Publication Date: 2024-08-30NANJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202410644527.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-08-30
Estimated Expiration
2044-05-23

AI Technical Summary

Technical Problem

Existing recommendation systems have limitations in processing user behavior sequences, especially in terms of capturing direct correlations between items and understanding collaboration signals between users, resulting in poor recommendation results.

Method used

A sequence recommendation method based on global information and hybrid time query attention mechanism is adopted to capture the global information between items through the global item conversion graph, and combined with the multidimensional elliptical Gaussian distribution and sliding window mechanism, calculate the hybrid time query self-attention weight, and fuse Short-term and long-term sequence embedding, using Wasserstein distance to calculate item distribution distance for recommendation.

Benefits of technology

The performance and accuracy of the recommendation system are improved, and it can better capture users' dynamic preferences and project relationships, provide personalized recommendations, and have strong versatility and applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568301A
    Figure CN118568301A
Patent Text Reader

Abstract

The invention discloses a sequence recommendation method based on global information and a mixed time query attention mechanism, which comprises the following steps: S1, capturing global information among items in a user interaction sequence by using a global item conversion graph to obtain graph embedding; s2, inputting an interaction sequence of a user into an embedding layer, and generating sequence embedding of a mean value and a covariance of items in the interaction sequence of the user; s3, embedding the sequence generated in the S2, inputting the sequence into a mixed time query self-attention module, and outputting the mean value of the user interaction sequence and the new sequence embedding of the covariance; s4, introducing the output of S3 into a feed-forward network layer to obtain updated sequence embedding; s5, defining the sequence embedding updated by the feedforward network layer in the step S4 as short-term sequence embedding and long-term sequence embedding; s6, generating final embedding according to the short-term sequence embedding and the long-term sequence embedding; and S7, performing a recommendation task according to the final embedding output in S6. The performance and accuracy of the recommendation system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of recommendation systems, and in particular to a sequence recommendation method based on global information and a hybrid time query attention mechanism. Background Art

[0002] With the explosive growth of network information, recommendation systems have played a key role in alleviating information overload. Recommendation systems can select target data that users are interested in from massive data and have important application value. Traditional recommendation methods include collaborative filtering recommendation, content-based recommendation methods, tag-based recommendation methods, etc. These methods capture user preferences and model the interaction between users and items in a static way. However, in real life, user behaviors occur sequentially, and the connection between user behaviors is very close. User preferences are dynamic and change over time. In this case, it is necessary to build a method that can model user dynamic preferences. Sequential recommendation mainly recommends items that users may be interested in by modeling user-item interactions in sequences (for example, the sequential dependency on viewing or purchasing items on online shopping platforms).

[0003] At present, sequence recommendation methods can be roughly divided into three categories, including traditional sequence models, latent representation models, and deep neural network models. Traditional sequence models include sequence pattern mining and Markov chain models, which model the sequence dependencies between user-item interactions in sequences by utilizing natural strength. Sequence pattern mining can discover implicit correlations and scalability, but will be affected by data sparsity and implicit patterns; Markov chain models are simple and intuitive, computationally efficient, but rely on assumptions and lack global information. The choice of a model suitable for a specific application scenario depends on data attributes, modeling requirements, and performance requirements. Latent representation models include factorization machines and embeddings, which first learn the latent representation of each user or item, and then use the learned representation to predict subsequent user-item interactions. Its advantages include the ability to extract meaningful features, reduce the curse of dimensionality, and improve the generalization ability of the model. However, latent representation models also have some disadvantages and problems, such as difficulty in interpreting the learned representation, possible information loss, and insufficient generalization ability. With the development of deep learning, deep neural networks are integrated into sequence recommendation, and recurrent neural networks (RNNs) and their variants are applied to user behavior sequences. In addition to RNN, other deep learning models such as Transformer have also been adopted for sequential recommendation tasks and have achieved good performance. Transformer-based sequence recommendation is good at capturing the dynamic characteristics of user interests by modeling complex item-item transformation relationships in sequences. For example, SASRec, through the scaled dot product attention mechanism, pioneered the use of Transformer for sequence recommendation, greatly improving the understanding of how items are related to each other over time. Later, BERT4Rec proposed end-to-end historical sequence recommendation using a bidirectional attention mechanism. TiSASRec aims to solve the problem of temporal information modeling to more accurately capture the time interval relationship between items.

[0004] Although these have achieved good success in sequential recommendation, there are still some limitations:

[0005] First, Transformer-based sequential recommendation has been widely used in the field of recommendation systems due to its good ability to process sequence data. These models capture long-distance dependencies in sequences through self-attention mechanisms and effectively understand the contextual information of user behavior sequences, thereby predicting users' interests in unknown items. However, they have certain limitations in processing spatial information between items, especially the similarity or correlation between items. Although some models can indirectly capture the correlation between items through interactions between users and items, this correlation is usually implicit. Due to the lack of explicit modeling of direct associations between items, the recommendation system cannot fully utilize the existing knowledge of relationships between items, which affects the recommendation effect.

[0006] Second, the general self-attention model essentially limits itself to a first-order Markov chain model with enhanced attention, using only the most recent items embedded as queries into the self-attention module. This design limits the model’s ability to leverage a wider range of user behavior patterns for recommendation, as it focuses primarily on direct item-to-item transitions rather than capturing collaborative behaviors or long-term interest patterns between users. As a result, the recommendation performance is poor in scenarios that require understanding and leveraging collaborative signals between users. Summary of the invention

[0007] Purpose of the invention: In view of the limitations of existing recommendation systems in processing user behavior sequences, especially the inadequacy in capturing direct associations between items and understanding collaboration between users, the present invention proposes a sequence recommendation method based on global information and hybrid temporal query attention mechanism, which can make full use of global information and user collaboration information to improve the performance and accuracy of the recommendation system.

[0008] Technical solution: A sequence recommendation method based on global information and hybrid time query attention mechanism, including the following steps:

[0009] S1. Use the global item transition graph to capture the global information between items in the user interaction sequence, define a rule-based global item graph, use the global item graph learned by singular value decomposition to obtain the enhanced graph, and obtain the graph embedding through graph encoding;

[0010] S2, input the user's interaction sequence into the embedding layer, use multidimensional elliptical Gaussian distribution to represent the items in the user's interaction sequence, and generate a sequence embedding of the mean and covariance of the items in the user's interaction sequence;

[0011] S3: Input the sequence embedding generated in S2 into the hybrid time query self-attention module, use a sliding window, calculate the query vector by time-decayed weighted average method, and add the position information to the calculation of attention weight in the form of bias to obtain the output of the hybrid time query self-attention. The output result is a new sequence embedding of the mean and covariance of the user interaction sequence;

[0012] S4, embed the new sequence output in S3, introduce the feedforward network layer, add nonlinearity, and then perform residual connection, layer normalization and random loss operations to obtain the updated sequence embedding;

[0013] S5, embedding the sequence updated by the feedforward network layer in step S4, and defining it as short-term sequence embedding and long-term sequence embedding according to the length of the time window;

[0014] S6, obtain a new short-term sequence embedding by fusing the short-term embedding obtained in S5 with the graph embedding obtained in S1, and combine the new short-term embedding with the long-term embedding obtained in S5 to generate the final embedding;

[0015] S7. Based on the final embedding output by S6, the Wasserstein distance is used to calculate the distance between the distributions of two items in the user interaction sequence as the ranking score to generate a recommendation list. The Bayesian personalized ranking loss is used as the basic loss function, and a regularization term that considers the distance between positive and negative sampling items and a global information encoding loss are introduced to optimize the basic loss function for sequence recommendation.

[0016] Furthermore, the specific steps of S1 are as follows:

[0017] S1.1. Define the user's interaction sequence The item v in the sequence i and project v i+k The updated weight of the edge between where v i represents the i-th item in the user interaction sequence, v i+k represents the i+kth item in the user interaction sequence, score Represents the target node v i Its k-hop neighbor v i+k The importance of

[0018] S1.2, repeat S1.1 for all users’ interaction sequences, build a global project graph G, and then i and v i+k Normalize the edge weights between:

[0019]

[0020] in, is the adjacency matrix, is the normalized adjacency matrix, deg(·) is the degree of the node in G;

[0021] S1.3, perform SVD processing on G to obtain the enhanced image The expression of SVD is:

[0022]

[0023] Among them, U q and V q is a standard orthogonal matrix, S q is a diagonal matrix; represents the normalized adjacency matrix;

[0024] S1.4. Capture global information in the form of a graph and use the graph encoding method of LightGCN to obtain the representation of the graph. The expression for graph embedding is:

[0025]

[0026] Among them, e c is the node embedding of layer c, c represents the number of layers of graph convolution, β represents the adjacency matrix, represents the normalized adjacency matrix.

[0027] Furthermore, the specific steps of S2 are as follows:

[0028] For all items, a multidimensional elliptical Gaussian distribution is used to describe the items. First, a mean embedding table M is defined. μ ∈R |V|×d and a covariance embedding table M ∑ ∈R |V|×d , where d represents the number of latent dimensions and V represents the number of items; then the sequence embedding of the mean and covariance of the items in the user interaction sequence is as follows:

[0029]

[0030]

[0031] in, The sequence embedding representing the mean of the items, The sequence embedding representing the covariance of items, represents the mean embedding of the nth item in the user interaction sequence, represents the covariance embedding of the nth item in the user interaction sequence, represents the nth item of the mean embedding table, Represents the nth entry of the covariance embedding table.

[0032] Furthermore, the specific steps of S3 are as follows:

[0033] S3.1. Obtain the time query embedding according to the following formula

[0034]

[0035] in, is a normalization factor that ensures that the sum of the weights is 1; e -d·l is the exponential decay weight of the lth element, and L is a hyperparameter used to control the scope of the attention query; represents the embedding at time t-L+l;

[0036] S3.2, use Wasserstein distance to measure the distance between two random embeddings;

[0037] Given an item s in a user's interaction sequence i and j , and the corresponding random embeddings are and For project s i , and are the mean embedding and covariance embedding of the i-th item in the user interaction sequence, and All are learnable parameters, ELU represents the activation function, diag represents the extraction of the diagonal matrix; by measuring the negative 2-Wasserstein distance W 2 (·,·) is used to define the attention weight, and the position information is added to the calculation of the attention weight in the form of a bias to obtain the attention weight A ij , the calculation formula is as follows:

[0038] A ij =-W 2 (s i ,s j )+m·[-(p-1),...,-2,-1,0]

[0039] in, is the second-order Wasserstein distance, A ij is the attention weight, m·[-(p-1),...,-2,-1,0] is a relative distance matrix, p represents the position index, and m is a tuning parameter that can be set according to the number of attention heads;

[0040] S3.3. Each item is represented by a random embedding containing mean and covariance, which uses the properties of linear combinations of Gaussian distributions to aggregate information. The formula is as follows:

[0041]

[0042]

[0043] in, is the normalized attention weight value, and The value vectors representing the mean and covariance, respectively, are obtained by linearly transforming the initial sequence embedding; represents the new sequence mean embedding after aggregating information, Represents the new sequence covariance embedding after aggregating information, where j ranges from 1 to n.

[0044] Furthermore, the specific steps of S4 are as follows:

[0045] S4.1. Embed the new sequence output in S3 and introduce a feedforward network layer to capture more complex relationships. The feedforward network layer first passes through a multi-layer perceptron (MLP) and then passes through a linear layer. The formula is as follows:

[0046]

[0047]

[0048] in, and are the mean output and covariance output of the feedforward network layer, respectively. All are learnable parameters;

[0049] S4.2. Use residual connection, layer normalization and random loss operation to update the output of the feedforward network layer to:

[0050]

[0051]

[0052] in, represents the updated sequence mean embedding, represents the updated sequence covariance embedding.

[0053] Further, in S5, the new sequence output by the feedforward network layer in step S4 is embedded according to the length L of the time window, and the method of defining it as short-term sequence embedding and long-term sequence embedding is as follows:

[0054] When L=1, the output of the feedforward network layer is short-term sequence embedding; when L=5, the output of the feedforward network layer is long-term sequence embedding.

[0055] Furthermore, the specific steps of S6 are as follows:

[0056] S6.1. The new short-term sequence embedding formula is as follows:

[0057]

[0058] in, middle Indicates that step five obtains short-term sequence embedding, Represents the graph embedding obtained from step 1. The two parts are FuseLayered to get the updated

[0059] S6.2, using the integrated query embedding method, the new short-term sequence embedding and long-term sequence embedding obtained in step 6.1 are combined to generate the final embedding; the formula is as follows:

[0060]

[0061]

[0062] in Embedding for new short-term sequences; is the long-term sequence embedding; λ is a learnable hyperparameter.

[0063] Furthermore, in S7,

[0064] (1) Calculate the Wasserstein distance between the distributions of two items to predict the ranking score. For item s i , next project r The prediction score is calculated as follows:

[0065]

[0066] (2) Bayesian personalized ranking is used as the basic loss function, and a regularization term that considers the distance between positive and negative sampling items and a global information encoding loss are introduced to optimize the basic loss function;

[0067] Regularization term l pvn The formula is as follows:

[0068]

[0069] Where [x] + =max(x,0),k + is the next item visited by the user, i.e., the positive item, k - are negative items randomly sampled from items that have never been interacted with in the user's interaction sequence; s t represents the tth item in the user interaction sequence; represents the distance between the tth item and the positive item in the user interaction sequence, Represents the distance between positive items and negative items; the global information encoding loss formula is as follows:

[0070]

[0071] in, is the embedding of the original global graph G after graph encoding, It is an enhanced graph The embedding obtained by graph encoding, N represents the number of samples;

[0072] The final loss function is:

[0073]

[0074] Among them, S u represents the user's interaction sequence, σ represents the logistic function, θ is the number of all learnable parameters, ω is a hyperparameter, α 1 and α 2 are two hyperparameters used to control the two constraints.

[0075] Compared with the prior art, the present invention has the following beneficial effects:

[0076] The present invention proposes a sequence recommendation method based on global information and hybrid time query attention mechanism, which solves the limitations of existing recommendation systems in capturing user dynamic preferences and modeling the relationship between items in the sequence. Compared with traditional recommendation methods, the present invention can understand user collaboration information by capturing the global information between items in the sequence and combining the hybrid time attention mechanism, thereby more accurately predicting user interests and behaviors. This method not only improves the performance and accuracy of the recommendation system, but also has strong versatility and applicability. It can be widely used in various types of recommendation systems to provide users with personalized recommendation experience. In summary, the present invention has important technical value and application prospects in the field of recommendation systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] Figure 1 is a flow chart of the present invention;

[0078] Figure 2 It is a framework diagram of HWSA-SF, an example of the present invention. DETAILED DESCRIPTION

[0079] The technical solution of the present invention is described in detail below with reference to the accompanying drawings, but the protection scope of the present invention is not limited to the embodiments.

[0080] like Figure 1 As shown, the present invention provides a sequence recommendation method based on global information and hybrid time query attention mechanism, comprising the following steps:

[0081] S1. Use the global item transition graph to capture the global information between items in the user interaction sequence, define a rule-based global item graph, obtain the enhanced graph using the global item graph learned by singular value decomposition (SVD), and obtain the graph embedding through graph encoding.

[0082] Traditional sequence modeling methods mainly focus on modeling sequence transition patterns within a single sequence, ignoring the use of global information between sequences, which may lead to poor quality user representation. To overcome this problem, the present invention uses a global item transition graph to capture the global information between sequences.

[0083] The specific steps of S1 are as follows:

[0084] S1.1. Define the user's interaction sequence The item v in the sequence i and project v i+k The updated weight of the edge between where v i represents the i-th item in the user interaction sequence, v i+k represents the i+kth item in the user interaction sequence, score Represents the target node v i Its k-hop neighbor v i+k The importance of.

[0085] S1.2, repeat S1.1 for all users’ interaction sequences, build a global project graph G, and then i and v i+k Normalize the edge weights between:

[0086]

[0087] in, is the adjacency matrix, is the normalized adjacency matrix, and deg(·) is the degree of the node in G.

[0088] S1.3, perform SVD processing on G to obtain the enhanced image The expression of SVD is:

[0089]

[0090] Among them, U q and V q is a standard orthogonal matrix, S q is a diagonal matrix, represents the normalized adjacency matrix.

[0091] S1.4. Capture global information in the form of a graph and use the graph encoding method of LightGCN to obtain the representation of the graph. The expression for graph embedding is:

[0092]

[0093] Among them, e cis the node embedding of layer c, c represents the number of layers of graph convolution, β represents the adjacency matrix, represents the normalized adjacency matrix.

[0094] S2. Input the user's interaction sequence into the embedding layer, use a multidimensional elliptical Gaussian distribution to represent the items in the user interaction sequence, and generate a sequence embedding of the mean and covariance of the items in the user interaction sequence to capture the uncertainty of the items.

[0095] The present invention adopts a unique method to represent items, which combines the concept of probability distribution instead of relying on traditional deterministic vector representation. The essence of this method is to use multi-dimensional elliptical Gaussian distribution to describe items to effectively capture potential uncertainties. Specifically, the elliptical Gaussian distribution is controlled by a mean vector and a covariance vector, where the covariance vector introduces the potential uncertainty of the items.

[0096] The specific steps of S2 are as follows:

[0097] For all items, a multidimensional elliptical Gaussian distribution is used to describe the items. First, a mean embedding table M is defined. μ ∈R |V|×d and a covariance embedding table M ∑ ∈R |V|×d , where d represents the number of latent dimensions and V represents the number of items. Since the mean and covariance can capture different information about the data, the sequence embeddings of the mean and covariance of the items in the user interaction sequence are obtained respectively, as follows:

[0098]

[0099]

[0100] in, The sequence embedding representing the mean of the items, The sequence embedding representing the covariance of items, represents the mean embedding of the nth item in the user interaction sequence, represents the covariance embedding of the nth item in the user interaction sequence, represents the nth item of the mean embedding table, Represents the nth entry of the covariance embedding table.

[0101] S3: Input the sequence embedding generated in S2 into the hybrid time query self-attention module, use a sliding window, calculate the query vector by time-decayed weighted average method, and add the position information to the calculation of attention weight in the form of bias to obtain the output of the hybrid time query self-attention. The output result is a new sequence embedding of the mean and covariance of the user interaction sequence;

[0102] The temporal query self-attention mechanism is a variant of self-attention that uses embeddings in the most recent L timestamps as its query mechanism.

[0103] The steps for S3 are as follows:

[0104] S3.1. Obtain the time query embedding according to the following formula

[0105]

[0106] in, is a normalization factor that ensures that the sum of the weights is 1; e -d·l is the exponential decay weight of the lth element, and L is a hyperparameter used to control the scope of the attention query. represents the embedding at time t-L+l. It integrates information from the past L time points and weights the time decay so that the most recent time points contribute more to the result.

[0107] S3.2. Traditional self-attention weight calculation cannot measure the distance between two distributions, nor does it satisfy the triangle inequality relationship. Therefore, the present invention uses Wasserstein distance to measure the distance between two random embeddings. Given two items of user interaction sequence s i and j , and the corresponding random embeddings are and By measuring the negative 2-Wasserstein distance W 2 (·,·) to define the attention weight, and add the position information to the attention weight A in the form of bias ij In the calculation of , the calculation formula is as follows:

[0108] A ij =-W 2 (s i ,s j )+m·[-(p-1),...,-2,-1,0]

[0109] in, is the second-order Wasserstein distance, A ij is the attention weight, m·[-(p-1),...,-2,-1,0] is a relative distance matrix, and p represents the position index; the adjustment parameter is m, which can be set according to the number of attention heads. For a model with 4 attention heads, the sequence of m values ​​is a geometric sequence: 2 -2 ,2 -4 ,2 -6 ,2 -8In general, for an n-head attention mechanism, the value of m is a The geometric sequence starts with

[0110] S3.3. Since each item is represented by a random embedding containing mean and covariance, it is necessary to summarize the mean and covariance separately. The properties of the linear combination of Gaussian distributions are used to aggregate information. The formula is as follows:

[0111]

[0112]

[0113] in, is the normalized value, and The value vectors representing the mean and covariance, respectively, are obtained by linearly transforming the initial sequence embedding; represents the new sequence mean embedding after aggregating information, Represents the new sequence covariance embedding after aggregating information, where j ranges from 1 to n.

[0114] S4, embed the new sequence output in S3, introduce the feedforward network layer, add nonlinearity, and then perform residual connection, layer normalization and random loss operations to obtain the updated sequence embedding;

[0115] The self-attention mechanism aggregates the embedding of historical items through adaptive weights, enhancing the expressive power of the model. However, its inherent linearity limits its ability to capture complex relationships between items. Therefore, the present invention introduces a feedforward network layer.

[0116] The specific steps of S4 are as follows:

[0117] S4.1. Embed the new sequence output in S3 and introduce a feedforward network layer to capture more complex relationships. The feedforward network layer first passes through a multi-layer perceptron (MLP) and then passes through a linear layer. The formula is as follows:

[0118]

[0119]

[0120] in, and are the mean output and covariance output of the feedforward network layer, respectively. All are learnable parameters;

[0121] S4.2. In addition, residual connections, layer normalization, and random loss operations are used to update the output of the feedforward network layer to:

[0122]

[0123]

[0124] in, represents the updated sequence mean embedding, Represents the updated sequence covariance embedding. The ELU activation function and an addition operation are used to ensure the positive definiteness of the covariance.

[0125] S5, embedding the sequence updated by the feedforward network layer in step S4, according to the length of the time window, is defined as short-term sequence embedding and long-term sequence embedding; specifically,

[0126] is the output of the feedforward network layer when L=1, i.e., short-term sequence embedding, The output of the feedforward network layer when L = 5, that is, long-term sequence embedding. The short-term sequence embedding L is 1, and the long-term sequence embedding L is 5, which is the best result obtained through multiple experiments.

[0127] S6: A new short-term sequence embedding is obtained by fusing the short-term embedding obtained in S5 with the graph embedding obtained in S1, and the new short-term embedding is combined with the long-term embedding obtained in S5 to generate the final embedding to balance the variance and bias of capturing user preferences.

[0128] The specific steps are as follows:

[0129] Step 6.1, obtain the new short-term sequence embedding, the formula is as follows:

[0130]

[0131] in, represents the mean output of step 4.2 when L=1, Represents the graph embedding obtained from step 1.4. The two parts are FuseLayered to get the updated The FuseLayer layer concatenates the two inputs together through a linear transformation and maps them to the same dimension as the original mean sequence output.

[0132] Step 6.2: Using the integrated query embedding method, the new short-term sequence embedding and the long-term sequence embedding obtained in step 6.1 are combined to generate the final embedding;

[0133] For step S3, choosing the right L value is very important. A larger L value makes the model rely on longer historical information to capture the evolution of user interests, which helps capture collaborative signals but may cause the model to accumulate bias over time. On the contrary, a smaller L value makes the model more dependent on recent interaction information to represent user interests. Although this reduces the risk of introducing bias, it also increases variance. In order to strike a balance between bias and variance, a suitable L value needs to be carefully selected.

[0134] Therefore, the present invention designs a method for integrated query embedding, which integrates short-term sequence embedding and long-term sequence embedding to generate the final embedding, and the formula is as follows:

[0135]

[0136]

[0137] in, is the new short-term sequence embedding obtained in step 6.1; is the long-term sequence embedding; λ is a learnable hyperparameter.

[0138] S7. Based on the final embedding output by S6, the Wasserstein distance is used to calculate the distance between the distributions of two items in the user interaction sequence as the ranking score to generate a recommendation list. The Bayesian personalized ranking loss is used as the basic loss function, and a regularization term that considers the distance between positive and negative sampling items and a global information encoding loss are introduced to optimize the basic loss function for sequence recommendation.

[0139] According to the final embedding output by S6, the next possible item in the user interaction sequence is predicted. Since the distribution of two items is given, the Wasserstein distance between the distributions of the two items needs to be calculated to predict the ranking score. Specifically, for item s i , next project r The prediction score is calculated as follows:

[0140]

[0141] The present invention adopts Bayesian personalized ranking as the basic loss function, and introduces a regularization term that considers the distance between positive and negative sampling items and a global information encoding loss to optimize the basic loss function;

[0142] Regularization term l pvn The formula is as follows:

[0143]

[0144] Where [x] +=max(x,0),k + is the next item visited by the user, i.e., the positive item, k - are negative items randomly sampled from items that have never been interacted with in the user's interaction sequence; s t represents the tth item in the user interaction sequence; represents the distance between the tth item and the positive item in the user interaction sequence, Represents the distance between positive and negative items.

[0145] The global information encoding loss formula is as follows:

[0146]

[0147] in is the embedding of the original global graph G after graph encoding, It is an enhanced graph The embedding obtained after graph encoding, N represents the number of samples.

[0148] The final loss function is:

[0149]

[0150] Among them, S u represents the user's interaction sequence, σ represents the logistic function, θ is the number of all learnable parameters, ω is a hyperparameter, α 1 and α 2 are two hyperparameters used to control the two constraints.

[0151] This embodiment uses two public datasets from Amazon for training, which contain more than 1.2 million users and 63,000 items, showing the high sparsity and different rating categories unique to Amazon datasets. This embodiment uses the python pytorch library to experiment with the HWSA-SF model constructed by the sequence recommendation method based on global information and hybrid time query attention mechanism proposed in the present invention.

[0152] This example selects 8 methods for comparison to evaluate the effectiveness and superiority of the proposed HWSA-SF in the field of recommendation systems. These comparison methods are divided into three categories: (1) static recommendation methods, such as BPRMF and LightGCN; (2) Transformer-based sequence methods, including BERT4Rec, SASRec, and STOSA; (3) graph-based sequence methods, such as SR-GNN and GCE-GNN.

[0153] Recall@5 and NDCG@5 are used as quantitative indicators to evaluate various models. The quantitative evaluation results are shown in Table 1.

[0154] Table 1 Comparative experimental results

[0155]

[0156] The following conclusions can be drawn from Table 1:

[0157] (1) The HWSA-SF proposed in this paper always outperforms all baselines on the dataset. The results show the effectiveness of HWSA-SF in sequence recommendation tasks.

[0158] (2) Obviously, when comparing the three different types of recommendation methods, the static recommendation method has the worst performance, indicating that temporal information is a very important factor in sequential recommendation. Among the graph-based sequential methods, GCE-GNN outperforms SR-GNN, which can be attributed to the global collaborative information it introduces. In addition, the Transformer-based sequential methods have the best performance, among which STOSA performs the best, followed by SASRec. STOSA outperforms SASRec on all datasets, indicating the importance of modeling uncertainty information and verifying the effectiveness of the Transformer framework.

[0159] (3) This paper designs a global learner that uses singular value decomposition to integrate global collaborative information into item representation, which can more accurately capture the correlation between different items and user preferences, thereby enhancing the robustness of the recommendation system. In addition, a hybrid temporal query self-attention module is introduced to strike a balance between capturing variance and bias in user preferences, which helps to improve the understanding of user interests and modeling capabilities.

[0160] In summary, the recommendation performance of the model proposed in this invention is better than other baseline models, which proves the effectiveness and superiority of this solution.

[0161] Although the present invention has been described above with preferred embodiments, it is not intended to limit the present invention. A person skilled in the art of the present invention may make various modifications and improvements without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be determined by the definition of the claims.

Claims

1. A sequence recommendation method based on global information and hybrid time query attention mechanism, characterized in that: S1. Use the global item transition graph to capture the global information between items in the user interaction sequence, define a rule-based global item graph, use the global item graph learned by singular value decomposition to obtain the enhanced graph, and obtain the graph embedding through graph encoding; S2, input the user's interaction sequence into the embedding layer, use multidimensional elliptical Gaussian distribution to represent the items in the user's interaction sequence, and generate a sequence embedding of the mean and covariance of the items in the user's interaction sequence; S3: Input the sequence embedding generated in S2 into the hybrid time query self-attention module, use a sliding window, calculate the query vector by time-decayed weighted average method, and add the position information to the calculation of attention weight in the form of bias to obtain the output of the hybrid time query self-attention. The output result is a new sequence embedding of the mean and covariance of the user interaction sequence; S4, embed the new sequence output in S3, introduce the feedforward network layer, add nonlinearity, and then perform residual connection, layer normalization and random loss operations to obtain the updated sequence embedding; S5, embedding the sequence updated by the feedforward network layer in step S4, and defining it as short-term sequence embedding and long-term sequence embedding according to the length of the time window; S6, obtain a new short-term sequence embedding by fusing the short-term embedding obtained in S5 with the graph embedding obtained in S1, and combine the new short-term embedding with the long-term embedding obtained in S5 to generate the final embedding; S7, based on the final embedding output by S6, using Wasserstein distance to calculate the distance between the distributions of two items in the user interaction sequence as a ranking score, and generating a recommendation list; Bayesian personalized ranking loss is used as the basic loss function, and a regularization term considering the distance between positive and negative sampling items and a global information encoding loss are introduced to optimize the basic loss function for recommendation tasks.

2. According to claim 1, a sequence recommendation method based on global information and hybrid time query attention mechanism is characterized in that: The specific steps of S1 are as follows: S1.

1. Define the user's interaction sequence The item v in the sequence i and project v i+k The updated weight of the edge between where v i represents the i-th item in the user interaction sequence, v i+k represents the i+kth item in the user interaction sequence, score Represents the target node v i Its k-hop neighbor v i+k The importance of S1.2, repeat S1.1 for all users’ interaction sequences, build a global project graph G, and then i and v i+k Normalize the edge weights between: in, is the adjacency matrix, is the normalized adjacency matrix, deg(·) is the degree of the node in G; S1.3, perform SVD processing on G to obtain the enhanced image The expression of SVD is: Among them, U q and V q is a standard orthogonal matrix, S q is a diagonal matrix; represents the normalized adjacency matrix; S1.

4. Capture global information in the form of a graph and use the graph encoding method of LightGCN to obtain the representation of the graph. The expression for graph embedding is: Among them, e c is the node embedding of layer c, c represents the number of layers of graph convolution, β represents the adjacency matrix, represents the normalized adjacency matrix.

3. According to claim 1, a sequence recommendation method based on global information and hybrid time query attention mechanism is characterized in that: The specific steps of S2 are as follows: For all items, a multidimensional elliptical Gaussian distribution is used to describe the items. First, a mean embedding table M is defined. μ ∈R |V|×d and a covariance embedding table M ∑ ∈R |V|×d , where d represents the number of latent dimensions and V represents the number of items; then the sequence embedding of the mean and covariance of the items in the user interaction sequence is as follows: in, The sequence embedding representing the mean of the items, The sequence embedding representing the covariance of items, represents the mean embedding of the nth item in the user interaction sequence, represents the covariance embedding of the nth item in the user interaction sequence, represents the nth item of the mean embedding table, Represents the nth entry of the covariance embedding table.

4. According to claim 3, a sequence recommendation method based on global information and hybrid time query attention mechanism is characterized in that: The specific steps of S3 are as follows: S3.

1. Obtain the time query embedding according to the following formula in, is a normalization factor that ensures that the sum of the weights is 1; e -d·l is the exponential decay weight of the lth element, and L is a hyperparameter used to control the scope of the attention query; represents the embedding at time t-L+l; S3.2, use Wasserstein distance to measure the distance between two random embeddings; Given an item s in a user's interaction sequence i and j , and the corresponding random embeddings are and For project s i , and are the mean embedding and covariance embedding of the i-th item in the user interaction sequence, W i μ and W i ∑ are all learnable parameters, ELU represents the activation function, and diag represents the extraction of the diagonal matrix; the attention weight is defined by measuring the negative 2-Wasserstein distance W2(·,·), and the position information is added to the calculation of the attention weight in the form of a bias to obtain the attention weight A ij , the calculation formula is as follows: From ij =-W2(s i ,s j )+m·[-(p-1),...,-2,-1,0] in, is the second-order Wasserstein distance, A ij is the attention weight, m·[-(p-1),...,-2,-1,0] is a relative distance matrix, p represents the position index, and m is the adjustment parameter, which is set according to the number of attention heads; S3.

3. Each item is represented by a random embedding containing mean and covariance, which uses the properties of linear combinations of Gaussian distributions to aggregate information. The formula is as follows: in, is the normalized attention weight value, V i μ and V i ∑ The value vectors representing the mean and covariance, respectively, are obtained by linearly transforming the initial sequence embedding; represents the new sequence mean embedding after aggregating information, Represents the new sequence covariance embedding after aggregating information, where j ranges from 1 to n.

5. A sequence recommendation method based on global information and hybrid time query attention mechanism according to claim 4, characterized in that: The specific steps of S4 are as follows: S4.

1. Embed the new sequence output in S3 and introduce a feedforward network layer to capture more complex relationships. The feedforward network layer first passes through a multi-layer perceptron and then through a linear layer. The formula is as follows: in, and are the mean output and covariance output of the feedforward network layer, respectively. All are learnable parameters; S4.

2. Use residual connection, layer normalization and random loss operation to update the output of the feedforward network layer to: in, represents the updated sequence mean embedding, represents the updated sequence covariance embedding.

6. A sequence recommendation method based on global information and hybrid time query attention mechanism according to claim 1, characterized in that: In S5, the new sequence output by the feedforward network layer in step S4 is embedded according to the length L of the time window, and the method of defining it as short-term sequence embedding and long-term sequence embedding is as follows: When L=1, the output of the feedforward network layer is short-term sequence embedding; when L=5, the output of the feedforward network layer is long-term sequence embedding.

7. The sequence recommendation method based on global information and hybrid time query attention mechanism according to claim 1, characterized in that: The specific steps of S6 are as follows: S6.

1. The new short-term sequence embedding formula is as follows: in, middle Indicates that step five obtains short-term sequence embedding, Represents the graph embedding obtained from step 1. The two parts are FuseLayered to get the updated S6.2, using the integrated query embedding method, the new short-term sequence embedding and long-term sequence embedding obtained in step 6.1 are combined to generate the final embedding; the formula is as follows: in Embedding for new short-term sequences; is the long-term sequence embedding; λ is a learnable hyperparameter.

8. A sequence recommendation method based on global information and hybrid time query attention mechanism according to claim 1, characterized in that: In S7, (1) Calculate the Wasserstein distance between the distributions of two items to predict the ranking score. For item s i , next project r The prediction score is calculated as follows: (2) Bayesian personalized ranking is used as the basic loss function, and a regularization term that considers the distance between positive and negative sampling items and a global information encoding loss are introduced to optimize the basic loss function; Regularization term l pvn The formula is as follows: Where [x] + =max(x,0),k + is the next item visited by the user, i.e., the positive item, and k- is a negative item randomly sampled from items that the user has never interacted with in the interaction sequence; s t represents the tth item in the user interaction sequence; represents the distance between the tth item and the positive item in the user interaction sequence, Represents the distance between positive items and negative items; the global information encoding loss formula is as follows: in, is the embedding of the original global graph G after graph encoding, It is an enhanced graph The embedding obtained by graph encoding, N represents the number of samples; The final loss function is: Among them, S u represents the user's interaction sequence, σ represents the logistic function, θ represents all learnable parameters, ω is a hyperparameter, α1 and α2 are two hyperparameters used to control two constraints.

Citation Information

Patent Citations

  • Session recommendation method for enhancing graph context sequence

    CN114610862A

  • Sequence recommendation method and device

    CN115391660A

  • Sequence recommendation method based on sequential dependency enhanced self-attention network

    CN115687772A

  • Sequence recommendation method and system based on collaborative attention network and comparative learning

    CN115982480A

  • Time enhancement information sequence recommendation method and system based on graph convolutional network

    CN116542720A

Cited By

  • Smart factory production line parameter optimization system and method based on large model

    CN119358785A

  • Power grid multivariable time sequence prediction model and method

    CN122020067A