Dialogue model training method, dialogue method, dialogue device and electronic equipment

By training the dialogue model in a comparative learning strategy, the problem of insufficient performance in existing dialogue models when dealing with ambiguity in dialogue entities is solved, and the performance of dialogue models in identifying the same and different entities is improved.

CN118917439APending Publication Date: 2024-11-08CHINA MOBILE COMM LTD RES INST +1

Patent Information

Application Number
CN202411029216.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

Existing dialogue models have poor performance when dealing with entity ambiguity in conversations, making it difficult to accurately distinguish semantic reference relationships between the same and different entities.

Method used

By obtaining dialogue sample data, the first type of word pair and the second type of word pair are determined, and the initial dialogue model is trained using a comparative learning strategy to obtain the target dialogue model, so that it can better distinguish the same and different data.

Benefits of technology

The identity and difference recognition ability of the dialogue model in processing dialogue sample data is improved, and the performance of the dialogue model is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118917439A_ABST
    Figure CN118917439A_ABST
Patent Text Reader

Abstract

The invention provides a dialogue model training method and device, a dialogue method and device and electronic equipment. The method comprises the steps of obtaining dialogue sample data; based on the dialogue sample data, a first type of word pairs and a second type of word pairs are determined, two words in each word pair of the first type of word pairs belong to the same entity and have the same semantic anaphora relationship, and two words in each word pair of the second type of word pairs do not belong to the same entity and have different semantic anaphora relationships; and based on the dialogue sample data, the first type of word pairs and the second type of word pairs, training the initial dialogue model through a comparative learning strategy to obtain a target dialogue model, thereby improving the performance of the dialogue model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of call technology, and in particular to a conversation model training method, a conversation method, a device and an electronic device. Background Art

[0002] Task-Oriented Dialogue Systems (TODS) are an important research direction in the field of artificial intelligence. They aim to help users efficiently complete specific tasks, such as booking a hotel, checking the weather, etc., through natural language interaction. The core of the system is to understand the user's intentions and provide accurate information and operational guidance during the conversation. To achieve this goal, TODS needs to have strong language understanding, dialogue management, and task execution capabilities. With the development of technology, the design and implementation of TODS are also constantly improving. For example, by integrating natural language processing technology, TODS can more accurately identify user instructions and needs, thereby providing more personalized services. In addition, TODS can also continuously optimize its dialogue strategy (for example, optimize the dialogue model) through machine learning algorithms to better adapt to the behavior patterns and preferences of different users. The widespread application of such systems not only improves people's life efficiency, but also brings convenience to business operations. For example, in e-commerce, customer service and other fields, TODS can significantly improve user experience and business processing efficiency. In recent years, deep learning technology, especially large language models (LLM), has been increasingly widely used as dialogue models in TODS.

[0003] However, entities in conversations are often ambiguous, that is, the same word may refer to different entities in different contexts, and different words may refer to the same entity. The performance of existing conversation models in distinguishing such data is poor, that is, the performance of existing conversation models is poor. Summary of the invention

[0004] Embodiments of the present application provide a dialogue model training method, a dialogue method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product to solve the problem of poor performance of existing dialogue models.

[0005] To solve the above technical problems, this application is implemented as follows:

[0006] In a first aspect, an embodiment of the present application provides a method for training a dialogue model, including:

[0007] Get conversation sample data;

[0008] Based on the conversation sample data, determining a first category of word pairs and a second category of word pairs, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships;

[0009] Based on the dialogue sample data, the first category of word pairs, and the second category of word pairs, an initial dialogue model is trained through a comparative learning strategy to obtain a target dialogue model.

[0010] In a second aspect, an embodiment of the present application provides a dialogue method, including:

[0011] Get the dialogue input data;

[0012] Determining a feature vector of the dialogue input data by using a target dialogue model;

[0013] outputting an operation result of the dialogue input data based on a feature vector of the dialogue input data;

[0014] The target dialogue model is a target dialogue model trained by the dialogue model training method.

[0015] In a third aspect, an embodiment of the present application provides a model training device, the device comprising:

[0016] A first acquisition module, used to acquire conversation sample data;

[0017] A first determination module is used to determine a first category of word pairs and a second category of word pairs based on the dialogue sample data, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships;

[0018] A training module is used to train the initial dialogue model through a comparative learning strategy based on the dialogue sample data, the first type of word pairs and the second type of word pairs to obtain a target dialogue model.

[0019] In a fourth aspect, an embodiment of the present application provides a conversation device, the device comprising:

[0020] The second acquisition module is used to acquire the dialogue input data;

[0021] A feature determination module, used to determine a feature vector of the dialogue input data through a target dialogue model;

[0022] An output module, used for outputting an operation result of the dialogue input data based on a feature vector of the dialogue input data;

[0023] The target dialogue model is a target dialogue model trained by the dialogue model training method.

[0024] In a fifth aspect, an embodiment of the present application provides an electronic device, including a transceiver and a processor.

[0025] The processor is configured to:

[0026] Get conversation sample data;

[0027] Based on the conversation sample data, determining a first category of word pairs and a second category of word pairs, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships;

[0028] Based on the dialogue sample data, the first category of word pairs, and the second category of word pairs, an initial dialogue model is trained through a comparative learning strategy to obtain a target dialogue model.

[0029] In a sixth aspect, an embodiment of the present application provides an electronic device, including a transceiver and a processor.

[0030] The processor is configured to:

[0031] Get the dialogue input data;

[0032] Determining a feature vector of the dialogue input data by using a target dialogue model;

[0033] outputting an operation result of the dialogue input data based on a feature vector of the dialogue input data;

[0034] The target dialogue model is a target dialogue model trained by the above-mentioned model training method.

[0035] In a seventh aspect, an embodiment of the present application provides an electronic device, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program implements the steps of the above method when executed by the processor.

[0036] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0037] In a ninth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which implements the steps in the above method when executed by a processor.

[0038] In the model training process of this embodiment, the first category of word pairs and the second category of word pairs can be determined based on the dialogue sample data, and the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships. Based on the dialogue sample data, the first category of word pairs and the second category of word pairs, the initial dialogue model can be trained through a comparative learning strategy to obtain a target dialogue model. In this way, the dialogue model can learn the similarities and differences in the dialogue sample data, so that the dialogue model can better distinguish between the same and different data, etc., and improve the performance of the dialogue model. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0040] Figure 1 is a flow chart of a conversation model training method provided in an embodiment of the present application;

[0041] Figure 2 is a flow chart of a dialogue method provided by an embodiment of the present application;

[0042] Figure 3 It is a principle block diagram of the dialogue model training method provided in the embodiment of the present application;

[0043] Figure 4 It is a language model training principle diagram provided in an embodiment of the present application;

[0044] Figure 5 It is a diagram of a graph encoder training principle provided in an embodiment of the present application;

[0045] Figure 6 It is a module schematic diagram of a dialogue model training device provided in an embodiment of the present application;

[0046] Figure 7 It is a module schematic diagram of a conversation device provided in an embodiment of the present application;

