Data processing method and device, electronic equipment and computer storage medium
By filtering and matching candidate dialogue materials in a multi-turn dialogue system and extracting semantic information using a neural network model, the problems of monotonous and inaccurate response statements are solved, achieving more accurate statement matching and improved dialogue quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ALIBABA INNOVATION PRIVATE LIMITED
- Filing Date
- 2021-03-29
- Publication Date
- 2026-08-04
AI Technical Summary
Existing multi-turn dialogue systems suffer from limited and inaccurate responses due to the diversity of language expressions, which affects the quality of the dialogue.
By acquiring keyword features from question dialogue segments, candidate dialogue materials are selected from multiple preset dialogue materials. Combined with semantic information matching degree, the answer statements in the target dialogue material are determined, and a neural network model is used to extract semantic information to improve matching accuracy.
It improves the accuracy and matching cost of responses in multi-turn dialogue systems, ensures the matching of responses with contextual semantics, and enhances dialogue quality.
Smart Images

Figure CN115129831B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data processing method, apparatus, electronic device, and computer storage medium. Background Technology
[0002] With the advancement of artificial intelligence technology, applications that enable multi-turn dialogues between machines and humans are becoming increasingly common, such as voice assistants, conversational self-service inquiries, and self-service ordering. In multi-turn dialogue applications, users input a sentence, and the machine outputs a response, thus enabling multi-turn conversations between machines and humans. In this process, quickly and accurately determining the response is a crucial factor affecting the quality of the dialogue.
[0003] Existing multi-turn dialogue systems retrieve response statements from pre-set dialogue texts. However, due to the inherent diversity of language, the response statements of existing retrieval-based dialogue systems are relatively simple and lack accuracy. Summary of the Invention
[0004] In view of this, embodiments of this application provide a data processing scheme to at least partially solve the above-mentioned problems.
[0005] According to a first aspect of the embodiments of this application, a data processing method is provided, applicable to automatic dialogue generation. The method includes: acquiring a question dialogue segment corresponding to a current question statement during an automatic dialogue with an interactive object; filtering multiple candidate dialogue materials associated with the question dialogue segment from a preset multiple dialogue materials based on keyword features of the question dialogue segment, wherein the candidate dialogue materials include a set answer statement and a related statement of the answer statement; determining a semantic matching degree between the question dialogue segment and the candidate dialogue materials based on semantic information of the question dialogue segment and semantic information between the answer statement and the related statement in the candidate dialogue materials; determining a target dialogue material from the multiple candidate dialogue materials based on the semantic matching degree, and using the answer statement in the target dialogue material as the answer statement of the current question statement.
[0006] According to a second aspect of the embodiments of this application, a data processing apparatus is provided, suitable for automatic dialogue generation. The apparatus includes: an acquisition module, configured to acquire a question dialogue segment corresponding to a current question statement during an automatic dialogue with an interactive object; a filtering module, configured to filter multiple candidate dialogue materials associated with the question dialogue segment from a preset multiple dialogue materials based on keyword features of the question dialogue segment, wherein the candidate dialogue materials include a set answer statement and a related statement of the answer statement; a matching module, configured to determine the semantic matching degree between the question dialogue segment and the candidate dialogue materials based on the semantic information of the question dialogue segment and the semantic information between the answer statement and the related statement in the candidate dialogue materials; and a determination module, configured to determine a target dialogue material from the multiple candidate dialogue materials based on the semantic matching degree, and use the answer statement in the target dialogue material as the answer statement of the current question statement.
[0007] According to a third aspect of the present application, an electronic device is provided, 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, wherein the executable instruction causes the processor to perform an operation corresponding to the data processing method described in the first aspect.
[0008] According to a fourth aspect of the embodiments of this application, a computer storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the data processing method as described in the first aspect.
[0009] According to the data processing scheme provided in the embodiments of this application, when determining the answer statement, matching is performed based on the question dialogue segment corresponding to the current question statement. This allows for the comprehensive use of the contextual semantic information of the question dialogue segment. Moreover, the dialogue material contains not only the answer statement but also related statements, making the matching between the dialogue material and the question dialogue segment more accurate. When performing the matching, candidate dialogue material is matched based on the keyword features of the question dialogue segment, and then the target dialogue material is matched based on the semantic information. This ensures the accuracy of the matching while reducing the matching cost, thus guaranteeing the accuracy of the matching. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings.
[0011] Figure 1This is a flowchart of the steps of a data processing method according to Embodiment 1 of this application;
[0012] Figure 2A This is a flowchart of the steps of a data processing method according to Embodiment 2 of this application;
[0013] Figure 2B for Figure 2A A schematic diagram of a neural network model in one usage scenario of the illustrated embodiment;
[0014] Figure 2C for Figure 2A A schematic diagram of a connection layer in the illustrated embodiment;
[0015] Figure 3 This is a structural block diagram of a data processing apparatus according to Embodiment 3 of this application;
[0016] Figure 4 This is a schematic diagram of the structure of an electronic device according to Embodiment 4 of this application. Detailed Implementation
[0017] To enable those skilled in the art to better understand the technical solutions in the embodiments of this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art should fall within the protection scope of the embodiments of this application.
[0018] The specific implementation of the embodiments of this application will be further described below with reference to the accompanying drawings.
[0019] Example 1
[0020] Reference Figure 1 The diagram shows a flowchart of the data processing method according to Embodiment 1 of this application.
[0021] In this embodiment, the method is applicable to automatic dialogue generation, and includes the following steps:
[0022] Step S102: Obtain the question dialogue segment corresponding to the current question statement during the automatic dialogue with the interactive object.
[0023] Automatic dialogue is used to automatically respond to statements entered by an interactive object. For example, it can be a dialogue between an artificial intelligence device and an interactive object. For instance, the interactive object might use an AI device to check the progress of a package delivery, food delivery, or the remaining quantity of goods. In this embodiment, the method can be applied to a retrieval-based automatic dialogue system to obtain an answer to the current question by retrieving existing dialogue material. Of course, in other embodiments, the method can be applied to other suitable systems, and there is no limitation thereto.
[0024] Taking a dialogue with an interactive object at least once as an example, the current question statement can be the latest question statement entered by the interactive object. Its corresponding dialogue segment can be all dialogue statements that contain the current question statement.
[0025] For example, the dialogue process is as follows:
[0026] Answer statement 1: AI Customer Service: Hello, according to our tracking, the package has been sent. Question 2: Interaction object: Which company?
[0027] In this example, the current question statement is the latest question statement, namely question statement 2. Its corresponding question dialogue segment contains question statement 1, answer statement 1, and question statement 2.
[0028] Step S104: Based on the keyword features of the question dialogue segment, select multiple candidate dialogue materials associated with the question dialogue segment from a set of preset dialogue materials.
[0029] The dialogue materials can be preset, and each dialogue material can be divided into a response statement and related statements. That is, the selected candidate dialogue materials include the preset response statement and the related statements of the response statement. The related statements can be preceding statements and / or following statements.
[0030] For example, a dialogue material that includes a preceding statement, a response statement, and a following statement is as follows:
[0031]
[0032]
[0033] Alternatively, another type of dialogue material is:
[0034] In statement 2 above: AI-powered customer service: None. In the preceding statement 3: Interaction object: What kind of courier service do you use? Answer statement: Intelligent Customer Service: Your package will be delivered by *** company. In statement 1: Interaction object: Can I change the courier company? In statement 2: AI-powered customer service: Which company would you like to switch to?
[0035] In one feasible approach, the keyword features in the question dialogue segment can be TF-IDF (Term Frequency-Inverse Term Frequency), which can be used to filter matching candidate dialogue materials from the dialogue material. This method of filtering candidate dialogue materials has low computational load and fast filtering speed. Of course, in other embodiments, other appropriate methods that can ensure filtering accuracy and speed can also be used to determine candidate dialogue materials.
[0036] Step S106: Determine the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the semantic information of the question dialogue segment and the semantic information between the answer statement and the related statement in the candidate dialogue material.
[0037] In one feasible approach, to improve matching accuracy and ensure more accurate responses to the questions asked by the interactive object, avoiding irrelevant answers, a trained neural network model can be used to extract semantic information from the question dialogue segment, as well as the semantic information from the answer and related statements in the candidate dialogue material. Since the candidate dialogue material contains not only the answer statement but also related statements, the extracted semantic information is more complete, thereby improving the accuracy of matching with the question dialogue segment.
[0038] Based on the identified semantic information, the question dialogue segment is matched with each candidate dialogue material to determine the semantic matching degree. For example, the semantic information of both the question dialogue segment and the candidate dialogue material can be represented by vectors, and the semantic matching degree between the two can be determined by calculating the angle between the vectors.
[0039] Step S108: Based on the semantic matching degree, determine the target dialogue material from the plurality of candidate dialogue materials, and use the answer statement in the target dialogue material as the answer statement to the current question statement.
[0040] In one feasible approach, the candidate dialogue material with the highest semantic matching degree can be selected as the target dialogue material, and the answer statement in it can be selected as the answer statement to the current question statement.
[0041] For example, if the semantic matching degree of the first candidate dialogue material is lower than that of the second candidate dialogue material, then the answer statement in the second candidate dialogue material is selected to answer the current question statement.
[0042] This approach ensures that when determining whether an answer matches a question, it considers not only the semantics of the answer itself but also the sentences preceding and / or following it, thus taking into account more semantic information. This makes the retrieved answer more context-appropriate and improves the effectiveness of communication with the user.
[0043] In this embodiment, the matching of the answer statement is based on the question dialogue segment corresponding to the current question statement. This allows for the comprehensive use of the contextual semantic information of the question dialogue segment. Moreover, the dialogue material contains not only the answer statement but also related statements, making the matching between the dialogue material and the question dialogue segment more accurate. During the matching process, candidate dialogue material is matched based on the keyword features of the question dialogue segment, and then the target dialogue material is matched based on the semantic information. This ensures the accuracy of the matching while reducing the matching cost.
[0044] The data processing method of this embodiment can be executed by any suitable electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as mobile phones, PADs, etc.) and PCs.
[0045] Example 2
[0046] Reference Figure 2A The flowchart illustrates the steps of the data processing method in Embodiment 2 of this application.
[0047] In this embodiment, the method is illustrated using a neural network model that includes an expression layer, a dialogue processing layer, and a connection layer. The data processing method includes the following steps:
[0048] Step S202: Obtain the question dialogue segment corresponding to the current question statement during the automatic dialogue with the interactive object.
[0049] The interaction object can be a user, or any other device that needs to be interacted with.
[0050] The dialogue segment corresponding to the current question statement can be a dialogue segment consisting of all statements from the beginning of the dialogue to the current question statement, or it can be a dialogue segment consisting of the N statements closest to the current question statement and the current question statement. The value of N can be determined according to the required matching precision and computational cost, such as 3, 5 or 10.
[0051] Step S204: Based on the keyword features of the question dialogue segment, select multiple candidate dialogue materials associated with the question dialogue segment from a set multiple dialogue materials, wherein the candidate dialogue materials include the set answer statement and the associated statement of the answer statement.
[0052] In one feasible approach, step S204 can be implemented as follows: determining multiple candidate dialogue materials that are semantically associated with the question dialogue segment based on the word frequency and inverse text frequency (i.e., TF-IDF) of the keywords in the question dialogue segment and the word frequency and inverse text frequency of the keywords in the dialogue material.
[0053] The word frequency and inverse text frequency corresponding to the keywords in the question dialogue segment can be calculated in any appropriate way. By using TF-IDF to perform preliminary screening of the dialogue material, obviously semantically irrelevant dialogue material can be filtered out, thereby reducing the amount of subsequent calculation. In real-time dialogue scenarios, this can improve response speed and reduce computational load.
[0054] Of course, other methods can be used to determine candidate dialogue materials in other embodiments, and this embodiment does not limit this.
[0055] In this embodiment, the associated statements include a preceding statement that precedes the answer statement in the dialogue sequence and a following statement that follows the answer statement in the dialogue sequence. The preceding statement forms a preceding dialogue segment, and the following statement forms a following dialogue segment.
[0056] Both the preceding and following dialogue segments can include one or more statements.
[0057] Of course, in other embodiments, the associated statements may be included only in the preceding dialog segment or only in the following dialog segment.
[0058] Step S206: Determine the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the semantic information of the question dialogue segment and the semantic information between the answer statement and the related statement in the candidate dialogue material.
[0059] In this embodiment, a neural network model is used to extract semantic information from the question dialogue segment and candidate dialogue material.
[0060] To improve the accuracy of semantic information, the neural network model in this embodiment includes an expression layer, a dialogue processing layer, and a connection layer. The expression layer extracts semantic information from natural language expressed in text form and converts it into vector representations. The dialogue processing layer extracts intra-segment semantic information and global semantic information respectively, and the connection layer fuses the intra-segment semantic information and global semantic information.
[0061] The expression layer can be the encoder in a transformer model, which includes a self-attention layer and a feedforward layer.
[0062] Of course, the expression layer can also be other network structures that can achieve semantic extraction, such as the part in the BERT model used to extract the semantics and features of sentences. This embodiment does not limit this.
[0063] Taking a question dialogue segment as an example, this paper explains how to obtain the question dialogue segment vector corresponding to the question dialogue segment through the expression layer. The methods for obtaining the preceding dialogue segment, the following dialogue segment, and the answer statement are similar, so they will not be described in detail here.
[0064] Suppose a question dialogue segment contains tq question-and-answer statements (tq is a positive integer). For each question statement, its feature information can be obtained separately through the expression layer. Taking the i-th question statement in the question dialogue segment as an example, word vectors and position vectors of each word in the i-th question statement are obtained through methods such as word embedding. These word vectors and position vectors are then input into the self-attention layer of the transformer model. The output of the self-attention layer is processed by a feedforward layer, and the output of the feedforward layer serves as the feature information of the i-th question statement, which can be represented as follows: That is, a vector that is expressed in vector form and carries the semantic information of the i-th question statement.
[0065] Here, 'q' indicates that the statement is a statement within the question dialogue segment. 'U' indicates that it is a statement, and 'i' indicates its position within the question dialogue segment, for example... This indicates the first question statement in the question dialogue segment, which is also the current question statement, and similarly... This indicates the second question statement in the question dialogue segment, that is, the statement preceding the current question statement.
[0066] The characteristic information of the question statements included in the question dialogue segment can be represented as follows: tq represents the number of question statements included in the question dialogue segment.
[0067] Similarly, feature information of the response statement can be obtained through the expression layer. Since there is only one response statement, it can be represented as U. r , .
[0068] The feature information of preceding statements included in the preceding dialogue segment obtained through the expression layer can be represented as follows: The 'th' indicates the number of preceding statements included in the preceding dialogue segment.
[0069] The feature information of subsequent statements included in subsequent dialogue segments obtained through the expression layer can be represented as follows: tf indicates the number of subsequent statements included in the following dialogue segment.
[0070] The above method allows for the accurate acquisition of feature information corresponding to each statement, ensuring the accurate extraction of intra-segment and global semantic information. The feature information of the statements output by the expression layer can be input into the dialogue processing layer to obtain intra-segment and global semantic information.
[0071] In one example, obtaining intra-segment semantic information and global semantic information through the dialogue processing layer can be achieved through the following sub-steps:
[0072] Sub-step S2061: Combine the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement into a global reference text.
[0073] This global reference text is used to extract global semantic information. If only intra-segment semantic information is obtained, this step can be omitted, and steps S2061 to S2063 are not limited to strict temporal relationships.
[0074] One feasible way to create a global reference text is as follows:
[0075] Global reference text can be represented as G = [U q U h U r U f ].
[0076] Among them, U q This represents the concatenation of characteristic information from all question statements in a question dialogue segment. tq represents the number of question statements. Similarly, U h U represents the concatenation of all characteristic information of preceding statements in the preceding dialogue segment. r U represents the characteristic information of the answer statement. f This indicates the concatenation of characteristic information of all subsequent statements in the following dialogue segment.
[0077] Sub-step S2062: Using the question dialogue segment, the answer statement, the preceding dialogue segment, and the following dialogue segment as target processing objects respectively, perform intra-segment processing on the target processing objects to obtain the corresponding intra-segment semantic information, and determine the global semantic information corresponding to the target processing object based on the target processing object and the global reference text.
[0078] Since the processing of the question dialogue segment, the answer statement, the preceding dialogue segment, and the following dialogue segment by the dialogue processing layer is similar, the explanation will be based on the question dialogue segment as the target processing object.
[0079] In one feasible approach, obtaining intra-segment semantic information can be achieved through the following processes A1 to C1.
[0080] Process A1: Determine the current statement from the statements contained in the target processing object in a chronological order that gradually moves away from the answer statement.
[0081] Because statements closer to the answer statement in a dialogue have a greater semantic relevance (containing more useful information) and statements farther away have a weaker semantic relevance (containing less useful information), the dialogue processing layer processes statements in chronological order, moving them further away from the answer statement when extracting useful semantic information from a dialogue segment. Specifically, in a question dialogue segment, the current question statement is initially identified as the current statement. In a previous dialogue segment, the statement closest to the answer statement is initially identified as the current statement; similarly, in a subsequent dialogue segment, the statement closest to the answer statement is initially identified as the current statement.
[0082] Process B1: Using the first self-attention layer, the feature information of the current statement and the extracted intra-segment semantic information are processed to obtain the intra-segment retained information corresponding to the current statement.
[0083] The characteristic information of the current statement in a question dialogue segment can be denoted as: This indicates that it is the feature information of the i-th question statement in the question dialogue segment.
[0084] If the current statement is the first statement, then the extracted semantic information within the segment is the initialized value, which can be denoted as: q indicates that it is a question dialogue segment, i-1 indicates the semantic information containing the first i-1 question statements, and l indicates the semantic information within the segment.
[0085] like Figure 2B As shown, the first self-attention layer is an attention layer, which is used to combine the feature information of the current sentence and the extracted intra-segment semantic information to determine the semantic information that needs to be retained in the current sentence, that is, the intra-segment retained information (denoted as...). ).
[0086] The processing procedure can be represented as follows:
[0087]
[0088] Here, dk refers to the dimension of the Wordembedding used when obtaining the feature information of the current statement, which is the dimension of one row in the feature information of the current statement. express The transpose of .
[0089] This method allows for the adjustment of the semantic information that needs to be retained in the current statement based on the extracted semantic information within the segment. This enables the determination of useful information in the current statement by considering the semantic information of the context within the overall question dialogue segment.
[0090] Process C1: Based on the intra-segment retained information of the current statement and the intra-segment adjustment weight of the extracted intra-segment semantic information, update the intra-segment retained information of the current statement to the extracted intra-segment semantic information until the processing of the statements contained in the target processing object is completed.
[0091] Procedure C1 can be implemented through procedures C11 and C12.
[0092] Process C11: Determine the intra-segment adjustment weight based on the intra-segment retained information of the current statement and the extracted intra-segment semantic information.
[0093] In one feasible approach, the intra-segment adjustment weight can be denoted as a. i It can be determined in the following way:
[0094]
[0095] Among them, MLP stands for Multilayer Perceptron, whose structure can be determined as needed and whose parameters are obtained through training. i The value range of a is -1 to 1, because a i Negative values are allowed, so adjusting the weights within a segment can determine whether to add the feature information of the current statement to the extracted semantic information within the segment or to delete some irrelevant information from the extracted semantic information within the segment. When a i When a negative value is taken, content can be deleted from the extracted semantic information within the segment, thereby correcting the extracted semantic information within the segment.
[0096] Process C12: Obtain the product of the intra-segment adjustment weight and the extracted intra-segment semantic information, and update the intra-segment reserved information of the current statement to the extracted intra-segment semantic information by summing the product with the intra-segment reserved information of the current statement.
[0097] In one example, updating the segment-reserved information of the current statement to the extracted segment-series semantic information can be represented as follows:
[0098]
[0099] The updated intra-segment semantic information can be denoted as: In this way, useful information from the current statement is updated into the semantic information within the segment, so that the semantic information within the segment contains all the useful information from the processed problem statements, while useless information is deleted, thereby helping to improve the accuracy of subsequent matching.
[0100] After updating the semantic information within the segment corresponding to the current statement, a new current statement can be determined according to the time sequence, and the above processing can be performed on it until the feature information of all question statements in the question dialogue segment is updated to the semantic information within the segment.
[0101] Since the intra-segment semantic information for each question statement is obtained, the intra-segment semantic information for each question statement can be concatenated to obtain the intra-segment semantic information for the question dialogue segment. This can be represented as:
[0102] In one feasible approach, global semantic information can be obtained through procedures A2 to D2.
[0103] Process A2: Determine the current statement from the statements contained in the target processing object in a sequence that gradually moves away from the answer statement in terms of time.
[0104] The principle for determining the current statement is the same as that described in process A1, so it will not be repeated here.
[0105] Process B2: Using a second self-attention layer, the feature information of the current statement and the global reference text are processed to obtain the semantic information corresponding to the current statement.
[0106] The second self-attention layer can be an attention layer, but because it performs different functions, the trained parameters may be different from those of the first self-attention layer.
[0107] like Figure 2B As shown, the feature information of the current statement and the global reference text (which is in vector form) can be input into the second self-attention layer to obtain the extracted semantic information that integrates the semantic information of the current statement and the global reference text.
[0108] Extracting semantic information is denoted as q indicates that it is a question statement in the question dialogue segment, g indicates that it is used for global semantic information, and i indicates the i-th question statement.
[0109] Semantic information is extracted in the following ways:
[0110]
[0111] Where dk is The dimension of a single line. G represents the vector representation of the global reference text. It represents the characteristic information of the current statement.
[0112] Process C2: Using the third self-attention layer, the extracted semantic information and the extracted global semantic information corresponding to the current statement are processed to obtain the global retained information corresponding to the current statement.
[0113] The third self-attention layer can be an attention layer, but because it performs a different function, the trained parameters may differ from those of the first and second self-attention layers. The extracted semantic information output by the second self-attention layer, along with the extracted global semantic information, is input into the third self-attention layer, which then determines the useful information in the current sentence based on the extracted global semantic information.
[0114] The extracted global semantic information can be represented as It represents the global semantic information extracted from the semantics of the first i-1 question statements in the question dialogue segment.
[0115] The globally reserved information corresponding to the current statement can be denoted as: Its extraction method can be represented as follows:
[0116]
[0117] Where dk is The dimension of a single line.
[0118] Process D2: Based on the global reserved information of the current statement and the global adjustment weight of the extracted global semantic information, update the global reserved information of the current statement to the extracted global semantic information until the processing of the statements contained in the target processing object is completed.
[0119] The second updated weight value can be denoted as a. gi It is determined in the following manner:
[0120]
[0121] MLP stands for Multilayer Perceptron. Its structure can be determined as needed, and its parameters can be obtained through training as needed. It should be noted that the structure and parameters of this multilayer perceptron can be the same as or different from those of the aforementioned multilayer perceptron.
[0122] Updating the globally reserved information of the current statement to the extracted global semantic information can be achieved in the following way:
[0123]
[0124] After obtaining the global semantic information corresponding to the current statement, a new current statement can be determined, and the above process A2 to D2 can be repeated until the global semantic information corresponding to all question statements in the question dialogue segment is obtained.
[0125] Based on the global semantic information of each question statement, they can be concatenated to obtain the global semantic information corresponding to the question dialogue segment, which can be represented as follows: Right now
[0126] Because the dialogue processing layer extracts intra-segment semantic information and global semantic information between each dialogue segment or response statement and the global reference text, and removes semantics irrelevant to the dialogue in the statements, it solves the problem that not all semantic information carried by statements is useful for retrieving response statements, and that useful information needs to be extracted and interfering information removed.
[0127] In the above process, because the intra-segment semantic information and global semantic information of the preceding dialogue segment, the following dialogue segment, and the answer statement are extracted independently, the dilution of the intra-segment semantic information and global semantic information of the answer statement by irrelevant information in the preceding and following dialogue segments is avoided. This ensures that the weight of the answer statement can be adjusted independently, thereby ensuring a more accurate semantic matching degree between the subsequent question dialogue segment and the candidate dialogue material, and making the semantic matching degree of the candidate dialogue material corresponding to the answer statement that matches the current question statement higher.
[0128] Sub-step S2063: Determine the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement.
[0129] After obtaining intra-segment semantic information and global semantic information, a connection layer can be used to calculate the degree of matching between the question and answer statements in the question dialogue segment. In this embodiment, such as Figure 2C As shown, the connection layer is used to calculate the semantic matching degree.
[0130] In one feasible approach, sub-step S2063 can be implemented through processes A3 to C3.
[0131] Process A3: Based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement, calculate the cross-attention matrix between the question dialogue segment and the preceding dialogue segment, the following dialogue segment, and the answer statement, respectively.
[0132] Different data can be input as needed and processed through the connection layer. For example, the connection layer's processing includes the following stages:
[0133] Phase I: Calculate the word-level cross-attention matrix.
[0134] Taking the question dialogue segment and the preceding dialogue segment as examples, the word-level cross-attention matrix can be denoted as: Each element in the word-level cross-attention matrix can be denoted as... This represents the transpose of the a-th row of the word vector concatenation matrix of the question statements in the question dialogue segment. q} b This is represented as the b-th row in the concatenation matrix of the word vectors of the preceding statements in the preceding dialogue segment.
[0135] Accordingly, word-level cross-attention matrices can be obtained based on the input question dialogue segment and the subsequent dialogue segment, and word-level cross-attention matrices can also be obtained for the question dialogue segment and the answer statement.
[0136] Phase II: Calculate the sentence-level cross-attention matrix.
[0137] Sentence-level cross-attention matrix can be denoted as: Each element in the matrix can be denoted as This represents the transpose of the a-th row in the concatenation matrix of the feature information of the question statement. h} b This is represented as row b in the concatenation matrix of the feature information from the preceding statement.
[0138] Phase III: Calculate the attention cross-attention matrix.
[0139] Attention cross-attention matrix can be denoted as Each element in the matrix can be denoted as This represents the transpose of the feature extraction result of the a-th row in the concatenated matrix of feature information of the question statement through a self-attention layer. h} b This is represented as the result of feature extraction through a self-attention layer in the b-th row of the feature information concatenation matrix of the preceding statement.
[0140] The self-attention layer can be a single-head self-attention layer in a transformer, U′ q It can be obtained by any appropriate means, so I will not go into details.
[0141] Process B3: Concatenate the cross-attention matrices of the question dialogue segment with the preceding dialogue segment, the following dialogue segment, and the answer statement.
[0142] The word-level cross-attention matrix, sentence-level cross-attention matrix, and attention cross-attention matrix of the preceding dialogue segment are concatenated to form the corresponding concatenation result, denoted as .
[0143] Process C3: Input the concatenation result into the convolutional neural network model to obtain the semantic matching degree between the output question dialogue segment and the candidate dialogue material.
[0144] For example, inputting the concatenated result determined based on the question dialogue segment and the preceding dialogue segment into a trained convolutional neural network, the first matching degree of its output is denoted as... Specifically, the first relevance is determined based on the feature information of the question statement and the feature information of the preceding statements in the question dialogue segment, as well as the concatenation matrix of the word vectors of the question statement and the concatenation matrix of the word vectors of the preceding statements. This relevance can be denoted as... Where u represents statement relevance, and h represents the statement relevance between the question statement and the preceding statement.
[0145] See also Figure 2C , Among them, U q It is a concatenation matrix of the feature information of the question statement, U h E is a concatenation matrix of feature information from the preceding statement. q It is the concatenated matrix of word vectors of the question statement, E h It is a concatenation matrix of word vectors from the preceding statement.
[0146] Accordingly, by inputting different data, the connection layer can obtain different matching degrees, such as the word vector concatenation matrix E of the input question statement. q The word vector concatenation matrix E of the answer statement r The concatenation matrix U of the feature information of the question statement h and the characteristic information of the answer statement U r (Since the answer statement consists of only one sentence, its concatenation matrix is itself), thus obtaining the second matching degree.
[0147] The concatenated matrix E of semantic information within the input segment and word vectors of the question statement q The word vector concatenation matrix E of the answer statement r This allows us to obtain a third matching degree, etc.
[0148] By inputting different data combinations into the connection layer, the corresponding matching degree is obtained. Then, the multilayer perceptron is used to process the output matching degree, and finally the semantic matching degree between the question dialogue segment and the candidate dialogue material is obtained.
[0149] For example, mapping multiple matching scores to the final matching confidence score can be expressed as:
[0150]
[0151] MLP stands for Multilayer Perceptron, which can be a linear multilayer perceptron. These are the matching degrees at the sentence level between the question statement and the preceding dialogue segment, the answer statement, and the following dialogue segment. These represent the semantic matching degree between the question statement and the preceding dialogue segment, the answer statement, and the following dialogue segment within the same segment. The method of obtaining this degree is similar to... Similarly, the difference lies in the input data being U q and U h Replace with the intra-segment semantic information of the question dialogue segment and the intra-segment semantic information of the preceding dialogue segment. These represent the matching degree between the question statement and the preceding dialogue segment, the answer statement, and the following dialogue segment at the global semantic level, respectively. The method of obtaining this degree is similar to... Similarly, the difference lies in the input data being U q and U h Replace with the global semantic information of the question dialogue segment and the global semantic information of the preceding dialogue segment.
[0152] Step S208: Based on the semantic matching degree, determine the target dialogue material from the plurality of candidate dialogue materials, and use the answer statement in the target dialogue material as the answer statement of the current question statement.
[0153] For example, select the one with the highest semantic matching degree as the target dialogue material, and select the answer statement in the target dialogue material as the answer statement for the current question statement.
[0154] By utilizing the preceding and following statements in the response to the question, the above method fully leverages the semantic information of the context, thereby improving retrieval accuracy. Furthermore, processing the preceding dialogue, the response, and the following dialogue separately to obtain their respective intra-segment semantic information and related semantic information allows for easier control of the response's weight, leading to better adjustments and more accurate retrieval results. This enhances the retrieval accuracy in multi-turn dialogue systems.
[0155] This method can calculate the degree of matching between the question statement and the answer statements of multiple candidate materials, and then determine the answer statement to answer the question statement based on the degree of matching, thus ensuring the accuracy of the response of the retrieval-based multi-turn dialogue system.
[0156] Example 3
[0157] Reference Figure 3 The diagram shows a structural block diagram of the data processing apparatus according to Embodiment 3 of this application.
[0158] In this embodiment, the data processing device is suitable for automatic dialogue generation, and the device includes:
[0159] The acquisition module 302 is used to acquire the question dialogue segment corresponding to the current question statement during the automatic dialogue with the interactive object;
[0160] The filtering module 304 is used to filter out multiple candidate dialogue materials associated with the question dialogue segment from a set of preset dialogue materials based on the keyword features of the question dialogue segment. The candidate dialogue materials include a set answer statement and an associated statement of the answer statement.
[0161] The matching module 306 is used to determine the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the semantic information of the question dialogue segment and the semantic information between the answer statement and the related statement in the candidate dialogue material.
[0162] The determining module 308 is used to determine the target dialogue material from the plurality of candidate dialogue materials based on the semantic matching degree, and use the answer statement in the target dialogue material as the answer statement to the current question statement.
[0163] Optionally, the filtering module 304 is used to determine multiple candidate dialogue materials that are semantically related to the question dialogue segment based on the word frequency and inverse text frequency of the keywords in the question dialogue segment, and the word frequency and inverse text frequency of the keywords in the dialogue material.
[0164] Optionally, the associated statements include a preceding statement that precedes the answer statement in the dialogue sequence and a following statement that follows the answer statement in the dialogue sequence, wherein the preceding statement forms a preceding dialogue segment and the following statement forms a following dialogue segment.
[0165] Optionally, the matching module 306 is used to form a global reference text from the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement; to perform intra-segment processing on the target processing objects, respectively, using the question dialogue segment, the answer statement, the preceding dialogue segment, and the following dialogue segment as target processing objects, to obtain corresponding intra-segment semantic information; and to determine the global semantic information corresponding to the target processing object based on the target processing object and the global reference text; and to determine the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement.
[0166] Optionally, the matching module 306 is configured to, when performing intra-segment processing on the target processing object to obtain corresponding intra-segment semantic information, determine the current statement from the statements contained in the target processing object in a sequence that gradually moves away from the answer statement; use a first self-attention layer to process the feature information of the current statement and the extracted intra-segment semantic information to obtain the intra-segment retained information corresponding to the current statement; and update the intra-segment retained information of the current statement to the extracted intra-segment semantic information according to the intra-segment adjustment weights of the intra-segment retained information of the current statement and the extracted intra-segment semantic information, until the processing of the statements contained in the target processing object is completed.
[0167] Optionally, the matching module 306 is configured to, when updating the intra-segment retained information of the current statement to the extracted intra-segment semantic information based on the intra-segment retained information of the current statement and the intra-segment semantic information, determine the intra-segment adjustment weight; obtain the product of the intra-segment adjustment weight and the extracted intra-segment semantic information; and update the intra-segment retained information of the current statement to the extracted intra-segment semantic information by summing the product with the intra-segment retained information of the current statement.
[0168] Optionally, when determining the global semantic information corresponding to the target processing object based on the target processing object and the global reference text, the matching module 306 determines the current statement from the statements contained in the target processing object in a sequence that gradually moves away from the answer statement; it uses a second self-attention layer to process the feature information of the current statement and the global reference text to obtain the extracted semantic information corresponding to the current statement; it uses a third self-attention layer to process the extracted semantic information corresponding to the current statement and the extracted global semantic information to obtain the globally retained information corresponding to the current statement; and it updates the globally retained information of the current statement to the extracted global semantic information based on the global adjustment weights of the globally retained information of the current statement and the extracted global semantic information, until the processing of the statements contained in the target processing object is completed.
[0169] Optionally, the matching module 306 is configured to, when determining the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement, calculate the cross-attention matrices between the question dialogue segment and the preceding dialogue segment, the following dialogue segment, and the answer statement respectively, based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement respectively; concatenate the cross-attention matrices between the question dialogue segment and the preceding dialogue segment, the following dialogue segment, and the answer statement respectively; and input the concatenation result into a convolutional neural network model to obtain the output semantic matching degree between the question dialogue segment and the candidate dialogue material.
[0170] The data processing apparatus of this embodiment is used to implement the corresponding data processing methods in the foregoing multiple method embodiments and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. Furthermore, the functional implementation of each module in the data processing apparatus of this embodiment can be referred to the description of the corresponding part in the foregoing method embodiments, which will also not be repeated here.
[0171] Example 4
[0172] Reference Figure 4 The diagram shows a structural schematic of an electronic device according to Embodiment 4 of this application. The specific embodiments of this application do not limit the specific implementation of the electronic device.
[0173] like Figure 4 As shown, the electronic device may include: a processor 402, a communications interface 404, a memory 406, and a communications bus 408.
[0174] in:
[0175] The processor 402, communication interface 404, and memory 406 communicate with each other via communication bus 408.
[0176] Communication interface 404 is used to communicate with other electronic devices or servers.
[0177] The processor 402 is used to execute program 410, specifically to perform the relevant steps in the above data processing method embodiment.
[0178] Specifically, program 410 may include program code that includes computer operation instructions.
[0179] Processor 402 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application. The smart device includes one or more processors, which 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.
[0180] Memory 406 is used to store program 410. Memory 406 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0181] Specifically, program 410 can be used to cause processor 402 to perform the operation corresponding to the aforementioned data processing method.
[0182] The specific implementation of each step in program 410 can be found in the corresponding steps and units described in the above data processing method embodiments, and will not be repeated here. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the devices and modules described above can be referred to the corresponding process descriptions in the foregoing method embodiments, and will not be repeated here.
[0183] It should be noted that, depending on the implementation needs, the various components / steps described in the embodiments of this application can be broken down into more components / steps, or two or more components / steps or parts of the operation of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of this application.
[0184] The methods described in the embodiments of this application can be implemented in hardware, firmware, or 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 as computer code downloaded over a network that is originally stored in a remote recording medium or a non-transitory machine-readable medium and will be stored in a local recording medium. Thus, the methods described herein can be stored as software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components (e.g., RAM, ROM, flash memory, etc.) capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the data processing methods described herein. Furthermore, when a general-purpose computer accesses code used to implement the data processing methods shown herein, the execution of the code transforms the general-purpose computer into a dedicated computer for executing the data processing methods shown herein.
[0185] Those skilled in the art will recognize that the units and method steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0186] The above embodiments are only used to illustrate the embodiments of this application, and are not intended to limit the embodiments of this application. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the embodiments of this application. Therefore, all equivalent technical solutions also fall within the scope of the embodiments of this application, and the patent protection scope of the embodiments of this application should be defined by the claims.
Claims
1. A data processing method suitable for automatic dialogue generation, the method comprising: Retrieve the question dialogue segment corresponding to the current question statement during an automated dialogue with the interactive object; Based on the keyword features of the question dialogue segment, multiple candidate dialogue materials associated with the question dialogue segment are selected from a set of dialogue materials. The candidate dialogue materials include a set answer statement and a related statement of the answer statement. Based on the semantic information of the question dialogue segment and the semantic information between the answer statements and related statements in the candidate dialogue material, the semantic matching degree between the question dialogue segment and the candidate dialogue material is determined; Based on the semantic matching degree, a target dialogue material is determined from the plurality of candidate dialogue materials, and the answer statement in the target dialogue material is used as the answer statement to the current question statement; The method further includes: using the expression layer in the trained neural network model to extract semantic information of the question dialogue segment from the question dialogue segment, and extracting semantic information between the answer statement and the related statement in the candidate dialogue material from the candidate dialogue material, wherein the trained neural network model includes: a dialogue processing layer; Determining the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the semantic information of the question dialogue segment and the semantic information between the answer statement and the related statement in the candidate dialogue material includes: using the dialogue processing layer in the trained neural network model to extract intra-segment semantic information and global semantic information from the semantic information of the question dialogue segment, and extracting intra-segment semantic information and global semantic information from the semantic information between the answer statement and the related statement in the candidate dialogue material; and determining the semantic matching degree based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment and the candidate dialogue material respectively.
2. The method according to claim 1, wherein, The step of filtering multiple candidate dialogue materials associated with the question dialogue segment from a preset set of dialogue materials based on the keyword features of the question dialogue segment includes: Based on the word frequency and inverse text frequency of the keywords in the question dialogue segment, and the word frequency and inverse text frequency of the keywords in the dialogue material, multiple candidate dialogue materials that are semantically associated with the question dialogue segment are determined.
3. The method of claim 1, wherein, The associated statements include a preceding statement that precedes the answer statement in the dialogue sequence and a following statement that follows the answer statement in the dialogue sequence, wherein the preceding statement forms a preceding dialogue segment and the following statement forms a following dialogue segment.
4. The method of claim 3, wherein, The step of determining the semantic matching degree based on the intra-segment semantic information and the global semantic information corresponding to the question dialogue segment and the candidate dialogue material respectively includes: The question dialogue segment, the preceding dialogue segment included in the candidate dialogue material, the following dialogue segment included in the candidate dialogue material, and the answer statement included in the candidate dialogue material are combined into a global reference text; The question dialogue segment, the answer statement, the preceding dialogue segment, and the following dialogue segment are respectively used as target processing objects. Intra-segment processing is performed on the target processing objects to obtain the corresponding intra-segment semantic information. The global semantic information corresponding to the target processing object is determined based on the target processing object and the global reference text. The semantic matching degree is determined based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement.
5. The method of claim 4, wherein, The target processing object is subjected to intra-segment processing to obtain the corresponding intra-segment semantic information, including: The current statement is determined from the statements contained in the target processing object in a chronological order that gradually moves away from the answer statement. The first self-attention layer is used to process the feature information of the current statement and the extracted intra-segment semantic information to obtain the intra-segment retained information corresponding to the current statement. Based on the segment-retained information and the segment-adjusted weights of the extracted segment-sequential semantic information, the segment-retained information is updated to the extracted segment-sequential semantic information until the processing of the statements contained in the target processing object is completed.
6. The method of claim 5, wherein, The step of updating the extracted intra-segment semantic information with the intra-segment retained information based on the intra-segment adjustment weights of the intra-segment retained information and the extracted intra-segment semantic information includes: Based on the retained information within the segment and the extracted semantic information within the segment, the adjustment weight within the segment is determined; Obtain the product of the segment adjustment weight and the extracted segment semantic information, and update the extracted segment semantic information by summing the product with the segment retained information.
7. The method of claim 4, wherein, Based on the target processing object and the global reference text, the global semantic information corresponding to the target processing object is determined, including: The current statement is determined from the statements contained in the target processing object in a chronological order that gradually moves away from the answer statement. A second self-attention layer is used to process the feature information of the current statement and the global reference text to obtain the extracted semantic information corresponding to the current statement; The third self-attention layer is used to process the extracted semantic information and the extracted global semantic information corresponding to the current statement to obtain the global retained information corresponding to the current statement. Based on the global adjustment weights of the globally retained information and the extracted global semantic information, the globally retained information is updated to the extracted global semantic information until the processing of the statements contained in the target processing object is completed.
8. The method of claim 4, wherein, The step of determining the semantic matching degree based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement includes: Based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement, calculate the cross-attention matrix between the question dialogue segment and the preceding dialogue segment, the following dialogue segment, and the answer statement, respectively. The cross-attention matrices of the question dialogue segment, the preceding dialogue segment, the following dialogue segment, and the answer statement are concatenated; The concatenated result is input into a convolutional neural network model to obtain the semantic matching degree.
9. A data processing apparatus suitable for automatic dialogue generation, the apparatus comprising: The acquisition module is used to acquire the question dialogue segment corresponding to the current question statement during the automatic dialogue with the interactive object. The filtering module is used to filter out multiple candidate dialogue materials associated with the question dialogue segment from a set of preset dialogue materials based on the keyword features of the question dialogue segment. The candidate dialogue materials include a set answer statement and an associated statement of the answer statement. The matching module is used to determine the semantic matching degree between the question dialogue segment and the candidate dialogue material based on the semantic information of the question dialogue segment and the semantic information between the answer statements and related statements in the candidate dialogue material. The determining module is used to determine the target dialogue material from the plurality of candidate dialogue materials based on the semantic matching degree, and to use the answer statement in the target dialogue material as the answer statement to the current question statement; The device is further configured to extract semantic information of the question dialogue segment from the question dialogue segment using the expression layer in the trained neural network model, and to extract semantic information between the answer statement and the associated statement in the candidate dialogue material from the candidate dialogue material, wherein the trained neural network model includes: a dialogue processing layer; The matching module is configured to determine the semantic matching degree between the question dialogue segment and the candidate dialogue material by performing the following steps: using the dialogue processing layer in the trained neural network model, extracting intra-segment semantic information and global semantic information from the semantic information of the question dialogue segment, and extracting intra-segment semantic information and global semantic information from the semantic information between the answer statement and the related statement in the candidate dialogue material; and determining the semantic matching degree based on the intra-segment semantic information and global semantic information corresponding to the question dialogue segment and the candidate dialogue material respectively.
10. An electronic device comprising: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform an operation corresponding to the data processing method as described in any one of claims 1-8.
11. A computer storage medium having stored thereon a computer program which, when executed by a processor, implements the data processing method according to any one of claims 1-8.