A user-personalized conversation response generation method and model

By using user history and current input sentences in the dialogue system to calculate personalized information and select knowledge sentences that meet user preferences, the problem of lack of personalization in dialogue systems in the existing technology is solved, and more flexible and high-quality dialogue generation is achieved.

CN116136871BActive Publication Date: 2025-09-05SOUTH CHINA NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310191200.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-01
Publication Date
2025-09-05
Estimated Expiration
2043-03-01

AI Technical Summary

Technical Problem

Existing knowledge-based dialogue systems lack user personalization considerations when generating responses, resulting in rigid and insufficiently persistent conversations. They also require additional datasets annotated with interlocutor information, increasing the system burden and reducing flexibility.

Method used

By utilizing the user's historical input sentences and the current round input sentences in the dialogue system, the matching degree score is calculated, the personalized information selective preservation vector and the user personalized representation vector are obtained, the knowledge sentences that meet the user's preferences are selected, and the context information is introduced in the generation process to generate dialogue responses that are more in line with the user's preferences.

Benefits of technology

The flexibility and application scope of the dialogue system are improved, the generated dialogue responses are more in line with user preferences, the attractiveness and persistence of the dialogue are increased, and the data processing burden of the dialogue system is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116136871B_ABST
    Figure CN116136871B_ABST
Patent Text Reader

Abstract

The present invention relates to a method and model for generating user-personalized dialogue responses. The method comprises the following steps: S1, obtaining a matching score between the personalized information contained in the current input statement and historical input statements; S2, obtaining a personalized information selective storage vector based on the matching score; S3, obtaining a user personalized representation vector based on the personalized information selective storage vector; after obtaining the user personalized representation vector, selecting a knowledge statement from candidate knowledge statements that best matches the user's personality based on the user personalized representation vector, and then generating a dialogue response statement using the selected knowledge statement. The solution of the present invention eliminates the need to introduce external interlocutor information annotation data to obtain user personalized information, thereby reducing the data processing burden of the dialogue system and increasing the flexibility and application scope of the dialogue system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a method and model for generating dialogue responses based on user personalization. Background Art

[0002] In recent years, the rise of new-generation artificial intelligence technologies, represented by deep learning, has driven the rapid development of natural language processing (NLP). Dialogue systems, a key topic within NLP, study how machines communicate with humans through text, and have attracted considerable attention from both academia and industry.

[0003] In the existing technology, end-to-end generative dialogue systems based on the sequence-to-sequence model (Seq2Seq) framework can generate corresponding response sequences for input dialogue sequences after training. However, such end-to-end generative dialogue systems tend to generate rigid, meaningless, and inappropriate general repetitive responses (such as "OK," "Yes," "I don't know," etc.), and lack the ability to expand the content of the dialogue.

[0004] Currently, knowledge-based dialogue systems have achieved promising results in increasing the information content of responses. Knowledge-grounded conversations (KGC) within these systems refer to the introduction of additional knowledge into the response generation process, making the generated responses more informative. The key challenge lies in knowledge selection (KS), specifically how to select appropriate portions from a given set of knowledge statements to incorporate into the response generation process. However, in this knowledge selection process, existing knowledge-based dialogue systems typically only consider the relationship between historical conversations and external knowledge, lacking consideration for user personalization. This results in unbiased knowledge selection and an inability to select user-preferred knowledge to construct responses. Furthermore, due to the one-to-many nature of conversations (i.e., a single conversation can have multiple appropriate responses), existing knowledge-based dialogue systems often suffer from unengaging and short-lived conversations. Therefore, when generating responses, knowledge-based dialogue systems should not only consider the direct relationship between historical dialogues and external knowledge, but should also pay more attention to user preferences, select knowledge that is more in line with user personality, and introduce it into the corresponding response generation process, thereby improving the quality of the dialogue.

[0005] In the prior art, although there are methods for introducing personalized user knowledge when generating responses, existing methods that consider user personalization require the introduction of additional conversation data sets annotated with interlocutor information. The corresponding knowledge is determined by annotating the interlocutor's personal information. This method increases the burden of data processing on the conversation system. In addition, the fixed data reduces the flexibility of the conversation system, thereby hindering the wider application of the conversation system. Summary of the Invention

[0006] Based on this, the purpose of the present invention is to provide a method for generating dialogue responses based on user personalization, which does not require the use of additional dialogue data sets annotated with interlocutor information for training, has better flexibility and applicability, and can improve the durability and simplicity of the dialogue system's chat with users.

[0007] A method for generating user-personalized dialogue responses comprises the following steps:

[0008] S1. Obtain a score for the degree of matching between the personalized information contained in the current input sentence and the historical input sentence based on the user's historical input sentences and the current input sentence in the current conversation;

[0009] S2. Obtaining a personalized information selective storage vector of the historical input sentence based on the matching score;

[0010] S3. Selectively save the vector according to the personalized information to obtain the user personalized representation vector corresponding to the input sentence of the current round;

[0011] S4. Obtaining, based on the user personalized representation vector, an information association vector between each candidate knowledge statement and the user personalized representation vector;

[0012] S5. Obtaining a knowledge selection distribution vector of the candidate knowledge sentence based on the information association vector;

[0013] S6. Calculate the attention score of each candidate knowledge statement based on the knowledge selection distribution vector, and determine the candidate knowledge statement with the highest attention score as the knowledge statement selected in the current round of dialogue;

[0014] S7, initializing the decoding hidden state vector of the recurrent neural network according to the context sentence and the selected knowledge sentence;

[0015] S8, updating the recurrent neural network to obtain an updated decoding hidden state vector;

[0016] S9, calculating a first attention value for a word in the vocabulary based on the updated decoded hidden state vector and the context sentence, and calculating a second attention value for a word in the selected knowledge sentence based on the updated decoded hidden state vector and the selected knowledge sentence;

[0017] S10. Calculate a final probability value of the word using the first attention value and the second attention value;

[0018] S11. Select the word with the highest final probability value as the generated word for the current time step.

[0019] In this invention, the user's historical input sentences and current-round input sentences during the current conversation are used to obtain personalized user information for each conversation round. Both the historical input sentences and the current-round input sentences are internal to the conversation system, eliminating the need to import external interlocutor information annotation data to obtain personalized user information, thereby reducing the data processing burden of the conversation system. Furthermore, because the corresponding historical input sentences and current input sentences vary in each conversation round, the data used to obtain personalized user information is not fixed in each conversation round, but changes accordingly with the user's input sentences. This not only improves the accuracy of the personalized user information obtained in each conversation round, but also enhances the flexibility of the conversation system, making it applicable to a variety of conversation scenarios and expanding the scope of its application.

[0020] Furthermore, in step S4, this solution also considers the correlation and similarity between each candidate knowledge statement and the user's personalized representation vector, thereby promoting the dialogue system to select more appropriate knowledge statements that align with user preferences. When calculating the first and second attention values, this solution incorporates contextual dialogue statements to ensure that the generated words are closer to the contextual statements. Simultaneously, the selected knowledge statements are also incorporated to ensure that the words from the selected knowledge statements appear in the generated dialogue response statements. This makes the generated dialogue response statements more appropriate and more informed by the user's preferred knowledge, thereby increasing the user's interest in the conversation and enhancing the duration of the conversation.

[0021] Furthermore, the step S1 includes: respectively encoding the historical input sentence and the current round input sentence to obtain a first historical input sentence personalized information hidden vector and a current round input sentence personalized information hidden vector, and using the first historical input sentence personalized information hidden vector and the current round input sentence personalized information hidden vector to obtain the matching degree score; the step S2 includes: calculating the personalized information selective preservation vector based on the matching degree score and the second historical input sentence personalized information hidden vector obtained by encoding the historical input sentence, wherein the second historical input sentence personalized information hidden vector and the first historical input sentence personalized information hidden vector have the same encoding method but different parameters.

[0022] In this scheme, the same encoding method is used to encode the historical input sentences in different steps. While achieving consistent vector length, the training of multiple parameters is conducive to obtaining the personalized information selective preservation vector that better reflects the user's personalized information, so that the subsequently obtained user personalized representation vector can more accurately and completely reflect the user preferences expressed in the user's input sentence in the current round.