[0047] Figure 8 is a structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0048] Fig. 9 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0050] See also Figure 1 , Figure 1 is a flow chart of a method for training a dialogue model provided in an embodiment of the present application, which is executed by a first electronic device, wherein the first electronic device may be a terminal or a server device, etc. Figure 1 As shown, the dialogue model training method provided in this embodiment includes the following steps:

[0051] Step 101: Obtain conversation sample data.

[0052] The conversation sample data may include but is not limited to text-type conversation data, voice-type conversation data, etc. It should be noted that the conversation sample data may include conversation data between at least one role. For example, for a certain conversation sample data, it may include conversation data between a user and a system. For example, it may include "User (USR): I want to take a train to city X on Monday, why's it available?; System (SYS): I have several possibilities for Monday. User (USR): ...book a table for 5 people at 21:00 on the same day, please. System (SYS): OK. The table will be reserved for 15 minutes.".

[0053] Step 102: Based on the conversation sample data, determine the first category of word pairs and the second category of word pairs, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships;

[0054] It should be noted that the number of conversation sample data can be one or more. If there are multiple conversation sample data, the operation of this step can be performed for each conversation sample data, that is, for each conversation sample data, the first category word pair and the second category word pair corresponding to the conversation sample data can be determined.

[0055] In addition, the first category of word pairs may include at least one first word pair, and the second category of word pairs may include at least one second word pair. It should be noted that each word pair includes two words, and there is at least one word difference between different word pairs. It can be understood that the words in the word pairs in the embodiment of the present application are the result of entity recognition of the conversation sample data. For the two words in each word pair in the first category of word pairs, they belong to the same entity and have the same semantic reference relationship, that is, they share the reference relationship. For the two words in each word pair in the second category of word pairs, they do not belong to the same entity and have different semantic reference relationships, that is, they do not share the reference relationship. For example, for the above conversation data, "Monday" and "the same day" belong to the same entity and share a semantic reference relationship, while "a train" and "the same day" do not belong to the same entity and have different semantic reference relationships.

[0056] As an example, for a certain conversation sample data, the first category of word pairs can be determined based on the conversation sample data, and the second category of word pairs can be determined based on the first category of word pairs. Alternatively, the second category of word pairs can be determined based on the conversation sample data, and the first category of word pairs can be determined based on the second category of word pairs. This is not specifically limited in this embodiment. For example, the first category of word pairs can be determined based on the conversation sample data, and in the process of determining the second category of word pairs based on the first category of word pairs, the first category of word pairs can be determined based on the conversation sample data, and then any word in each word pair of the first category of word pairs can be replaced to obtain the second category of word pairs. In addition, in the process of replacing a word in a word pair in the first category of word pairs, the word can be replaced by another word in the conversation sample data that belongs to a different entity from the word, and then the replaced word pair corresponding to the word pair can be obtained, that is, a word pair in the second category of word pairs can be obtained. For example, one of the word pairs in the first category is "Monday" and "the same day". "A train" is a different entity from "Monday" in the sample conversation data. If "Monday" is replaced with "a train", the corresponding replaced word pair is "a train" and "the same day", which belongs to one of the word pairs in the second category. In an example, for a certain conversation sample data, for each word pair in the first category, m c (positive integer) replacement words (belonging to the conversation sample data) replace one word in the word pair, and randomly sample m c ′ (positive integer) times replace the word (belonging to the dialogue sample data) to replace another word in the word pair, and get the corresponding (m c +m c′) replaced word pairs are put into the second category of word pairs. For each word pair in the first category of word pairs, the above process can be performed to replace, so as to obtain the final second category of word pairs.

[0057] Step 103: Based on the dialogue sample data, the first type of word pairs, and the second type of word pairs, the initial dialogue model is trained by a comparative learning strategy to obtain a target dialogue model.

[0058] Contrastive learning is a machine learning method that learns by comparing the similarities and differences between two things. It learns the general characteristics of unlabeled sample data by training the model to find out which data points are similar or different, and distinguishes similar and dissimilar data points. The goal is to learn the representation of data to capture the basic structure and relationship between different data points. The words in each word pair of the first category of word pairs determined based on the dialogue sample data are different expressions of the same entity and have the same semantic reference relationship, that is, the semantics of reference are the same, while the words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships, that is, the semantics of reference are different. The contrastive learning strategy can learn the similarities and differences of data. In this embodiment, the contrastive learning strategy can be used to train the initial dialogue model based on the dialogue sample data, the first category of word pairs, and the second category of word pairs to obtain the target dialogue model to improve the performance of the trained model.

[0059] In addition, it should be noted that the method of this embodiment can be applied to various scenarios, for example, in dialogue scenarios. Specifically, for example, it can be applied to but not limited to information query scenarios (for example, weather query, etc.), information booking scenarios (air ticket booking scenarios, high-speed rail ticket booking scenarios, ship ticket booking scenarios, bus ticket booking scenarios, etc.), e-commerce scenarios, customer service scenarios, etc. Then the above-mentioned dialogue sample data can be dialogue data in the specific scenario to which the method is applied, etc. The above-mentioned dialogue model can be a dialogue model in the scenario to which the method is applied, which can be used to extract features from the user's input data in the scenario for subsequent target tasks, etc. For example, the target task may include but is not limited to user intent recognition, and outputting corresponding reply information based on the recognized user intent, etc.

[0060] In the model training process of this embodiment, the first category of word pairs and the second category of word pairs can be determined based on the dialogue sample data, and the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships. Based on the dialogue sample data, the first category of word pairs and the second category of word pairs, the initial dialogue model can be trained through a comparative learning strategy to obtain a target dialogue model. In this way, the dialogue model can learn the similarities and differences in the dialogue sample data, so that the dialogue model can better distinguish between the same and different data, etc., and improve the performance of the dialogue model.

[0061] In one embodiment, the initial dialogue model includes an initial language model, and the target dialogue model includes a target language model;

[0062] Through the contrast learning strategy, the initial dialogue model is trained based on the dialogue sample data, the first type of word pairs, and the second type of word pairs to obtain the target dialogue model, including:

[0063] Determine the semantic vectors of words in the conversation sample data through the initial language model;

[0064] Determining a result of a target loss function of a contrastive learning strategy based on the semantic vectors of the two words in each word pair of the first category of word pairs and the semantic vectors of the two words in each word pair of the second category of word pairs;

[0065] Based on the result of the target loss function, the initial language model is trained to obtain the target language model.

[0066] It can be understood that the language model in the embodiment of the present application can be a pre-trained language model, which is a type of text encoder. The model training process is the process of continuously adjusting the model parameters according to the result of the loss function. In the model training process of the embodiment of the present application, the target language model can be obtained by training the initial language model through the contrast learning strategy. In this process, the initial language model can be used to determine the semantic vectors of the words in the dialogue sample data. In this way, the semantic vectors of the two words in each word pair of the first category of word pairs and the semantic vectors of the two words in each word pair of the second category of word pairs can be obtained. Then, the semantic vectors of the two words in each word pair of the first category of word pairs and the semantic vectors of the two words in each word pair of the second category of word pairs are used to obtain the result of the target loss function of the contrast learning strategy. The initial language model is trained by comparing the result of the target loss function of the learning strategy to obtain the target language model, so that the target language model can better distinguish between the same and different semantic data, etc., and improve the model performance.

