A conversation recommendation method based on graph neural network and attention mechanism
By constructing edge order graphs, short connection graphs and global graphs, combined with graph neural networks and attention mechanisms, the problems of information loss and dependency capture in session recommendation are solved, and the accuracy and effect of the recommendation system are improved.
Patent Information
- Application Number
- CN202410313053.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-19
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-03-19
AI Technical Summary
Existing session recommendation methods based on graph neural networks suffer from information loss when sessions are converted into graphs, making it difficult to capture longer-distance dependencies and unable to effectively utilize other session information, resulting in reduced recommendation accuracy.
A session recommendation method based on graph neural network and attention mechanism is used to construct three graph structures: edge sequence graph, short connection graph and global graph. It learns item representation through graph neural network and attention mechanism, and integrates location information and conversation context. Reduce information loss and capture more distant dependencies, and use the global picture to determine project importance.
It improves the accuracy of recommendation, can provide useful information that is more in line with the user's current preferences without user-related information, and enhances the effect of the recommendation system.
Smart Images

Figure CN118036654B
Abstract
Description
Technical Field
[0001] The present invention relates to intelligent conversation recommendation technology, and in particular to a conversation recommendation method based on graph neural network and attention mechanism. Background Art
[0002] In recent years, Internet technology has developed rapidly, thus promoting the generation and dissemination of information. The relationship between the Internet and life has become increasingly close, and more and more people are conducting various activities on the Internet. While the Internet brings people various conveniences, it also creates the problem of information overload. Massive data seriously interferes with users' choice of valuable information, making users at a loss as to where to start. In order to alleviate the problem of information overload, recommendation systems came into being.
[0003] Most existing recommendation systems rely on user-related information and long-term historical interaction records to make recommendations. However, as people today pay attention to privacy protection and users are often not logged in, the effectiveness of traditional recommendation systems will be greatly reduced. Therefore, the conversational recommendation system was created, which effectively makes up for the above shortcomings and can make effective recommendations without user-related information.
[0004] Conversational recommendation meets the needs of today's social development and has high practical value, so it is a key research area. Early recommendation methods mainly recommend by calculating the similarity of conversations or items, but ignore the relative order of items. Later, with the development of deep learning, recommendation methods based on deep learning emerged. Methods based on recurrent neural networks focus on modeling the sequential transformation of adjacent items, but cannot model complex item transformation patterns. Recently, due to the rapid development of graph neural networks, conversational recommendation methods based on graph neural networks have emerged. SR-GNN is the first model to apply graph neural networks to conversational recommendation. It models the conversation sequence into a common directed graph structure, and then uses the graph neural network to capture the complex transformation relationship between items. After obtaining the final representation of each item, the final representation of the current conversation is calculated, and it is used to calculate the score of the candidate item, so as to recommend the next item according to the size of the score, achieving good recommendation results. However, there is information loss when it converts the conversation sequence into a graph structure, which will reduce the recommendation accuracy to a certain extent.
[0005] Compared with traditional recommendation methods, conversation recommendation methods based on graph neural networks have improved the accuracy of recommendations to a certain extent. For example, patent CN114547276A discloses a conversation recommendation method that enhances graph context order, and patent CN115470406A discloses a conversation recommendation method based on graph neural network based on dual-channel information fusion. However, these existing solutions still have some problems. Most models suffer from information loss when converting conversations into graphs, and it is difficult to capture longer-distance dependencies while reducing the interference of irrelevant information. In addition, other conversation information is not effectively used to improve the recommendation effect, which reduces the accuracy of recommendations. Summary of the invention
[0006] Purpose of the invention: The purpose of the present invention is to solve the deficiencies in the prior art and provide a conversation recommendation method based on graph neural network and attention mechanism. The present invention improves and constructs three graph structures based on the current conversation graph, solves the problem of information loss, and can reconstruct the original conversation sequence from the conversation graph, so that no sequential information is lost in the composition process. The use of short-link graphs can reduce the interference of irrelevant project information while capturing more distant project information, thereby improving the accuracy of recommendations. The present invention also uses the global graph to cleverly judge the importance of neighboring projects in other conversations by judging their relevance to the current preferences of the current conversation rather than general preferences, thereby obtaining useful information that is closer to the user's current preferences, making the final recommendation results more in line with the user's current preferences.
[0007] Technical solution: A conversation recommendation method based on graph neural network and attention mechanism of the present invention comprises the following steps:
[0008] S1. Obtain session data and transform it to construct three graph data structures: edge sequence graph, short connection graph, and global graph;
[0009] In the edge-sequence graph, the incoming edges of each item are marked with serial numbers according to the order of the incoming edges, and the last item is marked, so that the original session sequence can be restored from the graph; in the short-link graph, each vertex in the graph is self-connected, and connections are added to the next few items, so that longer-distance dependencies can be captured; the global graph builds connections between sessions, directly connecting the neighbors of items in all sessions, so as to obtain richer feature representations, and the weight value of the connecting edge is expressed as the number of times this edge appears, thereby reflecting the importance of different neighbors;
[0010] S2. For the constructed edge-order graph, short-connection graph, and global graph, the graph neural network and attention mechanism are used to learn the representation of the items in the session context and in the global context, and the two levels of representation are fused and integrated with the location information; the specific process is as follows:
[0011] S21. For the edge-sequence graph, the neighbor information is first aggregated through the neural network GRU so that the order information can be retained, and then the node i itself is updated in combination with the node representation to obtain the updated node representation in the edge-sequence graph l represents the lth layer in the neural network GRU;
[0012] S22. For the short-connected graph, the self-attention mechanism is used to update the node a to obtain the updated node representation.
[0013] S23. Cross-stack multiple graph neural network layers that process edge sequence graphs and short connection graphs, denoted as EOP layers and SGA layers respectively, and concatenate the outputs of all previous layers as the input of the current layer in each layer to improve performance, reduce information loss, and capture longer-distance dependencies; after stacking multiple layers of the network, the final project representation of the project in the current session graph is obtained
[0014] S24. For the global graph, the neighbors of each item are linearly combined through soft attention, and the corresponding weights are calculated by the relevance of the neighbors to the current session and the edge weight value. After the final item is represented in the global context, it is fused with the representation in the session context h′ v ;
[0015] S25, fusing the reverse position information to obtain the item representation m of the fused position information i ;
[0016] S3, after completing the fusion position information of step S2, the intrinsic relationship between items is obtained through the self-attention mechanism, that is, E N =[e1,e2,…,e L ];
[0017] S4. Use the soft attention mechanism to calculate the importance of different items at different positions to the current session to calculate the final session representation S, and use the final session representation S to predict the next clicked item.
[0018] Furthermore, the updated node representation is calculated in step S21 The specific formula is:
[0019]
[0020]
[0021] Among them, record d i is the number of incoming edges of node i in the edge-sequence graph, then 1<<k<<d i , j k Indicates that the kth incoming edge of the node corresponds to the starting vertex, Represents the corresponding starting node of the kth incoming edge in the lth layer, and represents the hidden state in GRU, and is a learnable parameter, and || represents a concatenation operation.
[0022] Furthermore, the step S22 obtains the node representation after the short-link graph is updated The specific method is:
[0023] First, calculate the linearity of each neighbor node as follows:
[0024]
[0025]
[0026] Among them, j is the neighbor vertex corresponding to each incoming edge of node a, p (l′) , W q (l′) , W k (l′) , is a learnable parameter, is the calculated correlation score of each neighbor node, and It is the proportion obtained after the score is normalized by the softmax function;
[0027] Then, linearly combine each neighbor node to get the updated node representation:
[0028]
[0029] Among them, E in (a) represents the incoming edge set of node a, represents the correlation coefficient between neighbor node j and node a, W v (l′) is a learnable parameter.
[0030] Furthermore, the step S24 obtains the final item representation h′ after fusion. v The detailed process is as follows:
[0031] First, calculate the information aggregated from all neighboring nodes of node i The formula is as follows:
[0032]
[0033] In the above formula, is the neighbor embedding representation, π(v i ,v j ) finally represents the coefficients obtained according to the importance of different neighbors, and
[0034] π(v i ,v j )=softmax(π(v i ,v j ))
[0035] w ij is the weight of the edge connected to the neighbor, ⊙ represents the multiplication operation of the corresponding items of two vectors, || represents the concatenation operation, q1 and W1 are learnable parameters, Represents node v i The neighbor set, s c For the current session information;
[0036] Current session information c By using soft attention calculation, in order to reduce the impact of the last item that may be accidentally clicked, the local preference takes the average of the last two clicked items, which is specifically defined as follows:
[0037]
[0038]
[0039] β=softmax(∈)
[0040]
[0041] Among them, h loc represents the local preference vector, ∈ i represents the correlation score between each item in the session and the local preference of the current session. After normalization, the weighted sum is obtained to obtain the current session information. q2, W2, W3, and b2 are learnable parameters; β i and h i Respectively represent the corresponding coefficients of each item in the current session and the vector representation of each item;
[0042] Then, the item representation is combined with the neighborhood representation to obtain the updated item embedding representation The specific definitions are as follows:
[0043]
[0044] in, It indicates that the project is updated on the global graph, W4 is a learnable parameter, It is a neighborhood representation. After multiple layers, higher-order information can be aggregated. The specific definition is as follows:
[0045]
[0046] in, It indicates that z-order distant items are aggregated in the global graph, and agg indicates the aggregation operation. Indicates the previous layer of project representation, Indicates the previous layer domain representation;
[0047] Finally, after obtaining the final item in the global context representation, it is fused with the session context representation through the dropout function (to prevent overfitting) to obtain the fused final item representation h′ v , the specific formula is as follows:
[0048]
[0049] Furthermore, the specific information fusion formula of step S25 is as follows:
[0050]
[0051] Among them, m T is the item representation that integrates the position information, W5 and b3 are learnable parameters, and p L-T+1 Represents reverse position embedding, L is the current session length, and T represents the Tth position from the beginning to the end in the session sequence.
[0052] Furthermore, the specific steps in step S3 are as follows:
[0053] In the fusion position information m i After that, we first capture the intrinsic correlation between items through self-attention, which is defined as follows:
[0054]
[0055] Among them, R is the conversation item representation after self-attention, M = [m1,m2,…,m L ],W V , W K , W Q is a learnable parameter, d is the dimension of the key vector in self-attention;
[0056] Then it passes through the feedforward network, uses the relu function to increase nonlinearity, and adds a residual connection after the feedforward network. The specific definition is as follows:
[0057] E=W7relu(W6R+b4)+b5+R
[0058] Among them, W7, W6, b4, and b5 are all learnable parameters, and relu is the activation function;
[0059] After N self-attention layers, the final output of the multi-layer self-attention network is E N =[e1,e2,…,e L ].
[0060] Furthermore, the specific steps in step S4 are as follows:
[0061] Step S41: Calculate the importance of different items at different positions to the current session using the soft attention mechanism, so as to calculate the final session representation. The specific definition is as follows:
[0062]
[0063]
[0064] Among them, S is the final session representation, To fuse the item representation of the global context and the current session context, q3, W8, W9, and b6 are learnable parameters.
[0065] s′ is the session information, which is obtained by using the soft attention mechanism. The specific definition is as follows:
[0066]
[0067]
[0068] β′=softmax(∈′)
[0069]
[0070] Among them, q4, W′2, W′3, and b′2 are all learnable parameters;
[0071] Step S42: The final session representation S is used to predict the probability of the next clicked item using a cross entropy loss function, which is specifically defined as follows:
[0072]
[0073]
[0074] in, To predict the next click probability of an item, y i Represents the true value, which is the unique-hot-encoded blood volume of the item, and n is the number of all items.
[0075] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0076] 1. The current session input graph of the present invention uses an edge sequence graph and a short connection graph. By cross-stacking the graph neural network layers of the two graphs, it can reduce information loss and capture longer-distance dependencies while reducing the interference of irrelevant information. It also uses position information and attention mechanisms to improve recommendation effects;
[0077] 2. While modeling the current session, the present invention also reasonably utilizes the remaining session information to construct a global graph, so that the item representation is further enhanced, thereby obtaining more item information related to the current session and further improving the recommendation accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 It is the overall flow chart of the present invention;
[0079] Figure 2 A session graph constructed for an embodiment of the present invention;
[0080] Figure 3 A global graph constructed for an embodiment of the present invention;
[0081] Figure 4 This is a structural diagram of the conversation recommendation model of the present invention. DETAILED DESCRIPTION
[0082] The technical solution of the present invention is described in detail below, but the protection scope of the present invention is not limited to the embodiments.
[0083] like Figure 1 As shown, the conversation recommendation method based on graph neural network and attention mechanism of the present invention includes the following steps:
[0084] S1. Acquire session data and transform and construct three graph data structures: edge sequence graph, short-link graph and global graph; the edge sequence graph is constructed by marking the incoming edges of each project in the order of the incoming edges and marking the last project; the short-link graph is constructed by adding self-connection to each vertex in the graph and adding connections to the next few projects; the global graph is used to construct the connection between sessions, and the construction method is to directly connect the neighbors of the projects in all sessions, and the weight value of the connecting edge is expressed as the number of times this edge appears;
[0085] S2. For the constructed edge-order graph, short-connection graph, and global graph, the graph neural network and attention mechanism are used to learn the representation of the items in the session context and in the global context, and the two levels of representation are fused and integrated with the location information; the specific process is as follows:
[0086] S21. For the edge-sequence graph, the neighbor information is first aggregated through the neural network GRU so that the order information can be retained, and then the node i itself is updated in combination with the node representation to obtain the updated node representation in the edge-sequence graph l represents the lth layer in the neural network GRU;
[0087] S22. For the short-connected graph, the self-attention mechanism is used to update the node a to obtain the updated node representation.
[0088] S23. Cross-stack multiple graph neural network layers that process edge sequence graphs and short connection graphs, which are recorded as EOP layers and SGA layers respectively, and in each layer, the outputs of all previous layers are concatenated as the input of the current layer; after stacking multiple layers of networks, the final project representation of the project in the current session graph is obtained.
[0089] S24. For the global graph, the neighbors of each item are linearly combined through soft attention, and the corresponding weights are calculated by the relevance of the neighbors to the current session and the edge weight value. After the final item is represented in the global context, it is fused with the representation in the session context h′ v ;
[0090] S25, fusing the reverse position information to obtain the item representation m of the fused position information i ;
[0091] S3, after completing the fusion position information of step S2, the intrinsic relationship between items is obtained through the self-attention mechanism, that is, E N =[e1,e2,…,e L ];
[0092] S4. Use the soft attention mechanism to calculate the importance of different items at different positions to the current session to calculate the final session representation S, and use the final session representation S to predict the next clicked item.
[0093] In step S1 of this embodiment, the conversation sequence data is converted into the graph data structure required by the graph neural network, including the conversation graph and the global graph. The conversation graph in this embodiment includes two graph inputs: the edge sequence graph and the short connection graph, which are respectively Figure 2 b and Figure 2 c, and Figure 2 a is a graph of general session conversion. The session graph is a graph that converts the current session. The current session can be represented as s = {v1, v2, ..., v L}, where v represents the related items in the session, L represents the session length, and the items in the session are arranged by click time. The global graph builds connections between sessions, and the remaining sessions can provide more valuable information for the recommendations of the current session, thereby improving the accuracy of recommendations. Directly connecting the neighbors of items in all sessions can obtain richer feature representations, and the weight value of the connecting edge is expressed as the number of times this edge appears, thereby reflecting the importance of the neighbors.
[0094] Figure 3 This is the global graph in this embodiment. The global graph obtains each project neighbor node through 3 sessions, and the connected edges use the number of co-occurrences as weight values.
[0095] In step S2 of this embodiment, the edge sequence graph is aggregated through GRU to aggregate neighbor information so that the order information can be retained. The information is aggregated using GRU, and the specific definition is as follows:
[0096]
[0097] The node representation is combined with the information obtained from the neighbors to update the node itself. The specific definition is as follows:
[0098]
[0099] in, is the updated node representation of the edge-order graph, is a learnable parameter, and || represents a concatenation operation, which is used to aggregate information and update nodes.
[0100] For short-connected graphs, the self-attention mechanism is used to update nodes. Each node adds a self-connection and some direct connections to the back, so as to capture longer-distance dependencies while reducing the interference of irrelevant information. The specific definition is as follows:
[0101]
[0102]
[0103] Then, the neighboring nodes are linearly combined to obtain the updated representation of the node, which is specifically defined as follows:
[0104]
[0105] in, is the updated node representation of the short-link graph, E in (a) represents the incoming edge set of node a, represents the correlation coefficient between neighbor node j and node a, W v (l) is a learnable parameter.
[0106] The graph neural network layers that process edge order graphs and short connection graphs are cross-stacked, denoted as EOP layers and SGA layers, respectively. In each layer, the outputs of all previous layers are concatenated as the input of the current layer to improve performance, reduce information loss, and capture longer-distance dependencies. After stacking multiple layers of the network, the item representation in the session is obtained, denoted as
[0107] The global graph combines all different sessions to improve the recommendation effect. The global graph uses an undirected graph because the order between items is not important in the global graph and will limit the information enhancement of the current session. In the session, item A then clicks item B, which means that A and B are closely connected, and there may also be a session that clicks item A after item B. Similarly, the global graph does not only use similar sessions because it will also limit the information enhancement of the current session. Using only similar sessions will result in the loss of more valuable item conversion relationships, thereby reducing the final recommendation effect. The global graph directly connects each item's neighbors in all sessions to it, and uses the number of co-occurrences as the weight of the edge. Therefore, in the global graph, distance and co-occurrence times are important for item updates.
[0108] For the global graph, the neighbors of each item are first linearly combined through soft attention, and the corresponding weight is calculated by the relevance of the neighbors to the current session and the edge weight value, which is defined as follows:
[0109]
[0110] π(v i ,v j )=softmax(π(v i ,v j ))
[0111]
[0112] in, is the neighbor embedding representation, s c Indicates the current session information, w ij is the weight of the edge connected to the neighbor, ⊙ represents the multiplication operation of the corresponding items of two vectors, || represents the concatenation operation, q1 and W1 are learnable parameters, and Represents node v i The neighbor set of π(v i ,v j )Finally, it represents the coefficients obtained according to the importance of different neighbors. c By using soft attention calculation, in order to reduce the impact of the last item that may be accidentally clicked, the local preference takes the average of the last two clicked items, which is specifically defined as follows:
[0113]
[0114]
[0115] β=softmax(∈)
[0116]
[0117] Among them, h localrepresents the local preference vector, ∈ i It represents the correlation score between each item in the session and the local preference of the current session. After normalization, the weighted sum is taken to get the current session information. q2, W2, W3, and b2 are learnable parameters.
[0118] The item representation is then combined with the neighborhood representation to obtain the updated item embedding representation, which is defined as follows:
[0119]
[0120] in, It indicates that the project is updated on the global graph, W4 is a learnable parameter, is the neighborhood representation. After multiple layers, higher-order information can be aggregated, which is specifically defined as follows:
[0121]
[0122] in, It indicates that z-order distant items are aggregated in the global graph, and agg indicates the aggregation operation. Indicates the previous layer of project representation, Represents the previous domain representation. After obtaining the final item in the global context, it is fused with the session context representation. The specific definition is as follows:
[0123]
[0124] Among them, h′ v It is the final item representation after fusion, and the dropout function is used to prevent overfitting.
[0125] Because items at different positions in a session have different effects on the preferences of the entire session, position information can be used to improve the recommendation effect. Because the length of each session sequence is not the same, if the positions are arranged from front to back, the same position may have very different effects on sessions of different lengths. If the positions are arranged from back to front, the distance between the same position and the position of the item to be predicted in different sessions is the same, so the reverse position information can more accurately reflect the importance of the corresponding item for prediction. Therefore, the reverse position information is fused, and the specific definition is as follows:
[0126]
[0127] m T is the item representation that integrates the position information, W5 and b3 are learnable parameters, and p L-T+1 Represents reverse position embedding, L is the current session length, and T represents the Tth position from the beginning to the end in the session sequence.
[0128] For step S3 of the embodiment, after fusing the position information, the intrinsic relationship between items is captured through self-attention, which is specifically defined as follows:
[0129]
[0130] Among them, R is the conversation item representation after self-attention, M = [m1,m2,…,m L ],W V , W K , W Q is a learnable parameter, and d is the dimension of the key vector in the self-attention. Then it passes through the feedforward network, uses the relu function to increase nonlinearity, and adds a residual connection after the feedforward network. The specific definition is as follows:
[0131] E=W7relu(W6R+b4)+b5+R
[0132] Among them, W7, W6, b4, and b5 are all learnable parameters, and relu is the activation function. After N self-attention layers, the final output of the multi-layer self-attention network is E N =[e1,e2,…,e L ].
[0133] For step (4), the soft attention mechanism is finally used to calculate the importance of different items at different positions to the current session, so as to calculate the final session representation. The specific definition is as follows:
[0134]
[0135]
[0136] Among them, S is the final session representation, To fuse the item representation of the global context and the current session context, q3, W8, W9, and b6 are learnable parameters. s′ is the session information, using soft attention, and is specifically defined as follows:
[0137]
[0138]
[0139] β′=softmax(∈′)
[0140]
[0141] Among them, q4, W′2, W′3, and b′2 are all learnable parameters. The final session representation S is used to predict the probability of the next click item, using the cross entropy loss function, which is specifically defined as follows:
[0142]
[0143]
[0144] in, To predict the next click probability of an item, y i Represents the true value, which is the unique-hot-encoded blood volume of the item, and n is the number of all items.
[0145] The above is the specific content of this embodiment. This embodiment proposes a conversation recommendation model based on graph neural network and attention mechanism. Figure 4 The edge sequence graph and short connection graph used in the conversation graph effectively solve the problem of information loss caused by converting the conversation into a graph and the problem of being unable to capture longer-distance dependencies while reducing the interference of irrelevant information. It also uses location information and multi-layer self-attention to capture the intrinsic relationship between items. In the global graph, the correlation between neighbor items and the conversation and the frequency of occurrence are used to capture more relevant item information. Therefore, after combining the current session context information and cross-session context information, the accuracy of recommendations is improved.
Claims
1. A conversation recommendation method based on graph neural network and attention mechanism, characterized in that: The following steps are involved: S1. Acquire session data and transform and construct three graph data structures: edge sequence graph, short-link graph and global graph; the edge sequence graph is constructed by marking the incoming edges of each project in the order of the incoming edges and marking the last project; the short-link graph is constructed by adding self-connection to each vertex in the graph and adding connections to the next few projects; the global graph is used to construct the connection between sessions, and the construction method is to directly connect the neighbors of the projects in all sessions, and the weight value of the connecting edge is expressed as the number of times this edge appears; S2. For the constructed edge-order graph, short-connection graph, and global graph, the graph neural network and attention mechanism are used to learn the representation of the items in the session context and in the global context, and the two levels of representation are fused and integrated with the location information; the specific process is as follows: S21. For the edge-sequence graph, the neighbor information is first aggregated through the neural network GRU so that the order information can be retained, and then the node i itself is updated in combination with the node representation to obtain the updated node representation in the edge-sequence graph l represents the lth layer in the neural network GRU; S22. For the short-connected graph, the self-attention mechanism is used to update the node a to obtain the updated node representation. S23, cross-stack multiple graph neural network layers that process edge-order graphs and short-connection graphs, respectively recorded as EOP layers and SGA layers, and in each layer, the outputs of all previous layers are concatenated as the input of the current layer; After stacking multiple layers of networks, the final item representation of the items in the current session graph is obtained S24. For the global graph, the neighbors of each item are linearly combined through soft attention, and the corresponding weights are calculated by the relevance of the neighbors to the current session and the edge weight value. After the final item is represented in the global context, it is fused with the representation in the session context h′ v ; S25, fusing the reverse position information to obtain the item representation m of the fused position information i ; S3, after completing the fusion position information of step S2, the intrinsic relationship between items is obtained through the self-attention mechanism, that is, E N =[e1,e2,…,e L ]; the specific steps are as follows: In the fusion position information m i After that, we first capture the intrinsic correlation between items through self-attention, which is defined as follows: Among them, R is the conversation item representation after self-attention, M = [m1,m2,…,m L ],W V , W K , W Q is a learnable parameter, d is the dimension of the key vector in self-attention; L is the current session length; Then it passes through the feedforward network, uses the relu function to increase nonlinearity, and adds a residual connection after the feedforward network. The specific definition is as follows: E=W7relu(W6R+b4)+b5+R Among them, W7, W6, b4, and b5 are all learnable parameters, and relu is the activation function; After N self-attention layers, the final output of the multi-layer self-attention network is E j =[e1,e2,…,e L ]; S4. Use the soft attention mechanism to calculate the importance of different items at different positions to the current session to calculate the final session representation S, and use the final session representation S to predict the next clicked item. The specific steps are as follows: Step S41: Calculate the importance of different items at different positions to the current session using the soft attention mechanism, so as to calculate the final session representation. The specific definition is as follows: Among them, S is the final session representation, To fuse the item representation of the global context and the current session context, q3, W8, W9, b6 are learnable parameters, β i Indicates the attention coefficient corresponding to node i; s′ is the session information, which is obtained by using the soft attention mechanism. The specific definition is as follows: β′=softmax(∈′) Among them, q4, W2′, W3′, and b′2 are all learnable parameters; Step S42: The final session representation S is used to predict the probability of the next clicked item through the cross entropy loss function, which is specifically defined as follows: in, To predict the next click probability of an item, y i Represents the true value, which is the unique-hot-encoded blood volume of the item, and n is the number of all items.
2. The conversation recommendation method based on graph neural network and attention mechanism according to claim 1, characterized in that: The updated node representation is calculated in step S21. The specific formula is: Among them, record d i is the number of incoming edges of node i in the edge-sequence graph, then 1<<k<<d i , j k Indicates the starting vertex corresponding to the kth incoming edge of the node, Represents the starting node corresponding to the kth incoming edge of the lth layer, and represents the hidden state in GRU, and is a learnable parameter, and || represents a concatenation operation.
3. The conversation recommendation method based on graph neural network and attention mechanism according to claim 1, characterized in that: The step S22 obtains the node representation after the short-link graph is updated The specific method is: First, calculate the linearity of each neighbor node as follows: Among them, j is the neighbor vertex corresponding to each incoming edge of node a, p (l′) , is a learnable parameter, is the calculated correlation score of each neighbor node, and It is the proportion obtained after the score is normalized by the softmax function; Then, linearly combine each neighbor node to get the updated node representation: Among them, E un (a) represents the incoming edge set of node a, represents the correlation coefficient between neighbor node j and node a, is a learnable parameter.
4. The conversation recommendation method based on graph neural network and attention mechanism according to claim 1, characterized in that: The step S24 obtains the final item representation h′ after fusion v The detailed process is as follows: First, calculate the information aggregated from all neighboring nodes of node i The formula is as follows: In the above formula, is the neighbor embedding representation, π(v i ,v j ) finally represents the coefficients obtained according to the importance of different neighbors, and π(v i ,v j )=softmax(π(v i ,v j )) w ij is the weight of the edge connected to the neighbor, ⊙ represents the multiplication operation of the corresponding items of two vectors, || represents the concatenation operation, q1 and W1 are learnable parameters, Represents node v i The neighbor set of s c For the current session information; Current session information c By using soft attention calculation, the local preference is the average of the last two click items, which is defined as follows: β=softmax(∈) Among them, h local represents the local preference vector, ∈ i represents the correlation score between each item in the session and the local preference of the current session. After normalization, the weighted sum is obtained to obtain the current session information. q2, W2, W3, and b2 are learnable parameters; β i and h i Respectively represent the corresponding coefficients of each item in the current session and the vector representation of each item; Then, the item representation is combined with the neighborhood representation to obtain the updated item embedding representation The specific definitions are as follows: in, It indicates that the project is updated on the global graph, W4 is a learnable parameter, It is a neighborhood representation. After multiple layers, higher-order information can be aggregated. The specific definition is as follows: in, It indicates that z-order distant items are aggregated in the global graph, and agg indicates the aggregation operation. Indicates the previous layer of project representation, Indicates the previous layer domain representation; Finally, after obtaining the final item in the global context representation, it is fused with the session context representation through the dropout function to obtain the fused final item representation h′ v , the specific formula is as follows:
5. The conversation recommendation method based on graph neural network and attention mechanism according to claim 1, characterized in that: The specific information fusion formula of step S25 is as follows: Among them, m T is the item representation that integrates the position information, W5 and b3 are learnable parameters, and p L-T+1 Represents reverse position embedding, L is the current session length, and T represents the Tth position from the beginning to the end in the session sequence.