[0023] Furthermore, the step S3 includes: calculating the direct correlation between the personalized information selective preservation vector and the personalized information hidden vector of the current round input sentence to obtain the user personalized representation vector.

[0024] This solution considers both the personalized information in the user's previous input sentences and the user's current input sentence information when obtaining the user's personalized representation vector. This allows the obtained user personalized representation vector to more comprehensively reflect the user's individuality during the current conversation. Furthermore, using the direct relevance of the information contained in the representation vector to represent the user's personalized representation improves the stability and comprehensiveness of the user's personalized representation.

[0025] Furthermore, the step S4 includes: obtaining an information association vector between each candidate knowledge sentence hidden vector and the user personalized representation vector based on the candidate knowledge sentence hidden vector obtained by encoding the candidate knowledge sentence and the user personalized representation vector.

[0026] Furthermore, the step S5 includes:

[0027] S51. Encode the context sentences in the current dialogue to obtain a context sentence information hidden vector, wherein the context sentences include the historical dialogue sentences and the user's current turn input sentence;

[0028] S52. Obtain the knowledge selection distribution vector according to the information association vector, the context sentence information hiding vector, and the candidate knowledge sentence hiding vector.

[0029] In this scheme, when selecting knowledge statements, not only the relevance between the candidate knowledge statements and the contextual dialogue statements is considered, but also the correlation and similarity between each candidate knowledge statement and the user's personalized representation vector are considered, thereby promoting the dialogue system to select more appropriate knowledge statements that meet user preferences.

[0030] Furthermore, the historical dialogue sentences are the historical dialogue sentences of the previous round corresponding to the current round of dialogue, which improves the accuracy of knowledge sentence selection and improves the model running speed.

[0031] Furthermore, step S8 includes: obtaining a decoding hidden state vector of the current time step based on the decoding hidden state vector output at the previous time step, the generated word at the previous time step, and the gating vector, wherein the gating vector is used to indicate the degree of use of the information of the context sentence and the information of the selected knowledge sentence when the decoding hidden state vector is updated.

[0032] Furthermore, the gate vector is in,

[0033] , g τ Indicates the gate value of GRU in the current dialogue, W g and b g represents a trainable parameter vector, Represents the hidden vector of the context sentence information of the current dialogue, The knowledge sentence hidden vector representing the knowledge sentence selected in the current dialogue turn.

[0034] The present invention also relates to a user-personalized dialogue response generation model, comprising:

[0035] A matching degree calculation module is used to calculate the matching degree score between the user's historical input sentences and the current input sentence in the current conversation based on personalized information;

[0036] A user personalized information selective acquisition module, configured to obtain a personalized information selective storage vector of the historical input sentence according to the matching degree score;

[0037] The user personalized representation vector acquisition module is used to selectively save the vector according to the personalized information and obtain the user personalized representation vector corresponding to the input sentence of the current round.

[0038] An information association vector acquisition module, configured to obtain, based on the user personalized representation vector, an information association vector between each candidate knowledge statement and the user personalized representation vector;

[0039] a knowledge selection distribution calculation module, configured to obtain a knowledge selection distribution vector of a candidate knowledge statement according to the information association vector;

[0040] an attention score calculation module, configured to obtain an attention score for each candidate knowledge statement based on the knowledge selection distribution vector;

[0041] The knowledge sentence selection module selects the candidate knowledge sentence with the highest attention score;

[0042] The decoder decoding state initialization module initializes the decoding state of the recurrent neural network to obtain the initialized decoding hidden state vector and the initialized generated word;

[0043] The decoder decoding state update module updates the decoding state of the recurrent neural network to obtain an updated decoding hidden state vector;

[0044] a word attention value calculation module, configured to calculate a first attention value for a word in a word list based on the updated decoded hidden state vector and the context sentence, and to calculate a second attention value for a word in a selected candidate knowledge sentence based on the updated decoded hidden state vector and the selected candidate knowledge sentence;

[0045] A word final probability calculation module, configured to obtain a final probability value of a word based on the first attention value and the second attention value;

[0046] The dialogue response sentence generation module selects the word with the highest final probability value as the generated word and forms all the generated words into a dialogue response sentence and outputs it.

[0047] Furthermore, it also includes a gating vector acquisition module, which obtains a gating vector based on the context sentence and the selected candidate knowledge sentence, and the gating vector is used to indicate: when updating the decoding hidden state vector, the degree of use of the information of the context sentence and the selected candidate knowledge sentence is used; and the decoder decoding state update module obtains the decoding hidden state vector of the current time step based on the decoding hidden state vector output at the previous time step, the generated word at the previous time step, and the gating vector.

[0048] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1This is a flowchart of a method for generating user-personalized conversation responses according to the present invention;

[0050] Figure 2 This is a module diagram of a user-personalized dialogue response generation model of the present invention. DETAILED DESCRIPTION

[0051] The present invention relates to a user-personalized conversation response generation method. In a conversation with M (M≥2) rounds, during the τ (τ=1, 2, ..., M)th round (i.e., the current round), the user's historical input sentences and current round input sentences are obtained, and the user's personalized information contained in these historical input sentences and current round input sentences is extracted to obtain a user-personalized representation vector. The user-personalized representation vector is then used to select a knowledge sentence from a set of candidate knowledge sentences that best matches the user's preferences. The selected knowledge sentence is then used to generate a conversation response sentence containing the user's preferred knowledge, thereby improving the engagement and durability of the conversation. The conversation response generation method of the present invention does not require the introduction of external interlocutor information data or the annotation of this data, and is concise, effective, and highly flexible and applicable.

[0052] For details, please refer to Figure 1 A method for generating a user-personalized conversation response according to the present invention comprises the following steps:

[0053] S1. Obtain a matching score between the personalized information contained in the current input sentence and the historical input sentence according to the user's historical input sentences and the current input sentence in the current conversation.

[0054] In this step, the matching score is used to indicate the matching degree between the user's current input sentence and the user's personalized information contained in the historical input sentence. A high matching degree between the two indicates a high matching score, while a low matching degree between the two indicates a low matching score. This step specifically includes:

[0055] S11. Obtain the user's historical input sentences, encode the historical input sentences, and obtain the user's first historical input sentence personalized information hidden vector; and obtain the user's current round input sentence, encode the user's current round input sentence, and obtain the current round input sentence personalized information hidden vector.

[0056] In this step, a pre-trained language model can be used to encode the user's historical input sentences and the current round of input sentences. The pre-trained language model includes GPT (Generative Pre-trained Transformer), BERT (Bidirectional Encoder Representations from Transformers), etc.

[0057] In order to obtain the user's personalized information to the greatest extent possible, it is preferred to encode all historical input sentences in the current conversation process and obtain a first historical input sentence personalized information hidden vector corresponding to each historical input sentence. The first historical input sentence personalized information hidden vector includes the user's personalized information contained in the historical input sentence.

[0058] Specifically, in this embodiment, in the τth (τ=1,2,...,M) round (i.e., the current round) of the current conversation, the pre-trained language model Bert is used to convert the historical input sentences {X1,X2,...,X i ,…,X τ-1} are all encoded to obtain the personalized information hidden vectors of the first historical input sentences τ-1. The specific formula is as follows (1):

[0059] m i =M·(Bert(e(X i ))+TE i ) (1)

[0060] Among them, m i Represents the historical input sentence X corresponding to the current dialogue i The first historical input sentence personalized information hidden vector, M is a trainable parameter matrix, e(X i ) means that the historical input sentence X in the current dialogue i The words in the text are converted into vectors. In this embodiment, the historical input sentence X in the current dialogue is converted into i The word embedding GloVe model in the text is used to convert text to vectors, TE i Represents the historical input sentence X in the current dialogue i The corresponding turn number (i.e., the number of the conversation round in the current conversation) is used as the embedding vector of the position encoding, where i = 1, 2, ..., τ-1.

[0061] When encoding the current round input sentence, in order to ensure that the personalized information hidden vector of the current round input sentence and the personalized information hidden vector of the first historical input sentence have the same vector length, and to facilitate calculation and training, and further to ensure that the personalized feature information extracted from the historical input sentence and the personalized feature information extracted from the current round input sentence have the same properties of personalized features, in this embodiment, the same encoding method as that used in encoding the historical input sentence is used, and the pre-trained language model Bert is also used to encode the user's current round input sentence X τ Encode to obtain the personalized information hidden vector of the current round input sentence, as shown in the following formula (2):