[0067] In addition, it should be noted that the dialogue sample data is input into the initial language model, and the semantic vector of each word (word) in the dialogue sample data is obtained through the initial language model; according to the semantic vector of each word in the dialogue sample data, the semantic vector of each word (corresponding to the entity, which can also be called entity word) in the dialogue sample data is determined. For example, entity recognition can be performed on the dialogue sample data to obtain the words of the dialogue sample data, and for each word in the dialogue sample data subjected to entity recognition, the semantic vector of the word is obtained according to the semantic vector of each word in the word. There are many ways to obtain the semantic vector of the word according to the semantic vector of each word in the word, which are not specifically limited. For example, the semantic vector of the word can be obtained by performing pooling processing based on the semantic vector of each word in the word. More specifically, the average of the semantic vectors of each word in the word can be used as the semantic vector of the word.

[0068] In some embodiments, there are multiple dialogue sample data, and the result of the target loss function is the sum of the values ​​of the semantic contrast loss function of the dialogue sample data in the multiple dialogue sample data. The value of the semantic contrast loss function of each dialogue sample data is obtained by:

[0069] The semantic vectors of the two words in each word pair of the first category of the dialogue sample data and the semantic vectors of the two words in each word pair of the second category of the dialogue sample data are calculated.

[0070] Since there may be multiple dialogue sample data, the above process of determining the first category word pairs and the second category word pairs can be performed for each dialogue sample data, so that the first category word pairs and the second category word pairs corresponding to each dialogue sample data can be obtained. In the training process, training can be performed based on multiple dialogue sample data and the first category word pairs and the second category word pairs corresponding to the multiple dialogue sample data. For each dialogue sample data, the value of the semantic contrast loss function corresponding to the dialogue sample data of the contrast learning strategy can be obtained based on the semantic vectors of the two words in each word pair of the first category word pairs of the dialogue sample data and the semantic vectors of the two words in each word pair of the second category word pairs of the dialogue sample data. For each dialogue sample data, similar operations are performed, so that the values ​​of the semantic contrast loss functions corresponding to the multiple dialogue sample data can be obtained. The sum of the values ​​of the semantic contrast loss functions corresponding to the multiple dialogue sample data can be used as the result of the target loss function for model training to improve the model performance.

[0071] In some embodiments, the initial dialogue model further includes an initial graph encoder, and the target dialogue model further includes a target graph encoder; the dialogue sample data is multiple;

[0072] Through the contrast learning strategy, the initial dialogue model is trained based on the dialogue sample data, the first type of word pairs, and the second type of word pairs to obtain the target dialogue model, including:

[0073] For each of the multiple dialogue sample data, based on the semantic vectors of the words in the dialogue sample data, the positional relationship of the words in the dialogue sample data, the dialogue roles included in the dialogue sample data, and the semantic reference relationship between the words in the dialogue sample data, a dialogue graph of the dialogue sample data is constructed, wherein the dialogue graph includes N nodes and connection relationships between the N nodes, the nodes are used to represent the semantic vectors of the words or the dialogue roles, the number of nodes corresponding to the same dialogue role in the dialogue graph is the same as the number of dialogues of the dialogue role in the dialogue sample data, different nodes of the same dialogue role correspond to different dialogue contents, connections between nodes with the same semantic reference relationship in the dialogue graph, connections between nodes of the same dialogue role, connections between nodes of different dialogue roles with dialogues, connections between nodes of each dialogue role and nodes corresponding to each word in the dialogue content corresponding to the node, and connections between nodes corresponding to adjacent words in the dialogue sample data;

[0074] Determine the global feature representation of each conversation graph and the node feature vector of each node in each conversation graph through the initial graph encoder;

[0075] Based on at least one first sample pair and at least one second sample pair, an initial graph encoder is trained to obtain a target graph encoder, wherein the first sample pair includes a global feature representation of a first conversation graph and a node feature representation of each node in the first conversation graph, and the first conversation graph is any conversation graph among multiple conversation graphs, and the second sample pair includes a global feature representation of the first conversation graph and a node feature representation of each node in the second conversation graph, and the second conversation graph is any conversation graph among the multiple conversation graphs except the first conversation graph.

[0076] It should be noted that each node in the dialogue graph representing the semantic vector of a word corresponds to a semantic vector representing a word, and different nodes in the nodes representing the semantic vector of a word correspond to the semantic vectors of different words. Each node in the dialogue graph representing the dialogue role corresponds to a dialogue role, and different nodes in the nodes representing the dialogue role may correspond to different dialogue roles or the same dialogue role. The number of the same dialogue role in the dialogue graph corresponding to the dialogue sample data is the same as the number of dialogues of the dialogue role in the dialogue sample data set. For example, as in the above example, user A had two conversations, the content of the first conversation was "I want to take a train to city X on Monday, why's it available?", and the content of the second conversation was "...book a table for 5 people at 21:00 on the same day, please." The system had two conversations, the content of the first conversation was "I have several possibilities for Monday.", and the content of the second conversation was "OK. The table will be reserved for 15 minutes." In the corresponding conversation graph, there are two nodes of user A, one node corresponds to the first conversation content of user A, the nodes of each word in the first conversation content of user A are connected to the node, and there are edges between adjacent words in the first conversation content of user A; the other node of user A corresponds to the second conversation content of user A, the nodes of each word in the second conversation content of user A are connected to the node, and there are edges between adjacent words in the second conversation content of user A, and the two nodes corresponding to user A are connected. There are also two nodes corresponding to the system role. One node corresponds to the first conversation content of the system, and has a dialogue with the node of the first conversation content of user A, has an edge, and the nodes of each word in the first conversation content of the system are connected to the node, and there is an edge between adjacent words in the first conversation content of the system; another node corresponding to the system role corresponds to the second conversation content of the system, and has a dialogue with the node of the second conversation content of user A, and also has an edge, and the nodes of each word in the second conversation content of the system are connected to the node, and there is an edge between adjacent words in the second conversation content of the system, and the two nodes corresponding to the system role are connected. In addition, in the conversation graph, the node representation (embedding) of the node of the conversation role can be obtained according to the semantic vectors of all nodes connected to the node, for example, it can be the mean of the semantic vectors of all nodes connected to the node. In addition, it should be noted that in this embodiment, adjacent can be understood as positional adjacent in the conversation sample data.

[0077] For each of the multiple dialogue sample data, a corresponding dialogue graph is established through the above process, and multiple dialogue graphs can be obtained. Subsequently, each of the multiple dialogue graphs can be input into the initial graph encoder, and the global feature representation of each of the multiple dialogue graphs and the node feature vector of each node in each dialogue graph can be determined through the initial graph encoder. Then, according to the global feature representation of the multiple dialogue graphs and the node feature vector of each node in the multiple dialogue graphs, at least one first sample pair and at least one second sample pair can be constructed, and the initial graph encoder is trained using the at least one first sample pair and the at least one second sample pair to obtain a target graph encoder. It should be noted that at least one first sample pair corresponds to at least one dialogue graph, and each first sample pair includes a global feature representation of a dialogue graph and a node feature representation of each node in the dialogue graph, and the corresponding first sample pair includes the global feature representation of the dialogue graph and the node feature representation of each node in another dialogue graph.

