A conversation recommendation model training method and conversation recommendation method based on prompt learning and alignment strategy

Through a method based on prompt learning and alignment strategy, the problems of independent module processing and semantic gap in the dialogue recommendation system are solved, seamless information integration and semantic consistency of recommendation and dialogue tasks in the dialogue recommendation system are achieved, and the flexibility and performance of the system are improved.

CN119396979BActive Publication Date: 2025-09-30GUANGDONG UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411602543.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-09-30
Estimated Expiration
2044-11-11

AI Technical Summary

Technical Problem

In existing conversational recommendation systems, the independent processing of modules for recommendation subtasks and conversation subtasks hinders information transmission and integration, and the semantic gap between text information and knowledge graphs fails to be effectively aligned, affecting the semantic consistency and performance of the system.

Method used

A method based on prompt learning and alignment strategy is adopted. The knowledge graph is encoded through a graph convolutional network. Combined with multi-granularity contrastive learning and linear cross interaction methods, the conversation history and entity information are semantically aligned and fused, and a generative dialogue model is trained using multi-task shared soft prompt templates.

Benefits of technology

It achieves seamless information integration between recommendation and dialogue tasks, improves the semantic consistency of the model and the flexibility of the system, enhances the context understanding ability, and narrows the semantic gap between text information and knowledge graphs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396979B_ABST
    Figure CN119396979B_ABST
Patent Text Reader

Abstract

The present invention discloses a conversation recommendation model training method and a conversation recommendation method based on prompt learning and alignment strategies. The training method includes: inputting conversation history and knowledge graphs into a pre-trained language model and a graph convolutional network to obtain feature embeddings for text and entities, respectively; semantically aligning these features through multi-granularity contrastive learning, and semantically fusing them using a linear cross-interaction method to obtain multimodal feature embeddings; using these features to pre-train soft prompt templates shared by multiple tasks to guide the conversation model to complete conversation generation and recommendation tasks; freezing the parameters of the generative conversation model and training the model's learnable parameters using a loss function to obtain a trained model. The present invention can effectively improve semantic consistency between models, significantly enhance the contextual understanding ability of the pre-trained language model in the conversation recommendation system subtasks, and effectively narrow the semantic gap between text information and the knowledge graph through multi-granularity contrastive learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of natural language processing and dialogue systems, and more specifically, relates 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 (CRSs) aim to capture user preferences through natural language conversations and, based on these preferences, provide personalized recommendations and generate persuasive conversational text. Typically, a conversational recommender system consists of two subtasks: a recommendation subtask and a conversation subtask. The recommendation subtask aims to predict items that the user may be interested in from a set of candidate items, while the conversation subtask generates 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 utilize different frameworks and algorithms. This separate architecture hinders the transfer and integration of information between the two subtasks. The results of one module cannot be perceived and utilized by the other, resulting in semantic inconsistency and making it difficult to effectively and seamlessly connect the two modules.

[0003] Furthermore, the inputs to conversational recommender systems include conversational text data and knowledge graphs. These two types of data are heterogeneous, with a large semantic gap between them. This is because conversational data and external data often correspond to very different data structures or semantic content. Directly aligning their semantic spaces or performing data fusion can compromise the performance of the original representations. Therefore, it is necessary to develop a general approach to bridge the semantic gap between the different data signals of conversational recommender systems.

[0004] The prior art invention patent with 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 are integrated as prompts 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 of text information and knowledge graph when integrating them, 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 of inconsistent dialogue recommendation system frameworks and the failure to align the semantic spaces when fusing 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 strategies.

[0006] The primary purpose of the present invention is to solve the above technical problems, and the technical solutions of the present invention are as follows:

[0007] A first aspect of the present invention provides a method for training a conversation 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 the knowledge graph and combine it with the current input entity information to obtain the knowledge representation feature embedding of the entity;

[0010] Multi-granularity contrastive learning is used to semantically align the text feature embeddings of the conversation history with the knowledge representation feature embeddings of the entities, resulting in aligned conversation history text feature embeddings and entity feature embeddings.

[0011] The aligned text feature embedding and entity feature embedding are semantically fused using the linear cross interaction method to obtain a fused multimodal feature embedding. 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, thereby obtaining a dialogue response containing a recommended item;

[0013] 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.

[0014] Furthermore, the multi-granularity contrastive learning includes coarse-grained contrastive learning and fine-grained contrastive learning. 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 includes the following specific steps:

[0018] The text feature embedding of the conversation history and the knowledge representation feature embedding of the entities involved are then used to reduce the dimension through attention guidance. The attention-guided dimensionality reduction formula is as follows:

[0019] ProjAtt(h)=Softmax(tanh(h·a)·b)·h

[0020] Where 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 embedding 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, search for them in the text feature embedding of the conversation history, and obtain 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 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 + ), τ is the temperature hyperparameter.

