Dialogue discourse analysis and model training method, electronic device and storage medium
Through self-supervised learning and mask processing technology, it solves the time-consuming and labor-intensive problem of manual annotation in multi-round dialogue discourse analysis, improves model training efficiency and analysis accuracy, and achieves low-cost and efficient dialogue discourse analysis effects. .
Patent Information
- Application Number
- CN202210641346.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-08
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-06-08
AI Technical Summary
Existing multi-round dialogue discourse analysis methods require manual annotation, resulting in high model training costs and low efficiency, which in turn affects the efficiency and accuracy of dialogue discourse analysis.
Using a dialogue discourse analysis model based on self-supervised learning, by masking some rounds of dialogue, the generated masked feature vectors and unmasked feature vectors are differentially trained, which reduces the need for labeling dialogue data and improves efficiency. Model training efficiency and dialogue discourse analysis accuracy.
It effectively reduces model training costs, improves training efficiency, improves the accuracy of predicting relationships between multiple rounds of dialogue, and enables low-cost and efficient dialogue discourse analysis.
Smart Images

Figure CN114997182B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a method for analyzing a dialogue discourse, a method for training a dialogue discourse analysis model, and corresponding electronic equipment and computer storage media. Background Art
[0002] Conversation discourse analysis is a basic natural language processing task that can associate speeches in a conversation in the dimension of turns. It is widely used in processing two-person and multi-person conversations. In a two-person conversation, the main purpose of conversation discourse analysis is to align the speeches of both parties across turns; while for multi-person conversations, conversation discourse analysis mainly analyzes which context a given text is responding to, that is, which two texts constitute a contextual relationship.
[0003] Currently, most existing methods for analyzing conversational discourse are implemented through trained machine learning models, and these machine learning models generally adopt supervised learning in the training stage. This supervised learning method requires annotators to manually connect and annotate each speech in multiple rounds of conversations to indicate the contextual relationship between each speech. However, due to the complexity of multiple rounds of conversations, this annotation is very time-consuming and labor-intensive, resulting in high cost and low efficiency in model training, which in turn leads to high cost and low efficiency in conversational discourse analysis based on the trained model. Summary of the invention
[0004] In view of this, an embodiment of the present application provides a dialogue discourse analysis solution to at least partially solve the above problems.
[0005] According to a first aspect of an embodiment of the present application, a method for dialogue discourse analysis is provided, comprising: obtaining multiple rounds of dialogue to be analyzed; performing dialogue discourse analysis on the multiple rounds of dialogue using a pre-trained dialogue discourse analysis model, wherein the dialogue discourse analysis model is obtained by self-supervised training after masking some rounds of dialogue in a dialogue sample, and the dialogue sample is a sample containing multiple rounds of dialogue; and obtaining dialogue discourse analysis results between the multiple rounds of dialogue according to the output of the dialogue discourse analysis model.
[0006] According to a second aspect of an embodiment of the present application, a method for training a dialogue discourse analysis model is provided, comprising: obtaining a dialogue sample for dialogue discourse analysis training, wherein the dialogue sample includes multiple rounds of dialogue; obtaining a first feature vector corresponding to the multiple rounds of dialogue, and inputting the first feature vector into the dialogue discourse analysis model to be trained; performing masking on part of the first feature vector through the dialogue discourse analysis model, and encoding the masked first feature vector to generate a corresponding second feature vector; and performing self-supervised learning training on the dialogue discourse analysis model based on the difference between the second feature vector and the first feature vector.
[0007] According to a third aspect of an embodiment of the present application, another method for dialogue discourse analysis is provided, comprising: obtaining a customer service dialogue to be subjected to dialogue discourse analysis, the customer service dialogue comprising multiple rounds of dialogue; performing dialogue discourse analysis on the multiple rounds of dialogue using a pre-trained dialogue discourse analysis model, wherein the dialogue discourse analysis model is obtained by self-supervised training after masking some rounds of dialogue in a dialogue sample, and the dialogue sample is a sample comprising multiple rounds of dialogue; and obtaining a dialogue discourse analysis result of the customer service dialogue according to an output of the dialogue discourse analysis model.
[0008] According to a fourth aspect of an embodiment of the present application, another method for dialogue discourse analysis is provided, comprising: obtaining a medical service dialogue to be subjected to dialogue discourse analysis, wherein the medical service dialogue comprises multiple rounds of dialogue; performing dialogue discourse analysis on the multiple rounds of dialogue using a pre-trained dialogue discourse analysis model, wherein the dialogue discourse analysis model is obtained by self-supervised training after masking some rounds of dialogue in a dialogue sample, and the dialogue sample is a sample comprising multiple rounds of dialogue; and obtaining a dialogue discourse analysis result of the medical service dialogue according to an output of the dialogue discourse analysis model.
[0009] According to the fifth aspect of the embodiments of the present application, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method described in the first aspect, the second aspect, the third aspect or the fourth aspect.
[0010] According to a sixth aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect, the second aspect, the third aspect, or the fourth aspect is implemented.
[0011] According to a seventh aspect of an embodiment of the present application, a computer program product is provided, comprising computer instructions, wherein the computer instructions instruct a computing device to perform operations corresponding to the method described in the first aspect, the second aspect, the third aspect, or the fourth aspect.
[0012] According to the scheme provided by the embodiment of the present application, when conducting a multi-round dialogue discourse analysis, a dialogue discourse analysis model is used for analysis. Since the dialogue discourse analysis model in the embodiment of the present application is obtained by self-supervised training based on masking of some rounds of dialogue to obtain multiple rounds of dialogue, these dialogue data used for training do not need to be manually labeled, thereby effectively reducing the high cost of model training and improving the efficiency of model training, thereby also making the dialogue discourse analysis using the dialogue discourse analysis model have the effect of low cost and high efficiency. In addition, the self-supervised training of the dialogue discourse analysis model is based on the dialogue samples after masking, that is, in the dialogue samples including multiple rounds of dialogue, masking is performed on some rounds of dialogue, and the other parts are not masked. Based on the dialogue samples that include both masked dialogues and unmasked dialogues, self-supervised training is performed, so that the prediction of the dialogue discourse relationship between multiple rounds of dialogues is more accurate, and thus, the efficiency of using the dialogue discourse analysis model for dialogue discourse analysis is further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0014] Figure 1 A schematic diagram of an exemplary system for applying the method for analyzing dialogue discourse in an embodiment of the present application;
[0015] Figure 2A A flowchart of the steps of a method for training a dialogue discourse analysis model according to the first embodiment of the present application;
[0016] Figure 2B for Figure 2A A schematic diagram of an example scenario in the illustrated embodiment;
[0017] Figure 3A is a flowchart of the steps of a method for analyzing a dialogue discourse according to the second embodiment of the present application;
[0018] Figure 3B for Figure 3A A schematic diagram of an example scenario in the illustrated embodiment;
[0019] Figure 3C for Figure 3A A schematic diagram of another example scenario in the illustrated embodiment;
[0020] Figure 4 This is a schematic diagram of the structure of an electronic device according to the third embodiment of the present application. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0022] The specific implementation of the embodiment of the present application is further explained below in conjunction with the accompanying drawings of the embodiment of the present application.
[0023] Figure 1 An exemplary system applicable to the solution of the embodiment of the present application is shown. Figure 1 As shown, the system 100 may include a server 102, a communication network 104 and / or one or more user devices 106. Figure 1 The example in FIG. 1 is a plurality of user devices.
[0024] Server 102 may be any suitable server for storing information, data, programs, and / or any other suitable type of content. In some embodiments, server 102 may perform any suitable function. For example, in some embodiments, server 102 may be used to perform conversational discourse analysis. As an optional example, in some embodiments, server 102 may be used to perform conversational discourse analysis on multiple rounds of conversations using a conversational discourse analysis model. As another example, in some embodiments, a conversational discourse analysis model is deployed in server 102, and server 102 may also be used to train the conversational discourse analysis.
[0025] In some embodiments, the communication network 104 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 104 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN) and / or any other suitable communication network. The user device 106 can be connected to the communication network 104 via one or more communication links (e.g., communication link 112), and the communication network 104 can be linked to the server 102 via one or more communication links (e.g., communication link 114). The communication link can be any communication link suitable for transmitting data between the user device 106 and the server 102, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link or any suitable combination of such links.
[0026] The user device 106 may include any one or more user devices that collect multi-turn conversation data in various scenarios and send it to the server 102 for conversation discourse analysis. In some embodiments, the user device 106 may include any suitable type of device. For example, in some embodiments, the user device 106 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, a wearable computer, a game console, a media player, a vehicle entertainment system, and / or any other suitable type of user device.
[0027] Although server 102 is illustrated as one device, in some embodiments, any suitable number of devices may be used to perform the functions performed by server 102. For example, in some embodiments, multiple devices may be used to implement the functions performed by server 102. Alternatively, the functions of server 102 may be implemented using cloud services.
[0028] Based on the above system, the solution provided by the present application is described below through multiple embodiments. In order to facilitate understanding of the solution provided by the embodiments of the present application, in the following multiple embodiments, the training process of the dialogue discourse analysis model is first described. On this basis, the process of performing dialogue discourse analysis using the trained dialogue discourse analysis model is described.
[0029] Embodiment 1
[0030] Reference Figure 2A , shows a step flow chart of a method for training a dialogue discourse analysis model according to the first embodiment of the present application.
[0031] The dialogue discourse analysis model training method of this embodiment includes the following steps:
[0032] Step S202: Acquire a dialogue sample for dialogue discourse analysis training.
[0033] The conversation sample includes multiple rounds of conversations. In the embodiment of the present application, the conversation sample can be any conversation in an application scenario involving multi-person conversations, including but not limited to: customer service scenarios, online medical scenarios, online education scenarios, etc., and the embodiment of the present application does not limit this.
[0034] A multi-round conversation can be considered as a conversation formed by multiple relatively complete speeches. For example, a conversation sample includes "What time do we have a meeting?"; "It should be three o'clock in the afternoon"; "Have all the materials been packed?"; "Only our group"; "Ready", it can be considered that the conversation sample includes five rounds of conversation. For another example, a conversation sample includes "We have a meeting today, what time will it start?"; "It should be three o'clock this afternoon"; "Have all the materials been packed?"; "Only our group, other groups will not participate for the time being"; "Ready", it can be considered that the conversation sample includes five rounds of conversation.
[0035] It should be noted that in the embodiments of the present application, unless otherwise specified, "multiple rounds", "multiple people", "multiple" and other numbers related to "multiple" all mean two or more.
[0036] Step S204: obtaining first feature vectors corresponding to the multiple rounds of dialogue, and inputting the first feature vectors into a dialogue discourse analysis model to be trained.
[0037] In the embodiment of the present application, the dialogue discourse analysis model can be a model with a Transformer structure, preferably, a model with a Transformer structure that can implement the MLM (Masked Language Mode) self-supervision task, such as a BERT model. Among them, MLM is a model that is trained by destroying certain mask positions in a text sequence (such as a text sequence corresponding to multiple rounds of dialogue) and requiring the model to restore them. However, it is not limited to this, and other models with similar structures and / or functions are also applicable to the solutions of the embodiments of the present application.
[0038] The dialogue discourse analysis model uses the feature vector corresponding to the dialogue sample including multiple rounds of dialogue, that is, the first feature vector (such as the encoding vector) as input for subsequent training. For example, if a dialogue sample includes five rounds of dialogue, the five encoding vectors corresponding to the five rounds of dialogue can be concatenated and used as the input of the dialogue discourse analysis model. By training with the feature vector as input, the training efficiency of the dialogue discourse analysis model can be improved.
[0039] In one feasible manner, this step can be implemented as follows: encoding each round of dialogue in multiple rounds of dialogue included in the dialogue sample to generate a corresponding first feature coding vector, and superimposing the first feature coding vectors corresponding to each round of dialogue according to the time sequence between each round of dialogue to generate a feature matrix; and inputting the feature matrix into the dialogue discourse analysis model to be trained.
[0040] Taking the above dialogue sample including five rounds of dialogue as an example, the vectors corresponding to "What time do we have the meeting?"; "It should be three o'clock in the afternoon"; "Have all the materials been packed?"; "Only our group"; "Ready" are encoded respectively, and the encoding vectors corresponding to the five rounds of dialogue are generated, that is, the first feature encoding vectors. For the convenience of description, they are recorded as the first feature encoding vectors 011, 012, 013, 014 and 015 respectively. Assuming that the order between the above rounds of dialogue is their time sequence, 011, 012, 013, 014, 015 are superimposed in sequence to generate the corresponding feature matrix, which can be used as the input of the dialogue discourse analysis model.
[0041] By superimposing the first feature encoding vectors of each round of conversation in time sequence to generate a feature matrix as the model input, the model can effectively learn the characteristics (semantics) of the conversation and provide a good data foundation for the subsequent model to perform mask processing on part of the conversation.
[0042] Step S206: masking a part of the first feature vector using the dialogue discourse analysis model, and encoding the masked first feature vector to generate a corresponding second feature vector.
[0043] As mentioned above, the dialogue discourse analysis model in the embodiment of the present application has an MLM function. After receiving the first feature vector generated based on multiple rounds of dialogue in the dialogue sample, it can mask part of the feature vectors therein. The feature vectors are usually feature vectors corresponding to a certain round or some rounds of dialogue. Exemplarily, still taking the dialogue sample including five rounds of dialogue as an example, the corresponding first feature coding vectors are 011, 012, 013, 014 and 015 respectively. The vectors input into the dialogue discourse analysis model after splicing are simply shown as 011+012+013+014+015. Then the dialogue discourse analysis model can mask part of the vectors therein, such as [MASK]+012+013+014+015, indicating that the 011 vector is masked; or, such as [MASK]+012+[MASK]+014+015, indicating that the 011 and 013 vectors are masked. Using a method of masking a single vector is simple to implement and has higher accuracy; using a method of masking multiple vectors simultaneously is more efficient. However, those skilled in the art should understand that generally, masking is not performed on all vectors.
[0044] The dialogue discourse analysis model performs encoding processing on the basis of the feature vector corresponding to the entire dialogue sample after masking processing, thereby generating the corresponding second feature vector. For example, [MASK]+012+013+014+015 is encoded to obtain the corresponding feature vector, which also includes the vector parts corresponding to the multiple rounds of dialogue in the dialogue sample, that is, the second feature vector.
[0045] When the vector input into the dialogue discourse analysis model adopts the aforementioned feature matrix method, optionally, the dialogue discourse analysis model can mask the first feature coding vectors corresponding to some turns of dialogue in the feature matrix corresponding to the dialogue sample, and encode the masked feature matrix to generate the corresponding second feature coding vector.
[0046] For ease of explanation, a simple example is as follows: Taking the above-mentioned dialogue sample including five rounds of dialogue as an example, the corresponding feature matrix is: Each row corresponds to a round of conversation, and each element in the feature matrix may be a multi-dimensional feature vector, and all elements form the feature matrix. Assuming that the first round of conversation is masked, the feature matrix after masking can be illustrated as: Then encode the feature matrix to obtain the second feature encoding vector, such as,
[0047] Among them, whether it is for the feature matrix or the first feature vector, the masking process can adopt the random masking method, which can not only reduce the implementation cost of the scheme, but also ensure the accuracy, objectivity and comprehensiveness of the training effect from the overall training perspective. However, it is not limited to this, and other masking methods are also applicable to the scheme of the embodiment of the present application. The encoding process of the masked vector can be implemented by conventional encoding methods, which will not be described in detail here.
[0048] Step S208: performing self-supervised learning training on the dialogue discourse analysis model according to the difference between the second eigenvector and the first eigenvector.
[0049] In the embodiment of the present application, the dialogue discourse analysis model adopts a self-supervised learning training method, so there is no need to annotate the dialogue samples used for training. Based on this, after the second feature vector is obtained, the model training can be performed according to the difference between it and the first feature vector. For example, the model can be trained according to the cosine distance between the second feature vector and the first feature vector. When the feature vector is a feature code, this step can be implemented as self-supervised learning training of the dialogue discourse analysis model according to the difference between the first feature code vector and the second feature code vector corresponding to each round of dialogue.
[0050] Specifically, the model can be trained based on the cosine distance between the second eigenvector and the first eigenvector corresponding to each round of dialogue. For a certain round of dialogue, if the cosine distance between the corresponding second eigenvector and the first eigenvector is larger, it indicates that the correlation between it and the masked dialogue is weaker; otherwise, the smaller the cosine distance, the stronger the correlation between it and the masked dialogue. This is because if a certain round of dialogue is masked, if the correlation between it and another round of dialogue is strong, the impact on the other round of dialogue will be greater, and the cosine distance between the vector corresponding to the other round after masking and the original vector will be smaller, and the similarity will be lower. Conversely, the larger the cosine distance, the higher the similarity, and the weaker the impact.
[0051] For example, suppose there are five rounds of dialogue A, B, C, D, E, and the corresponding first feature vectors are C01, C02, C03, C04, C05. Then suppose A is masked to obtain [MASK], B, C, D, E, and the corresponding second feature vectors are C'01, C'02, C'03, C'04, C'05. If A is strongly associated with B, the lower the similarity between C02 and C'02, the smaller the cosine distance. If A is weakly associated with D, the higher the similarity between C05 and C'05, the larger the cosine distance.
[0052] Based on this, the dialogue discourse analysis model can be trained so that the cosine distance corresponding to the feature vector with strong correlation is smaller, and the cosine distance corresponding to the feature vector with weak correlation is larger, so as to adjust the model parameters of the dialogue discourse analysis model so that the trained dialogue discourse analysis model can accurately predict the correlation strength between multiple rounds of dialogues. It should be noted that the cosine distance is used as an example in the above description, but those skilled in the art should understand that in actual applications, other distance calculation methods or other similarity calculation methods can also be applied to the solution of the embodiment of the present application.
[0053] The above process is illustrated below by taking a specific example.
[0054] Specifically, the process includes:
[0055] (I) Perform data preprocessing and encoding on dialogue samples containing multiple rounds of dialogue.
[0056] Among them, the data preprocessing of the dialogue sample (in text form) includes the data preprocessing of each round of dialogue in the dialogue sample to complete data preprocessing processes such as data normalization (such as normalization of names, addresses and entities, etc.), removal of stop words and merging of continuous speeches.
[0057] The conversation samples after data preprocessing still include multiple rounds of conversations, which are arranged in time sequence. Each round of conversation (in text form) is sent to the first deep neural network encoder to obtain a high-dimensional distributed vector representing its semantic representation. Among them, the implementation form of the first deep neural network encoder includes but is not limited to convolutional neural networks, recurrent neural networks, pre-trained language models, etc. After the first deep neural network encoder completes the encoding, the encoding results (high-dimensional distributed embedding) corresponding to each round of conversation are superimposed in time sequence into a feature matrix for use in the following pre-training process.
[0058] (2) Pre-training of the MLM self-supervised task for dialogue discourse analysis model.
[0059] In this process, the second deep neural network encoder is used as a dialogue discourse analysis model to further model the feature matrix generated in (I). Specifically, a neural network encoder with a Transformer structure can be used to read the feature matrix as input, and randomly select some rows in the feature matrix (i.e., the part of the dialogue in some rounds in the feature matrix corresponding to the part), and replace the row embedding with a randomly initialized [MASK] embedding. When the second deep neural network encoder completes encoding, it collects all the output embeddings associated with the randomly selected positions and optimizes their cosine distance with the embedding that was not masked before the input.
[0060] Thus, learning based on the "destruction-reconstruction" method of dialogue samples is realized, thereby introducing the MLM self-supervision task into the dialogue round, and realizing the MLM self-supervision pre-training learning task of the dialogue discourse analysis model. It should be noted that in actual applications, the first deep neural network encoder and the second deep neural network encoder can be the same encoder or two different encoders; or, they can be different encoders with the same structure or different encoders with different structures.
[0061] The trained dialogue discourse analysis model can directly predict the relationship between multiple rounds of dialogue in the subsequent application stage, that is, perform dialogue discourse analysis.
[0062] In a scenario example, Figure 2B As shown, it is assumed that the text-based dialogue sample set contains 100,000 dialogue samples, each of which contains multiple rounds of dialogue, and the number of dialogue rounds contained in each dialogue sample can be the same or different. After the 100,000 dialogue samples are preprocessed as described above, subsequent encoding and model training processing can be performed.
[0063] For example, extract each conversation sample one by one from the 100,000 conversation samples after data preprocessing, and encode the multiple rounds of conversations contained in each conversation sample through the first deep neural network encoder, which is shown as 5 rounds in this example, to obtain the corresponding 5 encoding vectors, which are respectively shown as encoding vectors E11E12E13... corresponding to the first round of conversation; encoding vectors E21E22E23... corresponding to the second round of conversation; encoding vectors E31E32E33... corresponding to the third round of conversation; encoding vectors E41E42E43... corresponding to the fourth round of conversation; encoding vectors E51E52E53... corresponding to the fifth round of conversation. These 5 encoding vectors are superimposed in the time sequence of their corresponding conversations to form a feature matrix, Figure 2B It is simply illustrated as a 5*N matrix, where 5 represents the number of rows, and each row corresponds to a round of dialogue.
[0064] After the feature matrix is input into the second deep neural network encoder, the rows are randomly masked. In this example, the first row of the feature matrix, i.e., the vector corresponding to the first round of dialogue, is randomly masked. Then, the second deep neural network encoder encodes the randomly masked feature matrix to obtain a new encoding vector, which also corresponds to the five rounds of dialogue.
[0065] Since the first round of dialogue is masked in this example, the cosine distances between the encoding vectors corresponding to the second, third, fourth, and fifth rounds of dialogue in the new encoding vector and the encoding vectors corresponding to the second, third, fourth, and fifth rounds of dialogue in the five encoding vectors generated by the first deep neural network encoder can be calculated respectively.
[0066] Furthermore, the obtained cosine distance is optimized so that the cosine distance of the dialogue that is strongly associated with the first round of dialogue is smaller, and the cosine distance of the dialogue that is weakly associated with the first round of dialogue is larger.
[0067] The above training process is iteratively executed until a training termination condition is reached, such as reaching a preset number of training times, or the optimized cosine distance reaches a preset distance threshold.
[0068] Through the above training process, the discourse structure in multiple rounds of dialogue can be learned without using any labeled data, so that the trained dialogue discourse analysis model can complete the dialogue discourse analysis task.
[0069] It can be seen that, through this embodiment, when performing conversation discourse analysis on multiple rounds of dialogue, the conversation discourse analysis model is used for analysis. Because the conversation discourse analysis model in this embodiment is obtained by self-supervised training based on multiple rounds of dialogue obtained after masking some rounds of dialogue, these dialogue data used for training do not need to be manually labeled, thereby effectively reducing the high cost of model training and improving the efficiency of model training, thereby also making the use of the conversation discourse analysis model for conversation discourse analysis have the effect of low cost and high efficiency. In addition, the self-supervised training of the conversation discourse analysis model is based on the conversation samples after masking, that is, in the conversation samples including multiple rounds of dialogue, some rounds of dialogue are masked, and the other parts are not masked. Based on the conversation samples that include both masked dialogues and unmasked dialogues, self-supervised training is performed, so that the prediction of the conversation discourse relationship between multiple rounds of dialogue is more accurate, and thus, the efficiency of using the conversation discourse analysis model for conversation discourse analysis is further improved.
[0070] Embodiment 2
[0071] This embodiment focuses on explaining the dialogue discourse analysis method provided in the embodiment of the present application from the perspective of application of the trained dialogue discourse analysis model.
[0072] Reference Figure 3A , shows a step flow chart of a method for analyzing dialogue discourse according to Embodiment 2 of the present application.
[0073] The dialogue discourse analysis method of this embodiment includes the following steps:
[0074] Step S302: obtaining multiple rounds of dialogues to be analyzed.
[0075] In this embodiment, the multi-round dialogue obtained is in the form of text. However, those skilled in the art should understand that in actual applications, the dialogue obtained may also be in the form of voice, which can be converted into text.
[0076] The multiple rounds of conversations obtained for dialogue analysis may be conversations in any scenario, including but not limited to: conversations in e-commerce scenarios, conversations in online medical scenarios, conversations in conference scenarios, conversations in online education scenarios, etc., and the embodiments of the present application do not impose any restrictions on this.
[0077] Step S304: performing dialogue discourse analysis on the multiple rounds of dialogue using a pre-trained dialogue discourse analysis model.
[0078] The dialogue discourse analysis model is obtained by self-supervised training based on masking of some rounds of dialogue in the dialogue sample, and the dialogue sample is a sample containing multiple rounds of dialogue. In specific implementation, the dialogue discourse analysis model of this step can adopt the dialogue discourse analysis model obtained by training in the above-mentioned embodiment 1.
[0079] In a feasible manner, this step can be implemented as follows: obtaining a first dialogue feature vector corresponding to the multi-round dialogue; inputting the first dialogue feature vector into a pre-trained dialogue discourse analysis model, masking the dialogue feature vector corresponding to a certain dialogue round in the first dialogue feature vector through the dialogue discourse analysis model, and extracting features from the masked dialogue feature vector to obtain the corresponding second dialogue feature vector; calculating the similarity between each dialogue round that has not been masked in the second dialogue feature vector and each dialogue round that corresponds to the first dialogue feature vector; and outputting the correlation strength information between a certain dialogue round that has been masked and each dialogue round that has not been masked according to the similarity. In this way, it is possible to effectively distinguish which dialogues that have not been masked are strongly correlated with the masked dialogues and which are weakly correlated, and effectively implement the dialogue discourse analysis of multi-round dialogues.
[0080] Optionally, in the above process, obtaining the first dialogue feature vector corresponding to the multiple dialogues can be implemented by encoding each dialogue in the multiple dialogues to obtain the corresponding feature coding vector; according to the time sequence between the dialogues, the feature coding vectors corresponding to each dialogue are superimposed into a feature matrix to facilitate the subsequent processing of the dialogue discourse analysis model and improve the processing efficiency of the dialogue discourse analysis model. Then, on this basis, when the dialogue discourse analysis model performs dialogue discourse analysis on the multiple dialogues, it can perform dialogue discourse analysis on the multiple dialogues based on the feature matrix.
[0081] After the multiple rounds of dialogues are processed by the dialogue discourse analysis model, information on the strength of association between the dialogues corresponding to the masked vectors and the dialogues corresponding to the unmasked vectors will be output, such as association probability, association degree level, etc.
[0082] Step S306: obtaining the dialogue discourse analysis results of the multiple rounds of dialogues according to the output of the dialogue discourse analysis model.
[0083] After obtaining the information on the correlation between multiple rounds of dialogue output by the dialogue discourse analysis model, the dialogue discourse analysis results between the multiple rounds of dialogue can be obtained. For example, the masked dialogue A has a strong correlation with the unmasked dialogue B, which is the context. However, the unmasked dialogues C, D, and E do not have a strong correlation with the dialogue A and are not the context.
[0084] In a feasible manner, the correlation strength information output by the dialogue discourse analysis model can also be filtered according to a preset correlation strength threshold; based on the filtering result, other rounds of dialogue whose correlation strength with a certain round of dialogue that is masked is greater than the correlation strength threshold are obtained, wherein the other rounds of dialogue are part of the rounds of dialogue that are not masked; based on the correlation strength information between a certain round of dialogue and other rounds of dialogue, the dialogue discourse analysis results between the multiple rounds of dialogue are obtained. Thus, the dialogues with strong correlation with a certain round of dialogue that is masked can be screened out by the correlation strength threshold, and their relationship can be further determined to improve the speed and efficiency of the dialogue discourse analysis. Among them, the correlation strength threshold can be appropriately set by those skilled in the art according to actual needs, such as being set to 0.7, etc., and the embodiments of the present application are not limited to this.
[0085] For example, a conversation including multiple rounds of dialogue is input into the trained dialogue discourse analysis model to perform discourse analysis on it. Specifically, suppose the rounds of the input multiple rounds of dialogue are five rounds: A, B, C, D, and E. In order to perform discourse analysis on the multiple rounds of dialogue, traversal analysis can be performed on pairs of sentences. Taking A and B as an example, the relationship strength between A and B is obtained as follows:
[0086] (1) Input A, B, C, D, and E into the deep neural network encoder of the Transformer structure for encoding, and read the output first embedding of position B;
[0087] (2) The deep neural network encoder with Transformer structure (which can be the same as or different from the encoder in (1)) encodes [MASK], B, C, D, E generated after random masking of A, B, C, D, E, and reads the output second embedding at position B;
[0088] (3) Calculate the cosine distance between the first embedding and the second embedding. The larger the distance, the worse the correlation between A and B, that is, the less relevant they are, which indicates that A has a smaller impact on B. Conversely, the smaller the distance, the stronger the correlation between A and B, that is, the more relevant they are, which indicates that A has a greater impact on B.
[0089] Finally, the association strengths of all sentence pairs are sorted, and associations with a value greater than or equal to a preset association strength threshold (such as a score of 0.7 after normalization) are retained, and associations with a value less than the threshold are eliminated, thus obtaining the final dialogue discourse analysis results.
[0090] The following is an illustrative example of the above process using specific scenarios. Figure 3B and Figure 3C shown.
[0091] in, Figure 3B A customer service scenario is shown, in which an electronic device first obtains a customer service dialogue (in text form) containing multiple rounds of dialogue to be analyzed; encodes each round of dialogue in the customer service dialogue, such as encoding through a deep neural network encoder, and superimposes the encoding vectors obtained by encoding into a feature matrix according to the time sequence of multiple rounds of dialogue; inputs the feature matrix into a pre-trained dialogue discourse analysis model to perform dialogue discourse analysis on it through the dialogue discourse analysis model, including: masking vectors corresponding to some dialogues in the feature matrix through the dialogue discourse analysis model; encoding based on the feature matrix obtained after masking to obtain new encoding vectors; according to the vectors corresponding to each round of dialogue, comparing the similarity between the new encoding vectors corresponding to each of the other dialogues except the masked dialogue and the original encoding vector, and outputting the correlation strength information between the other dialogues and the masked dialogue based on the similarity; and then, based on the correlation strength information, obtaining the dialogue discourse analysis results between the multiple rounds of dialogue in the customer service dialogue. Among them, the dialogue discourse analysis model used in this example is obtained by self-supervised training after masking some rounds of dialogue in the dialogue sample, and the dialogue sample is a sample containing multiple rounds of dialogue, for example, it can be the dialogue discourse analysis model obtained by training in the aforementioned embodiment one.
[0092] Subsequently, the obtained analysis results of the dialogue discourse can be processed accordingly according to the actual needs of technical personnel in this field, such as for data statistics, or for customer service quality inspection, etc.
[0093] Figure 3CAn online medical scenario is shown, in which an electronic device first obtains a medical service dialogue (in text form) containing multiple rounds of dialogue to be analyzed; encodes each round of dialogue in the medical service dialogue, such as encoding through a deep neural network encoder, and superimposes the encoding vectors obtained by encoding into a feature matrix according to the time sequence of multiple rounds of dialogue; inputs the feature matrix into a pre-trained dialogue discourse analysis model to perform dialogue discourse analysis on it through the dialogue discourse analysis model, including: masking vectors corresponding to some dialogues in the feature matrix through the dialogue discourse analysis model; encoding based on the feature matrix obtained after masking to obtain new encoding vectors; according to the vectors corresponding to each round of dialogue, comparing the similarity between the new encoding vectors corresponding to each of the other dialogues except the masked dialogue and the original encoding vector, and outputting the correlation strength information between the other dialogues and the masked dialogue based on the similarity; and then, based on the correlation strength information, obtaining the dialogue discourse analysis results between the multiple rounds of dialogue in the medical service dialogue. Among them, the dialogue discourse analysis model used in this example is obtained by self-supervised training after masking some rounds of dialogue in the dialogue sample, and the dialogue sample is a sample containing multiple rounds of dialogue, for example, it can be the dialogue discourse analysis model obtained by training in the aforementioned embodiment one.
[0094] Subsequently, the obtained analysis results of the dialogue discourse can be processed accordingly according to the actual needs of technical personnel in this field, such as for data statistics, or for quality inspection of medical services, etc.
[0095] It can be seen that through this embodiment, when performing dialogue discourse analysis on multiple rounds of dialogue, the dialogue discourse analysis model is used for analysis. Because the dialogue discourse analysis model in the embodiment of the present application is obtained by self-supervised training based on multiple rounds of dialogue obtained after masking some rounds of dialogue, these dialogue data used for training do not need to be manually labeled, thereby effectively reducing the high cost of model training and improving the efficiency of model training, thereby also making the dialogue discourse analysis using the dialogue discourse analysis model have the effect of low cost and high efficiency. In addition, the self-supervised training of the dialogue discourse analysis model is based on the dialogue samples after masking, that is, in the dialogue samples including multiple rounds of dialogue, some rounds of dialogue are masked, and the other parts are not masked. Based on the dialogue samples that include both masked dialogues and unmasked dialogues, self-supervised training is performed, so that the prediction of the dialogue discourse relationship between multiple rounds of dialogues is more accurate, and thus, the efficiency of using the dialogue discourse analysis model for dialogue discourse analysis is further improved.
[0096] Embodiment 3
[0097] Reference Figure 4, shows a schematic diagram of the structure of an electronic device according to the third embodiment of the present application. The specific embodiment of the present application does not limit the specific implementation of the electronic device.
[0098] like Figure 4 As shown, the electronic device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0099] in:
[0100] The processor 402 , the communication interface 404 , and the memory 406 communicate with each other via a communication bus 408 .
[0101] The communication interface 404 is used to communicate with other electronic devices or servers.
[0102] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above method embodiment.
[0103] Specifically, the program 410 may include program codes, which include computer operation instructions.
[0104] The processor 402 may be a CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0105] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0106] The program 410 may be specifically used to enable the processor 402 to execute operations corresponding to the method described in any one of the aforementioned method embodiments.
[0107] The specific implementation of each step in program 410 can refer to the corresponding description of the corresponding steps and units in the above method embodiment, and has corresponding beneficial effects, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above method embodiment, which will not be repeated here.
[0108] In addition, an embodiment of the present application also provides a computer program product, including computer instructions, which instruct a computing device to perform operations corresponding to any one of the above-mentioned multiple method embodiments.
[0109] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0110] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the method shown here.
[0111] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0112] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.
Claims
1. A method for analyzing dialogue discourse, comprising: Obtain multiple rounds of dialogue to be analyzed; Performing a dialogue discourse analysis on the multiple rounds of dialogue using a pre-trained dialogue discourse analysis model, and outputting information on the strength of association between a certain round of dialogue that has been masked and each round of dialogue that has not been masked, wherein the pre-trained dialogue discourse analysis model is obtained by self-supervised training after masking some rounds of dialogue in a dialogue sample, and the dialogue sample is a sample containing multiple rounds of dialogue; According to the output of the pre-trained dialogue discourse analysis model, the dialogue discourse analysis results between the multiple rounds of dialogue are obtained.
2. The method according to claim 1, wherein: The pre-trained dialogue discourse analysis model performs dialogue discourse analysis on the multiple rounds of dialogue, including: Obtaining a first dialogue feature vector corresponding to the multiple rounds of dialogue; Inputting the first dialogue feature vector into the pre-trained dialogue discourse analysis model, performing masking processing on the dialogue feature vector corresponding to the certain round of dialogue in the first dialogue feature vector by the pre-trained dialogue discourse analysis model, and performing feature extraction on the masked dialogue feature vector to obtain a corresponding second dialogue feature vector; Calculating the similarity between the conversation rounds that are not masked in the second conversation feature vector and the conversation rounds corresponding to the first conversation feature vector; The association strength information between the certain round of dialogue that has been subjected to masking and the rounds of dialogue that have not been subjected to masking is output according to the similarity.
3. The method according to claim 2, wherein: The obtaining, according to the output of the dialogue discourse analysis model, dialogue discourse analysis results between the multiple rounds of dialogues includes: According to a preset association strength threshold, filtering the association strength information output by the dialogue discourse analysis model; According to the filtering processing result, other rounds of dialogues whose correlation strength with the certain round of dialogues subjected to masking processing is greater than the correlation strength threshold are obtained, wherein the other rounds of dialogues are part of the rounds of dialogues that are not subjected to masking processing; According to the correlation strength information between the certain round of dialogue and the other rounds of dialogue, dialogue discourse analysis results between the multiple rounds of dialogue are obtained.
4. The method according to claim 2, wherein: The obtaining of the first dialogue feature vector comprises: encoding each round of dialogue in the multiple rounds of dialogue respectively to obtain a corresponding feature coding vector; and superimposing the feature coding vectors corresponding to each round of dialogue into a feature matrix according to the time sequence between the rounds of dialogue; The performing conversation discourse analysis on the multiple rounds of conversations by the conversation discourse analysis model completed in advance training includes: performing conversation discourse analysis on the multiple rounds of conversations based on the feature matrix by the conversation discourse analysis model completed in advance training.
5. A method for training a dialogue discourse analysis model, comprising: Obtaining a dialogue sample for dialogue discourse analysis training, wherein the dialogue sample includes multiple rounds of dialogue; Obtaining first feature vectors corresponding to the multiple rounds of dialogue, and inputting the first feature vectors into a dialogue discourse analysis model to be trained; Masking a portion of the first feature vector using the dialogue discourse analysis model, encoding the masked first feature vector, and generating a corresponding second feature vector; According to the difference between the second feature vector and the first feature vector, the dialogue discourse analysis model is trained through self-supervised learning to obtain the pre-trained dialogue discourse analysis model, wherein the pre-trained dialogue discourse analysis model is used to obtain dialogue discourse analysis results between the multiple rounds of dialogues, and the dialogue discourse analysis results are obtained based on the correlation strength information between a round of dialogue that is masked and each round of dialogue that is not masked, output by the pre-trained dialogue discourse analysis model, and the correlation strength information is obtained by performing dialogue discourse analysis on the multiple rounds of dialogues using the pre-trained dialogue discourse analysis model.
6. The method according to claim 5, wherein: The obtaining of first feature vectors corresponding to the multiple rounds of dialogues and inputting the first feature vectors into a dialogue discourse analysis model to be trained includes: Encode each round of dialogue in the multiple rounds of dialogue to generate a corresponding first feature coding vector, and superimpose the first feature coding vectors corresponding to each round of dialogue according to the time sequence between the rounds of dialogue to generate a feature matrix; The feature matrix is input into the dialogue discourse analysis model to be trained.
7. The method according to claim 6, wherein: The masking of part of the first feature vector by the dialogue discourse analysis model and encoding of the masked first feature vector to generate a corresponding second feature vector includes: The first feature coding vectors corresponding to some rounds of dialogue in the feature matrix are masked by the dialogue discourse analysis model, and the masked feature matrix is encoded to generate corresponding second feature coding vectors.
8. The method according to claim 7, wherein: The step of performing self-supervised learning training on the dialogue discourse analysis model according to the difference between the second feature vector and the first feature vector to obtain the pre-trained dialogue discourse analysis model includes: According to the difference between the first feature coding vector and the second feature coding vector corresponding to each round of dialogue, the dialogue discourse analysis model is trained through self-supervision learning to obtain the pre-trained dialogue discourse analysis model.
9. The method according to any one of claims 5 to 8, wherein: The masking process is a random masking process.
10. A method for analyzing dialogue discourse, comprising: Obtaining a customer service dialogue for which dialogue discourse analysis is to be performed, wherein the customer service dialogue includes multiple rounds of dialogue; Performing a dialogue discourse analysis on the multiple rounds of dialogue using a pre-trained dialogue discourse analysis model, and outputting information on the strength of association between a certain round of dialogue that has been masked and each round of dialogue that has not been masked, wherein the pre-trained dialogue discourse analysis model is obtained by self-supervised training after masking some rounds of dialogue in a dialogue sample, and the dialogue sample is a sample containing multiple rounds of dialogue; According to the output of the pre-trained dialogue discourse analysis model, a dialogue discourse analysis result of the customer service dialogue is obtained.
11. A method for analyzing a dialogue, comprising: Obtaining a doctor-patient service dialogue to be subjected to dialogue discourse analysis, wherein the doctor-patient service dialogue includes multiple rounds of dialogue; Performing a dialogue discourse analysis on the multiple rounds of dialogue using a pre-trained dialogue discourse analysis model, and outputting information on the strength of association between a certain round of dialogue that has been masked and each round of dialogue that has not been masked, wherein the pre-trained dialogue discourse analysis model is obtained by self-supervised training after masking some rounds of dialogue in a dialogue sample, and the dialogue sample is a sample containing multiple rounds of dialogue; According to the output of the pre-trained dialogue discourse analysis model, the dialogue discourse analysis result of the doctor-patient service dialogue is obtained.
12. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method according to any one of claims 1-11.
13. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
14. A computer program product, comprising computer instructions, wherein the computer instructions instruct a computing device to execute operations corresponding to the method according to any one of claims 1 to 11.