[0078] In this implementation, the semantic feature information corresponding to the dialogue sample data is used in the language model training process. In this embodiment, a graph encoder can also be trained. The graph structure can represent the structured information of the dialogue sample data. The graph structure information corresponding to the dialogue sample data can be used to train the graph encoder to obtain a target graph encoder to improve the dialogue model performance.

[0079] In some embodiments, performing initial graph encoder training based on at least one first sample pair and at least one second sample pair to obtain a target graph encoder includes:

[0080] Inputting at least one first sample pair and at least one second sample pair into a discriminator for identification respectively;

[0081] Determine the result of the graph contrast loss function based on the mutual information output by the discriminator;

[0082] Based on the result of the graph contrast loss function, the initial graph encoder is trained to obtain the target graph encoder.

[0083] It can be understood that the result output by the discriminator may include the mutual information (MI) between the global feature representation of the first conversation graph corresponding to each first sample pair and each node in the first conversation graph, and the mutual information between the global feature representation of the first conversation graph corresponding to each second sample pair and each node in the second conversation graph.

[0084] Mutual information can be used to measure the correlation between two pieces of information. In this implementation, the corresponding mutual information can be obtained based on the first sample pair through the discriminator, and the corresponding mutual information can be obtained based on the second sample pair through the discriminator. The result of the graph contrast loss function is determined by the mutual information output by the discriminator, which can also be understood as the result of the structural contrast loss function. Based on the result of the graph contrast loss function, the initial graph encoder is trained so that the graph encoder can learn the structural information of the dialogue sample data and improve the performance of the trained target graph encoder.

[0085] like Figure 2 As shown, a conversation method is also provided, which can be applied to a second electronic device, the second electronic device can be the same as or different from the first electronic device, the second electronic device can be a terminal, or a server device, etc., the method includes:

[0086] Step 201: Obtaining dialogue input data.

[0087] The dialogue input data may be understood as dialogue data input by the user during the actual application process.

[0088] Step 202: Determine a feature vector of the dialogue input data through a target dialogue model, wherein the target dialogue model is a target dialogue model trained by the above-mentioned dialogue model training method.

[0089] Step 203: Based on the feature vector of the dialogue input data, output the operation result of the dialogue input data.

[0090] The operation result here can be the operation result obtained after performing corresponding tasks (for example, including but not limited to tasks in information query scenarios (for example, weather query, etc.), information booking scenarios (air ticket booking scenarios, high-speed rail ticket booking scenarios, ship ticket booking scenarios, bus ticket booking scenarios, etc.), e-commerce scenarios, customer service scenarios, etc.) based on the feature vector of the dialogue input data. For example, in the weather query scenario, the user inputs the dialogue data "Please query the weather of city B today", and the operation result of the specific weather of city B today can be output. It should be noted that the feature vector of the dialogue input data can be the semantic feature output by the target language model in the target dialogue model, or it can be a global representation of the dialogue graph corresponding to the dialogue input data output by the target graph encoder (the construction process is similar to the dialogue graph construction process of the above-mentioned dialogue sample data, the difference is that the former is the dialogue input data and the latter is the dialogue sample data) and the node feature representation of each node of the dialogue graph.

[0091] The above process is described in detail below with reference to some specific embodiments.

[0092] Introduction of related technologies:

[0093] Task-Oriented Dialogue Systems (TODS) are an important research direction in the field of artificial intelligence. They aim to help users efficiently complete specific tasks, such as booking a hotel, checking the weather, etc., through natural language interaction. The core of this system is to understand the user's intentions and provide accurate information and operational guidance during the conversation. To achieve this goal, TODS needs to have strong language understanding, dialogue management, and task execution capabilities. With the development of technology, the design and implementation of TODS are also constantly improving. For example, by integrating natural language processing technology, TODS can more accurately identify user instructions and needs, thereby providing more personalized services. In addition, TODS can also continuously optimize its dialogue strategy through machine learning algorithms to better adapt to the behavior patterns and preferences of different users. The widespread application of this system not only improves people's life efficiency, but also brings convenience to business operations. For example, in e-commerce, customer service and other fields, TODS can significantly improve user experience and business processing efficiency.

[0094] In recent years, deep learning technology, especially large language models (LLM), has been increasingly used in TODS. LLM can automatically learn and understand natural language through pre-training and fine-tuning, so that it performs well in multi-round conversations. Such models are usually trained on large-scale text data to learn the patterns and structures of language, enabling them to understand and generate natural language. In TODS, LLM can be used to understand user queries, generate appropriate answers, and even provide assistance in complex tasks. For example, a TODS based on LLM can handle complex booking tasks, not only understanding the date, location, and type of booking that the user wants to make, but also recommending appropriate options based on the user's preferences. In addition, LLM can continuously improve its performance in specific tasks through continuous learning and optimization, making TODS more intelligent and efficient. The widespread application of this technology has not only promoted the development of TODS, but also provided new possibilities for the application of artificial intelligence in other fields.

[0095] However, there are inherent differences in language features between plain text and conversation context, which reduces the practicality of plain text pre-trained language models in task-based dialogue systems. The language information and context contained in plain text data may not always be applicable in dialogue systems. Dialogue systems need to deal with interactive and dynamic language environments, where users' intentions and needs may change as the conversation progresses. Therefore, plain text pre-trained language models may not be able to fully capture this dialogue dynamics and context dependency.

[0096] In the related art, the inherent differences in language features between plain text and conversation contexts have reduced the practicality of plain text pre-trained language models in task-based dialogue systems. This difference is mainly reflected in the interactivity and dynamics of the dialogue. In a dialogue, the user's intentions and needs are constantly changing as the dialogue progresses, while plain text data often lacks this dynamicity. Therefore, it is difficult for traditional pre-trained language models to capture the context changes in the dialogue and the evolution of user intentions. For example, in a task-based dialogue, users may make a request and then adjust or refine their needs based on the system's response. This dynamic change requires the dialogue system to be able to update its understanding of the user's intentions in real time. However, plain text pre-trained models often cannot do this because they do not learn this dialogue dynamics during the pre-training stage. In addition, the context information in the dialogue is often non-linear, that is, the user's current utterance may be associated with multiple previous utterances, and plain text models have difficulty handling such complex contextual relationships.

[0097] In addition, the relevant technologies cannot fully capture the flow of dialogue information and context dependencies. One of the core challenges of dialogue systems is to understand and predict the flow of information in dialogues. During a dialogue, the transmission and update of information are continuous, not isolated. Every sentence of the user may depend on the content of the previous dialogue, and the response of the system also needs to consider the overall intentions and needs of the user. Existing pre-trained language models, such as BERT, although they perform well in processing general text data, face challenges in context dependencies when processing dialogue data. These models usually lack a deep understanding of dialogue structure and the laws of information flow, resulting in poor performance in tasks such as dialogue state tracking and intent recognition. To address this problem, researchers need to develop new pre-training strategies that enable models to better understand and predict information flow and context dependencies in dialogues.