[0062] q=Q·(Bert(e(X τ ))+TE τ ) (2)

[0063] Among them, q represents the input sentence X in the current dialogue τ The personalized information hidden vector of the current round input sentence, Q is a trainable parameter matrix different from the aforementioned parameter matrix M, e(X τ ) means that the current round input sentence X in the current round dialogue τ The words in the text are converted into vectors. In this embodiment, the specific step is to convert the input sentence X τ The word embedding GloVe model in the text is used to convert text to vectors, TE τ is the current turn input sentence X in the current turn dialogue τ The corresponding turn (i.e. the number of rounds in the current conversation) is used as the embedding vector for position encoding.

[0064] S12: Obtain a matching score between the personalized information contained in the current round input sentence and the historical input sentence based on the personalized information hidden vector of the first historical input sentence and the personalized information hidden vector of the current round input sentence.

[0065] Specifically, in this embodiment, the matching score is obtained in the following manner:

[0066] z i =softmax(q T m i ) (3)

[0067]

[0068] Among them, z i Indicates the matching score in the current dialogue, q T represents the transpose of the personalized information hidden vector of the current round input sentence, q T m i Indicates qT 、m i The inner product calculation is performed between the two, and the softmax activation function is used to convert the output value into the range [0,1], i = 1, 2, ..., τ-1.

[0069] S2. Obtaining a personalized information selective storage vector of the historical input sentence according to the matching degree score.

[0070] The matching score obtained in step S12 is only a specific value between [0, 1] and does not include the user's personalized information. Therefore, in this solution, based on the matching score, a selection is made among the personalized information in the user's historical input sentences, and the personalized information that is more relevant to and more closely matches the user's current input sentence is selected for storage, thereby obtaining a personalized information selective storage vector.

[0071] Specifically, in this embodiment, selective preservation is achieved by training the network model with parameter changes. Through this training, the network model is given the ability to selectively preserve. In this embodiment, a residual network is specifically used to achieve selective preservation of personalized information. The matching score is subjected to a residual network operation to select the matching score. The result output by the residual network operation is then calculated and processed with the personalized information hidden vector of the historical input sentence to obtain the personalized information selective preservation vector. The details are as follows:

[0072]

[0073] u i =U·(Bert(e(X i ))+TE i ) (6)

[0074] ResidualNet(z i )= (z i )⊙T(z i )+z i ⊙(1-T(z i )) (7)

[0075] H(z i )=softmax(q T z i ) (8)

[0076] T(z i )=σ(W T z i +b T ) H (9)

[0077] Among them, o represents the personalized information selective preservation vector of the current dialogue; ResidualNet() represents the residual network operation; u i Represents the historical input sentence X of the current dialogue i The second historical input sentence personalized information hidden vector; Indicates sum calculation; z i represents the matching score in the current dialogue; U is a trainable parameter matrix; e(X i ) means that the historical input sentence X in the current dialogue i The words in the text are converted into vectors. In this embodiment, the historical input sentence X i The word embedding GloVe model in TE is used to convert text to vector; i Represents the historical input sentence X in the current dialogue i The corresponding turn (i.e., the number of the conversation in the current conversation) is used as the embedding vector of the position encoding, where i = 1, 2, ..., -1; ⊙ represents the Hadamard product; the softmax function is used to convert the output value to the range [0, 1]; q T represents the transpose of the personalized information hidden vector of the current round input sentence; σ() is the sigmoid function; W T Represents a vector matrix initialized to all 1 elements, b T Indicates that it is initialized to a vector with all elements set to 1, W T 、b T The element values ​​can be changed through training, which ultimately makes the residual network close to the ideal performance.

[0078] The second historical input sentence personalized information hidden vector u can be set i The personalized information hidden vector m of the first historical input sentence i Similarly, in this case, the personalized information hidden vector of the first historical input sentence obtained previously is directly used as the personalized information hidden vector of the second historical input sentence in this step, and there is no need to perform the calculation step of the personalized information hidden vector of the second historical input sentence.

[0079] In addition, as a preference, the second historical input sentence personalized information hidden vector u can also be set i The personalized information hidden vector m of the first historical input sentence iThe two are different, based on this, the parameter matrix U is different from the aforementioned trainable parameter matrices M and Q. In this case, the step S2 needs to include: S21 obtains the user's historical input sentences, encodes the historical input sentences, and obtains the user's second historical input sentence personalized information hidden vector; S22 obtains the personalized information selective preservation vector based on the matching degree score and the second historical input sentence personalized information hidden vector. That is, before obtaining the personalized information selective preservation vector, it is also necessary to encode the historical input sentences to obtain the user's second historical input sentence personalized information hidden vector, and preferably, all historical input sentences before the current round of input sentences in the current dialogue process are encoded. Among them, the step S21 can also be performed together with the step S11, as long as it is completed before the step S22. The reason for using the same method as m i The encoding method is the same but the parameters are different i The reason is that the training of multiple parameters is conducive to obtaining the personalized information selective preservation vector that better reflects the user's personalized information, so that the subsequently obtained user personalized representation vector can more accurately and completely reflect the user preferences expressed in the user's input sentence in the current round.

[0080] S3. Selectively save a vector according to the personalized information to obtain a user personalized representation vector corresponding to the input sentence of the current round.

[0081] In this solution, in order to select knowledge sentences that are more in line with user preferences, when obtaining the user personalized representation vector, the personalized information in the user's historical input sentences and the user's current round input sentence information are taken into consideration at the same time, so that the obtained user personalized representation vector can more comprehensively reflect the user's personality reflected in the current round of dialogue.

[0082] Specifically, in this embodiment, the direct correlation between the information contained in the personalized information selective preservation vector and the personalized information hidden vector of the current round input sentence is calculated to obtain a user personalized representation vector that reflects the user's personalized characteristics as reflected in the user's current round input sentence. Using the direct correlation of the contained information to represent the user personalized representation vector can improve the stability and comprehensiveness of the user personalized representation. Specifically,

[0083] p=softmax(W v (o+q)) (10)

[0084] Where p represents the user personalized representation vector in the current dialogue; W vis a trainable parameter vector whose purpose is to learn the calculation process of the user personalized representation vector p; o represents the selective preservation vector of personalized information in the current dialogue; q is the personalized information hidden vector of the current input sentence in the current dialogue; the softmax function is used to convert the output value into the range [0,1].

[0085] In the present invention, the above steps S1-S3 are for characterizing the user's personality preferences, wherein the greater the degree to which the user's personality preferences are characterized in multiple rounds of historical conversations, the more conducive it is to the selection of subsequent knowledge sentences.

[0086] S4. Obtain an information association vector between each candidate knowledge statement and the user personalized representation vector based on the user personalized representation vector. This step specifically includes:

[0087] S41. Obtain a candidate knowledge sentence, encode the candidate knowledge sentence, and obtain a hidden vector of the candidate knowledge sentence.

[0088] In this scheme, there is a candidate knowledge statement set K = {K1, K2, ..., K j ,...,K l}, where K j represents the jth candidate knowledge statement, where l ≥ 2. The dataset corresponding to this set of candidate knowledge statements can be accessed via loading. To perform the calculation, each candidate knowledge statement in the set of candidate knowledge statements needs to be encoded to obtain a candidate knowledge statement hidden vector for each candidate knowledge statement. Encoding of the candidate knowledge statements can be achieved using an encoder that includes a pre-trained language model, such as GPT or BERT.

[0089] Specifically, in this embodiment, the pre-trained language model Bert is used to encode all candidate knowledge sentences one by one, thereby obtaining the candidate knowledge sentence hidden vector of each candidate knowledge sentence. The specific encoding method is as follows:

[0090]

[0091] in, represents the hidden vector of the jth candidate knowledge sentence in the τth (τ=1,2,...,M)th round of dialogue, K τ,j represents the jth candidate knowledge sentence in the τth round of dialogue, e(K τ,j ) represents the candidate knowledge statement K τ,j The words in the text are converted into vectors. In this embodiment, the candidate knowledge sentence K τ,j The word embedding GloVe model in the text is used to convert text to vectors, Bert k() represents the Bert model used to encode candidate knowledge sentences, j = 1, 2, ..., l.

