Conversation recommendation model training method based on prompt learning and alignment strategy and conversation recommendation method
By adopting a model training method based on prompt learning and alignment strategies in the dialogue recommendation system, the problems of inconsistency of the framework and semantic alignment are solved, and the seamless integration of information and semantic consistency improvement in the dialogue recommendation system are achieved.
Patent Information
- Application Number
- CN202411602543.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-11-11
AI Technical Summary
The existing dialogue recommendation system framework is not unified, and its semantic space is not aligned when integrating text information and knowledge graphs, resulting in semantic inconsistency and information integration hindered.
The dialogue recommendation model training method is adopted based on prompt learning and alignment strategies. The text feature embedding of learning dialogue history is semantically aligned with the knowledge representation feature embedding of entities through multi-grained comparison, and the linear cross-interaction method is used to perform semantic fusion to realize the dialogue recommendation system. seamless integration of information in.
Significantly improve semantic consistency between models, enhance system flexibility, and facilitate future expansion and maintenance. Through task-oriented multi-task sharing soft prompt templates, the context understanding ability of pre-trained language models is enhanced, effectively reducing text information The semantic gap with the knowledge graph.
Smart Images

Figure CN119396979A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing and dialogue systems, and more specifically, to a dialogue recommendation model training method and a dialogue recommendation method based on prompt learning and alignment strategy. Background Art
[0002] Conversational Recommender Systems (CRS) aim to obtain user preferences through natural language conversations, and based on this, provide personalized recommendations to users and generate persuasive conversational texts. Generally, a conversational recommender system consists of two subtasks: a recommendation subtask and a conversation subtask. The goal of the recommendation subtask is to predict the items that the user may be interested in from a set of candidate items, while the conversation subtask is to generate appropriate questions or responses based on the current conversation content and recommendation results. In traditional conversational recommender system implementations, these two subtasks are often handled by independent modules, which may use different frameworks and algorithms. This separate architecture leads to the obstruction of information transmission and integration between the two subtasks. The results of one module cannot be perceived and utilized by the other module, resulting in semantic inconsistency problems, and it is difficult to effectively and seamlessly associate the two modules.
[0003] In addition, the input of the conversational recommendation system includes conversational text data and knowledge graphs. These two types of data are heterogeneous, and there is a large semantic gap between them, because conversational data and external data usually correspond to very different data structures or semantic contents. If their semantic spaces are directly aligned or data fusion is performed directly, the performance of the original representation may be impaired. Therefore, it is necessary to develop a general method to bridge the semantic gap between different data signals of the conversational recommendation system.
[0004] The invention patent with the prior art publication number CN115525744A proposes a conversation recommendation system based on a prompt learning method, including the following steps: S1: Through self-supervised learning based on entity prediction, the semantic information of the conversation text and the knowledge graph is integrated as a prompt for task sharing, and the pre-trained language model is supplemented with the knowledge information required for the conversation recommendation system; S2: Through the prompt design specific to the conversation task, the pre-trained language model is driven to generate a template sentence with an item slot as an intermediate result of the reply; S3: Through the prompt specific to the recommendation task, the pre-trained language model is driven to generate items of interest to the user. This scheme does not align the semantic space when integrating text information and knowledge graphs, which may damage the performance of the original representation. Summary of the invention
[0005] In order to overcome the technical problems in the prior art that the dialogue recommendation system framework is not unified and the semantic space is not aligned when integrating text information and knowledge graphs, the present invention provides a dialogue recommendation model training method and a dialogue recommendation method based on prompt learning and alignment strategy.
[0006] The primary purpose of the present invention is to solve the above technical problems. The technical solution of the present invention is as follows:
[0007] A first aspect of the present invention provides a method for training a dialog recommendation model based on prompt learning and alignment strategy, comprising the following steps:
[0008] Input the conversation history into the pre-trained language model to obtain the text feature embedding of the conversation history;
[0009] Use graph convolutional networks to encode knowledge graphs and combine them with the current input entity information to obtain knowledge representation feature embedding of entities;
[0010] Multi-granularity contrastive learning is used to semantically align the text feature embedding of the conversation history with the knowledge representation feature embedding of the entity, obtaining the aligned text feature embedding of the conversation history and the feature embedding of the entity.
[0011] The aligned text feature embedding and entity feature embedding are semantically fused using the linear cross interaction method to obtain the fused multimodal feature embedding, and the learnable parameters in the linear cross interaction method are optimized through self-supervised entity prediction.
[0012] Pre-training a multi-task shared soft prompt template using the multimodal feature embedding to obtain a multi-task shared soft prompt template with learnable parameters; using the multi-task shared soft prompt template to guide a preset generative dialogue model to complete a dialogue generation task and a recommendation task, and obtain a dialogue response containing a recommended item;
[0013] Freeze the parameters of the preset generative dialogue model, use the loss function to train the learnable parameters of the model, and obtain the trained model.
[0014] Furthermore, the multi-granularity contrastive learning includes coarse-granularity contrastive learning and fine-granularity contrastive learning, and the overall training objective expression of contrastive learning is:
[0015] L cl =(L crude +L fine ) / 2
[0016] Among them, L cl is the overall loss value, L crude is the coarse-grained contrast loss value, L fine is the fine-grained contrast loss value.
[0017] Furthermore, the coarse-grained contrastive learning comprises the following specific steps:
[0018] The text feature embedding of the conversation history and the knowledge representation feature embedding of the entities involved are reduced in dimension through attention guidance. The attention-guided dimensionality reduction formula is as follows:
[0019] ProjAtt(h)=Softmax(tanh(h·a)·b)·h
[0020] Among them, ProjAtt(h) is the representation vector after dimensionality reduction, h is the feature embedding of the conversation history text, and a and b are randomly initialized learnable matrices;
[0021] Maintain a text embedding queue whose length matches the size of the dataset. In each training batch, save the overall text embedding of the batch in the queue, pair the entity embeddings within the same batch with each other as positive samples, and pair the entity embeddings of the current batch with the text embeddings of non-current batches in the queue as negative samples.
[0022] The model parameters, including the learnable matrices a and b, are updated using the preset contrastive learning loss function.
[0023] Furthermore, the fine-grained contrastive learning includes the following specific steps:
[0024] Extract named entity phrases from the conversation text and search for them in the text feature embedding of the conversation history to get the named entity phrase embedding e T ;
[0025] Extract the entity embedding corresponding to the named entity phrase in the conversation text from the entity-level knowledge representation to obtain the entity knowledge embedding e E ;
[0026] (e T , e E ) pairs are regarded as positive examples, while different knowledge representations in the same batch are regarded as negative examples.
[0027] Update model parameters using the preset contrastive learning loss function.
[0028] Furthermore, the preset contrastive learning loss function expression is:
[0029]
[0030] in,
[0031]
[0032] Among them, e and e + There are two types of entity embeddings, {e -} is a positive example (e,e + ), and τ is the temperature hyperparameter.
[0033] Furthermore, the linear cross interaction method uses a linear transformation operation to interactively calculate the similarity matrix between the text feature embedding and the entity feature embedding to obtain a fused feature representation, which is expressed as follows:
[0034]
[0035] E fuseT =E tokens +E entities ·Attn
[0036] E fuseE =E entities +E tokens ·Attn T
[0037] Among them, Attn is the similarity matrix between two representations, E tokens is the text feature embedding of the conversation history, W is the linear transformation matrix, E entities is the knowledge representation feature embedding of the entity, E fuseT and E fuseE They represent the text feature embedding and entity feature embedding after semantic fusion respectively. During the fusion process, the learnable parameters are optimized through self-supervised entity prediction. The expressions are as follows:
[0038] Pr(e|θ fuse θ share )=softmax(u p ·N T )
[0039] Among them, θ fuse represents the learnable parameters of the linear cross-interaction method, θ share represents the learnable parameter of multi-task shared soft hint, u p is the user preference representation, and N is the embedding of all entities mentioned in the conversation history.
[0040] Furthermore, in the pre-training phase, the prompt template The following expression is used for modeling:
[0041]
[0042] Among them, E fuse is the fused multimodal feature embedding, P share is a soft prompt template shared by multiple tasks, C is the original dialogue history, R is the original dialogue response, and [;] is the concatenation operation;
[0043] In the dialogue generation task stage, the prompt template The following expression is used for modeling:
[0044]
[0045] Among them, P gen is the soft prompt template for the dialogue generation task, C is the original dialogue history, R is the original dialogue response, and [;] is the concatenation operation;
[0046] In the recommended task stage, the prompt template The following expression is used for modeling:
[0047]
[0048] Among them, P rec is the soft prompt template for the recommendation task, C is the original dialogue history, R is the original dialogue response, and [;] is the concatenation operation;
[0049] The soft prompt template P share , P gen , P rec All contain learnable parameters.
[0050] Furthermore, the pre-trained language model is a RoBERTa model, the graph convolutional network is an R-GCN network, and the preset generative dialogue model is a pre-trained DialoGPT model.
[0051] Furthermore, in the pre-training phase, cross entropy loss is used for optimization;
[0052] In the dialogue generation task stage, the expression of the loss function used for training is as follows:
[0053]
[0054] in, is the jth knowledge prompt template, θ gen Learnable parameters for soft prompts for the dialogue generation task, R j is the jth original dialogue response, l i is the length of the ith original conversation, w i,j is the word at the jth position in the ith original dialogue, w <j is the word before position j, and N is the number of training instances;
[0055] In the recommendation task stage, the expression of the loss function used for training is as follows:
[0056]
[0057] in, Indicates recommending entity e to the user j The probability of ej represents the jth entity, θ rec represents the learnable parameters of the recommendation task, N is the number of training instances, M is the total number of entities, is the i-th knowledge prompt template, y i,j represents a binary true label that is equal to 1 when item i is the correct label for the jth training instance.
[0058] A second aspect of the present invention provides a dialogue recommendation method based on prompt learning and alignment strategy, wherein the method adopts the model obtained through the above training, uses the model to perform dialogue recommendation, and obtains a dialogue recommendation response.
[0059] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0060] The use of a unified generative dialogue model achieves seamless information integration between recommendation and dialogue tasks, significantly improving the semantic consistency between models. The shared model architecture also enhances the flexibility of the system, facilitating future expansion and maintenance. Task-oriented multi-task shared soft prompt templates significantly enhance the contextual understanding ability of the pre-trained language model in the dialogue recommendation system subtasks, providing the model with comprehensive semantic information guidance. The soft prompt learning mechanism can also avoid the introduction of subjective factors due to artificially designed prompt templates, which helps to promote the improvement of model performance. Multi-granularity comparative learning effectively narrows the semantic gap between text information and knowledge graphs. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to make the purpose and technical solution of the present invention clearer, the present invention provides the following drawings and descriptions:
[0062] Figure 1 A flow chart of a model training method provided by an embodiment of the present invention;
[0063] Figure 2 A schematic diagram of a system provided by an embodiment of the present invention;
[0064] Figure 3 The embodiment of the present invention provides a pre-training stage, a recommendation task stage and a dialog generation task stage, respectively. DETAILED DESCRIPTION
[0065] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0066] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0067] The first aspect of the present invention provides a method for training a dialog recommendation model based on prompt learning and alignment strategy, such as Figure 1 The figure shows a flow chart of a conversation recommendation model training method based on prompt learning and alignment strategy. Figure 2 The figure shows a system schematic diagram of a conversation recommendation model training method based on prompt learning and alignment strategy provided by the present invention, and the specific steps are as follows:
[0068] S1: Input the conversation history into the pre-trained language model, encode the features of the conversation content, and obtain the conversation history context text embedding E text Embed E with reply text resp , embed the reply text into E resp After mapping transformation, the historical context text is embedded in E text Merge to get the text feature embedding E of the conversation history toens .
[0069] RoBERTa is a bidirectional encoder that uses a large amount of text corpus for pre-training and can extract contextual features well. Therefore, we use frozen RoBERTa as the text encoder. For all tokens W = {W1, W2, ..., w n}, the feature extraction of conversation context information can be modeled using the following formula:
[0070] E tokens =RoBERTa(W)
[0071] Where E tokens ={t1, t2, ..., t n} is the feature output from RoBERTa, which is the knowledge representation of the conversation text, and n represents the number of tokens in the conversation history. In a specific embodiment, the conversation history context is encoded using RoBERTa and converted into a text embedding, and the entities involved in the conversation are searched in the knowledge graph embedding to obtain entity embedding. For example, the conversation history context is "
[0072] User: I like family movies like The Greatest Showman *2017).
[0073] Assistance: Do you like older Disney films like The Shaggy Dog(1959)? Or Escape to Witch Mountain (1975)?
[0074] User: I've seen those. They are pretty good!
[0075] Response: Or for something newer, you might like A Wrinkle in Time(2007).
[0076] ", where User represents the text input by the user, Assistance represents the text generated by the model, and Response represents the next response target of the model. The text in User and Assistance together constitute the conversation history context. The conversation history context and Response are encoded using RoBERTa to obtain the conversation history context text embedding E text ∈R BS×SQ×HS and reply text embedded in E resp ∈R BS×SQ×HS , where BS is the batch size, SQ is the sequence length, i.e. the length of the text sequence, and HS is the hidden size. Set BS to 64 and HS to 768. resp After mapping transformation, text Merge to get the text feature embedding E of the conversation history toens .
[0077] S2: Use the graph convolutional network to encode the knowledge graph, obtain the top-level node representation matrix, and search in the node representation matrix based on the input entity information to obtain the knowledge representation feature embedding E of the entity entities In a specific embodiment, the entity names existing in the text, such as "The Greatest Showman (2017)", "The ShaggyDog (1959)", "Escape to Witch Mountain (1975)", are searched in the knowledge graph embedding to obtain the entity embedding E entities ∈R BS×EQ×HS , where EQ is the number of entities.
[0078] The knowledge graph G consists of an entity set N and a relationship set R, and stores entity information in the form of triples <n1, r, n2>. In order to make full use of the relationship information between entities, R-GCN is used to encode the knowledge graph G. Formally, the (1+1)th layer node representation e can be modeled using the following formula:
[0079]
[0080] in, is the node representation e of the lth layer, represents the set of adjacent nodes e under the relation r, and W (1) is the learnable matrix, Z e,r is the normalization factor. After aggregating the node information of the lth layer, we obtain the node representation matrix of the top layer of R-GCN.
[0081] Search the entities mentioned in the conversation history in all node representation matrices and obtain the entity-level knowledge representation matrix E entities ={e1, e2, ..., e n}, where n represents the number of entities in the conversation history.
[0082] In order to construct the final knowledge representation so that the conversational recommendation system can fully understand user preferences, the linear cross-interaction method is used to fuse Etokens and Eentities. However, because these two kinds of semantic knowledge belong to heterogeneous data and are in two different semantic spaces, direct fusion may not be able to obtain a good overall knowledge representation. Therefore, reducing the modal difference between the two kinds of semantic knowledge is very important for obtaining a good overall knowledge representation to improve the conversation performance and recommendation performance of the conversational recommendation system. In order to obtain a better final knowledge representation, multi-granularity contrastive learning is proposed to achieve the alignment of the two kinds of semantic knowledge for better subsequent semantic fusion.
[0083] S3: Embedding text features of conversation history into E using multi-granularity contrastive learning tokens The knowledge representation feature embedding E entities Perform semantic alignment to obtain aligned conversation history text feature embedding and entity feature embedding;
[0084] Contrastive learning is a strategy widely used in the pre-training stage. It optimizes representation learning by bringing semantically similar representations closer and pushing semantically irrelevant representations away. Through multi-granularity contrastive learning, the semantic gap between text information and knowledge graphs is effectively narrowed. The proposed multi-granularity contrastive learning mainly includes two types of granularity contrasts, coarse-grained contrast and fine-grained contrast. The overall training objective expression of contrastive learning is:
[0085] Lcl =(L crude +L fine ) / 2
[0086] Among them, L cl is the overall loss value, L crude is the coarse-grained contrast loss value, L fine is the fine-grained contrast loss value.
[0087] More specifically, coarse-grained contrastive learning is to use the overall text embedding and the overall entity embedding for contrastive learning to align the semantics of text and entity. The specific steps are:
[0088] The text feature embedding of the conversation history and the knowledge representation feature embedding of the entities involved are reduced in dimension through attention guidance. The attention-guided dimensionality reduction formula is as follows:
[0089] ProjAtt(h)=Softmax(tanh(h·a)·b)·h
[0090] Among them, ProjAtt(h) is the representation vector after dimensionality reduction, h is the feature embedding of the conversation history text, a and b are randomly initialized learnable matrices. Here we set the dimension of matrix a to [hidden_size, hidden_size] and the dimension of matrix b to [hidden_size, 1]. In a specific embodiment, hidden_size is 1024.
[0091] Maintain a text embedding queue whose length matches the size of the dataset. In each training batch, save the overall text embedding of the batch in the queue, pair the entity embeddings within the same batch with each other as positive samples, and pair the entity embeddings of the current batch with the text embeddings of non-current batches in the queue as negative samples.
[0092] The contrastive learning loss function is used to update the model parameters, including the learnable matrices a and b.
[0093] Fine-grained contrastive learning is to use the named entity phrase embeddings in the conversation text and the corresponding entity embeddings in the knowledge graph for contrastive learning to optimize the semantic association between text and entities. The specific steps are:
[0094] Extract named entity phrases from the conversation text and search for them in the text feature embedding of the conversation history to get the named entity phrase embedding e T ;
[0095] Extract the entity embedding corresponding to the named entity phrase in the conversation text from the entity-level knowledge representation to obtain the entity knowledge embedding e E ;
[0096] (e T , e E ) pairs are regarded as positive examples, while different knowledge representations in the same batch are regarded as negative examples.
[0097] The model parameters are updated using the contrastive learning loss function.
[0098] The contrastive learning loss function used above is expressed as:
[0099]
[0100] in,
[0101]
[0102] Among them, e and e + There are two types of entity embeddings, {e -} is a positive example (e, e + ), τ is the temperature hyperparameter, and in a specific embodiment, it is set to 0.07. The two knowledge representations of dialogue text and entity capture the user's preferences from different perspectives. Through contrastive learning, the two different semantic spaces are aligned, and the two knowledge representations can also utilize and promote each other.
[0103] S4: The aligned text feature embedding and entity feature embedding are semantically fused using the linear cross interaction method to obtain the fused multimodal feature embedding E fuse , and optimize the learnable parameters in the linear cross-interaction method through self-supervised entity prediction;
[0104] More specifically, the linear cross interaction method uses linear transformation operations to interactively calculate the similarity matrix between text feature embedding and entity feature embedding to obtain a fused feature representation, which is expressed as follows:
[0105]
[0106] E fuseT =E tokens +E entities ·Attn
[0107] E fuseE =E entities +E tokens ·Attn T
[0108] Among them, Attn is the similarity matrix between two representations, E tokens is the text feature embedding of the conversation history, W is the linear transformation matrix, E entities is the knowledge representation feature embedding of the entity, E fuseT and E fuseEThey represent the text feature embedding and entity feature embedding after semantic fusion respectively. During the fusion process, the learnable parameters are optimized through self-supervised entity prediction. The expressions are as follows:
[0109] Pr(e|θ fuse θ share )=softmax(u p ·N T )
[0110] Among them, θ fuse represents the learnable parameters of the linear cross-interaction method, θ share represents the learnable parameter of multi-task shared soft label, u p is the user preference representation, and N is the embedding of all entities mentioned in the conversation history.
[0111] S5: Using the multimodal feature embedding E fuse Pre-train the multi-task shared soft prompts to obtain a multi-task shared soft prompt template with learnable parameters; use the prompt template to guide the pre-trained DialoGPT model to complete the dialogue generation task and recommendation task, and obtain a dialogue response containing the recommended items. A unified generative dialogue model is used to achieve seamless information integration between recommendation and dialogue tasks, significantly improving the semantic consistency between models. The shared model architecture also enhances the flexibility of the system and facilitates future expansion and maintenance. In the pre-training stage, the prompt templates of the dialogue generation task stage and the recommendation task stage are composed as follows: Figure 3 As shown in Figure 1, soft prompt template learning is introduced to guide the DialoGPT model to better adapt to our downstream tasks. Specifically, the soft prompt template in the method includes a multi-task shared soft prompt template P share ∈R n _pre×HS , Recommended task soft prompt P rec ∈R n_rec×HS , Dialogue generation task soft prompt template P gen ∈R n_gen×Hs Among them, n_pre is the sequence length of the multi-task shared soft prompt template, which is set to 20, n_rec is the sequence length of the soft prompt template for the recommendation task, which is set to 10, n_gen is the sequence length of the soft prompt template for the dialogue generation task, which is set to 20, and HS is the hidden size, which is set to 1024. These soft prompt templates are mapped to obtain the soft prompt embedding E task , where E in the pre-training task task Including multi-task shared soft label embedding, E task Including multi-task shared soft prompt embedding and recommendation task soft prompt embedding, E task Includes multi-task shared soft label embedding and dialogue generation task soft prompt embedding.
[0112] More specifically, during the pre-training phase, the final prompt template The following expression is used for modeling:
[0113]
[0114] Among them, E fuse is the fused multimodal feature embedding, P share is a learnable parameter θ share The multi-task shared soft prompt template, C is the original dialogue history, R is the original dialogue response, and [;] is the concatenation operation;
[0115] In the dialogue generation task phase, the final prompt template The following expression is used for modeling:
[0116]
[0117] Among them, P gen Contains learnable parameters θ for the dialogue generation task gen The soft prompt template is , C is the original dialogue history, R is the original dialogue response, [;] is the concatenation operation, and the expression of the loss function in the dialogue generation task stage is as follows:
[0118]
[0119] in, is the jth knowledge prompt template, θ gen Learnable parameters for soft prompts for the dialogue generation task, R j is the jth original dialogue response, l i is the length of the ith original conversation, w i,j is the word at the jth position in the ith original dialogue, w <j is the word before position j, and N is the number of training instances;
[0120] In the recommended task stage, the final prompt template The following expression is used for modeling:
[0121]
[0122] Among them, P rec is the learnable parameter θ for the recommendation task recThe soft prompt template is , C is the original dialogue history, G is the response template generated by the dialogue generation task, and [;] is the concatenation operation. The task-oriented multi-task shared soft prompt template significantly enhances the context understanding ability of the pre-trained language model in the dialogue recommendation system subtask, providing the model with comprehensive semantic information guidance. The soft prompt learning mechanism can also avoid the introduction of subjective factors due to the artificial design of the prompt template, which helps to promote the improvement of model performance.
[0123] The expression of the loss function in the recommendation task stage is as follows:
[0124]
[0125] in, Indicates recommending entity e to the user j The probability of e j represents the jth entity, θ rec represents the learnable parameters of the soft prompt template for the recommendation task, N is the number of training instances, M is the total number of entities, is the i-th knowledge prompt template, y i,j represents a binary true label that is equal to 1 when item i is the correct label for the jth training instance.
[0126] In a specific embodiment, E task 、E fuse 、E text 、E resp Input into DialoGPT and generate dialogue text based on the current dialogue history. For example, generate text G: "Have you seen [ITEM]? This is also a good movie." Then we use RoBERTa to encode text G to obtain the embedded representation E. gen ∈R BS×SQ×HS , E task 、E fuse 、E text 、E gen Input into DialoGPT to obtain the recommendation result, for example, obtain the recommendation result: "The Lion King (2019)", and merge the recommendation result with the generated text G to obtain the final response "Have you seen The Lion King (2019)? This is also a good movie.".
[0127] S6: Freeze the parameters of the preset generative dialogue model, and use the loss function to train the learnable parameters of the model to obtain a trained model;
[0128] The parameters of the model of the present invention are composed of five parts, namely, the DialoGPT model parameters θ plm , the learnable parameter θ of the linear cross-interaction method fuse , the learnable parameters θ of the soft hint template shared by multiple tasks share , the soft prompts for the dialogue generation task can learn parameters θ gen and the soft hint parameter θ of the recommendation task rec During the entire training process, the DialoGPT model parameter θ plm is frozen, and only the remaining parameters are trained.
[0129] A second aspect of the present invention provides a dialogue recommendation method based on prompt learning and alignment strategy, wherein the method adopts the model obtained through the above training, uses the model to perform dialogue recommendation, and obtains a dialogue recommendation response.
[0130] To comprehensively evaluate the dialogue recommender system model, we selected two widely recognized datasets: ReDial and Inspired. The ReDial dataset is specially designed for movie recommendations, and its dialogue content is based on real situations and collected by Amazon Mechanical Turk (AMT) workers by simulating the interaction between searchers and recommenders.
[0131] The experiments were evaluated on two datasets (ReDial and INSPIRED). The following are the main advantages of the proposed MGCCRS in these tasks:
[0132] Advantages of recommendation tasks: Table 1 shows the results of the recommendation tasks on the RdDial dataset, and Table 2 shows the results of the recommendation tasks on the INSPIRED dataset. Bold numbers indicate statistically significant improvements compared to the best baseline. ReDial, KBRD, KGSF, GPT-2, DialoGPT, BERT, BART, and UniCRS in the table are all existing technologies.
[0133] It can be seen from the figure that the MGCCRS of the present invention is significantly better than the baseline model in Recall@10 and Recall@50, especially on the INSPIRED dataset, where the Recall@50 of MGCCRS reaches 0.438, which is about 7% higher than UniCRS. This shows that MGCCRS has significantly improved in both accuracy and coverage.
[0134] Table 1
[0135]
[0136] Table 2
[0137]
[0138]
[0139] Advantages of dialogue generation tasks (see Table 3 and Table 4):
[0140] Table 3 shows the results of the dialogue generation task on the RdDial dataset, and Table 4 shows the results of the dialogue generation task on the INSPIRED dataset. The bold numbers indicate statistically significant improvements compared to the best baseline. ReDial, KBRD, KGSF, GPT-2, DialoGPT, BERT, BART, and UniCRS in the table are all existing technologies.
[0141] It can be seen from the figure that the MGCCRS of the present invention performs well in the evaluation indicators Dist-2, Dist-3, and Dist-4 of the dialogue generation task. For example, on the INSPIRED dataset, the Dist-4 value of MGCCRS reaches 6.131, which is significantly higher than other models, indicating that the generated dialogue has higher diversity and context consistency.
[0142] These data support the advantages of the MGCCRS in improving recommendation accuracy and dialogue generation quality. Through innovative knowledge alignment and semantic fusion mechanisms, the model can be more effectively adapted to different task requirements.
[0143] Table 3
[0144]
[0145] Table 4
[0146]
[0147]
[0148] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. A method for training a conversational recommendation model based on prompt learning and alignment strategy, characterized in that: The steps include: Input the conversation history into the pre-trained language model to obtain the text feature embedding of the conversation history; Use graph convolutional networks to encode knowledge graphs and combine them with the current input entity information to obtain knowledge representation feature embedding of entities; Multi-granularity contrastive learning is used to semantically align the text feature embedding of the conversation history with the knowledge representation feature embedding of the entity, obtaining the aligned text feature embedding of the conversation history and the feature embedding of the entity. The aligned text feature embedding and entity feature embedding are semantically fused using the linear cross interaction method to obtain the fused multimodal feature embedding, and the learnable parameters in the linear cross interaction method are optimized through self-supervised entity prediction. Pre-training a multi-task shared soft prompt template using the multimodal feature embedding to obtain a multi-task shared soft prompt template with learnable parameters; Using the multi-task shared soft prompt template to guide a preset generative dialogue model to complete a dialogue generation task and a recommendation task, and obtain a dialogue response including a recommended item; Freeze the parameters of the preset generative dialogue model, use the loss function to train the learnable parameters of the model, and obtain the trained model.
2. According to the method for training a dialog recommendation model based on prompt learning and alignment strategy in claim 1, it is characterized in that: The multi-granularity contrastive learning includes coarse-granularity contrastive learning and fine-granularity contrastive learning. The overall training objective expression of contrastive learning is: l cl =(l crude +L fine ) / 2 Among them, L cl is the overall loss value, L crude is the coarse-grained contrast loss value, L fine is the fine-grained contrast loss value.
3. According to the method for training a dialog recommendation model based on prompt learning and alignment strategy in claim 2, it is characterized in that: The specific steps of the coarse-grained contrastive learning are as follows: The text feature embedding of the conversation history and the knowledge representation feature embedding of the entities involved are reduced in dimension through attention guidance. The attention-guided dimensionality reduction formula is as follows: ProjAtt(h)=Softmax(tanh(h·a)·b)·h Among them, ProjAtt(h) is the representation vector after dimensionality reduction, h is the feature embedding of the conversation history text, and a and b are randomly initialized learnable matrices; Maintain a text embedding queue whose length matches the size of the dataset. In each training batch, save the overall text embedding of the batch in the queue, pair the entity embeddings within the same batch with each other as positive samples, and pair the entity embeddings of the current batch with the text embeddings of non-current batches in the queue as negative samples. The model parameters, including the learnable matrices a and b, are updated using the preset contrastive learning loss function.
4. According to claim 2, a method for training a dialog recommendation model based on prompt learning and alignment strategy is characterized in that: The specific steps of the fine-grained contrastive learning are as follows: Extract named entity phrases from the conversation text and search for them in the text feature embedding of the conversation history to get the named entity phrase embedding e T ; Extract the entity embedding corresponding to the named entity phrase in the conversation text from the entity-level knowledge representation to obtain the entity knowledge embedding e E ; (e T ,e E ) pairs are regarded as positive examples, while different knowledge representations in the same batch are regarded as negative examples. Update model parameters using the preset contrastive learning loss function.
5. A method for training a dialog recommendation model based on prompt learning and alignment strategy according to claim 3 or 4, characterized in that: The preset contrastive learning loss function expression is: in, Among them, e and e + There are two types of entity embeddings, {e - } is a positive example (e,e + ), and τ is the temperature hyperparameter.
6. According to the method for training a dialog recommendation model based on prompt learning and alignment strategy in claim 1, it is characterized in that: The linear cross interaction method uses linear transformation operations to interactively calculate the similarity matrix between text feature embedding and entity feature embedding to obtain the fused feature representation, which is expressed as follows: And fuseT =E tokens +E entities ·Attn And fuseE =E entities +E tokens ·Attn T Among them, Attn is the similarity matrix between two representations, E tokens is the text feature embedding of the conversation history, W is the linear transformation matrix, E entities is the knowledge representation feature embedding of the entity, E fuseT and E fuseE They represent the text feature embedding and entity feature embedding after semantic fusion respectively. During the fusion process, the learnable parameters are optimized through self-supervised entity prediction. The expressions are as follows: Pr(e∣θ fuse ;θ share )=softmax(u p ·N T ) Among them, θ fuse represents the learnable parameters of the linear cross-interaction method, θ share represents the learnable parameter of multi-task shared soft hint, u p is the user preference representation, and N is the embedding of all entities mentioned in the conversation history.
7. According to claim 1, a method for training a dialog recommendation model based on prompt learning and alignment strategy is characterized in that: In the pre-training phase, the final prompt template The following expression is used for modeling: Among them, E fuse is the fused multimodal feature embedding, P share is a soft prompt template shared by multiple tasks, C is the original dialogue history, R is the original dialogue response, and [;] is the concatenation operation; In the dialogue generation task stage, the final prompt template The following expression is used for modeling: Among them, P gen is the soft prompt template for the dialogue generation task, C is the original dialogue history, R is the original dialogue response, and [;] is the concatenation operation; In the recommendation task stage, the final prompt template The following expression is used for modeling: Among them, P rec is the soft prompt template for the recommendation task, C is the original dialogue history, R is the original dialogue response, and [;] is the concatenation operation; The soft prompt template P share , P gen , P rec All contain learnable parameters.
8. The method for training a dialog recommendation model based on prompt learning and alignment strategy according to claim 7, characterized in that: In the pre-training phase, cross entropy loss is used for optimization; In the dialogue generation task stage, the expression of the loss function used for training is as follows: in, is the jth knowledge prompt template, θ gen Learnable parameters for soft prompts for the dialogue generation task, R j is the jth original dialogue response, l i is the length of the ith original conversation, w i,j is the word at the jth position in the ith original dialogue, w <j is the word before position j, and N is the number of training instances; In the recommendation task stage, the expression of the loss function used for training is as follows: in, Indicates recommending entity e to the user j The probability of e j represents the jth entity, θ rec represents the learnable parameters of the recommendation task, N is the number of training instances, M is the total number of entities, is the i-th knowledge prompt template, y i,j represents a binary true label that is equal to 1 when item i is the correct label for the jth training instance.
9. According to the method for training a dialog recommendation model based on prompt learning and alignment strategy in claim 1, it is characterized in that: The pre-trained language model is a RoBERTa model, the graph convolutional network is an R-GCN network, and the preset generative dialogue model is a pre-trained DialoGPT model.
10. A conversation recommendation method based on prompt learning and alignment strategy, characterized in that: The method adopts the model trained by claims 1-9, uses the model to perform dialogue recommendation, and obtains a dialogue recommendation response.
Citation Information
Patent Citations
Conversation recommendation system based on prompt learning
CN114880444A
Conversation recommendation system based on prompt learning method
CN115525744A
Language behavior dialogue strategy method based on multi-modal deep learning
CN118865979A
Cited By
Bank financing product recommendation method and system
CN119963296A
A method and system for recommending bank wealth management products
CN119963296B
Recommendation system deviation correction method fusing big language model world knowledge
CN120045792A
Pseudo tag guidance-based comparative learning man-post matching recommendation method
CN120407932A