[0098] Moreover, entities are important elements for a coherent understanding of the entire conversation, and related technologies cannot fully acquire or utilize the semantic and structural associations referred to by conversation entities. In task-based conversations, entity recognition and linking are key to understanding user intentions and needs. However, existing pre-trained language models often have limitations when dealing with entities in conversations. These models may not be able to accurately recognize and link entities in conversations, especially when faced with abbreviations, synonyms, or implicit entities in context. In addition, entities in conversations are often polysemous, that is, the same word may refer to different entities in different contexts. Traditional pre-trained models have difficulty handling this polysemousness because they do not learn enough contextual information during the pre-training stage to distinguish the semantic and structural associations of different entities. Therefore, researchers need to develop new models and technologies to improve the accuracy and robustness of entity recognition and linking in dialogue systems.

[0099] The embodiments of the present application provide a model training method that can more efficiently handle the dynamics and contextual dependencies in conversations and truly utilize conversation context information. By combining pre-trained and fine-tuned models and adjusting the training process, the problem of reduced practicality of current pure text pre-trained models in task-based conversation systems is solved. Specifically, this proposal will adopt a Transformer-based pre-training model and introduce conversation context information in the pre-training stage. In this way, the model can learn the interactivity and dynamics in the conversation during the pre-training stage, so as to better handle task-based conversation data in the fine-tuning stage.

[0100] In addition, the proposal of the embodiment of the present application will also adopt the objective function of contrastive learning to fully learn the semantic and structural associations between entities, and further enhance the model's ability to understand the context of the conversation. By designing a unified framework, this proposal fully integrates the reference information into the pre-training process from both semantic and structural aspects. Specifically, the design of the objective function of contrastive learning enables the model to recognize and distinguish the subtle differences between different entities. Usually in a conversation, the identification and linking of entities are the key to understanding user intentions and needs. However, the ambiguity of entities and the implicit entities in the context make this task complicated. Through contrastive learning, the model is able to learn the semantic similarities and differences between entities, so as to more accurately identify and link entities in the conversation. Through the objective function of contrastive learning and a unified pre-training framework, this proposal significantly improves the model's ability to understand the context of the conversation, providing strong support for building a more intelligent task-based dialogue system.

[0101] In addition, the pre-trained language models are applied to task-based dialogue systems, taking advantage of the powerful language understanding capabilities of these models. However, most studies in related technologies have achieved effective processing of general text data, but have not been able to achieve in-depth understanding of dialogue data. In order to solve this problem, the proposal of the embodiment of the present application will introduce contextual information in unlabeled dialogue sample data into the pre-training process through unsupervised learning, so that the model can better capture the information flow and contextual dependencies in the dialogue. In this way, the model can not only process general text data, but also understand and predict the information flow in the dialogue, thereby improving the performance of the task-based dialogue system.

[0102] The model (CECPT) proposed in the proposal of the embodiment of the present application may include two components: semantic pre-training and graph structure pre-training, such as Figure 3 shown.

[0103] First, preprocessing is performed, including the use of the AllenNLP toolkit and the modification of the parsed reference pairs during pre-training:

[0104] In order to build extensive and role-sensitive graph learning dialogue knowledge from large-scale task-oriented datasets (dialogue sample data), CECPT uses automatic coreference resolution tools to parse connected multi-turn utterances into a predefined graph structure. Considering the potential relations between the words mentioned (also known as mentions) in the dialogue history, pre-trained coreference resolution relations will naturally benefit the coreference-enhanced relation modeling work in dialogue texts.

[0105] Secondly, dialogue semantic pre-training:

[0106] For example, a conversation sample data d consists of a series of constituent utterances (conversation content), denoted as (u1, u2, ..., uN). Each utterance can consist of multiple tokens. A multi-layer Transformer architecture is used, and the token representation is extracted from the hidden vector of the final layer. In addition, in order to distinguish the role of the speaker in the conversation, role tags are added before each utterance, for example, [USR] and [SYS]. In addition, a special [CLS] tag is added at the beginning of the conversation.

