Conversational Recommender System Combining Sparse Graph and Multi-hop Attention
By integrating sparse graphs and multi-hop attention technology in the conversation recommendation system, the problem that existing systems are difficult to capture long-term dependencies and deal with noise nodes is solved, and higher quality recommendation and dialogue generation are achieved.
Patent Information
- Application Number
- CN202210592414.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2042-05-27
Smart Images

Figure CN114817508B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of recommendation technology, and in particular to a conversation recommendation system integrating sparse graph and multi-hop attention. Background Art
[0002] A conversational recommender system is a system that recommends items to users through conversations. Graph neural networks are a framework for representing knowledge graphs. However, the knowledge graph corresponding to a conversation is not only large in scale, but also contains noisy nodes, which affect the aggregation of the main node and adjacent nodes. In addition, although recurrent neural networks can encode word sequences, they may have difficulty remembering long-term dependencies between word sequences. Summary of the invention
[0003] The present invention aims to at least solve the technical problems existing in the prior art, and in particular innovatively proposes a conversation recommendation system that integrates sparse graphs and multi-hop attention.
[0004] In order to achieve the above-mentioned object of the present invention, the present invention provides a conversation recommendation system integrating sparse graph and multi-hop attention, including: a conversation state tracking module, a recommendation module, and an integration mechanism module, wherein the data output end of the conversation state tracking module is connected to the data input end of the recommendation module, and the data output end of the recommendation module is connected to the data input end of the integration mechanism module;
[0005] Dialogue state tracking module: An encoder based on a multi-hop attention network is used to encode the dialogue context. The network can quickly encode long dialogue sequences to capture long-term dependencies. The TopicRNN model is then used to capture the global semantic information in the document, because a large number of long-term dependencies in language originate from semantic coherence. In multi-round multi-topic dialogues, the capture of sub-topics will affect the quality of dialogue generation.
[0006] Recommendation module: The sparse graph attention network (SGAT) is used to capture features of the knowledge graph and regularize the sparse graph. The item embedding generated by the graph is used to calculate the score that matches the conversation context. Finally, the probability of the item is obtained. The sparse graph attention network can not only avoid overfitting of the graph neural network, but also capture the explicit and potential relationships between various attributes.
[0007] Integration mechanism module: According to the conversation context, the conversation state tracking module predicts the next word and uses the SGAT-based recommendation model to obtain recommended items.
[0008] Furthermore, encoding the conversation context using an encoder based on a multi-hop attention network includes:
[0009] Will U h = {W h,1 ,W h,2 ,...,Wh,Mh} for each word W h,j Mapped to word vector θ h,j , encode the dialogue D into a high-order representation β = {β1,β2,...,β N}, where U h represents the hth sentence in dialogue D, β N Represents the tensor form of the Nth sentence in the dialogue D, β is called the memory tensor, W h,j Indicates U h The jth word in , j = 1, 2, ..., Mh;
[0010] Then, the query vector Q is used as the head to be read, iterated with the number of hops l, and the attention weight of the memory tensor at the lth hop is calculated. The calculation formula is:
[0011] Q l+1 =Q l +O l
[0012] Q l+1 represents the query vector Q of the l+1th hop;
[0013] Q l represents the query vector Q of the lth hop;
[0014] O l represents the memory vector of the lth jump;
[0015]
[0016] represents the attention weight of the lth jump of the kth memory component;
[0017] Represents the content of the lth jump of the kth memory component;
[0018] · T represents transpose;
[0019] Softmax(·) is the Softmax activation function;
[0020] The following formula is used to measure the memory content and query vector Q l The correlation between:
[0021]
[0022] The value is between 0 and 1, and the closer the memory score is to 1, the greater the association.
[0023] Where e represents the natural base;
[0024] z kRepresents the element at the kth position in array z;
[0025] z u Represents the element at position u in array z;
[0026] The model then transforms Weighted to Sum to read the memory vector O l :
[0027]
[0028] Represents the content of the l+1th jump of the kth memory component.
[0029] Furthermore, the TopicRNN model includes:
[0030] Input global semantic information, which includes user input U and context C. User input U is a sentence, and context C is the previous conversation.
[0031] Data processing: S-1, input the data into the hierarchical recursive encoding-decoding model HRED, and obtain h = HRED (U, C), where h represents the hidden state;
[0032] S-2, then obtain a topic vector φ from the user input U and context C, φ follows a normal distribution;
[0033] S-3, re-initialize the decoder, that is, assign h to H0, H0 is the decoder initialization state;
[0034] S-4, C contains T=(t1,t2,...,t n-1 ), where T represents a word sequence in C, t1 represents the first word, t2 represents the second word, and t n-1 represents the n-1th word,
[0035] S-5, to calculate word t n Enter the loop: Calculate the decoder's hidden state H n =fw(H n-1 ,T), where fw() is the decoder, H n-1 is the hidden state of the decoder at round n-1;
[0036] S-6, get a stop word indicator l from context C n , l n ~Bernoulli(sigmoid(W T H n-1), Bernoulli() represents Bernoulli distribution (01 distribution), sigmoid() is the sigmoid activation function, W T is the transpose of the weight matrix, l n Corresponding Figure 1 l n,s , represents the stop word indicator of the s-th step of the n-th round;
[0037] S-7, finally get t n ~p(t n |H n ,φ,l n ,B), at this time Where B is Bernoulli (sigmoid (W T H n-1 )), ~ means obedience, H n is the hidden state of the decoder in the nth round, φ is the topic vector, l n is the stop word indicator, B represents the Bernoulli distribution, and w j represents the jth word, Indicates w j The transpose of
[0038] S-8, output prediction tag t n , t n Represents the nth word.
[0039] Furthermore, the sparse attention network SGAT includes:
[0040] A multi-layer convolution module is used to aggregate the feature information of the first-order neighborhood nodes to obtain a high-level representation of an item containing knowledge graph information. The purpose is to learn how to selectively filter out the nodes that need to participate in the aggregation operation and how to aggregate neighborhood information.
[0041] For each edge e ij Assign a binary gate b ij ∈{0,1} to identify each edge that will participate in the aggregation operation and prune the edges that are irrelevant to the task, where e ij represents the edge connecting nodes i and j, b ij Represents edge e ij The binary gate in the SGAT model implements edge clipping.
[0042] If b ij is equal to 1, then the edge participates in the aggregation operation; if b ij If it is equal to 0, the edge does not participate in the aggregation operation, which is equivalent to adding a set of binary masks to the adjacency matrix A:
[0043]
[0044] in represents the adjacency matrix A with binary mask B added;
[0045] B represents a binary mask;
[0046] ⊙ represents the splicing operation;
[0047] N is the number of edges in the graph G;
[0048] {0,1} N Represents a set of binary masks, a total of N;
[0049] Since we want to use as few edges as possible in semi-supervised node classification to reduce computing resource consumption and reduce the sparsity of the graph, we train the model parameters P and binary mask B by minimizing the sum of L0 norm and empirical risk. The process is as follows:
[0050]
[0051] Where R(P,B) represents the model risk;
[0052] n represents the number of training samples;
[0053] L(·) represents the empirical risk;
[0054] f i (·,·,·) represents the predicted value of the i-th node; that is, the i-th node is classified into two categories.
[0055] X represents the node feature matrix;
[0056] A represents the adjacency matrix;
[0057] B represents a binary mask;
[0058] ||·||0 represents the L0 norm;
[0059] P represents the model training parameters;
[0060] y i Represents the label of the i-th sample;
[0061] λ is a regularization hyperparameter; it is used to balance data loss and edge sparsity.
[0062] ||B||0 represents the l0 norm of the binary mask B, that is, the number of non-zero elements in B;
[0063] is an indicator that satisfies the condition z ij ≠0 value is 1, otherwise it is 0;
[0064] z ij Represents the element at row i and column j of the binary mask B;
[0065] For the encoder function f(X,A⊙B,P) that obtains the predicted value, the aggregation function based on the attention coefficient is defined as:
[0066]
[0067] represents the hidden state of node i in layer l+1;
[0068] σ(·) is the Softmax activation function;
[0069] N i Represents the set of neighbor nodes of node i;
[0070] a ij It is edge ij The attention coefficient, e ij represents the edge connecting nodes i and j;
[0071] represents the hidden state of node j in layer l;
[0072] w (l) represents the weight of the lth layer;
[0073] Attention coefficient a ij The calculation formula is as follows:
[0074]
[0075] A ij Represents the element in the i-th row and j-th column of the adjacency matrix;
[0076] b ij Represents the element in the i-th row and j-th column of the binary mask matrix;
[0077] N i Represents the set of neighbor nodes of node i;
[0078] Furthermore, a multi-head attention similar to GAT is added to enhance the capabilities of the SGAT model. The multi-head SGAT layer is defined as:
[0079]
[0080] represents the hidden state of node i in layer l+1;
[0081] || indicates connection;
[0082] Where O is the number of heads;
[0083] σ(·) is the Softmax activation function;
[0084] a ij It is edge ij The attention coefficient;
[0085] is the weight matrix of the o-th head in layer l.
[0086] Multi-head refers to the stacking of multiple self-attention layers.
[0087] Furthermore, the integration mechanism module includes:
[0088] In the s-th step decoding of the n-th round, GRU takes the previously generated word and the previously generated hidden state as input to generate a new hidden state. After the model generates a word and a hidden state, it feeds the generated data into the model to generate the next one.
[0089]
[0090] where h n,s represents the hidden state obtained in the sth step of the nth round;
[0091] GRU(·,·) denotes gated recurrent unit;
[0092] h n,s-1 represents the hidden state obtained in the s-1th step of the nth round;
[0093] Represents the tensor representation of the word generated by decoding at the s-1th step in round n;
[0094] After obtaining the new hidden state h n,s After that, it is passed to two branches, and then the next word is generated and the top-ranked item names are obtained. The specific steps are as follows:
[0095] In one branch, h n,s Used as input to the dialogue state tracking module to generate the next word, the probability of generating the next word is calculated as follows:
[0096]
[0097] in express The word probability of
[0098] ∝ is the symbol of direct proportion;
[0099] exp(·) is an exponential function in higher mathematics with the natural constant e as the base;
[0100] W represents the model parameters;
[0101] · T represents transpose;
[0102] h n,s represents the hidden state obtained in the sth step of the nth round;
[0103] l n,s Represents the stop word indicator of the nth round and sth step;
[0104] B represents a binary mask;
[0105] φ represents the topic vector;
[0106] In another branch, h n,s Passed to the SGAT-based recommender, the probability of predicting an item is calculated as follows:
[0107]
[0108] in express Probability of being an entity word;
[0109] represents the predicted word t at the nth round s step;
[0110] R represents the hidden state obtained through the sparse graph attention mechanism.
[0111] The integration mechanism will be n,s They are sent to two branches, one for word prediction and the other for entity prediction, and finally the Gate is used to select whether the next word is an entity or a common word.
[0112] Furthermore, the conversation recommendation method of the system includes the following steps:
[0113] S1, first use the encoder based on the multi-hop attention network based on the GRU and dialogue state tracking module to encode the text at the word level and context level respectively, and obtain the token-embedding correspondence Figure 1 In and context-embedding, i.e. memory vector O l ,correspond Figure 1 h in n,s-1 , and then get the hidden state h through GRU n,s ;
[0114] S2, TopicRNN of the dialogue state tracking module obtains the semantic information M after removing stop words from the dialogue text;
[0115] S3, passes the external knowledge graph through the sparse graph attention network of the recommendation module to obtain nodes-embeddingin ,correspond Figure 1 Location Emnedding, Location Emnedding nodes may be places or other elements depending on the project; then it is combined with the hidden state h t Combined with the softmax layer in the recommendation module integration mechanism, the probability of obtaining items;
[0116] The external knowledge graph has a corresponding external knowledge graph for different projects.
[0117] S4, M and hidden state h t The word is decoded by the decoder of the dialogue state tracking module Represents the tensor representation of the word generated by decoding at the s-th step of the n-th round;
[0118] S5, insert the item into the corresponding slot in the sentence to get the machine's response. The integration mechanism of the corresponding recommendation module.
[0119] Furthermore, the decoder is LSTM or GRU.
[0120] In summary, due to the adoption of the above technical solution, the present invention can reduce the computational complexity of sparse graphs and capture local semantic dependencies and global semantic dependencies.
[0121] Specifically, we designed a multi-hop attention network to encode the conversation context, which can quickly capture the long-term dependencies of the conversation sequence. In addition, we developed a recommendation model based on a sparse graph attention mechanism to match items with conversations, thereby reducing the complexity of graph calculations and the interference of noisy nodes. Extensive experiments on tourism and movie conversation datasets show that our proposed model has significantly improved the quality of recommendations and conversation generation compared to existing methods.
[0122] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0123] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0124] Figure 1 It is a system block diagram of the present invention. DETAILED DESCRIPTION
[0125] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0126] Conversational recommender systems (CRS) have become an emerging research topic, aiming to provide users with high-quality recommendations through natural language interactions. Different from traditional recommender systems, CRS utilizes conversation data to complete recommendation tasks. CRS usually consists of a conversation module and a recommendation module. Most existing CRS focus on natural language processing or provide semantically rich search solutions for conversation systems. Traditionally, CRS mainly uses slot filling methods to obtain user preferences to make recommendations. Or use natural language to interact with users to achieve item recommendations. Recently, a popular trend is to incorporate knowledge or reinforcement learning into user modeling and conversation interactions to improve the performance of CRS. For example, task-oriented conversation systems (such as Mem2Seq) use multi-hop attention-based storage networks to combine knowledge and user input. In addition, to meet the needs of multiple topics, deep conversational recommender models (DCR) use graph convolutional networks (GCNs) to capture the relationship between different venues and match venues with conversation contexts. However, these methods have two problems. First, the deep conversational recommendation model based on GCN cannot fully capture spatial information, because the conversational recommendation system using the graph convolutional network model assigns exactly the same weights to neighboring nodes. In addition, there is a lot of noise in the graph, which may cause the conversational recommendation model based on GCN to overfit. In addition, the deep conversational recommendation model based on RNN has difficulty capturing long-term dependencies when generating conversation topics. On this basis, the hierarchical recurrent encoder (HRED) based on RNN is used to solve the long dependency problem in natural language processing tasks. However, this method still has difficulty in generating semantically correct and coherent sentences. In particular, when two words in the same sentence are far apart, the model cannot accurately capture the dependency relationship between the two words, affecting the overall structure of the sentence, which will hinder the smooth communication between users and agents. To solve these two problems, we find that the sparse graph attention network (SGAT) can effectively remove the edges in the graph that are not relevant to the task. SGAT uses a binary mask assigned to each edge to filter out noisy nodes. In addition, different attention scores can solve the spatial limitations caused by the same weight of the first order. In addition, we also noticed that the combination of memory network and multi-hop attention in Mem2Seq enhances the ability to capture long-term dependencies. The reason is that the embedding vectors are stored in external memory, and the query vector can easily access the "memory". Inspired by the existing graph attention network and storage network, we propose a sparse multi-hop conversational recommender system (SMCR). The main idea of the model is to integrate enhanced memory networks and sparse graph attention networks into the conversational recommendation system. Specifically, we encode the conversation text by fusing the encoder of the multi-hop attention mechanism to obtain a high-order representation of the text. In addition, the recommendation module also uses SGAT to match candidate items and user preferences.In summary, the main contributions of this paper are as follows: We propose a recommendation model based on sparse graph attention mechanism to match items with conversation context, thereby accurately identifying important edges in the knowledge graph and reducing the complexity of graph calculation and the interference of noise nodes. We design a multi-hop attention encoder to encode the context by combining the encoder based on the multi-hop attention mechanism and the encoder based on RNN to quickly encode long conversation sequences to capture long-term dependencies. We conduct extensive experiments on the MultiWOZ and Redial datasets to conduct model comparison evaluation, and the experiments show that our method is superior to existing methods.
[0127] 1. Related Work
[0128] Dialogue systems. According to different application scenarios, dialogue systems are divided into three categories: task-oriented dialogue systems (such as Cortana and Siri), chat dialogue systems (such as XiaoIce), and question-answering dialogue systems (such as online store assistants). Traditional dialogue systems are usually based on rules or templates. For example, Weizenbaum et al. developed the Eliza system to simulate the treatment of mental patients by psychotherapists. Subsequently, Wallace et al. developed the Alice system based on AIML and XML languages to create stimulus-response chatbots. However, these methods rely on a large number of manual labels. To solve this problem, DeBaser et al. designed a multi-party dialogue system based on machine learning and rules, using support vector machines for decision-making. In addition, thanks to the rapid development of deep learning and natural language technology, more and more researchers have turned their attention to dialogue systems based on deep learning. For example, Dhinga et al. combined reinforcement learning and knowledge graphs to develop a knowledge base InfoBot model, which is a dialogue agent that provides users with entities in the knowledge base through interactive query functions. Lipton et al. proposed the BBQ network, which incorporates reinforcement learning in the dialogue system. The research on these dialogue systems can achieve very smooth human-computer interaction, but we believe that discovering user interests through dialogue and guiding users to complete purchases, subscriptions and other behaviors has greater commercial value. Therefore, it is particularly important to build a dialogue-based recommendation system.
[0129] Conversational Recommender Systems. In recent years, with the rapid development of deep learning, interactive recommendation systems have attracted more and more attention from researchers. For example, Christakopoulu et al. proposed a novel view that recommendation is an interactive process. Greco et al. used hierarchical reinforcement learning to model the CRS target as a target-specific representation module. Sun Xiaoming et al. proposed a unified framework that integrates recommendation systems and dialogue systems to build an intelligent conversational recommendation system. Due to the lack of public large-scale dialogue datasets, Li Yajie et al. provided a real dialogue dataset Redial. To achieve question-answering between machines and humans, Zhang Yongfeng et al. not only introduced the system ask user response (SAUR) paradigm for conversational search and recommendation, but also designed a unified implementation framework for e-commerce product search and recommendation. Although these studies have achieved certain success, they only use dialogue information for modeling, resulting in a lack of sufficient context to express user preferences. Overall, it is crucial to build a conversation-based recommendation system. To address these issues, many researchers have focused on knowledge-based conversational recommender systems, which can provide external knowledge and narrow the gap between dialogue systems and recommender systems to improve the performance of recommender models.
[0130] Knowledge-based conversational recommender systems. Knowledge graphs (KGs) can represent structured relationships between entities and have been successfully applied to conversational recommender systems. Chen et al. proposed a new end-to-end framework and introduced knowledge information about user preferences. Moon et al. proposed a DialKG Walker model that converts words in the conversation context into a traversal of the KG structure, and predicts natural entities through an attention-based graph path decoder given the previous conversation context. Liao et al. combined a sequence-to-sequence model with a neural latent topic component and a graph convolutional network for recommendation in the tourism field. Lei et al. used graphs to solve the multi-turn conversational recommendation problem and proposed a conversational path reasoning framework to synchronize the conversation with graph-based path reasoning. The model makes the use of attributes more explicit and greatly improves the interpretability of conversational recommendations. Zhou et al. used a mutual information maximization method to align the word-level and entity-level semantic spaces to bridge the natural semantic gap.
[0131] In summary, these works use the paths of knowledge graphs to simulate the dialogue process or use knowledge graphs for modeling. However, in the real world, dialogues are multi-level, multi-round, and multi-topic, and there are complex dependencies between sub-dialogues in the dialogue. In addition, there are many items involved in the dialogue, and each item has many attributes, which will add a lot of calculations to the modeling. Therefore, we believe that since the knowledge graph is complex and sparse, there are always some noise nodes in the process of extracting and aggregating graph information, which do not contribute to the aggregation results. Effectively distinguishing between noise nodes and important nodes will improve aggregation efficiency and save computational space. Based on these assumptions, we develop a recommendation model with a sparse graph attention network to match items with dialogue context to reduce the complexity of graph calculation and the interference of noise nodes. In addition, we also design a multi-hop attention network to encode the dialogue context, which can quickly encode long dialogue sequences to capture long-term dependencies.
[0132] 2. Proposed model
[0133] We propose a conversational recommendation method (SMCR) that combines recommendation systems and conversational systems. We will explain how the multi-hop attention-based encoder maps conversational information to vectors and how it introduces external knowledge into the context. The SMCR method consists of two parts: a dialogue state tracking module and a SGAT-based recommendation module. The detailed structure of the model is shown in Figure 1 shown.
[0134] 2.1 Dialogue State Tracking Module
[0135] We adopt Hierarchical Recurrent Encoder-Decoder (HRED) to model dialogue state tracking. First, we use HRED to build an encoder based on sentence-level and word-level RNNs, namely Figure 1 The TopicRNN in the above code encodes the context and words respectively, and then decodes them using a decoder based on LSTM or GRU. HRED corresponds to the fusion of multi-hop attention and TopicRNN in the encoding process.
[0136] 2.1.1 Multi-hop encoder
[0137] In dialogue generation modeling, it is difficult to handle the problem of long-term dependencies using RNN-based encoders. Inspired by the end-to-end memory network proposed by Sukhbatar et al., we develop a multi-hop attention-based encoder to encode the dialogue context, based on the fact that using attention mechanisms in the encoding stage helps to handle long-term dependencies. In addition to external memory, memory networks can also enhance the persistence of memory. Specifically, we consider a dialogue D as n sentences D = {U1,U2,U3,...,U n} sequence, U nRepresents the nth sentence. Each U n ∈D is a sequence containing Mn words, that is, U n = {W n,1 ,W n,2 ,...,W n,Mn}, where W n,Mn is a random variable, taken from the word table V, representing the word at the Mth position in the nth sentence in D.
[0138] U h ∈D, the encoder will dialogue U h = {W h,1 ,W h,2 ,...,W h,Mh} for each word W h,j Mapped to word vector θ h,j In this way, the encoder encodes the dialogue D into a high-order representation β = {β1,β2,...,β N}, β N Represents the tensor form of the Nth sentence in dialogue D,
[0139] β is called the memory tensor. Then, we use the query vector Q as the head to read. The model iterates with the number of hops l and calculates the attention weight of the memory tensor at the lth hop. The calculation formula is,
[0140] Q l+1 =Q l +O l
[0141] Q l+1 represents the query vector Q of the l+1th hop;
[0142] Q l represents the query vector Q of the lth hop;
[0143] O l represents the memory vector of the lth jump;
[0144]
[0145] It represents the content of the lth jump of the kth memory component, and β is the memory tensor.
[0146] The following formula is used to measure the memory content and query vector Q l The degree of correlation between them.
[0147]
[0148] The value is between 0 and 1. The closer the memory score is to 1, the greater the relevance. kRepresents the element at the kth position in array z, z u Represents the element at position u in array z;
[0149] The model then transforms Weighted to Sum to read the memory vector O l :
[0150]
[0151] represents the attention weight of the memory tensor position k at the lth hop;
[0152] in is the memory content of position k;
[0153] The result is the memory vector O l , which will become one of the inputs of the decoder, corresponding to Figure 1 h in n,s-1 .
[0154] 2.1.2 TopicRNN Learning
[0155] Although the RNN model can capture the local relationship of sentences well, it lacks the ability to capture the dependencies of words in long sequences, while the TopicRNN model can capture the global semantic information in documents well. This is because a large number of long-term dependencies in language stem from semantic coherence. In multi-round multi-topic dialogues, the capture of subtopics will affect the quality of dialogue generation. The generation learning process of the TopicRNN model can be described as Algorithm 1.
[0156]
[0157] The output of the decoder is influenced by the topic vector φ, and its output is treated as a bias, allowing us to separate global semantics from local dynamic semantics. n Determine how the topic vector φ affects the output. Specifically, if the indicator l n If is equal to 1, it means that the word is a stop word and the output will not be affected. In addition, it means that the word belongs to the topic φ. The weight is introduced to increase the proportion of words belonging to the topic φ in the output, as well as to better model stop words and non-stop words. The weight is determined by the bias b j The dot product of the transpose of the topic vector φ is obtained. It can be seen that the topic vector φ captures the long-range semantic information that has a direct impact on the output and is added. Where token represents a word, and l n correspond Figure 1 l n,s .
[0158] 2.2 Recommendation module based on SGAT
[0159] 2.2.1 SGAT Recommender
[0160] Usually, an item has many attributes. For example, when a new visitor queries for a hotel, the hotel has an address, area, network, name, free parking spaces, etc., which is very suitable for modeling items using graph-structured data. When a user sends a request that he wants a Chinese restaurant, the user clearly provides the system with two constraints, "Chinese" and "restaurant". Therefore, the system not only accurately captures them, but also takes into account potential constraints such as location and business hours, because users are more willing to consider restaurants near the hotel. In order to capture the explicit and latent relationships between these places, we use a sparse graph attention mechanism. Unlike graph convolutional networks, it can assign different weights to the neighborhood nodes of the vertices in the graph, enhancing the spatial information of the model. However, in the real world, graphs are large and complex, and most importantly, graphs are sparse and full of noise. Therefore, if not properly regularized, graph attention is prone to overfitting. The sparse graph attention mechanism is a type of graph attention mechanism. Regularization technology is used in graph attention. SGAT can remove at least 20% of useless edges from the graph while maintaining high classification accuracy. In addition, the binary gates in the SGAT model cleverly implement edge pruning. We define an undirected graph G = (V, E), with a node set V = {v1, v2, .., v w} and edge set To connect these nodes, where v w represents the w-th node. Dense matrix Represents node features, and a row of the matrix represents the feature vector of a node. We use A to represent the adjacency matrix, and add a self-loop to each node to save the node's own information. Specifically, add 1 to the diagonal of the adjacency matrix. A′=A+I w represents an adjacency matrix with self-connection, where is an identity matrix. Represents a real number of w×w dimensions.
[0161] Given such a graph G = (V, E), we generate item embeddings to calculate the score matching the conversation context. Finally, we get the recommended items. In general, in order to aggregate the feature information of the first-order neighborhood nodes, we use a multi-layer convolution module. As a result, we get a high-order representation of the project that contains a lot of knowledge graph information. The purpose is to learn how to selectively filter out the nodes that need to participate in the aggregation operation and how to aggregate neighborhood information. We give each edge e ij Assign a binary gate b ij∈{0,1} to identify each edge that will participate in the aggregation operation and prune edges that are irrelevant to the task. ij represents the edge connecting nodes i and j, b ij Represents edge e ij of binary gates.
[0162] In short, if b ij is equal to 1, it means that the edge participates in the aggregation operation. ij If it is equal to 0, it means that the edge does not participate in the aggregation operation. This is equivalent to adding a set of binary masks to the adjacency matrix A:
[0163]
[0164] Where B represents a binary mask, N is the number of edges in the graph G, {0,1} N Represents a set of binary masks. Since we want to use as few edges as possible in semi-supervised node classification, we train the model parameters P and binary masks B by minimizing the sum of L0 norm and empirical risk. The optimization process is as follows:
[0165]
[0166] Where R(P,B) represents the model risk, n represents the number of training samples, and y i represents the label of the sample, L(·) represents the empirical risk, A represents the adjacency matrix, P represents the model training parameters, B represents the binary mask, X represents the node feature matrix, ||B||0 represents the L0 norm of the binary mask B, that is, the number of non-zero elements in B, is an indicator that satisfies the condition and is 1, otherwise it is 0, and λ is a regularized hyperparameter used to balance data loss and edge sparsity. For the encoder function f(X,A⊙B,P), we define the following attention-based aggregation function as:
[0167]
[0168] represents the hidden state of node i in layer l+1;
[0169] σ(·) is the Softmax activation function;
[0170] j∈N i Indicates that j belongs to the set of neighbor nodes of node i;
[0171] represents the hidden state of node j in layer l;
[0172] w (l) represents the weight of the lth layer;
[0173] Here a ij It is edge ij SGAT is the attention coefficient of layer l edge e ij Specify a single attention coefficient, where l is the number of convolutional layers.
[0174] We calculate the standardized attention coefficient by normalizing A⊙B row by row,
[0175]
[0176] A ij Represents the element in the i-th row and j-th column of the adjacency matrix;
[0177] b ij Represents the element in the i-th row and j-th column of the binary mask matrix;
[0178] N i Represents the set of neighbor nodes of node i;
[0179] To enhance the capability of the SGAT model, we add multi-head attention similar to GAT. Therefore, we define the multi-head SGAT layer as:
[0180]
[0181] represents the hidden state of node i in layer l+1;
[0182] Where O is the number of heads, || represents the connection, a ij It is edge ij The attention coefficient, is the weight matrix of the o-th head in layer l.
[0183] 2.2.2 Integration Mechanism
[0184] Given the context of the conversation, we can predict the next utterance through the dialogue state tracking module and obtain the recommended items using the SGAT-based recommendation model. We adopt an integrated mechanism to achieve the above two tasks. Gated recurrent units (GRU) are widely used in end-to-end dialogue systems. Specifically, in the s-th decoding step of the n-th round, the GRU takes the previously generated word and the previously generated hidden state as input to generate a new hidden state,
[0185]
[0186] where h n,s represents the hidden state obtained in the sth step of the nth round;
[0187] Represents the tensor representation of the word generated by decoding at the s-1th step in round n;
[0188] n here represents the nth round;
[0189] After obtaining the new hidden state h n,s After that, it is passed to two branches. We illustrate how to generate the next word and get the top-ranked item names respectively.
[0190] In one branch, h n,s Used as input to the dialogue state tracking module to generate the next word, the probability of generating the next word is calculated as follows:
[0191]
[0192] in express The word probability of
[0193] ∝ is the symbol of direct proportion;
[0194] exp(·) is an exponential function in higher mathematics with the natural constant e as the base;
[0195] W represents the model parameters;
[0196] B represents a binary mask;
[0197] φ represents the topic vector;
[0198] · T represents transpose;
[0199] In another branch, h n,s Passed to the SGAT-based recommender. The probability of predicting an item is calculated as follows:
[0200]
[0201] express Probability of being an entity word;
[0202] represents the predicted word t at the nth round s step;
[0203] R represents the hidden state obtained through the sparse graph attention mechanism.
[0204] Although the embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
Claims
1. A conversational recommendation system integrating sparse graph and multi-hop attention, characterized in that: include: A dialogue state tracking module, a recommendation module, and an integration mechanism module, wherein the data output end of the dialogue state tracking module is connected to the data input end of the recommendation module, and the data output end of the recommendation module is connected to the data input end of the integration mechanism module; Dialogue state tracking module: uses an encoder based on a multi-hop attention network to encode the dialogue context, and then uses the TopicRNN model to capture the global semantic information in the document; The method of encoding the conversation context using an encoder based on a multi-hop attention network includes: Will U h = {W h,1 ,W h,2 ,...,W h,Mh } for each word W h,j Mapped to word vector θ h,j , encode the dialogue D into a high-order representation β = {β1,β2,...,β N }, where U h represents the hth sentence in dialogue D, β N Represents the tensor form of the Nth sentence in the dialogue D, β is called the memory tensor, W h,j Indicates U h The jth word in , j = 1, 2, ..., Mh; Then, the query vector Q is used as the head to be read, iterated with the number of hops l, and the attention weight of the memory tensor at the lth hop is calculated. The calculation formula is: Q l+1 =Q l +O l Q l+1 represents the query vector Q of the l+1th hop; Q l represents the query vector Q of the lth hop; O l represents the memory vector of the lth jump; represents the attention weight of the lth jump of the kth memory component; Represents the content of the lth jump of the kth memory component; · Τ represents transpose; Softmax(·) is the Softmax activation function; The following formula is used to measure the memory content and query vector Q l The correlation between: Where e represents the natural base; z k Represents the element at the kth position in array z; z u Represents the element at position u in array z; Then, the model is constructed by Weighted to Sum to read the memory vector O l : Represents the content of the l+1th jump of the kth memory component; The TopicRNN model includes: Input global semantic information, which includes user input U and context C. User input U is a sentence, and context C is the previous conversation. Data processing: S-1, input the data into the hierarchical recursive encoding-decoding model HRED, and obtain h = HRED (U, C), where h represents the hidden state; S-2, then obtain a topic vector φ from the user input U and context C, φ follows a normal distribution; S-3, re-initialize the decoder, that is, assign h to H0, H0 is the decoder initialization state; S-4, C contains T=(t1,t2,...,t n-1 ), where T represents a word sequence in C, t1 represents the first word, t2 represents the second word, and t n-1 represents the n-1th word, S-5, to calculate word t n Enter the loop: Calculate the decoder's hidden state H n =fw(H n-1 ,T), where fw() is the decoder, H n-1 is the hidden state of the decoder at round n-1; S-6, get a stop word indicator l from context C n , l n ~Bernoulli(sigmoid(W T H n-1 ), Bernoulli() represents Bernoulli distribution, sigmoid() is the sigmoid activation function, W T is the transpose of the weight matrix, l n That is l n,s , represents the stop word indicator of the s-th step of the n-th round; S-7, finally get t n ~p(t n |H n ,φ,l n ,B), at this time p(t n =j|H n ,φl n ,B) Where B is Bernoulli (sigmoid (W T H n-1 )), ~ means obedience, H n is the hidden state of the decoder in the nth round, φ is the topic vector, l n is the stop word indicator, B represents the Bernoulli distribution, and w j represents the jth word, Indicates w j The transpose of S-8, output prediction tag t n , t n Indicates the nth word; Recommendation module: Use the sparse graph attention network SGAT to capture the features of the knowledge graph and regularize the sparse graph. The project embedding generated by the graph is used to calculate the score matching the conversation context. Finally, the probability of the item is obtained. The sparse graph attention network SGAT includes: A multi-layer convolution module is used to aggregate the feature information of the first-order neighborhood nodes to obtain a high-level representation of the project containing knowledge graph information; Then for each edge e ij Assign a binary gate b ij ∈{0,1} to identify each edge that will participate in the aggregation operation and prune the edges that are irrelevant to the task, where e ij represents the edge connecting nodes i and j, b ij Represents edge e ij Binary gates of If b ij is equal to 1, then the edge participates in the aggregation operation; if b ij If it is equal to 0, the edge does not participate in the aggregation operation, which is equivalent to adding a set of binary masks to the adjacency matrix A: in represents the adjacency matrix A with binary mask B added; B represents a binary mask; ⊙ represents the splicing operation; N is the number of edges in the graph G; {0,1} N Represents a set of binary masks, a total of N; The model parameters P and binary mask B are trained by minimizing the sum of L0 norm and empirical risk as follows: Where R(P,B) represents the model risk; n represents the number of training samples; L(·) represents the empirical risk; f i (·,·,·) represents the predicted value of the i-th node; X represents the node feature matrix; A represents the adjacency matrix; B represents a binary mask; ||·||0 represents the L0 norm; P represents the model training parameters; y i Represents the label of the i-th sample; λ is a regularization hyperparameter; ||B||0 represents the l0 norm of the binary mask B, that is, the number of non-zero elements in B; 1 [zij≠0] is an indicator that satisfies the condition z ij ≠0 value is 1, otherwise it is 0; z ij Represents the element at row i and column j of the binary mask B; For the encoder function f(X,A⊙B,P) that obtains the predicted value, the aggregation function based on the attention coefficient is defined as: represents the hidden state of node i in layer l+1; σ(·) is the Softmax activation function; N i Represents the set of neighbor nodes of node i; a ij It is edge ij The attention coefficient, e ij represents the edge connecting nodes i and j; represents the hidden state of node j in layer l; w (l) represents the weight of the lth layer; Attention coefficient a ij The calculation formula is as follows: A ij Represents the element in the i-th row and j-th column of the adjacency matrix; b ij Represents the element in the i-th row and j-th column of the binary mask matrix; N i Represents the set of neighbor nodes of node i; Integration mechanism module: According to the conversation context, the conversation state tracking module predicts the next word and uses the SGAT-based recommendation model to obtain recommended items.
2. A conversation recommendation system integrating sparse graph and multi-hop attention according to claim 1, characterized in that: Also includes: Multi-head attention is added, and the multi-head SGAT layer is defined as: represents the hidden state of node i in layer l+1; || indicates connection; Where O is the number of heads; σ(·) is the Softmax activation function; a ij It is edge ij The attention coefficient; is the weight matrix of the o-th head in layer l.
3. A conversation recommendation system integrating sparse graph and multi-hop attention according to claim 1, characterized in that: The integration mechanism module includes: In the s-th decoding step of the n-th round, the GRU takes the previously generated word and the previously generated hidden state as input to generate a new hidden state, where h n,s represents the hidden state obtained in the sth step of the nth round; GRU(·,·) denotes gated recurrent unit; h n,s-1 represents the hidden state obtained in the s-1th step of the nth round; Represents the tensor representation of the word generated by decoding at the s-1th step in round n; After obtaining the new hidden state h n,s After that, it is passed to two branches, and then the next word is generated and the top-ranked item names are obtained. The specific steps are as follows: In one branch, h n,s Used as input to the dialogue state tracking module to generate the next word, the probability of generating the next word is calculated as follows: in express The word probability of ∝ is the symbol of direct proportion; exp(·) is an exponential function in higher mathematics with the natural constant e as the base; W represents the model parameters; · Τ represents transpose; h n,s represents the hidden state obtained in the sth step of the nth round; l n,s Represents the stop word indicator of the sth step of the nth round; B represents a binary mask; φ represents the topic vector; In another branch, h n,s Passed to the SGAT-based recommender, the probability of predicting an item is calculated as follows: in express Probability of being an entity word; represents the predicted word t at the nth round s step; R represents the hidden state obtained through the sparse graph attention mechanism.
4. The conversation recommendation system integrating sparse graph and multi-hop attention according to claim 1, characterized in that: The conversation recommendation method of the system comprises the following steps: S1, first use the GRU-based encoder and the multi-hop attention network-based encoder to encode the text at the word level and context level respectively, and obtain and h n,s-1 , and then get the hidden state h through GRU n,s ;in represents the tensor representation of the word generated by decoding at the s-1th step in the nth round, h n,s-1 represents the hidden state obtained in the s-1th step of the nth round, h n,s represents the hidden state obtained in the sth step of the nth round; S2, TopicRNN obtains the semantic information M after removing stop words from the conversation text; S3, the external knowledge graph is embedded into the point i through the sparse graph attention network n , and then compare it with the hidden state h t Combined with the probability of getting the item after passing through the softmax layer; S4, M and hidden state h t The word is decoded by the decoder Represents the tensor representation of the word generated by decoding at the s-th step of the n-th round; S5, insert the item into the corresponding slot in the sentence and get the machine’s response.
5. A conversation recommendation system integrating sparse graph and multi-hop attention according to claim 4, characterized in that: The decoder is LSTM or GRU.
Citation Information
Patent Citations
Multi-round dialogue reply generation system and method based on relational graph attention network
CN114281954A
Session recommendation method, system and equipment based on multi-aspect global relation item representation learning and medium
CN114330299A
Cited By
Multi-granularity sparse attention implicit graph converter model training method and system
CN121390148A