[0092] In this embodiment, the candidate knowledge sentence hidden vector set corresponding to the candidate knowledge sentence set can be expressed as Among them, K0 represents an empty candidate knowledge sentence.

[0093] In addition, in this embodiment, the set of candidate knowledge sentences used in each round of dialogue is the same. Therefore, the encoded candidate knowledge sentence hidden vectors can be stored for subsequent use without multiple encodings.

[0094] S42. Obtain an information association vector between each candidate knowledge sentence hidden vector and the user personalized representation vector based on the candidate knowledge sentence hidden vector and the user personalized representation vector.

[0095] In this solution, the information association vector is used to reflect the similarity and association between the hidden vector of each candidate knowledge statement and the user's personalized representation vector in terms of the information contained, thereby helping the selected knowledge statement to better meet the user's preferences.

[0096] Specifically, in this embodiment, the information association vector is obtained in the following manner:

[0097]

[0098]

[0099] Among them, r τ,j represents the jth (j=1,2,...,l) information association vector in the τth (τ=1,2,...,M) round of dialogue, p represents the user personalized representation vector in the current round of dialogue, represents the candidate knowledge sentence hidden vector of the j-th candidate knowledge sentence in the τ-th round of dialogue; F is a fully connected layer activated by the tanh function, the tanh function is the hyperbolic tangent activation function, cos() represents the cosine value of the vector, and ⊙ represents the Hadamard product.

[0100] Of course, in other embodiments, step S41 of encoding the candidate knowledge sentence to obtain the candidate knowledge sentence hidden vector may not be performed between step S3 and step S42, as long as it is completed before step S42.

[0101] S5. Obtain the knowledge selection distribution vector of the candidate knowledge sentence based on the information association vector. This step specifically includes:

[0102] S51. Obtain the context sentence of the current dialogue round, encode the context sentence, and obtain a context sentence information hiding vector.

[0103] In this solution, contextual conversation information helps select knowledge statements that are more relevant to the current conversation turn. To select knowledge statements that are more personalized to the user, contextual sentence information is considered during the knowledge statement selection process. The contextual sentence is formed by concatenating historical conversation sentences and the current user's input sentence. The historical conversation sentence consists of the user's previous input sentences during the current conversation and the corresponding conversation reply sentences.

[0104] In this scheme, an encoder including a pre-trained language model is used to encode the context sentence to obtain the context sentence information hidden vector.

[0105] Specifically, in this embodiment, the context sentence C is encoded using the pre-trained language model Bert:

[0106]

[0107] in, represents the context sentence information hidden vector of the τth (τ=1,2,...,M) round of dialogue, C τ represents the context sentence in the τth round of dialogue, e(C τ ) means the context statement C τ The words in the text are converted into vectors. In this embodiment, the context sentence C τ The word embedding GloVe model in the text is used to convert text to vectors, Bert c () represents the Bert model for context sentence encoding.

[0108] In addition, considering that as a context sentence in a conversation process, on the one hand, the closer the historical conversation sentence is to the current input sentence, the more important it is, and the farther the historical conversation sentence is from the current input sentence, the less important it is; on the other hand, adding too many historical conversation sentences will weaken the importance of the historical conversation sentence closest to the current user input sentence, thereby causing the conversation response generation model to be unable to distinguish between the historical conversation sentence closest to the current user input sentence and other historical conversation sentences; on the other hand, adding too many historical conversation sentences will increase the input amount, and the computational requirements for the conversation response generation model will increase exponentially, and the running speed of the conversation response generation model will also be reduced. Therefore, in this embodiment, C is used. τ =[X τ-1 ; Y τ-1 ;X τ ] to obtain the context statement, where Xτ-1 Indicates the user's input sentence in the previous round of dialogue, Y τ-1 Represents the input sentence X for the user in the previous round of dialogue τ-1 The given dialogue reply sentence, X τ It represents the user's input sentence in the current round, that is, the context sentence is obtained by splicing the historical dialogue sentence in the previous round and the user's input sentence in the current round.

[0109] Of course, in other embodiments, step S51 of encoding the context sentence to obtain the context sentence information hiding vector may not be performed between step S42 and step S52, as long as it is completed before step S52.

[0110] S52. Obtain the knowledge selection distribution vector according to the information association vector, the context sentence information hiding vector, and the candidate knowledge sentence hiding vector.

[0111] In this solution, based on the information association vector and the context sentence information hidden vector, the knowledge information contained in each candidate knowledge sentence hidden vector is selected. The knowledge that is most relevant to and matches the user's personalized information, the context sentence, and the user's current input sentence is selected to obtain a knowledge selection distribution vector. This knowledge selection distribution vector is a comprehensive result that includes the relevance of the candidate knowledge sentence with the context sentence and the user's personalized information.

[0112] The selectivity of knowledge can be achieved by training the parameters in the dialogue response generation model with parameter changes. Through this training, the dialogue response generation model has the ability to select knowledge.

[0113] Specifically, in this embodiment, the context sentence information is hidden in the vector H C and information association vector r j Splicing, the splicing vector obtained after splicing is used as the query vector, and the candidate knowledge sentence hidden vector H of the jth candidate knowledge sentence is used Kj As the key vector, we obtain the knowledge selection distribution vector β corresponding to the candidate knowledge sentence in the τth round of dialogue. τ,j , as follows:

[0114] β τ,j =v T tanh(W q [H Cτ ; r τ,j ]+W k [H Kτ,j ]) (15)

[0115] Among them, β τ,jrepresents the knowledge selection distribution vector corresponding to the hidden vector of the jth (j=1,2,...,l) candidate knowledge sentence in the τth (τ=1,2,...,M)th round of dialogue, v, W q and W k are all trainable parameter vectors, v T represents the transpose of vector v, represents the context sentence information hidden vector in the τth round of dialogue, r τ,j represents the information association vector corresponding to the hidden vector of the j-th candidate knowledge sentence in the τ-th round of dialogue, represents the candidate knowledge sentence hidden vector of the j-th candidate knowledge sentence in the τ-th round of dialogue, tanh() is the hyperbolic tangent activation function, express r τ,j The concatenation of two vectors.

[0116] S6. Calculate the attention score of each candidate knowledge statement based on the knowledge selection distribution vector, and determine the candidate knowledge statement with the highest attention score as the knowledge statement selected in the current round of dialogue.

[0117] In this solution, attention refers to the expression of the importance of data, and the attention score refers to the size of the vector value. The larger the value, the greater the importance of the vector. In this solution, the attention score is used to represent the importance of the candidate knowledge sentence in this round of dialogue. The larger the value, the more consistent the corresponding candidate knowledge sentence is with the user's personalized information and contextual dialogue sentence information.

[0118] Specifically, in this embodiment, the attention score of each candidate knowledge statement is obtained in the following manner, and then the candidate knowledge statement with the highest score is selected as the final selected knowledge statement:

[0119] α τ,j =softmax j (β τ,j ) (16)

[0120]

[0121]

[0122] Among them, α τ,j represents the attention score corresponding to the hidden vector of the jth (j=1,2,...,l) candidate knowledge sentence in the τth (τ=1,2,...,M)th round of dialogue, β τ,j represents the knowledge selection distribution vector corresponding to the hidden vector of the j-th candidate knowledge sentence in the τ-th round of dialogue. The softmax function is used to convert the output value into the range [0,1];

[0123] Indicates that in all α τ,j Take the maximum value α τ,x (x=1,2,…,j,…,l), and let It represents the hidden vector of the candidate knowledge sentence with the highest attention score in the τth round of dialogue. The hidden vector of this candidate knowledge sentence is the hidden vector of the knowledge sentence selected in this scheme, and the corresponding candidate knowledge sentence is the knowledge sentence finally selected in this scheme.

[0124] In this embodiment, the attention score α τ,j A relative score is calculated by comparing a candidate knowledge statement with all other candidate knowledge statements. A higher relative score indicates that the candidate knowledge statement meets the selection criteria more accurately. Using a relative score can more accurately indicate the degree of compliance of a candidate knowledge statement.