[0107] like Figure 4 As shown, the semantic contrast model (language model) takes the current dialogue discourse (e.g., OK. The table will be reserved for 15 minutes.), the previous dialogue discourse (e.g., I want to take a train to city X on Monday, who's available? ... book a table for 5 people at 21:00 on the same day, please. I have several possibilities for Monday.) and the reference resolution results (i.e., the corresponding first category word pairs and the second category word pairs) as input, adopts the pre-trained language model (PLM) as the text encoder, and trains it to distinguish the various reference pairs (i.e., the corresponding word pairs) mentioned in the dialogue.

[0108] A coreference discriminator can be used as a semantic contrast pre-training task, with the goal of promoting close representations of words or mentions that share a semantic coreference relationship, compared to pairs with different semantic coreference relationships. Using these coreference pairs as positive samples (corresponding to the first category of word pairs), the text encoder is trained to distinguish them from coreference pairs that exhibit different semantic coreference connections (as negative samples, corresponding to the second category of word pairs). Therefore, this approach enables the text encoder to capture conversational coreference semantics without the need for human annotation.

[0109] For example, a word pair (c, c') is a positive example pair (positive reference pair, a word pair in the first category of word pairs), they belong to the same entity and share a semantic reference relationship, such as Figure 4 Specifically, by randomly sampling, one mention of 'c' in the original positive example pair is replaced with a mention from the labeled Another negative reference in c (e.g., 'a train'), randomly sample c with replacement m c times, get m c The number of negative pairs is randomly sampled and replaced by m for c' c ' times, get m c ′Number of negative pairs. In order to distinguish positive pairs from negative pairs, a training target is established for the positive pairs (c, c'), and the contrast loss (i.e., the value of the semantic contrast loss function corresponding to the positive pairs (c, c')) is used to correctly classify the positive pairs:

[0110]

[0111] Where x represents the semantic vector of a word / mention (e.g., word c), and W is the number of matrix parameters (i.e., the matrix parameters in the initial language model) for learning similarities between word pairs. c,c′ represents the value of the semantic contrast loss function corresponding to the word pair including word c and word c' (a positive reference pair), x c′ Represents the semantic vector of word c', represents the transposition of the semantic vector of word c, The word that replaces word c for the i-th time The transpose of the semantic vector, is the word that replaces word c' for the jth time The semantic vector of .

[0112] Therefore, in order to obtain the overall training goal of referential semantic pre-training, the word pair set P corresponding to all dialogue sample data d in the batch Bd (multiple dialogue sample data) is d The losses of all positive reference pairs in (the first type of word pairs corresponding to the dialogue sample data d) are summed to obtain the result L of the target loss function:

[0113]

[0114] Then the dialogue structure is pre-trained:

[0115] Since referentially related entities can be connected to each other, graph representations can effectively capture structural information, thus facilitating the modeling of interconnected mentions in multi-round conversations. In this training process, we first introduce the construction of the conversation graph and then explain how to learn the conversation structure using the graph comparison mechanism.

[0116] First, the conversation diagram is constructed:

[0117] Each type of node or edge is used to encode a certain information or information flow in the conversation, such as Figure 5 The two left graphs are shown. For nodes, the embeddings of word and utterance nodes can be initialized using a text encoder, and the embeddings of all word nodes for each mention / word are averaged to obtain the embeddings of the mention / word node. For edges, each word node in an utterance is connected to the utterance node (also known as the node of the dialogue role), and is connected to its neighboring word nodes through the context represented by the dotted line, as shown in Figure 5 Each utterance node can also be connected to p (integer) recent past utterances and f (integer) future utterances.

[0118] Secondly, graph contrast learning mechanism:

[0119] like Figure 5 As shown in the figure, the structural contrastive model (graph encoder) takes a predefined conversation graph as input, initializes node embedding using the above text encoder, and maximizes the mutual information between a single node representation and the overall graph representation through contrastive learning. In order to learn the conversation structure without losing too much conversation semantic information and reduce the cost of manual annotation, Infograph can be used to perform unsupervised pre-training on the conversation graph. Infograph uses mutual information (MI) as the core indicator and learns the graph structure by maximizing the mutual information between node representation and graph representation through contrastive learning.

[0120] For example, there is a batch of conversation graph samples, including N conversation graphs (G1, G2, ... GN), taking G1 as an example, where node v∈G1 (i.e. G1). The graph encoder is a K-layer graph isomorphism network GIN. When graph G1 is input to the graph encoder, the k-th layer representation of node v can be obtained according to the following formula:

[0121]

[0122] in, represents the embedding of node v in the kth layer (i.e., the feature vector of node v in the kth layer), N (v) Represents the neighbor nodes of node v. represents the k-1th layer representation of node μ, represents the k-1th level representation of node v. (k)(·) represents the multilayer perceptron in the kth layer of the graph encoder, ∈ (k) Represents the combined parameters of the graph encoder at layer k.

[0123] By connecting the representations of all layers, we can get the representation of node v as follows:

[0124]

[0125] where h v represents the representation of node v (node ​​feature vector of node v), and g(·) represents the connection operation.

[0126] The representation of the conversation graph (global feature representation) can be obtained by concatenating and summing the representations of the nodes in each graph:

[0127]

[0128] H G1 It is the global feature representation of the conversation graph G1 (ie G1), and g(·) represents the connection operation. It should be noted that the connection operation in the embodiment of the present application can be an average or a dimension connection, for example, two 10-dimensional vectors become a 20-dimensional vector after dimension connection, etc. Among them, sum represents the summing and pooling operation. After obtaining the global feature representation, construct positive sample pairs (first sample pairs) and negative sample pairs (second sample pairs), and send them to the discriminator to continuously learn the representation of the graph. In a batch of samples, the global feature representation of the conversation graph and the node representation of its own nodes are taken as positive sample pairs, and the global feature representation of the conversation graph in the same batch and the node representation of the nodes in other conversation graphs are taken as negative sample pairs.

[0129] by Figure 5 Take the graphs GA and GB in the figure as an example. Through the graph encoder, we can obtain the node representation of graph GA (corresponding to the thin solid box in the figure), the global representation of graph GA (corresponding to the dotted box in the figure), and the node representation of graph GB (corresponding to the thick solid box in the figure). Then the global feature representation and node representation of graph GA can constitute a positive sample pair, and the global representation of graph GA and the node representation of graph GB can constitute a negative sample pair. Subsequently, both positive and negative sample pairs are sent to the discriminator to calculate and maximize the mutual information (MI). A method similar to the Infograph algorithm is used, and its structural pre-training loss L G (i.e., the result of the graph contrast loss function) is calculated as follows:

[0130]

[0131] where φ is the parameter of the discriminator D, is the parameter of GIN, The output of the discriminator and The mutual information between them, y′ is the negative sample corresponding to the input sample y, N is the total number of graphs, is the total number of nodes, v i Represents the number of nodes in graph i. represents the global representation of graph i (i.e., global feature representation), Represents the local representation of node j in graph i (i.e., node feature representation). sp(·) is a softplus function (an activation function). It can represent the average mutual information corresponding to the positive sample pairs, It can represent the average mutual information of negative sample pairs.

[0132] The proposal of the embodiment of the present application proposes an innovative dialogue modeling framework, which adopts a contrast pre-training strategy and explicitly integrates the information flow guided by reference. Through this strategy, the semantic coherence and structural consistency in the dialogue can be captured more effectively. In addition, by incorporating the reference information into the pre-training process, the modeling of the semantic and structural dimensions of the dialogue is achieved within a unified framework. This method not only enhances the model's understanding of the dialogue context, but also improves its ability to handle complex dialogue structures. The proposal implemented in this application is to use a graph contrast training mechanism to explore the semantic and structural levels in dialogue modeling. The solution of this embodiment shows good performance improvement in multiple downstream tasks (for example, intent recognition, etc.), which provides new perspectives and possibilities for further research and application of dialogue systems.

[0133] like Figure 6 As shown, Figure 6 is a structural diagram of a dialogue model training device provided in an embodiment of the present application, such as Figure 6 As shown, the dialogue model training device 600 includes:

[0134] The first acquisition module 601 is used to acquire conversation sample data;

[0135] A first determination module 602 is used to determine, based on the conversation sample data, a first category of word pairs and a second category of word pairs, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships;

[0136] The training module 603 is used to train the initial dialogue model through a comparative learning strategy based on the dialogue sample data, the first type of word pairs and the second type of word pairs to obtain a target dialogue model.

[0137] In some embodiments, the initial dialogue model includes an initial language model, and the target dialogue model includes a target language model;

[0138] The training module 603 includes:

[0139] A semantic vector determination module, used to determine the semantic vectors of words in the dialogue sample data through an initial language model;

[0140] A first loss determination module, configured to determine a result of a target loss function of a contrastive learning strategy based on semantic vectors of two words in each word pair of the first category of word pairs and semantic vectors of two words in each word pair of the second category of word pairs;

[0141] The first model training module is used to train the initial language model based on the result of the target loss function to obtain the target language model.

[0142] In some embodiments, there are multiple dialogue sample data, and the result of the target loss function is the sum of the values ​​of the semantic contrast loss function of the dialogue sample data in the multiple dialogue sample data. The value of the semantic contrast loss function of each dialogue sample data is obtained by:

[0143] The semantic vectors of the two words in each word pair of the first category of the dialogue sample data and the semantic vectors of the two words in each word pair of the second category of the dialogue sample data are calculated.

[0144] In some embodiments, the initial dialogue model further includes an initial graph encoder, and the target dialogue model further includes a target graph encoder; the dialogue sample data is multiple;

[0145] The training module 603 further includes:

[0146] A construction module is used to construct a dialogue graph of the dialogue sample data for each dialogue sample data in the plurality of dialogue sample data based on the semantic vectors of words in the dialogue sample data, the positional relationship of words in the dialogue sample data, the dialogue roles included in the dialogue sample data, and the semantic reference relationship between words in the dialogue sample data, wherein the dialogue graph includes N nodes and connection relationships between the N nodes, the nodes are used to represent the semantic vectors of words or dialogue roles, the number of nodes corresponding to the same dialogue role in the dialogue graph is the same as the number of dialogues of the dialogue role in the dialogue sample data, different nodes of the same dialogue role correspond to different dialogue contents, connections between nodes with the same semantic reference relationship in the dialogue graph, connections between nodes of the same dialogue role, connections between nodes of different dialogue roles with dialogues, connections between nodes of each dialogue role and corresponding words in the dialogue content corresponding to the node, and connections between nodes corresponding to adjacent words in the dialogue sample data;

[0147] A graph feature vector determination module, used to determine the global feature representation of each conversation graph and the node feature vector of each node in each conversation graph through an initial graph encoder;

[0148] The second training module is used to perform initial graph encoder training based on at least one first sample pair and at least one second sample pair to obtain a target graph encoder, wherein the first sample pair includes a global feature representation of a first conversation graph and a node feature representation of each node in the first conversation graph, and the first conversation graph is any conversation graph among multiple conversation graphs, and the second sample pair includes a global feature representation of the first conversation graph and a node feature representation of each node in the second conversation graph, and the second conversation graph is any conversation graph among the multiple conversation graphs except the first conversation graph.

[0149] In some embodiments, the second training module includes:

[0150] An input module, used for inputting at least one first sample pair and at least one second sample pair into a discriminator for identification respectively;

[0151] A second loss determination module, used to determine a result of a graph contrast loss function according to the mutual information output by the discriminator;

[0152] The graph encoder training module is used to train the initial graph encoder based on the result of the graph contrast loss function to obtain the target graph encoder.

[0153] The device 600 provided in this embodiment can implement each process of each embodiment of the above-mentioned dialogue model training method applied to the first electronic device. The technical features correspond one to one and can achieve the same technical effect. To avoid repetition, they will not be described here.

[0154] See also Figure 7 , Figure 7 is a structural diagram of a dialogue device provided in an embodiment of the present application, such as Figure 7 As shown, the dialogue device 700 includes:

[0155] The second acquisition module 701 is used to acquire dialogue input data;

[0156] A feature determination module 702, used to determine a feature vector of the dialogue input data through a target dialogue model;

[0157] An output module 703, used for outputting the operation result of the dialogue input data based on the feature vector of the dialogue input data;

[0158] Among them, the target dialogue model is the target dialogue model trained by the above-mentioned dialogue model training method.

[0159] The device 700 provided in this embodiment is capable of implementing each process of each embodiment applied to the above-mentioned dialogue method, and the technical features correspond one to one and can achieve the same technical effect. To avoid repetition, they will not be described here.

[0160] An embodiment of the present application also provides an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor. When the program is executed by the processor, each process of the above-mentioned embodiment of the dialogue model training method applied to the first electronic device is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0161] For details, see Figure 8 An embodiment of the present application further provides an electronic device, including a bus 801, a transceiver 802, an antenna 803, a bus interface 804, a processor 805 and a memory 806.

[0162] The processor 805 is used for:

[0163] Get conversation sample data;

[0164] Based on the dialogue sample data, determine the first category of word pairs and the second category of word pairs, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships;

[0165] Based on the dialogue sample data, the first type of word pairs and the second type of word pairs, the initial dialogue model is trained through a comparative learning strategy to obtain the target dialogue model.

[0166] In some embodiments, the initial dialogue model includes an initial language model, and the target dialogue model includes a target language model;

[0167] The processor 805 is specifically configured to:

[0168] Determine the semantic vectors of words in the conversation sample data through the initial language model;

[0169] Determining a result of a target loss function of a contrastive learning strategy based on the semantic vectors of the two words in each word pair of the first category of word pairs and the semantic vectors of the two words in each word pair of the second category of word pairs;

[0170] Based on the result of the target loss function, the initial language model is trained to obtain the target language model.

[0171] In some embodiments, there are multiple dialogue sample data, and the result of the target loss function is the sum of the values ​​of the semantic contrast loss function of the dialogue sample data in the multiple dialogue sample data. The value of the semantic contrast loss function of each dialogue sample data is obtained by:

[0172] The semantic vectors of the two words in each word pair of the first category of the dialogue sample data and the semantic vectors of the two words in each word pair of the second category of the dialogue sample data are calculated.

[0173] In some embodiments, the initial dialogue model further includes an initial graph encoder, and the target dialogue model further includes a target graph encoder; the dialogue sample data is multiple;

[0174] The processor 805 is specifically configured to:

[0175] For each of the multiple dialogue sample data, based on the semantic vectors of the words in the dialogue sample data, the positional relationship of the words in the dialogue sample data, the dialogue roles included in the dialogue sample data, and the semantic reference relationship between the words in the dialogue sample data, a dialogue graph of the dialogue sample data is constructed, wherein the dialogue graph includes N nodes and connection relationships between the N nodes, the nodes are used to represent the semantic vectors of the words or the dialogue roles, the number of nodes corresponding to the same dialogue role in the dialogue graph is the same as the number of dialogues of the dialogue role in the dialogue sample data, different nodes of the same dialogue role correspond to different dialogue contents, connections between nodes with the same semantic reference relationship in the dialogue graph, connections between nodes of the same dialogue role, connections between nodes of different dialogue roles with dialogues, connections between nodes of each dialogue role and nodes corresponding to each word in the dialogue content corresponding to the node, and connections between nodes corresponding to adjacent words in the dialogue sample data;

[0176] Determine the global feature representation of each conversation graph and the node feature vector of each node in each conversation graph through the initial graph encoder;

[0177] Based on at least one first sample pair and at least one second sample pair, an initial graph encoder is trained to obtain a target graph encoder, wherein the first sample pair includes a global feature representation of a first conversation graph and a node feature representation of each node in the first conversation graph, and the first conversation graph is any conversation graph among multiple conversation graphs, and the second sample pair includes a global feature representation of the first conversation graph and a node feature representation of each node in the second conversation graph, and the second conversation graph is any conversation graph among the multiple conversation graphs except the first conversation graph.

[0178] In some embodiments, the processor 805 is specifically configured to:

[0179] Inputting at least one first sample pair and at least one second sample pair into a discriminator for identification respectively;

[0180] Determine the result of the graph contrast loss function based on the mutual information output by the discriminator;

[0181] Based on the result of the graph contrast loss function, the initial graph encoder is trained to obtain the target graph encoder.

[0182] exist Figure 8 In the embodiment, the bus architecture (represented by bus 801) is shown, and bus 801 may include any number of interconnected buses and bridges, and bus 801 links various circuits including one or more processors represented by processor 805 and memory represented by memory 806. Bus 801 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 804 provides an interface between bus 801 and transceiver 802. Transceiver 802 may be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. Data processed by processor 805 is transmitted on a wireless medium via antenna 803, and further, antenna 803 also receives data and transmits the data to processor 805.

[0183] The processor 805 is responsible for managing the bus 801 and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. The memory 806 can be used to store data used by the processor 805 when performing operations.

[0184] Optionally, the processor 805 may be a CPU, an ASIC, an FPGA or a CPLD.

[0185] The processor in the electronic device 800 provided in this embodiment can implement each process of the above-mentioned embodiments applied to the training method. The technical features correspond one to one and can achieve the same technical effect. To avoid repetition, they will not be described here.

[0186] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the embodiment of the dialogue model training method applied to the first electronic device is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium is a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0187] An embodiment of the present application also provides an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor. When the program is executed by the processor, the various processes applied to the above-mentioned dialogue method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0188] For details, see Fig. 9 As shown, an embodiment of the present application further provides an electronic device, including a bus 901 , a transceiver 902 , an antenna 903 , a bus interface 904 , a processor 905 and a memory 906 .