[0033] Furthermore, 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:

[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 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. 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 the soft prompt template shared by multiple tasks, C is the original dialogue history, R is the original dialogue response, and [;] is the splicing 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 splicing operation;

[0046] In the task recommendation 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 Both 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 i-th original conversation, w i,j is the word at position j in the ith original conversation, w <j is the word that comes 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] The second aspect of the present invention provides a dialogue recommendation method based on prompt learning and alignment strategy, which adopts the model obtained by the above training, uses the model to perform dialogue recommendation, and obtains a dialogue recommendation response.

[0059] Compared with the prior art, the beneficial effects of the technical solution of the present invention are:

[0060] The adoption of a unified generative dialogue model enables 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. Through task-oriented multi-task shared soft prompt templates, the pre-trained language model's contextual understanding ability in the dialogue recommendation system subtasks is significantly enhanced, 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. Through multi-granularity comparative learning, the semantic gap between text information and knowledge graphs is effectively narrowed. 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 Flowchart of the 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 prompt template for each of the dialogue generation task stages. DETAILED DESCRIPTION

[0065] In order to more clearly understand the above-mentioned objects, 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, in the absence of conflict, the embodiments of the present application and the features therein can be combined with each other.

[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 scope of protection 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 conversation 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 diagram of a conversation recommendation model training method based on prompt learning and alignment strategy provided by the present invention. 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 E into the reply text resp After mapping transformation and historical context text embedding 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 effectively extract contextual features. 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] Among them E tokens ={t1, t2, ..., t n} is the feature output from RoBERTa, which is the knowledge representation of the conversation text. 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 text embeddings. At the same time, the entities involved in the conversation are searched in the knowledge graph embedding to obtain entity embeddings. 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 model's next response target. 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 batch size, SQ is sequence length, i.e. text sequence length, HS is hidden size, BS is set to 64, HS is set to 768. resp After mapping transformation and E text Merge to get the text feature embedding E of the conversation history toens .

[0077] S2: Use 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 in the text, such as "The Greatest Showman (2017)", "The Shaggy Dog (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, storing entity information in the form of triples <n1, r, n2>. To fully utilize 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 at the lth layer, we obtain the node representation matrix at 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] To construct the final knowledge representation so that the conversational recommendation system can fully understand user preferences, a linear cross-interaction method is used to fuse Etokens and Eentities. However, because these two types of semantic knowledge are heterogeneous data and reside in two different semantic spaces, direct fusion may not produce a good overall knowledge representation. Therefore, reducing the modal difference between these two types of semantic knowledge is crucial for obtaining a good overall knowledge representation to improve the conversational and recommendation performance of the conversational recommendation system. To achieve a better final knowledge representation, multi-granularity contrastive learning is proposed to align these two types of semantic knowledge, thereby improving 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 embeddings and entity feature embeddings;

[0084] Contrastive learning is a widely used strategy in the pre-training phase. It optimizes representation learning by bringing semantically similar representations closer together and pushing semantically unrelated representations apart. Through multi-granularity contrastive learning, it effectively narrows the semantic gap between text information and knowledge graphs. The proposed multi-granularity contrastive learning mainly includes two types of granularity comparisons: coarse-grained comparison and fine-grained comparison. The overall training objective of contrastive learning is expressed as:

[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 to perform contrastive learning to align the semantics of text and entities. The specific steps are:

[0088] The text feature embedding of the conversation history and the knowledge representation feature embedding of the entities involved are then used to reduce the dimension through attention guidance. The attention-guided dimensionality reduction formula is as follows:

[0089] ProjAtt(h)=Softmax(tanh(h·a)·b)·h

[0090] Where 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. 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 embedding 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 to perform contrastive learning to optimize the semantic association between text and entities. The specific steps are as follows:

[0094] Extract named entity phrases from the conversation text, search for them in the text feature embedding of the conversation history, and obtain 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 as positive examples, while different knowledge representations in the same batch are regarded as negative examples.

[0097] The model parameters are updated using 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 a temperature hyperparameter, set to 0.07 in one specific embodiment. Conversation text and entity knowledge representations capture user preferences from different perspectives. Through contrastive learning, these two different semantic spaces are aligned, allowing the two knowledge representations to leverage and enhance each other.

[0103] S4: Use the linear cross interaction method to semantically fuse the aligned text feature embedding and entity feature embedding 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 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. 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: Embed E using the multimodal features 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 recommended items. Using a unified generative dialogue model, seamless information integration between recommendation and dialogue tasks is achieved, 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 2, we introduce soft prompt template learning 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 recommendation task soft prompt template, which is set to 10, n_gen is the sequence length of the dialogue generation task soft prompt template, 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 Including 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 splicing operation;

[0115] In the dialogue generation task stage, 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 loss function of the dialogue generation task stage is expressed 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 i-th original conversation, w i,j is the word at position j in the ith original conversation, w <j is the word that comes 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 a learnable parameter θ for the recommendation task recThe soft prompt template is denoted by [;], where C represents the original conversation history, G represents the response template generated by the conversation generation task, and [;] represents the concatenation operation. By sharing task-oriented, multi-task soft prompt templates, the pre-trained language model's contextual understanding capabilities in the conversational recommendation system subtask are significantly enhanced, providing the model with comprehensive semantic information guidance. This soft prompt learning mechanism also avoids the subjective factors introduced by manually designed prompt templates, helping to improve 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 the conversation text based on the current conversation history. For example, generate text G: "Have you seen [ITEM]? This is also a good movie." Then we use RoBERTa to encode the 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 recommendation results, 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 learnable parameter θ for the recommendation task rec During the entire training process, the DialoGPT model parameters θ plm is frozen, and only the remaining parameters are trained.

[0129] The second aspect of the present invention provides a dialogue recommendation method based on prompt learning and alignment strategy, which adopts the model obtained by the above training, uses the model to perform dialogue recommendation, and obtains a dialogue recommendation response.

[0130] To comprehensively evaluate conversational recommender models, we selected two widely recognized datasets: ReDial and Inspired. The ReDial dataset is specifically designed for movie recommendations. Its dialogue content is based on real-world scenarios and is collected by Amazon Mechanical Turk (AMT) workers by simulating interactions between searchers and recommenders.

[0131] The experiments were conducted on two datasets (ReDial and INSPIRED). The following are the main advantages of the proposed MGCCRS in these tasks:

[0132] Recommendation task advantages: Table 1 shows the results of the recommendation task on the RdDial dataset, and Table 2 shows the results of the recommendation task 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] The figure shows that the proposed MGCCRS significantly outperforms the baseline model in both Recall@10 and Recall@50. In particular, on the INSPIRED dataset, MGCCRS achieves a Recall@50 of 0.438, approximately 7% higher than UniCRS. This demonstrates significant improvements 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. 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] The figure shows that the proposed MGCCRS performs well on the Dist-2, Dist-3, and Dist-4 evaluation metrics for the dialogue generation task. For example, on the INSPIRED dataset, the Dist-4 value of the MGCCRS reaches 6.131, a significant improvement over other models, indicating that the generated dialogues have greater diversity and contextual 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 the purpose of clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection 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 the knowledge graph and combine it with the current input entity information to obtain the knowledge representation feature embedding of the entity; Multi-granularity contrastive learning is used to semantically align the text feature embeddings of the conversation history with the knowledge representation feature embeddings of the entities, resulting in aligned conversation history text feature embeddings and entity feature embeddings. The aligned text feature embedding and entity feature embedding are semantically fused using the linear cross interaction method to obtain a fused multimodal feature embedding. 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 the dialogue generation task and the recommendation task, and obtain a dialogue response containing the recommended items; Freeze the parameters of the preset generative dialogue model and use the loss function to train the model's learnable parameters to obtain a trained model; During 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 the soft prompt template shared by multiple tasks, C is the original dialogue history, R is the original dialogue response, and [;] is the splicing 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 splicing 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 Both contain learnable parameters.

2. The method for training a conversation recommendation model based on prompt learning and alignment strategy according to claim 1, characterized in that: The multi-granularity contrastive learning includes coarse-grained contrastive learning and fine-grained contrastive learning. The overall training objective of contrastive learning is expressed as: 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. The method for training a conversation recommendation model based on prompt learning and alignment strategy according to claim 2, 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 then used to reduce the dimension through attention guidance. The attention-guided dimensionality reduction formula is as follows: ProjAtt(h)=Softmax(tanh(h·a)·b)·h Where 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 embedding 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. The method for training a conversation recommendation model based on prompt learning and alignment strategy according to claim 2, characterized in that: The specific steps of the fine-grained contrastive learning are as follows: Extract named entity phrases from the conversation text, search for them in the text feature embedding of the conversation history, and obtain 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 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. The method for training a conversation 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 + ), τ is the temperature hyperparameter.

6. The method for training a conversation recommendation model based on prompt learning and alignment strategy according to claim 1, 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 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. 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. The method for training a conversation recommendation model based on prompt learning and alignment strategy according to claim 1, 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 i-th original conversation, w i,j is the word at position j in the ith original conversation, w <j is the word that comes 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.

8. The method for training a conversation recommendation model based on prompt learning and alignment strategy according to claim 1, characterized in that: The pre-trained language model is the RoBERTa model, the graph convolutional network is the R-GCN network, and the preset generative dialogue model is the pre-trained DialoGPT model.

9. A conversation recommendation method based on prompt learning and alignment strategy, characterized in that: The method adopts a model trained according to any one of claims 1 to 8, uses the model to perform dialogue recommendation, and obtains a dialogue recommendation response.