[0125] In this solution, steps S4-S6 are the process of selecting knowledge statements based on the user's personalized representation vector. During the knowledge statement selection process, if only the correlation between the candidate knowledge statement and the contextual dialogue statement is considered, the diversity of the information basis will be lacking. Furthermore, when the contextual dialogue statements are relatively repetitive, repeated knowledge statements may be easily selected, thereby generating repeated dialogue response statements. Therefore, if only the correlation between the candidate knowledge statement and the contextual dialogue statement is considered, the selected knowledge statement is usually not the correct knowledge statement required, and the generated dialogue response statement may also be incorrect. Therefore, during the knowledge statement selection process, this solution not only considers the correlation between the candidate knowledge statement and the contextual dialogue statement, as in step S52, but also considers the correlation and similarity between each candidate knowledge statement and the user's personalized representation vector, as in step S42, thereby promoting the dialogue system to select more appropriate knowledge statements that meet user preferences.

[0126] S7. Initialize the recurrent neural network according to the context sentence and the selected knowledge sentence, and obtain the initialized decoding hidden state vector and the initialized generated word.

[0127] In this solution, in order to avoid a large difference between the decoding state at the time of initialization and the decoding state after the update and to facilitate training, when the recurrent neural network is initialized, the context sentence information hidden vector and the aforementioned selected knowledge sentence hidden vector are used as input to initialize the recurrent neural network.

[0128] Specifically, in this embodiment, a recurrent neural network (GRU) is used to take the context sentence information hidden vector and the previously selected knowledge sentence hidden vector as input. After calculation by the recurrent neural network (GRU), an initialized decoding hidden state vector is obtained, thereby initializing the GRU, that is, initializing the decoding state. The initialization calculation method is as follows:

[0129]

[0130] Among them, s τ,0 represents the initialized decoded hidden state vector in the τth (τ=1,2,...,M)th round of dialogue, W0 and b0 both represent the trainable parameter vectors in the τth round of dialogue, represents the context sentence information hidden vector in the τth round of dialogue, represents the hidden vector of the knowledge sentence selected in the τth round of dialogue, Indicates that Concatenates two vectors.

[0131] At the same time, in this scheme, the initial generated word is empty, that is, y τ,0 =0.

[0132] S8. Update the recurrent neural network to obtain an updated decoding hidden state vector. This step specifically includes:

[0133] S81. Obtain a gating vector according to the context sentence information hidden vector and the selected knowledge sentence hidden vector.

[0134] The gating vector is specifically expressed as follows:

[0135]

[0136]

[0137] Among them, G τ represents the gate vector of GRU in the τth (τ=1,2,...,M) round of dialogue, g τ represents the gate value of GRU in the τth round of dialogue, W g and b g represents a trainable parameter vector, Represents the context sentence information hidden vector of the τth round of dialogue, The knowledge sentence hidden vector representing the knowledge sentence selected in the τth round of dialogue.

[0138] In this scheme, the gate value g is used to update the decoding hidden state vector. τ As a gate, control Propensity context sentence information hidden vector and the selected knowledge sentence hidden vector The degree to which the information of the context sentence and the selected knowledge sentence is used, thereby affecting the decoded hidden state vector.

[0139] For the current dialogue, the context sentence information hidden vector and the selected knowledge sentence hidden vector are fixed in the process of generating the dialogue reply sentence. In addition, the importance of the context sentence information and the selected knowledge sentence information is also fixed. Therefore, the values ​​and vectors (such as g τ 、 ) is also fixed during the generation of the response statement for the current dialogue round. Therefore, during each dialogue round, the gate value and gate vector only need to be calculated once and can be stored for easy subsequent use.

[0140] Of course, in other embodiments, the gate vector calculation step S81 may be performed simultaneously with step S7 or before step S7.

[0141] S82. Obtain a decoding hidden state vector for the current time step according to the decoding hidden state vector outputted at the previous time step, the generated word at the previous time step, and the gating vector.

[0142] Specifically, in this embodiment, in the recurrent neural network GRU, the decoding hidden state vector generated in the previous time step, the generated word in the previous time step, and the gating vector are used as input information in the current time step to update the decoding hidden state vector of the current time step in the recurrent neural network GRU. This is shown below:

[0143] s τ,t =GRU(s τ,t-1 ,e(y τ,t-1 ),G τ ) (twenty two)

[0144] Among them, s τ,t represents the decoded hidden state vector generated at the current time step t in the τth (τ=1,2,...,M)th round of dialogue, s τ,t-1 represents the decoded hidden state vector generated at the previous time step in the τth round of dialogue; y τ,t-1 is the generated word at the previous time step in the τth round of dialogue, e(y τ,t-1 ) represents the generated word y at the previous time step in the τth round of dialogue τ,t-1 Convert text to vector. In this embodiment, the generated word y in the previous time step is converted to τ,t-1 Embedded in the GloVe model to convert text to vector, G τRepresents the gating vector of GRU in the τth round of dialogue.

[0145] In this embodiment, the decoding hidden state vector of the current time step is obtained specifically in the following manner:

[0146] x τ,t =[e(y τ,t-1 );G τ ] (twenty three)

[0147] z τ,t =σ(W z,1 x τ,t +W z,2 s τ,t-1 +b z ) (twenty four)

[0148] r τ,t =σ(W r,1 x τ,t +W r,2 s τ,t-1 +b r ) (25)

[0149]

[0150]

[0151] Among them, x τ,t represents the first input of the current time step in the τth (τ=1,2,...,M)th round of dialogue in GRU, y τ,t-1 represents the generated word at the last time step in the τth round of dialogue, e(y τ,t-1 ) means that in the τth round of dialogue, the word y is generated in the previous time step τ,t-1 Convert text to vector. In this embodiment, the word y generated in the previous time step is converted to τ,t-1 Embedded in the GloVe model to convert text to vector, G τ represents the gate vector in the τth round of dialogue, [e(y τ,t-1 );G τ ] means to concatenate two vectors, z τ,t represents the reset gate in the GRU at the current time step of the τth round of dialogue, r τ,t represents the forget gate in the GRU at the current time step of the τth round of dialogue, represents the update gate pre-position in the GRU at the current time step of the τth round of dialogue, s τ,t The update gate in the GRU representing the current time step of the τth round of dialogue is also the decoded hidden state vector of the current time step in this embodiment, s τ,t-1represents the decoded hidden state vector of the previous time step in the τth round of dialogue, which is also the second input of the current time step in the GRU, ⊙ represents the Hadamard product, σ() is the sigmoid function, tanh() is the hyperbolic tangent activation function, and W z,1 、W z,2 、W r,1 、W r,2 、W s,1 、W s,2 、b z 、b r 、b s are all trainable parameter vectors. And, when t=1, y τ,t-1 Indicates the generated word for initialization, s τ,t-1 represents the initialized decoded hidden state vector.

[0152] S9. Calculate the first attention value of the word in the vocabulary based on the decoded hidden state vector of the current time step and the context sentence; and calculate the second attention value of the word in the selected knowledge sentence based on the decoded hidden state vector of the current time step and the selected knowledge sentence.

[0153] In this invention, words are selected from two parts to form a dialogue response sentence: a vocabulary table consisting of all words statistically obtained from candidate knowledge sentences and predicted user input sentences, and a vocabulary table obtained from the aforementioned selected knowledge sentences. Therefore, it is necessary to calculate the attention value of the words in the vocabulary table and the words in the selected knowledge sentences respectively. Here, attention also refers to the expression of the importance of data. Specifically, the attention value refers to the magnitude of the vector value. The larger the value, the greater the importance, that is, the greater the probability of the word being selected as a word in the dialogue response sentence generated in the current dialogue round.

[0154] In order to make the generated dialogue response sentences more appropriate and more knowledgeable about user preferences during the word generation process of the dialogue response sentences, this scheme introduces contextual dialogue sentences when calculating the first attention value and the second attention value to make the generated words closer to the context sentences. At the same time, the aforementioned selected knowledge sentences are also introduced so that the words in the selected knowledge sentences appear in the generated dialogue response sentences.

[0155] Specifically, in this embodiment, the reply generation decoder calculates the first attention value c of the word in the word list at the current time step t through the aforementioned decoding hidden state vector and the context sentence information hidden vector. τ,gen :

[0156]