[0189] The processor 905 is used for:

[0190] Get the dialogue input data;

[0191] Determine a feature vector of the dialogue input data through a target dialogue model;

[0192] Based on the feature vector of the dialogue input data, output the operation result of the dialogue input data;

[0193] The target dialogue model is a target dialogue model trained by the dialogue model training method of each of the above embodiments.

[0194] exist Fig. 9 In the embodiment, the bus architecture (represented by bus 901) may include any number of interconnected buses and bridges, and bus 901 links various circuits including one or more processors represented by processor 905 and memory represented by memory 906. Bus 901 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 904 provides an interface between bus 901 and transceiver 902. Transceiver 902 may be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. Data processed by processor 905 is transmitted on a wireless medium via antenna 903, and further, antenna 903 also receives data and transmits the data to processor 905.

[0195] The processor 905 is responsible for managing the bus 901 and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. The memory 906 can be used to store data used by the processor 905 when performing operations.

[0196] Optionally, the processor 905 may be a CPU, an ASIC, an FPGA or a CPLD.

[0197] The processor in the electronic device 900 provided in this embodiment can implement each process of the above-mentioned embodiments applied to the dialogue method. The technical features correspond one to one and can achieve the same technical effect. To avoid repetition, they will not be described here.

[0198] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process applied to the embodiment of the dialogue method described above is implemented, and the same technical effect can be achieved. To avoid repetition, it is not described here. Among them, the computer-readable storage medium is, for example, ROM, RAM, magnetic disk or optical disk.

