Conversation rewriting method and device, computer equipment and storage medium
By adopting a rewriting model containing multiple specific levels in incomplete dialogue rewriting and using the above dialogue information for in-depth encoding and processing, the shortcomings of the Seq2Seq model in terms of rewriting accuracy are solved, and a higher accuracy of dialogue rewriting is achieved and integrity.
Patent Information
- Application Number
- CN202411540057.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-18
AI Technical Summary
The existing methods of incomplete dialogue rewriting based on Seq2Seq model have the problem of low rewriting accuracy, especially in deep digging and effective utilization of context information.
Using a rewrite model that includes text encoder layer, text selection layer, multi-dimensional feature calculation layer, editing matrix prediction layer and output layer, encode, select, and similar by receiving incomplete dialogue text input from user and multiple rounds of above-mentioned dialogues. degree calculation, edit matrix prediction and final rewrite processing to generate complete, clear and easy to understand conversation text.
By making great use of the above dialogue information, the accuracy of incomplete dialogue rewriting is significantly improved, and the completeness and accuracy of the generated complete dialogue text is enhanced.
Smart Images

Figure CN119476312A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of artificial intelligence development technology and financial technology, and in particular to dialogue rewriting methods, devices, computer equipment and storage media. Background Art
[0002] In the field of financial services, especially in the daily operations of financial institutions such as banks and insurance companies, natural language interactions with customers play a pivotal role. These interactions not only occur frequently, but also often involve complex and detailed contextual information, including but not limited to customers' personal information, account status, transaction history, and specific business needs.
[0003] In natural conversations, in order to improve efficiency, people usually omit the subject or use reference to express their meaning. This language habit is also common in the interaction between financial institutions and their customers. However, this concise way of expression, when separated from the specific context, often leads to ambiguity and ambiguity of information, making it difficult for the recipient of the conversation to accurately understand the customer's true intention. In order to meet this challenge, the incomplete conversation rewriting task came into being. The core goal of this task is to rewrite these incomplete conversations containing omissions and references into complete, clear and easy-to-understand sentences or paragraphs through technical means. In early practice, most incomplete conversation rewriting tasks were treated as machine translation tasks, that is, a sequence-to-sequence (Seq2Seq) model framework was used to generate the rewritten text.
[0004] However, although the Seq2Seq model has achieved certain results in processing natural language generation tasks, its limitations are becoming increasingly prominent in the specific scenario of incomplete dialogue rewriting. Specifically, pure generative rewriting methods often lack the necessary control mechanism, as well as the lack of in-depth mining and effective use of contextual information, which makes it difficult for the Seq2Seq model to accurately capture and restore the customer's true intentions during the rewriting process, thereby reducing the accuracy of the rewriting. Summary of the invention
[0005] The purpose of the embodiments of the present application is to propose a conversation rewriting method, apparatus, computer device and storage medium to solve the technical problem that the existing method of rewriting incomplete conversations based on the Seq2Seq model has low rewriting accuracy.
[0006] In order to solve the above technical problems, the embodiment of the present application provides a dialogue rewriting method, which adopts the following technical solution:
[0007] Receiving an incomplete conversation text input by a user, and multiple rounds of previous conversations corresponding to the incomplete conversation text;
[0008] Calling a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an edit matrix prediction layer, and an output layer;
[0009] The incomplete dialogue text and the previous dialogue are encoded in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue;
[0010] Performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence;
[0011] In the multi-dimensional feature calculation layer, multi-dimensional similarity calculation processing is performed on the target preceding sentence and the incomplete dialogue text to obtain corresponding similarity features;
[0012] Performing edit matrix prediction processing on the similarity features in the edit matrix prediction layer to obtain a corresponding target edit matrix;
[0013] According to the target editing matrix, the incomplete dialogue text is rewritten in the output layer to obtain a rewritten complete dialogue text.
[0014] Furthermore, the step of performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence specifically includes:
[0015] performing correlation calculation on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding correlation score;
[0016] Performing prediction processing on the correlation score based on a preset multi-layer perceptron to obtain a corresponding prediction result;
[0017] Based on the prediction result, select the sentences involved in the rewriting from the conversation;
[0018] The preceding sentence involved in the rewriting is taken as the target preceding sentence.
[0019] Furthermore, the step of performing multi-dimensional similarity calculation processing on the target preceding sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain corresponding similarity features specifically includes:
[0020] In the multi-dimensional feature calculation layer, the cosine similarity between the first word of the target context sentence and the second word of the incomplete dialogue text is calculated;
[0021] Calculating the linear similarity between the first word-gram of the target context sentence and the second word-gram of the incomplete dialogue text;
[0022] Calculating the correlation similarity between the first word of the target context sentence and the second word of the incomplete conversation text;
[0023] The cosine similarity, the linear similarity and the association similarity are integrated to obtain the similarity feature.
[0024] Furthermore, the step of rewriting the incomplete dialogue text in the output layer according to the target editing matrix to obtain the rewritten complete dialogue text specifically includes:
[0025] Performing traversal processing on each element in the target edit matrix in the output layer;
[0026] If the current element traversed indicates a no-operation, the word element corresponding to the current element in the incomplete dialogue text is not rewritten;
[0027] If the current element being traversed indicates an insert operation, a first designated word-element matching the third word-element of the incomplete dialogue text is determined from the target preceding sentence, and the first designated word-element is inserted at the position of the third word-element; wherein the third word-element is the word-element corresponding to the current element in the incomplete dialogue text;
[0028] If the current element being traversed represents a rewrite operation, a second designated word-element matching the fourth word-element of the incomplete dialogue text is determined from a preset vocabulary, and the fourth word-element is rewritten using the second designated word-element until the rewrite of all word-element of the incomplete dialogue text is completed and a complete dialogue text after rewriting is obtained; wherein the fourth word-element is the word-element in the incomplete dialogue text corresponding to the current element.
[0029] Furthermore, after the step of rewriting the incomplete dialogue text in the output layer according to the target editing matrix to obtain the rewritten complete dialogue text, the method further includes:
[0030] Performing intent verification on the complete conversation text based on a preset intent calculation model;
[0031] If the complete dialogue text passes the intent verification, the complete dialogue text is optimized based on a preset optimization strategy to obtain a corresponding target dialogue text;
[0032] storing the target dialogue text;
[0033] The target conversation text is sent to the user.
[0034] Furthermore, the step of performing intent verification on the complete conversation text based on a preset intent calculation model specifically includes:
[0035] Call the pre-trained intent calculation model;
[0036] Performing intent calculation on the complete conversation text based on the intent calculation model to obtain a corresponding first intent probability distribution;
[0037] Performing intent calculation on the incomplete dialogue text based on the intent calculation model to obtain a corresponding second intent probability distribution;
[0038] Comparing the first intention probability distribution with the second intention probability distribution based on a preset comparison strategy to obtain a corresponding comparison result;
[0039] An intent verification result corresponding to the complete conversation text is generated based on the comparison result.
[0040] Furthermore, the step of optimizing the complete dialogue text based on a preset optimization strategy to obtain a corresponding target dialogue text specifically includes:
[0041] Deleting separators from the complete dialogue text to obtain a corresponding first dialogue text;
[0042] performing error correction processing on the first dialogue text to obtain a corresponding second dialogue text;
[0043] adjusting the format of the second dialogue text to obtain a corresponding third dialogue text;
[0044] The third dialogue text is used as the target dialogue text.
[0045] In order to solve the above technical problems, the embodiment of the present application further provides a dialogue rewriting device, which adopts the following technical solution:
[0046] A receiving module, configured to receive an incomplete dialogue text input by a user, and multiple rounds of previous dialogues corresponding to the incomplete dialogue text;
[0047] A first calling module is used to call a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an edit matrix prediction layer and an output layer;
[0048] A first processing module, configured to encode the incomplete dialogue text and the previous dialogue in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue;
[0049] A second processing module, configured to perform text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence;
[0050] A third processing module is used to perform multi-dimensional similarity calculation processing on the target preceding sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain corresponding similarity features;
[0051] A fourth processing module, configured to perform edit matrix prediction processing on the similarity feature in the edit matrix prediction layer to obtain a corresponding target edit matrix;
[0052] The rewriting module is used to rewrite the incomplete dialogue text in the output layer according to the target editing matrix to obtain a rewritten complete dialogue text.
[0053] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0054] Receiving an incomplete conversation text input by a user, and multiple rounds of previous conversations corresponding to the incomplete conversation text;
[0055] Calling a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an edit matrix prediction layer, and an output layer;
[0056] The incomplete dialogue text and the previous dialogue are encoded in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue;
[0057] Performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence;
[0058] In the multi-dimensional feature calculation layer, multi-dimensional similarity calculation processing is performed on the target preceding sentence and the incomplete dialogue text to obtain corresponding similarity features;
[0059] Performing edit matrix prediction processing on the similarity features in the edit matrix prediction layer to obtain a corresponding target edit matrix;
[0060] According to the target editing matrix, the incomplete dialogue text is rewritten in the output layer to obtain a rewritten complete dialogue text.
[0061] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0062] Receiving an incomplete conversation text input by a user, and multiple rounds of previous conversations corresponding to the incomplete conversation text;
[0063] Calling a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an edit matrix prediction layer, and an output layer;
[0064] The incomplete dialogue text and the previous dialogue are encoded in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue;
[0065] Performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence;
[0066] In the multi-dimensional feature calculation layer, multi-dimensional similarity calculation processing is performed on the target preceding sentence and the incomplete dialogue text to obtain corresponding similarity features;
[0067] Performing edit matrix prediction processing on the similarity features in the edit matrix prediction layer to obtain a corresponding target edit matrix;
[0068] According to the target editing matrix, the incomplete dialogue text is rewritten in the output layer to obtain a rewritten complete dialogue text.
[0069] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0070] The present application first receives an incomplete dialogue text input by a user, and multiple rounds of previous dialogues corresponding to the incomplete dialogue text; then calls a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an editing matrix prediction layer and an output layer; then, the incomplete dialogue text and the previous dialogue are encoded in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue; subsequently, the first vector representation and the second vector representation are subjected to text selection processing in the text selection layer to obtain a corresponding target previous sentence; further, a multi-dimensional similarity calculation processing is performed on the target previous sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain a corresponding similarity feature; and an editing matrix prediction processing is performed on the similarity feature in the editing matrix prediction layer to obtain a corresponding target editing matrix; finally, according to the target editing matrix, the incomplete dialogue text is rewritten in the output layer to obtain a rewritten complete dialogue text. The present application uses a rewriting model including a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an editing matrix prediction layer and an output layer to rewrite the incomplete dialogue text input by the user according to the previous dialogue corresponding to the incomplete dialogue text, thereby making the greatest possible use of the previous dialogue information to complete the current dialogue, effectively ensuring the accuracy of the rewriting of the incomplete dialogue, and improving the completeness and accuracy of the generated complete dialogue text. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are 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 work.
[0072] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0073] Figure 2 A flowchart of an embodiment of a method for rewriting a conversation according to the present application;
[0074] Figure 3 is a structural schematic diagram of an embodiment of a dialogue rewriting device according to the present application;
[0075] Figure 4 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0076] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0077] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0078] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0079] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0080] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0081] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to the laptop computer 1011, tablet computer 1012 or mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0082] The server 103 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal device 101 .
[0083] It should be noted that the conversation rewriting method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the conversation rewriting device is generally arranged in the server / terminal device.
[0084] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0085] Continue to refer Figure 2 , shows a flow chart of an embodiment of the dialogue rewriting method according to the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted. The dialogue rewriting method provided in the embodiment of the present application can be applied to any scenario where dialogue rewriting is required, and the dialogue rewriting method can be applied to products in these scenarios, for example, financial dialogue rewriting in the financial insurance field. The dialogue rewriting method comprises the following steps:
[0086] Step S201, receiving an incomplete dialogue text input by a user, and multiple rounds of previous dialogues corresponding to the incomplete dialogue text.
[0087] In this embodiment, the electronic device (eg Figure 1The server / terminal device shown in the figure) can obtain the incomplete conversation text and the above conversation through a wired connection or a wireless connection. It should be noted that the above-mentioned wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future. The executor of the present application may be a conversation rewriting system, or simply referred to as the system. The user can input the incomplete conversation text that needs to be rewritten and multiple rounds of above conversations related to the incomplete conversation text through the front-end interface of the system. Among them, in the business scenario of financial insurance, the above-mentioned incomplete conversation text may include claims conversation text, payment conversation text, and so on.
[0088] Step S202, calling a pre-trained rewriting model; wherein the rewriting model includes at least a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an editing matrix prediction layer and an output layer.
[0089] In this embodiment, the training process of the above rewriting model includes: 1) data preparation and preprocessing. Collect a large number of data sets containing multiple rounds of dialogues and corresponding rewriting results. And concatenate the multiple rounds of dialogues and the current incomplete dialogue, separated by a specific delimiter (such as [SEP]) for subsequent processing. 2) Text encoding. Input the preprocessed text into the text encoder layer (BERT network structure) to obtain the embedding representation of each word. And concatenate the embeddings of multiple rounds of previous dialogues C and the current incomplete dialogue X as input for subsequent processing. 3) Text selection. The attention value between the word embedding of each previous sentence and the word embedding of the incomplete dialogue is calculated through the text selection layer. And the previous sentence is predicted through the MLP layer to determine whether it is selected to participate in the dialogue rewriting. The predicted value is 0 or 1, indicating non-participation and participation, respectively. 4) Multi-dimensional feature calculation. Use the multi-dimensional feature calculation layer to calculate the cos similarity, linear similarity and attention similarity for each word in the selected previous sentence set and the incomplete dialogue X as different dimensional features. And use these three similarity values as features for subsequent edit matrix prediction. 5) Edit matrix prediction. The U-net convolutional network structure is used as the edit matrix prediction layer to predict the M*N matrix Y composed of the selected previous sentence set C and the incomplete dialogue X. Each element in the matrix represents an edit operation (insertion, rewrite, empty operation) between the corresponding two words. And according to the predicted edit matrix, perform edit operations on the incomplete dialogue. For the empty operation position, keep the original word unchanged; for the insertion operation position, insert the corresponding word from the previous sentence; for the rewrite operation position, predict and insert a new word from the vocabulary. 6) Output the rewrite result. Use the output layer to generate the rewritten complete dialogue based on the edit matrix and the edit operation. 7) Loss function calculation and optimization. By calculating the cross entropy loss function of the rewrite edit distance, the sentence selection loss function and the meaning loss function. Figure 1 The weighted sum of the loss function is used as the total loss. In addition, the KL divergence can be used to calculate the difference between the intent probability distribution of the conversation before and after the rewriting. The intent calculation network adopts the BERT+MLP+Softmax structure. In addition, the model can be trained using an optimization algorithm (such as Adam) to minimize the total loss. 8) Model evaluation and tuning. Use the test data set to evaluate the model and calculate the accuracy, recall and other indicators of the rewriting results. And according to the evaluation results, adjust the model parameters, network structure, etc. to improve the performance of the model.
[0090] Step S203, encoding the incomplete dialogue text and the previous dialogue in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue.
[0091] In this embodiment, the complete input text can be formed by splicing multiple rounds of previous conversations with the current incomplete conversation text with a specific separator (such as [SEP]) in the text encoder layer. Then, the spliced input text is segmented and converted into a token sequence that can be recognized by the model using the BERT word segmenter. Then, the token sequence is input into the BERT encoder (text encoder layer) to obtain the embedding representation of each token. Among them, the above embedding representation includes a first vector representation corresponding to the incomplete conversation text, and a second vector representation corresponding to the previous conversation.
[0092] Step S204: performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence.
[0093] In this embodiment, the above-mentioned specific implementation process of performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain the corresponding target context sentence will be further described in detail in subsequent specific embodiments of the present application and will not be elaborated in detail here.
[0094] Step S205 , performing multi-dimensional similarity calculation processing on the target preceding sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain corresponding similarity features.
[0095] In this embodiment, the multi-dimensional similarity calculation processing is performed on the target context sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain the corresponding similarity feature. This application will provide further detailed descriptions of this in subsequent specific embodiments and will not be elaborated on here.
[0096] Step S206, performing edit matrix prediction processing on the similarity features in the edit matrix prediction layer to obtain a corresponding target edit matrix.
[0097] In this embodiment, the target edit matrix is predicted by inputting the obtained similarity features into the edit matrix prediction layer (U-net). Each element in the target edit matrix represents an edit operation (insert, rewrite, or null operation) between two corresponding tokens.
[0098] Step S207, rewriting the incomplete dialogue text in the output layer according to the target editing matrix to obtain a rewritten complete dialogue text.
[0099] In this embodiment, the specific implementation process of rewriting the incomplete dialogue text in the output layer according to the target editing matrix to obtain the rewritten complete dialogue text will be further described in detail in subsequent specific embodiments of the present application and will not be elaborated on here.
[0100] The present application first receives an incomplete dialogue text input by a user, and multiple rounds of previous dialogues corresponding to the incomplete dialogue text; then calls a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an editing matrix prediction layer and an output layer; then, the incomplete dialogue text and the previous dialogue are encoded in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue; subsequently, the first vector representation and the second vector representation are subjected to text selection processing in the text selection layer to obtain a corresponding target previous sentence; further, a multi-dimensional similarity calculation processing is performed on the target previous sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain a corresponding similarity feature; and an editing matrix prediction processing is performed on the similarity feature in the editing matrix prediction layer to obtain a corresponding target editing matrix; finally, according to the target editing matrix, the incomplete dialogue text is rewritten in the output layer to obtain a rewritten complete dialogue text. The present application uses a rewriting model including a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an editing matrix prediction layer and an output layer to rewrite the incomplete dialogue text input by the user according to the previous dialogue corresponding to the incomplete dialogue text, thereby making the greatest possible use of the previous dialogue information to complete the current dialogue, effectively ensuring the accuracy of the rewriting of the incomplete dialogue, and improving the completeness and accuracy of the generated complete dialogue text.
[0101] In some optional implementations, step S204 includes the following steps:
[0102] In the text selection layer, a correlation calculation is performed on the first vector representation and the second vector representation to obtain a corresponding correlation score.
[0103] In this embodiment, the first vector representation embedding of the incomplete conversation text and the second vector representation embedding of the previous conversation are subjected to attention calculation in the text selection layer to obtain the correlation score between them. The attention mechanism measures the degree of association between different sentences by calculating the correlation scores between them.
[0104] The correlation score is predicted based on a preset multi-layer perceptron to obtain a corresponding prediction result.
[0105] In this embodiment, the calculated attention value (relevance score) can be further processed by using an MLP (multi-layer perceptron) to output a prediction result, which indicates whether the previous sentence in the previous conversation is selected for rewriting.
[0106] Based on the prediction result, the preceding sentences involved in the rewriting are selected from the preceding dialogue.
[0107] In this embodiment, based on the obtained prediction result (usually a threshold or probability), the above sentences that are considered to be most relevant to the incomplete dialogue are screened out from the above-mentioned above dialogue for subsequent processing.
[0108] The preceding sentence involved in the rewriting is taken as the target preceding sentence.
[0109] The present application obtains a corresponding correlation score by calculating the correlation between the first vector representation and the second vector representation in the text selection layer; then predicts the correlation score based on a preset multi-layer perceptron to obtain a corresponding prediction result; then filters out the previous sentences involved in the rewriting from the previous dialogue based on the prediction result; and subsequently uses the previous sentences involved in the rewriting as the target previous sentences. The present application obtains a correlation score by calculating the correlation between the first vector representation and the second vector representation in the text selection layer; then predicts the correlation score based on the use of a multi-layer perceptron to obtain a prediction result, and then based on the prediction result, it can be achieved that the previous sentences involved in the rewriting can be quickly and accurately filtered out from the previous dialogue and used as the final target previous sentences, so that only the obtained target previous sentences need to be used in the rewriting later, thereby effectively reducing the inputted previous text data, which is beneficial to improving the accuracy and rewriting rate of dialogue rewriting.
[0110] In some optional implementations of this embodiment, step S205 includes the following steps:
[0111] In the multi-dimensional feature calculation layer, the cosine similarity between the first word-gram of the target context sentence and the second word-gram of the incomplete dialogue text is calculated.
[0112] In this embodiment, a word unit is a token. For each token of the target context sentence and each token of the incomplete conversation text, similarities in multiple dimensions between them can be calculated. Specifically, calculating the cosine similarity includes: calculating the cosine similarity between the embeddings of two tokens to measure the similarity between them.
[0113] The linear similarity between the first word-gram of the target context sentence and the second word-gram of the incomplete dialogue text is calculated.
[0114] In this embodiment, calculating the linear similarity includes: multiplying the embedding of the token of the incomplete dialogue text by a parameter matrix to obtain a multiplied value, and then calculating the dot product similarity between the multiplied value and the target previous sentence token.
[0115] The correlation similarity between the first word-gram of the target context sentence and the second word-gram of the incomplete dialogue text is calculated.
[0116] In this embodiment, calculating the association similarity includes: using an attention mechanism to calculate a correlation score between two tokens to reflect the degree of association between them.
[0117] The cosine similarity, the linear similarity and the association similarity are integrated to obtain the similarity feature.
[0118] In this embodiment, the integrated similarity can be obtained by multi-dimensionally integrating the cosine similarity, linear similarity and correlation similarity, and used as the final similarity feature. These similarity features are used as inputs of the subsequent editing matrix prediction layer.
[0119] The present application calculates the cosine similarity between the first word of the target context sentence and the second word of the incomplete dialogue text in the multi-dimensional feature calculation layer; and calculates the linear similarity between the first word of the target context sentence and the second word of the incomplete dialogue text; and calculates the association similarity between the first word of the target context sentence and the second word of the incomplete dialogue text; and subsequently integrates the cosine similarity, the linear similarity and the association similarity to obtain the similarity feature. The present application calculates the cosine similarity, the linear similarity and the association similarity between the first word of the target context sentence and the second word of the incomplete dialogue text in the multi-dimensional feature calculation layer, and then integrates the obtained cosine similarity, linear similarity and association similarity, so that the final similarity feature can be obtained quickly and accurately, thereby improving the richness and accuracy of the generated similarity feature.
[0120] In some optional implementations, step S207 includes the following steps:
[0121] Each element in the target editing matrix is traversed and processed in the output layer.
[0122] In this embodiment, the dimension of the target edit matrix corresponds to the number of word pairs in the original dialogue text. Each element in the target edit matrix represents the type of edit operation between word pairs, such as insertion, replacement (rewrite) or null operation. By traversing each element of the target edit matrix, the incomplete dialogue text is rewritten according to its value. Specifically, according to the predicted target edit matrix, corresponding edit operations (such as inserting missing words, replacing inaccurate words, etc.) can be performed on the original dialogue text, thereby obtaining a semantically complete rewritten dialogue text that can be understood out of context.
[0123] If the current traversed element represents a no-operation, the word element corresponding to the current element in the incomplete dialogue text is not rewritten.
[0124] In this embodiment, the processing method for the null operation includes: keeping the original token in the incomplete conversation text unchanged, that is, not making any modification.
[0125] If the current element being traversed represents an insert operation, a first designated word-element matching the third word-element of the incomplete dialogue text is determined from the target context sentence, and the first designated word-element is inserted at the position of the third word-element; wherein the third word-element is the word-element in the incomplete dialogue text corresponding to the current element.
[0126] In this embodiment, the processing method for the insertion operation includes: selecting a most relevant token from the target context dialogue for insertion. In order to select the most relevant token, the similarity score between the current insertion position and each token in the target context dialogue can be calculated, and then the token with the highest similarity score is selected as the inserted token. The similarity score can be calculated by methods such as cosine similarity and dot product similarity.
[0127] If the current element being traversed represents a rewrite operation, a second designated word-element matching the fourth word-element of the incomplete dialogue text is determined from a preset vocabulary, and the fourth word-element is rewritten using the second designated word-element until the rewrite of all word-element of the incomplete dialogue text is completed and a complete dialogue text after rewriting is obtained; wherein the fourth word-element is the word-element in the incomplete dialogue text corresponding to the current element.
[0128] In this embodiment, the processing method for the rewriting operation includes: generating a new token for replacement. The generation of the new token can be achieved by searching for the most similar token in a predefined vocabulary, or a new token can be generated by a generative model (such as GPT, BERT, etc.).
[0129] In addition, after the above steps, the system has performed necessary editing operations on each token in the incomplete conversation text. These edited tokens are then combined to form a rewritten complete conversation text. The rewritten conversation text maintains the original conversation's intent and context information, while correcting the incomplete or erroneous parts.
[0130] The present application traverses each element in the target editing matrix in the output layer, and rewrites the incomplete dialogue text in a matching rewriting manner according to the operation type corresponding to the current traversed element, so as to maximize the use of the information of the previous dialogue to complete the current dialogue, thereby ensuring the accuracy of the rewriting of the incomplete dialogue.
[0131] In some optional implementations of this embodiment, after step S207, the electronic device may further perform the following steps:
[0132] The complete conversation text is subjected to intent verification based on a preset intent calculation model.
[0133] In this embodiment, the above intention verification refers to the intention verification of the complete conversation text. Figure 1 Consistency check, through the complete dialogue text Figure 1 The consistency check is performed to ensure that the intention of the dialogue before and after the rewriting is consistent, thereby improving the accuracy of the dialogue rewriting. The specific implementation process of the above-mentioned intention verification of the complete dialogue text based on the preset intention calculation model will be further described in detail in the subsequent specific embodiments of this application, and will not be elaborated on here.
[0134] If the complete dialogue text passes the intent verification, the complete dialogue text is optimized based on a preset optimization strategy to obtain a corresponding target dialogue text.
[0135] In this embodiment, the above-mentioned specific implementation process of optimizing the complete dialogue text based on the preset optimization strategy to obtain the corresponding target dialogue text will be further described in detail in the subsequent specific embodiments of this application, and will not be elaborated in detail here.
[0136] The target dialogue text is stored.
[0137] In this embodiment, the target conversation text can be saved to a specified location, such as a database, a file system, a blockchain, etc.
[0138] The target conversation text is sent to the user.
[0139] In this embodiment, the target dialogue text may be output to the user by displaying the target dialogue text on a user interface, returning the target dialogue text to the caller through an API, and the like.
[0140] The present application performs intent verification on the complete conversation text based on a preset intent calculation model; if the complete conversation text passes the intent verification, the complete conversation text is optimized based on a preset optimization strategy to obtain a corresponding target conversation text; the target conversation text is then stored; and the target conversation text is subsequently sent to the user. The present application obtains the rewritten complete conversation text based on the use of the rewriting model, and intelligently verifies the intent of the complete conversation text based on the intent calculation model to ensure that the intent of the complete conversation text can be consistent with the incomplete conversation text. In addition, the complete conversation text is intelligently optimized based on the use of the optimization strategy, thereby improving the accuracy of the generated target conversation text. In addition, the target conversation text is stored, thereby ensuring the security of the target conversation text.
[0141] In some optional implementations, performing intent verification on the complete conversation text based on a preset intent calculation model includes the following steps:
[0142] Call the pre-trained intent calculation model.
[0143] In this embodiment, the above-mentioned intention calculation model is a pre-built deep learning model with intention calculation function, which accepts the dialogue text as input and outputs an intention probability distribution vector. Each element in the vector represents a possible intention, and its value represents the probability of the intention appearing in the dialogue.
[0144] The intention calculation model is used to calculate the intention of the complete conversation text to obtain a corresponding first intention probability distribution.
[0145] In this embodiment, the intention calculation model may be used to calculate the intention probability distribution of the complete conversation text, thereby obtaining the corresponding first intention probability distribution.
[0146] The intention calculation model is used to calculate the intention of the incomplete dialogue text to obtain a corresponding second intention probability distribution.
[0147] In this embodiment, the intention calculation model may be used to calculate the intention probability distribution of the incomplete dialogue text, thereby obtaining a corresponding second intention probability distribution.
[0148] The first intention probability distribution is compared with the second intention probability distribution based on a preset comparison strategy to obtain a corresponding comparison result.
[0149] In this embodiment, the KL divergence (Kullback-Leibler Divergence) can be used to compare the intent probability distribution of the conversation before and after the rewrite. KL divergence is a method to measure the difference between two probability distributions. It calculates the amount of additional information (or "surprise") of one probability distribution relative to another probability distribution. If the rewritten conversation maintains the intent of the original conversation, their intent probability distributions should be similar, so the value of KL divergence should be smaller. The above comparison result is the value of KL divergence calculated based on the first intent probability distribution and the second intent probability distribution.
[0150] An intent verification result corresponding to the complete conversation text is generated based on the comparison result.
[0151] In this embodiment, a threshold is pre-set to determine whether the KL divergence value is within an acceptable range. If the KL divergence value is less than the threshold, it is considered that the rewritten dialogue maintains the intention of the original dialogue; otherwise, it is considered that the rewritten dialogue does not maintain the intention of the original dialogue. The rewriting strategy needs to be further adjusted or the model needs to be retrained later.
[0152] The present application calculates the intent of a complete conversation text based on the use of an intent calculation model to obtain a first intent probability distribution, and calculates the intent of an incomplete conversation text to obtain a second intent probability distribution, and then compares the first intent probability distribution with the second intent probability distribution based on the use of a comparison strategy to obtain a comparison result, and then by analyzing the comparison results, it is possible to quickly and accurately generate an intent verification result corresponding to the complete conversation text, effectively ensuring the accuracy of the generated intent verification result.
[0153] In some optional implementations of this embodiment, the optimizing process on the complete dialogue text based on a preset optimization strategy to obtain a corresponding target dialogue text includes the following steps:
[0154] Delimiter deletion processing is performed on the complete dialogue text to obtain a corresponding first dialogue text.
[0155] In this embodiment, the above-mentioned separator deletion process refers to removing the separators (such as [SEP]) inserted when splicing multiple rounds of dialogues.
[0156] Perform error correction processing on the first dialogue text to obtain a corresponding second dialogue text.
[0157] In this embodiment, the error correction process may include correcting grammatical errors, spelling errors, or improper use of punctuation marks in the dialogue text to improve the quality and readability of the generated dialogue text.
[0158] The format of the second dialogue text is adjusted to obtain a corresponding third dialogue text.
[0159] In this embodiment, the format of the second dialogue text may be adjusted so that the third dialogue text is more in line with the user's reading habits.
[0160] The third dialogue text is used as the target dialogue text.
[0161] The present application can quickly and accurately optimize the complete dialogue text by performing delimiter deletion, error correction and format adjustment on the complete dialogue text, thereby improving the quality and readability of the generated target dialogue text and ensuring the accuracy and compliance of the generated target dialogue text.
[0162] In some optional implementations, the user information obtained is subject to the user's consent and complies with relevant laws and policies.
[0163] In addition, the non-Company software tools or components that appear in the embodiments of the present application are merely examples and do not represent actual use.
[0164] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0165] It should be emphasized that in order to further ensure the privacy and security of the above complete conversation text, the above complete conversation text can also be stored in a blockchain node.
[0166] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0167] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0168] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0169] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0170] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0171] Further references Figure 3 , as a response to the above Figure 2 The present application provides an embodiment of a dialogue rewriting device, which is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0172] like Figure 3 As shown, the dialogue rewriting device 300 described in this embodiment includes: a receiving module 301, a first calling module 302, a first processing module 303, a second processing module 304, a third processing module 305, a fourth processing module 306 and a rewriting module 307. Among them:
[0173] The receiving module 301 is used to receive an incomplete dialogue text input by a user, and multiple rounds of previous dialogues corresponding to the incomplete dialogue text;
[0174] A first calling module 302 is used to call a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an edit matrix prediction layer and an output layer;
[0175] A first processing module 303 is used to encode the incomplete dialogue text and the previous dialogue in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue;
[0176] A second processing module 304 is used to perform text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence;
[0177] The third processing module 305 is used to perform multi-dimensional similarity calculation processing on the target preceding sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain corresponding similarity features;
[0178] A fourth processing module 306 is used to perform edit matrix prediction processing on the similarity feature in the edit matrix prediction layer to obtain a corresponding target edit matrix;
[0179] The rewriting module 307 is used to rewrite the incomplete dialogue text in the output layer according to the target editing matrix to obtain a rewritten complete dialogue text.
[0180] In this embodiment, the operations performed by the above modules or units correspond one-to-one to the steps of the dialogue rewriting method in the aforementioned implementation mode, and will not be repeated here.
[0181] In some optional implementations of this embodiment, the second processing module 304 includes:
[0182] A first calculation submodule, configured to perform correlation calculation on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding correlation score;
[0183] A prediction submodule, used to perform prediction processing on the correlation score based on a preset multi-layer perceptron to obtain a corresponding prediction result;
[0184] A screening submodule, configured to screen out the preceding sentences involved in the rewriting from the preceding dialogue based on the prediction result;
[0185] The first determination submodule is used to take the preceding sentence involved in the rewriting as the target preceding sentence.
[0186] In some optional implementations of this embodiment, the third processing module 305 includes:
[0187] A second calculation submodule, configured to calculate, in the multi-dimensional feature calculation layer, a cosine similarity between a first word unit of the target context sentence and a second word unit of the incomplete dialogue text;
[0188] A third calculation submodule, configured to calculate a linear similarity between a first word-gram of the target context sentence and a second word-gram of the incomplete dialogue text;
[0189] A fourth calculation submodule, configured to calculate the correlation similarity between the first word-gram of the target preceding sentence and the second word-gram of the incomplete dialogue text;
[0190] The integration submodule is used to integrate the cosine similarity, the linear similarity and the association similarity to obtain the similarity feature.
[0191] In some optional implementations of this embodiment, the rewriting module 307 includes:
[0192] A traversal submodule, used for traversing each element in the target editing matrix in the output layer;
[0193] A first processing submodule, configured to not rewrite the word element corresponding to the current element in the incomplete dialogue text if the current element traversed indicates a no operation;
[0194] A second processing submodule is configured to determine a first designated word element that matches a third word element of the incomplete dialogue text from the target preceding sentence if the current element being traversed indicates an insert operation, and insert the first designated word element at the position of the third word element; wherein the third word element is a word element in the incomplete dialogue text that corresponds to the current element;
[0195] The third processing submodule is used to determine a second designated word element that matches the fourth word element of the incomplete dialogue text from a preset word list if the current traversed element represents a rewrite operation, and use the second designated word element to rewrite the fourth word element until the rewrite process of all word elements of the incomplete dialogue text is completed and the rewritten complete dialogue text is obtained; wherein the fourth word element is the word element in the incomplete dialogue text corresponding to the current element.
[0196] In some optional implementations of this embodiment, the dialogue rewriting device further includes:
[0197] A verification module, used for performing intent verification on the complete conversation text based on a preset intent calculation model;
[0198] An optimization module, configured to optimize the complete dialogue text based on a preset optimization strategy to obtain a corresponding target dialogue text if the complete dialogue text passes the intent verification;
[0199] A storage module, used for storing the target dialogue text;
[0200] A sending module is used to send the target conversation text to the user.
[0201] In some optional implementations of this embodiment, the verification module includes:
[0202] The calling submodule is used to call the pre-trained intent calculation model;
[0203] a fifth calculation submodule, configured to perform intent calculation on the complete conversation text based on the intent calculation model to obtain a corresponding first intent probability distribution;
[0204] a sixth calculation submodule, configured to perform intent calculation on the incomplete dialogue text based on the intent calculation model to obtain a corresponding second intent probability distribution;
[0205] a comparison submodule, configured to compare the first intention probability distribution with the second intention probability distribution based on a preset comparison strategy to obtain a corresponding comparison result;
[0206] A generation submodule is used to generate an intention verification result corresponding to the complete conversation text based on the comparison result.
[0207] In some optional implementations of this embodiment, the optimization module includes:
[0208] A fourth processing submodule, configured to perform a delimiter removal process on the complete dialogue text to obtain a corresponding first dialogue text;
[0209] A fifth processing submodule, configured to perform error correction processing on the first dialogue text to obtain a corresponding second dialogue text;
[0210] A sixth processing submodule, configured to adjust the format of the second dialogue text to obtain a corresponding third dialogue text;
[0211] The second determining submodule is used to use the third dialogue text as the target dialogue text.
[0212] To solve the above technical problems, the present application also provides a computer device. Figure 4 , Figure 4 This is a basic structural block diagram of the computer device in this embodiment.
[0213] The computer device 4 includes a memory 41, a processor 42, and a network interface 43 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 4 with components 41-43, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0214] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0215] The memory 41 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 41 can be an internal storage unit of the computer device 4, such as a hard disk or memory of the computer device 4. In other embodiments, the memory 41 can also be an external storage device of the computer device 4, such as a plug-in hard disk equipped on the computer device 4, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 41 can also include both the internal storage unit of the computer device 4 and its external storage device. In this embodiment, the memory 41 is generally used to store the operating system and various application software installed on the computer device 4, such as computer-readable instructions of the dialogue rewriting method, etc. In addition, the memory 41 can also be used to temporarily store various types of data that have been output or are to be output.
[0216] The processor 42 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 42 is generally used to control the overall operation of the computer device 4. In this embodiment, the processor 42 is used to run the computer-readable instructions stored in the memory 41 or process data, such as running the computer-readable instructions of the dialogue rewriting method.
[0217] The network interface 43 may include a wireless network interface or a wired network interface. The network interface 43 is generally used to establish a communication connection between the computer device 4 and other electronic devices.
[0218] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the dialogue rewriting method as described above.
[0219] 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, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0220] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A dialogue rewriting method, characterized in that: The steps include: Receiving an incomplete conversation text input by a user, and multiple rounds of previous conversations corresponding to the incomplete conversation text; Calling a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an edit matrix prediction layer, and an output layer; The incomplete dialogue text and the previous dialogue are encoded in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue; Performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence; In the multi-dimensional feature calculation layer, multi-dimensional similarity calculation processing is performed on the target preceding sentence and the incomplete dialogue text to obtain corresponding similarity features; Performing edit matrix prediction processing on the similarity features in the edit matrix prediction layer to obtain a corresponding target edit matrix; According to the target editing matrix, the incomplete dialogue text is rewritten in the output layer to obtain a rewritten complete dialogue text.
2. The method for rewriting dialogue according to claim 1, characterized in that: The step of performing text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence specifically includes: performing correlation calculation on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding correlation score; Performing prediction processing on the correlation score based on a preset multi-layer perceptron to obtain a corresponding prediction result; Based on the prediction result, select the sentences involved in the rewriting from the conversation; The preceding sentence involved in the rewriting is taken as the target preceding sentence.
3. The dialogue rewriting method according to claim 1, characterized in that: The step of performing multi-dimensional similarity calculation processing on the target preceding sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain corresponding similarity features specifically includes: In the multi-dimensional feature calculation layer, the cosine similarity between the first word of the target context sentence and the second word of the incomplete dialogue text is calculated; Calculating the linear similarity between the first word-gram of the target context sentence and the second word-gram of the incomplete dialogue text; Calculating the correlation similarity between the first word of the target context sentence and the second word of the incomplete conversation text; The cosine similarity, the linear similarity and the association similarity are integrated to obtain the similarity feature.
4. The method for rewriting dialogue according to claim 1, characterized in that: The step of rewriting the incomplete dialogue text in the output layer according to the target editing matrix to obtain the rewritten complete dialogue text specifically includes: Performing traversal processing on each element in the target edit matrix in the output layer; If the current element traversed indicates a no-operation, the word element corresponding to the current element in the incomplete dialogue text is not rewritten; If the current element being traversed indicates an insert operation, a first designated word-element matching the third word-element of the incomplete dialogue text is determined from the target preceding sentence, and the first designated word-element is inserted at the position of the third word-element; wherein the third word-element is the word-element corresponding to the current element in the incomplete dialogue text; If the current element being traversed represents a rewrite operation, a second designated word-element matching the fourth word-element of the incomplete dialogue text is determined from a preset vocabulary, and the fourth word-element is rewritten using the second designated word-element until the rewrite of all word-element of the incomplete dialogue text is completed and a complete dialogue text after rewriting is obtained; wherein the fourth word-element is the word-element in the incomplete dialogue text corresponding to the current element.
5. The method for rewriting dialogue according to claim 1, characterized in that: After the step of rewriting the incomplete dialogue text in the output layer according to the target editing matrix to obtain the rewritten complete dialogue text, the method further includes: Performing intent verification on the complete conversation text based on a preset intent calculation model; If the complete dialogue text passes the intent verification, the complete dialogue text is optimized based on a preset optimization strategy to obtain a corresponding target dialogue text; storing the target dialogue text; The target conversation text is sent to the user.
6. The method for rewriting dialogue according to claim 5, characterized in that: The step of performing intent verification on the complete conversation text based on a preset intent calculation model specifically includes: Call the pre-trained intent calculation model; Performing intent calculation on the complete conversation text based on the intent calculation model to obtain a corresponding first intent probability distribution; Performing intent calculation on the incomplete dialogue text based on the intent calculation model to obtain a corresponding second intent probability distribution; Comparing the first intention probability distribution with the second intention probability distribution based on a preset comparison strategy to obtain a corresponding comparison result; An intent verification result corresponding to the complete conversation text is generated based on the comparison result.
7. The method for rewriting dialogue according to claim 5, characterized in that: The step of optimizing the complete dialogue text based on a preset optimization strategy to obtain a corresponding target dialogue text specifically includes: Deleting separators from the complete dialogue text to obtain a corresponding first dialogue text; performing error correction processing on the first dialogue text to obtain a corresponding second dialogue text; adjusting the format of the second dialogue text to obtain a corresponding third dialogue text; The third dialogue text is used as the target dialogue text.
8. A dialogue rewriting device, characterized in that: include: A receiving module, configured to receive an incomplete dialogue text input by a user, and multiple rounds of previous dialogues corresponding to the incomplete dialogue text; A first calling module is used to call a pre-trained rewriting model; wherein the rewriting model at least includes a text encoder layer, a text selection layer, a multi-dimensional feature calculation layer, an edit matrix prediction layer and an output layer; A first processing module, configured to encode the incomplete dialogue text and the previous dialogue in the text encoder layer to obtain a first vector representation corresponding to the incomplete dialogue text and a second vector representation corresponding to the previous dialogue; A second processing module, configured to perform text selection processing on the first vector representation and the second vector representation in the text selection layer to obtain a corresponding target context sentence; A third processing module is used to perform multi-dimensional similarity calculation processing on the target preceding sentence and the incomplete dialogue text in the multi-dimensional feature calculation layer to obtain corresponding similarity features; A fourth processing module, configured to perform edit matrix prediction processing on the similarity feature in the edit matrix prediction layer to obtain a corresponding target edit matrix; The rewriting module is used to rewrite the incomplete dialogue text in the output layer according to the target editing matrix to obtain a rewritten complete dialogue text.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the dialogue rewriting method according to any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the dialogue rewriting method according to any one of claims 1 to 7 are implemented.