[0157] φ c(y τ,t =w) =w T (W y s τ,t +b y ) (29)

[0158] Among them, c τ,gen represents the word y in the vocabulary in the τth (τ=1,2,...,M)th round of dialogue τ,t The first attention value at the current time step, σ() represents the sigmoid function, b c 、W y 、b y are all trainable parameter vectors, w is the word y at the current time step t in the τth round of dialogue τ,t One-hot vector, w T represents the transpose of the w vector, Represents the context sentence information hidden vector of the τth round of dialogue, s τ,t represents the decoded hidden state vector generated at the current time step t in the τth round of dialogue.

[0159] At the same time, the second attention value k of the words in the selected knowledge sentence can be obtained by similar calculation method τ,gen :

[0160]

[0161] Among them, k τ,gen represents the word y in the knowledge sentence selected in the τth (τ=1,2,...,M)th round of dialogue τ,t The second attention value at the current time step, σ() represents the sigmoid function, b k Both represent trainable parameter vectors, w is the word y at the current time step t in the τth round of dialogue τ,t One-hot vector of , Indicates the selected knowledge statement The dth word in G() represents a fully connected layer activated by the tanh function, (s τ,t ) T represents the transpose of the decoded hidden state vector generated at the current time step t in the τth round of dialogue.

[0162] Here, the calculation method of formula (30) is different from that of formula (28), which sums and superimposes the attention values ​​of the words that appear repeatedly in the selected knowledge sentences.

[0163] S10. Calculate the final probability value of the word using the first attention value and the second attention value.

[0164] The final probability value of a word is calculated by using the first attention value of the word in the above word table and the second attention value of the word in the above selected knowledge sentence. In the present invention, the final probability value of the word is obtained by the following method:

[0165]

[0166]

[0167] Among them, P τ,final (w) represents the final probability value of the word at the current time step in the current dialogue, c τ,gen represents the word y in the vocabulary in the τth (τ=1,2,...,M)th round of dialogue τ,t The first attention value, k τ,gen Represents the word y in the knowledge sentence selected in the τth round of dialogue τ,t The second attention value, W1, W2, b1, b2, μ, λ are all trainable parameters, μ and λ need to satisfy the condition μ + λ = 1, Represents the context sentence information hidden vector of the τth round of dialogue, s τ,t represents the decoded hidden state vector generated at the current time step t in the τth round of dialogue, It represents the hidden vector of the knowledge sentence selected in the τth round of dialogue, Indicates that s τ,t 、 Three vectors are concatenated. Indicates the selected knowledge statement The dth word in .

[0168] When calculating the final probability value of the word as mentioned above, similarly, in order to make the generated dialogue response sentence more appropriate and more knowledgeable about user preferences during the word generation process of the dialogue response sentence, this embodiment also introduces the context sentence information hidden vector and the selected knowledge sentence hidden vector.

[0169] S11. Select the word with the highest final probability value as the generated word for the current time step.

[0170] In this solution, in this step, at the current time step, among the words in the vocabulary and the words in the selected knowledge sentence, the word with the highest final probability score is selected and used as the generated word for the current time step. The specific method is as follows:

[0171]

[0172] Among them, y τ,t represents the generated word at the current time step t in the τth (τ=1,2,...,M)th round of dialogue, Indicates taking the maximum value, P τ,final (w) represents the final probability score of the word at time step t in the conversation turn.

[0173] S12. Generate a dialogue reply statement.

[0174] After obtaining the generated word at the current time step t, it is necessary to determine whether the generated word is a terminator. If so, all generated words in the current dialogue turn are combined into a text sequence as the dialogue response statement and output. If not, the generated word at the current time step t is transmitted to step S82, where the recurrent neural network continues decoding and obtains the generated word for the next time step. This cycle repeats until the generated word is a terminator. Here, the dialogue system uses a copy mechanism to copy all generated words from the vocabulary or selected knowledge statement, and then combines them into a text sequence as the dialogue response statement.

[0175] In this embodiment, a word list is added. <eos>Indicates the end of the word, when y in formula (32) τ,t The result is <eos>, then stop decoding and output the sentence.

[0176] In the present invention, except for initialization decoding, each decoding generates a generated word, and multiple generated words constitute the final reply sentence.

[0177] In this solution, steps S7-S12 are the process of using the selected knowledge sentence and the reply generation decoder to decode and generate the dialogue reply sentence.

[0178] In addition, in order to improve the accuracy of the conversation response generation method based on user personalization, step S13, parameter optimization, is further included. Specifically, the following steps are included:

[0179] S131: Initialize the network parameters in steps S1-S10;

[0180] S132: Execute steps S1-S12 using a conversation data training sample set to optimize the network parameters, and use a loss function to calculate the loss, and stop iteration when the loss value of the loss function tends to be stable after multiple iterations, wherein the conversation data training sample set includes knowledge sentences of standard answers and conversation response sentences.

[0181] Specifically, in this embodiment, the loss function is a linear combination of a knowledge selection loss function and a response generation loss function. The knowledge selection loss function aims to supervise the conversational response generation model's learning of knowledge selection; the response generation loss function is used to quantify the difference between true response sentences and response sentences generated by the conversational response generation model. A true response sentence refers to a standard conversational response sentence corresponding to a user's input question in the conversational data training sample set, i.e., a correct conversational response sentence. The response sentence generated by the conversational response generation model will differ from the standard conversational response sentence in the conversational data training sample set due to the performance of the conversational response generation model. Therefore, reducing the gap between true response sentences and response sentences generated by the conversational response generation model is beneficial for training the response sentences generated by the conversational response generation model to be closer to the correct conversational response sentences. The specific expression of the loss function is as follows:

[0182]

[0183]

[0184]

[0185] in, represents the loss function, represents the response generation loss function, represents the knowledge selection loss function, θ is a general term for all trainable parameters, λ represents a configurable parameter, and its value range is [0,1]. In this embodiment, λ = 1, M represents the length of the dialogue round in the current dialogue process, that is, the total number of dialogue rounds, and Y τ represents the true response sentence of the τth round of dialogue (i.e., the correct dialogue response sentence), |Y τ | represents the sequence length of the real response sentence in the τth round of dialogue, is the tth word of the true response sentence in the τth round of dialogue, represents the final probability value of the tth word in the true response sentence of the τth round of dialogue, which is calculated by formula (32) after the dialogue response generation model is run. * The index of the candidate knowledge sentence representing the true choice of the τth (τ=1,2,...,M)th round of dialogue, The attention score calculated by formula (16) after the dialogue response generation model runs the candidate knowledge sentence (i.e., the correct knowledge sentence) representing the true choice in the τth round of dialogue is used.

[0186] In this scheme, after each iteration, the loss function is calculated according to formulas (35)-(37): The loss value, when the loss function After multiple iterations, the loss value steadily decreases until it reaches a plateau, indicating that the performance of the dialogue response generation model will no longer improve. At this point, iteration can be stopped. Each complete traversal of all samples in the dialogue data training sample set is called an iteration.

[0187] Specifically, in this embodiment, the number of training iterations is 20.

[0188] In this invention, supervised training of the parameters in the dialogue response generation model is performed using a training set of dialogue data with standard answers (the standard answers include the selected correct knowledge statements and the correct dialogue response statements). This allows the model to learn the knowledge selection capabilities described in this invention. During parameter training, the direction of parameter change is controlled by minimizing loss, ultimately minimizing the loss to a certain level, indicating that the model has achieved relatively ideal performance.

[0189] In addition, the present invention also relates to a user-personalized dialogue response generation model, see Figure 2 The model includes: a user history input sentence encoding module 111, a user current input sentence encoding module 112, a matching degree calculation module 12, a user personalized information selective acquisition module 2, a user personalized representation vector acquisition module 3, a candidate knowledge sentence encoding module 41, an information association vector acquisition module 42, a context dialogue sentence encoding module 51, a knowledge selection distribution vector acquisition module 52, an attention score calculation module 61, a knowledge sentence selection module 62, a decoder initialization module 7, a gate vector acquisition module 81, a decoder decoding state update module 82, a word attention value calculation module 9, a word final probability calculation module 10, a dialogue reply sentence generation module 12, a storage module, a word library 13, and a candidate knowledge sentence library 14. Among them:

[0190] The user historical input sentence encoding module 111 is configured to encode the user's historical input sentences during the current conversation to obtain a historical input sentence personalized information hidden vector. The historical input sentence personalized information hidden vector includes the user's personalized information reflected in the historical input sentence and the turn information of the historical input sentence (i.e., the turn number of the current conversation). Furthermore, the historical input sentence personalized information hidden vector includes a first historical input sentence personalized information hidden vector and a second historical input sentence personalized information hidden vector.

[0191] The user turn input sentence encoding module 112 is used to encode the user's turn input sentence during the current conversation to obtain a personalized information hidden vector for the turn input sentence. The personalized information hidden vector for the turn input sentence includes the user's personalized information reflected in the turn input sentence and the turn information of the turn input sentence (i.e., the conversation round number in the current conversation).

[0192] In this case, the user history input sentence encoding module 111 and the user current turn input sentence encoding module 112 both use the pre-trained language model Bert, and the user history input sentence encoding module 111 and the user current turn input sentence encoding module 112 are used to jointly execute the step S11.

[0193] The matching degree calculation module 12 is used to calculate the matching degree score of the personalized information between the first historical input sentence personalized information hidden vector and the current round input sentence personalized information hidden vector. The matching degree calculation module 12 is used to perform the step S12.

[0194] The user personalized information selective acquisition module 2 is used to obtain the personalized information selective storage vector of the historical input sentence according to the matching degree score. The user personalized information selective acquisition module 2 adopts a residual network. The user personalized information selective acquisition module 2 is used to perform the step S2.

[0195] The user personalized characterization vector acquisition module 3 is used to obtain the user personalized characterization vector according to the personalized information selective storage vector and the historical input sentence personalized information hidden vector. The user personalized characterization vector acquisition module 3 is used to execute the step S3.

[0196] The candidate knowledge sentence encoding module 41 is used to encode the candidate knowledge sentence to obtain the candidate knowledge sentence hidden vector. Specifically, the candidate knowledge sentence encoding module adopts the pre-trained language model Bert. The candidate knowledge sentence encoding module 41 is used to perform the step S41.

[0197] The information association vector acquisition module 42 is used to obtain an information association vector based on the user personalized representation vector and the candidate knowledge sentence hidden vector. The information association vector acquisition module 42 is used to perform the step S42.

[0198] The contextual dialogue sentence encoding module 51 is used to encode the contextual dialogue sentence to obtain a contextual sentence information hidden vector. Specifically, in this solution, the contextual dialogue sentence includes historical dialogue sentences and the current round input sentence. The contextual dialogue sentence encoding module uses the pre-trained language model Bert for encoding. The contextual dialogue sentence encoding module 51 is used to perform step S51.

[0199] The knowledge selection distribution calculation module 52 is used to obtain a knowledge selection distribution vector according to the information association vector, the context sentence information hiding vector and the candidate knowledge sentence hiding vector. The knowledge selection distribution calculation module 52 is used to execute the step S52.

[0200] The attention score calculation module 61 is used to obtain the attention score of each candidate knowledge sentence hidden vector based on the knowledge selection distribution vector.

[0201] The knowledge statement selection module 62 selects the candidate knowledge statement hidden vector with the highest attention score and selects it as the knowledge statement hidden vector that best meets the user's preference in the current round of dialogue. The candidate knowledge statement corresponding to the knowledge statement hidden vector is the selected knowledge statement.

[0202] The attention score calculation module 61 and the knowledge sentence selection module 62 are used to jointly execute step S6.

[0203] The decoder initialization module 7 is used to initialize the decoding state of the recurrent neural network according to the determined knowledge sentence hidden vector and the context sentence information hidden vector. The decoder initialization module 7 is used to execute step S7.

[0204] The gating vector acquisition module 81 is configured to obtain a gating vector based on the context sentence information hidden vector and the selected knowledge sentence hidden vector. The gating vector indicates the extent to which the context sentence information and the selected knowledge sentence information are used when updating the decoding hidden state vector. The gating vector acquisition module 81 is configured to execute step S81.

[0205] The decoder decoding state updating module 82 is used to obtain the decoding hidden state vector of the current time step based on the decoding hidden state vector output at the previous time step, the generated word at the previous time step, and the gating vector. The decoder decoding state updating module 82 is used to perform the step S82.

[0206] The word attention value calculation module 9 is used to calculate the attention values ​​of the words in the vocabulary and the words in the selected knowledge sentence based on the decoded hidden state vector of the current time step, the context sentence information hidden vector, and the selected knowledge sentence hidden vector. The attention value calculation module obtains the first attention value of the words in the vocabulary based on the context sentence information hidden vector and the decoded hidden state vector of the current time step; and obtains the second attention value of the words in the selected knowledge sentence based on the selected knowledge sentence hidden vector and the decoded hidden state vector of the current time step. The word attention value calculation module 9 is used to execute step S9.

[0207] The word final probability calculation module 10 obtains the word final probability value according to the first attention value of the word in the word table and the second attention value of the word in the selected knowledge sentence. The word final probability calculation module 10 is used to perform the step S10.

[0208] The dialogue response sentence generation module 12 selects the word with the highest final probability value at the current time step as the generated word at the current time step, and determines whether the generated word is a terminator. If so, all generated words are combined into a text sequence as the dialogue response sentence and output. If not, the generated word at the current time step is transmitted to the decoder decoding state update module for further decoding to obtain the generated word at the next moment, until the generated word at the current time step is a terminator. The dialogue response sentence generation module 12 is configured to execute steps S11 and S12.

[0209] The storage module is used to store the personalized information hidden vector of the historical input sentence, the personalized information hidden vector of the current round input sentence, the candidate knowledge sentence hidden vector, the context sentence information hidden vector, the knowledge sentence hidden vector that best meets the user's preference, the selected knowledge sentence, the gating vector, the decoding hidden state vector of the current time step updated by the decoder decoding state update module 82, and the generated word.

[0210] The word library 13 includes all the words in the word list.

[0211] The candidate knowledge sentence library 14 includes all candidate knowledge sentences.

[0212] In addition, the present invention also provides a user-personalized conversation response generation device, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, wherein the processor implements the steps of the above-mentioned conversation response generation method when executing the computer program.

[0213] The present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a computer, the steps of the above-mentioned dialogue response generation method are implemented.

[0214] In addition, the performance of the user-personalized dialogue response generation model after parameter optimization can be tested using the dialogue data test sample set.

[0215] In this solution, the performance test uses common indicators for dialogue response generation systems: ACC, BLEU-4, ROUGE-2, and DISTINCT-2. ACC is used to indicate the accuracy of the dialogue system's knowledge selection on the dialogue data test sample set. BLEU-4 and ROUGE-2 are used to evaluate the overall quality of response generation. The higher the BLEU-4 and ROUGE-2 scores, the closer the dialogue response sentence is to the correct answer. DISTINCT-2 is used to measure the diversity of the generated dialogue responses.

[0216] The above-mentioned user-personalized dialogue response generation model is implemented in the PyTorch framework through steps S1 to S13. The dataset used is the Holliday-E dataset, which contains the actual (i.e., correct) knowledge statements and knowledge statement selection labels corresponding to each round of dialogue, so as to evaluate the model performance.

[0217] The conversations in the Holl-E dataset are divided into training sets, validation sets, and test sets of 7211, 930, and 913, respectively. Each conversation has 5 turns, with an average of 60 knowledge statements per turn. Furthermore, the vocabulary size of the Holl-E dataset is limited to 16K, word embeddings are initialized using GloVe, the length of the sentence vectorized is set to 300, the dropout rate applied to the word embeddings is 0.5, the length of each direction of the context sentence information hidden vector and the candidate knowledge sentence hidden vector is set to 200 (the sum of the two directions is 400), the input vector length of the reply generation decoder is set to 400, the batch size is 8 dialogs, and the parameters of the user-personalized dialogue reply generation model are optimized using the ADAM optimizer. The initial learning rate is set to 0.0005, and the total number of iterations is 20.