[0199] The embodiments of the present application also provide a computer program product, including a computer program. When the computer program is executed by a processor, the various processes of the above-mentioned method embodiments are implemented and the same technical effects can be achieved. To avoid repetition, they are not described here.

[0200] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0201] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.

[0202] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A dialogue model training method, characterized in that: The method comprises: Get conversation sample data; Based on the conversation sample data, determining a first category of word pairs and a second category of word pairs, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships; Based on the dialogue sample data, the first category of word pairs, and the second category of word pairs, an initial dialogue model is trained through a comparative learning strategy to obtain a target dialogue model.

2. The method according to claim 1, characterized in that: The initial dialogue model includes an initial language model, and the target dialogue model includes a target language model; The method of training the initial dialogue model based on the dialogue sample data, the first type of word pairs, and the second type of word pairs through the comparative learning strategy to obtain the target dialogue model includes: Determining semantic vectors of words in the conversation sample data by using the initial language model; Determining a result of a target loss function of a contrastive learning strategy according to the semantic vectors of the two words in each word pair of the first category of word pairs and the semantic vectors of the two words in each word pair of the second category of word pairs; Based on the result of the target loss function, the initial language model is trained to obtain the target language model.

3. The method according to claim 2, characterized in that There are multiple dialogue sample data, and the result of the target loss function is the sum of the values ​​of the semantic contrast loss function of the dialogue sample data in the multiple dialogue sample data. The value of the semantic contrast loss function of each dialogue sample data is obtained by: The semantic vectors are calculated by using the semantic vectors of the two words in each word pair of the first category of the dialogue sample data and the semantic vectors of the two words in each word pair of the second category of the dialogue sample data.

4. The method according to claim 2, characterized in that: The initial dialogue model further includes an initial graph encoder, and the target dialogue model further includes a target graph encoder; the dialogue sample data is multiple; The method of training the initial dialogue model based on the dialogue sample data, the first type of word pairs, and the second type of word pairs through the comparative learning strategy to obtain the target dialogue model includes: For each of the multiple dialogue sample data, based on the semantic vectors of the words in the dialogue sample data, the positional relationship of the words in the dialogue sample data, the dialogue roles included in the dialogue sample data, and the semantic reference relationship between the words in the dialogue sample data, a dialogue graph of the dialogue sample data is constructed, wherein the dialogue graph includes N nodes and connection relationships between the N nodes, the nodes are used to represent the semantic vectors of the words or the dialogue roles, the number of nodes corresponding to the same dialogue role in the dialogue graph is the same as the number of dialogues of the dialogue role in the dialogue sample data, different nodes of the same dialogue role correspond to different dialogue contents, connections between nodes with the same semantic reference relationship in the dialogue graph, connections between nodes of the same dialogue role, connections between nodes of different dialogue roles with dialogues, connections between nodes corresponding to each dialogue role and each word in the dialogue content corresponding to the node, and connections between nodes corresponding to adjacent words in the dialogue sample data; Determining, by means of the initial graph encoder, a global feature representation of each conversation graph and a node feature vector of each node in each conversation graph; The initial graph encoder is trained based on at least one first sample pair and at least one second sample pair to obtain the target graph encoder, wherein the first sample pair includes a global feature representation of a first conversation graph and a node feature representation of each node in the first conversation graph, and the first conversation graph is any conversation graph among multiple conversation graphs, and the second sample pair includes a global feature representation of the first conversation graph and a node feature representation of each node in a second conversation graph, and the second conversation graph is any conversation graph among the multiple conversation graphs except the first conversation graph.

5. The method according to claim 4, characterized in that The performing the initial graph encoder training based on at least one first sample pair and at least one second sample pair to obtain the target graph encoder comprises: Inputting the at least one first sample pair and the at least one second sample pair into a discriminator for identification respectively; Determining a result of a graph contrast loss function based on the mutual information output by the discriminator; Based on the result of the graph contrast loss function, the initial graph encoder is trained to obtain the target graph encoder.

6. A conversation method, characterized in that: The method comprises: Get the dialogue input data; Determining a feature vector of the dialogue input data by using a target dialogue model; outputting an operation result of the dialogue input data based on a feature vector of the dialogue input data; Wherein, the target dialogue model is a target dialogue model trained by any one of the methods in claims 1 to 5.

7. A model training device, characterized in that: A first acquisition module, used to acquire conversation sample data; A first determination module is used to determine a first category of word pairs and a second category of word pairs based on the dialogue sample data, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships; A training module is used to train the initial dialogue model through a comparative learning strategy based on the dialogue sample data, the first type of word pairs and the second type of word pairs to obtain a target dialogue model.

8. An electronic device, characterized in that: Including transceiver and processor, The processor is configured to: Get conversation sample data; Based on the conversation sample data, determining a first category of word pairs and a second category of word pairs, wherein the two words in each word pair of the first category of word pairs belong to the same entity and have the same semantic reference relationship, and the two words in each word pair of the second category of word pairs do not belong to the same entity and have different semantic reference relationships; Based on the dialogue sample data, the first category of word pairs, and the second category of word pairs, an initial dialogue model is trained through a comparative learning strategy to obtain a target dialogue model.

9. An electronic device, characterized in that: include: A processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, the program implements the steps of the method according to any one of claims 1 to 5, or implements the steps of the method according to claim 6.

10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of any one of the methods of claims 1 to 5, or implements the steps of the method of claim 6.

11. A computer program product, characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dual learning for question answering (QA)

    CN113139119A

  • Dialogue text clustering method and related equipment

    CN117332086A

Cited By

  • Dialogue model training method and apparatus, dialogue method and apparatus, and electronic device

    WO2026026627A1