[0218] After training, validation, and testing, the experimental results of the user-personalized dialogue response generation model of the present invention on the Holl-E dataset are shown in Table 1. On the four evaluation indicators of ACC, BLEU-4, ROUGE-2, and DISTINCT-2, the model performs better than the existing FoCus-baseline (call For Customized conversation) and Fu et al. model (the model is "Tingchen Fu, Xueliang Zhao, Chongyang Tao, Ji-Rong Wen, and Rui Yan. 2022. There Are a Thousand Hamlets in a Thousand People's Eyes: Enhancing Knowledge-grounded Dialogue with Personal Memory. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3901–3913, Dublin, Ireland. Association for Computational Linguistics (Volume 1: Long Papers), pages 3901–3913, Dublin, Ireland). Linguistics”), the user-personalized dialogue response generation model of the present invention achieves the best dialogue response effect. This fully proves that the solution uses the user's historical input sentences and the current round input sentences in the current dialogue process to obtain user personalized information in each round of dialogue, and uses this user personalized information to select appropriate knowledge sentences from candidate knowledge sentences. This not only improves the accuracy and comprehensiveness of the user personalized information obtained in each round of dialogue, but also improves the accuracy of candidate knowledge sentence selection, thereby improving the accuracy and diversity of the dialogue system's responses.

[0219] Table 1 Comparison of the effects of the user-personalized dialogue response generation model of the present invention and two existing dialogue response generation models

[0220]

[0221] Compared to existing technologies, the solution of the present invention utilizes the user's historical input sentences and current-round input sentences during the current conversation process to obtain personalized user information for each conversation round. Both the historical input sentences and the current-round input sentences are internal to the conversation system, eliminating the need to import external interlocutor information annotation data to obtain personalized user information, thereby reducing the data processing burden of the conversation system. Furthermore, because the corresponding historical input sentences and current input sentences vary in each conversation round, the data used to obtain personalized user information is not fixed in each conversation round, but changes accordingly with the user's input sentences. This not only improves the accuracy of the personalized user information obtained in each conversation round, but also enhances the flexibility of the conversation system, making it applicable to a variety of conversation scenarios and expanding the scope of its application.

[0222] The above-described embodiments merely represent several implementations of the present invention. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art would be able to make numerous modifications and improvements without departing from the spirit of the present invention, and the present invention is intended to encompass such modifications and variations.< / eos> < / eos>

Claims

1. A method for generating user-personalized dialogue responses, characterized by: The steps include: S1. Obtain a score for the degree of matching between the personalized information contained in the current input sentence and the historical input sentence based on the user's historical input sentences and the current input sentence in the current conversation; S2. Obtaining a personalized information selective storage vector of the historical input sentence based on the matching score; S3. Selectively save the vector according to the personalized information to obtain the user personalized representation vector corresponding to the input sentence of the current round; S4. Obtaining, based on the user personalized representation vector, an information association vector between each candidate knowledge statement and the user personalized representation vector; S5. Obtaining a knowledge selection distribution vector of the candidate knowledge sentence based on the information association vector; S6. Calculate the attention score of each candidate knowledge statement based on the knowledge selection distribution vector, and determine the candidate knowledge statement with the highest attention score as the knowledge statement selected in the current round of dialogue; S7, initializing the decoding hidden state vector of the recurrent neural network according to the context sentence and the selected knowledge sentence; S8. updating the decoding hidden state vector of the recurrent neural network to obtain an updated decoding hidden state vector; S9, calculating a first attention value for a word in the vocabulary based on the updated decoded hidden state vector and the context sentence, and calculating a second attention value for a word in the selected knowledge sentence based on the updated decoded hidden state vector and the selected knowledge sentence; S10. Calculate a final probability value of the word using the first attention value and the second attention value; S11. Select the word with the highest final probability value as the generated word for the current time step.

2. The method for generating a dialogue response according to claim 1, wherein: The step S1 includes: encoding the historical input sentence and the current round input sentence respectively to obtain a first historical input sentence personalized information hidden vector and a current round input sentence personalized information hidden vector, and using the first historical input sentence personalized information hidden vector and the current round input sentence personalized information hidden vector to obtain the matching degree score; The step S2 includes: calculating the personalized information selective preservation vector based on the matching degree score and a second historical input sentence personalized information hidden vector obtained by encoding the historical input sentence, wherein the second historical input sentence personalized information hidden vector and the first historical input sentence personalized information hidden vector are encoded in the same manner but with different parameters.

3. The method for generating a dialogue response according to claim 2, wherein: The step S3 includes: calculating the direct correlation between the personalized information selective preservation vector and the personalized information hidden vector of the current round input sentence, to obtain the user personalized representation vector.

4. The method for generating a dialogue response according to claim 1, 2 or 3, wherein: The step S4 includes: obtaining an information association vector between each candidate knowledge sentence hidden vector and the user personalized representation vector based on the candidate knowledge sentence hidden vector obtained by encoding the candidate knowledge sentence and the user personalized representation vector.

5. The method for generating a dialogue response according to claim 4, wherein: The step S5 comprises: S51. Encode the context sentences in the current dialogue to obtain a context sentence information hidden vector, wherein the context sentences include the historical dialogue sentences and the user's current turn input sentence; S52. Obtain the knowledge selection distribution vector according to the information association vector, the context sentence information hiding vector, and the candidate knowledge sentence hiding vector.

6. The method for generating a dialogue response according to claim 5, wherein: The historical dialogue sentences are the historical dialogue sentences of the previous round corresponding to the current round of dialogue.

7. The method for generating a dialogue response according to claim 6, wherein: The step S8 includes: obtaining a decoding hidden state vector of the current time step based on the decoding hidden state vector output at the previous time step, the generated word at the previous time step, and the gating vector, wherein the gating vector is used to indicate the degree of use of information of the context sentence and information of the selected knowledge sentence when the decoding hidden state vector is updated.

8. The method for generating a dialogue response according to claim 7, wherein: The gating vector is in, g τ Indicates the gate value of GRU in the current dialogue, W g and b g represents a trainable parameter vector, Represents the hidden vector of the context sentence information of the current dialogue, The candidate knowledge sentence hidden vector representing the knowledge sentence selected in the current dialogue round.

9. A user-personalized dialogue response generation model, characterized in that: include: A matching degree calculation module is used to calculate the matching degree score between the user's historical input sentences and the current input sentence in the current conversation based on personalized information; A user personalized information selective acquisition module, configured to obtain a personalized information selective storage vector of the historical input sentence according to the matching degree score; A user personalized representation vector acquisition module is used to selectively save vectors according to the personalized information and obtain the user personalized representation vector corresponding to the input sentence of the current round; An information association vector acquisition module obtains an information association vector between each candidate knowledge statement and the user personalized representation vector based on the user personalized representation vector; a knowledge selection distribution calculation module, which obtains a knowledge selection distribution vector of a candidate knowledge sentence according to the information association vector; an attention score calculation module, selecting a distribution vector based on the knowledge and obtaining an attention score for each candidate knowledge statement; The knowledge sentence selection module selects the candidate knowledge sentence with the highest attention score; The decoder decoding state initialization module initializes the decoding state of the recurrent neural network to obtain the initialized decoding hidden state vector and the initialized generated word; The decoder decoding state update module updates the decoding state of the recurrent neural network to obtain an updated decoding hidden state vector; a word attention value calculation module that calculates a first attention value for a word in the word list based on the updated decoded hidden state vector and the context sentence, and calculates a second attention value for a word in the selected candidate knowledge sentence based on the updated decoded hidden state vector and the selected candidate knowledge sentence; A word final probability calculation module obtains a final probability value of the word based on the first attention value and the second attention value; The dialogue response sentence generation module selects the word with the highest final probability value as the generated word and forms all the generated words into a dialogue response sentence and outputs it.

10. The dialogue response generation model according to claim 9, characterized in that: It also includes a gating vector acquisition module, which obtains a gating vector based on the context sentence and the selected candidate knowledge sentence. The gating vector is used to indicate the extent to which the information of the context sentence and the selected candidate knowledge sentence is used when updating the decoding hidden state vector; and the decoder decoding state update module obtains the decoding hidden state vector of the current time step based on the decoding hidden state vector output at the previous time step, the generated word at the previous time step, and the gating vector.

Citation Information

Patent Citations

  • Personalized task type dialogue system based on structured user attribute description

    CN110851580A

  • Personalized dialogue generation method and system based on user dialogue history

    CN112182161A