A method of sentence processing and related apparatus
By segmenting and merging multiple candidate statements, matching statements for the target statement are generated based on importance parameter values and word dependencies. This solves the problem of mismatch between multiple candidate statements and improves the processing performance of question answering and search systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENPAY PAID TECH
- Filing Date
- 2022-05-09
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies cannot determine the matching statement of the target statement from multiple candidate statements when none of them match the target statement, resulting in poor processing performance of question answering and search systems.
The similarity between candidate statements and target statements is calculated. If they do not match, they are segmented. Candidate statements are filtered based on importance parameter values, and the matching statements of the target statements are obtained by fusing based on word dependencies.
Even when multiple candidate statements do not match the target statement, it can still meet the matching requirements of the target statement, thus improving the processing performance of question-answering and search systems.
Smart Images

Figure CN117094307B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, and in particular to a method and related apparatus for statement processing. Background Technology
[0002] With the rapid development of natural language processing technology, sentence similarity calculation is widely used in application scenarios such as question-answering systems and search systems. Typically, by calculating the sentence similarity between two sentences, it is determined whether the two sentences match, and the matching sentence is used as the processing result in question-answering systems, search systems, and other scenarios.
[0003] In related technologies, for a target statement and multiple candidate statements, the similarity between each candidate statement and the target statement is first calculated by using the word features of each candidate statement and the word features of the target statement; then, based on the similarity, the candidate statement that matches the target statement is determined from the multiple candidate statements.
[0004] However, in practical applications, there are situations where multiple candidate statements do not match the target statement. In such cases, the above method cannot determine the candidate statement that matches the target statement from among multiple candidate statements, which fails to meet the actual requirement of obtaining the matching statement of the target statement. As a result, the processing effect of application scenarios such as question-answering systems and search systems is poor. Summary of the Invention
[0005] To address the aforementioned technical problems, this application provides a method and related apparatus for sentence processing, which can still meet the actual need to obtain a matching sentence for the target sentence even when multiple first candidate sentences do not match the target sentence, thereby improving the processing effect in application scenarios such as question-answering systems and search systems.
[0006] The embodiments of this application disclose the following technical solutions:
[0007] On the one hand, this application provides a method for statement processing, the method comprising:
[0008] Obtain the statement similarity between multiple first candidate statements and the target statement;
[0009] If it is determined based on the statement similarity that none of the multiple first candidate statements match the target statement, the multiple first candidate statements are segmented to obtain multiple second candidate statements;
[0010] Based on the importance parameter value of the second candidate statement to the target statement, a plurality of first statements to be merged are determined from the plurality of second candidate statements;
[0011] Based on the dependency relationships between the words in the plurality of first statements to be merged, the plurality of first statements to be merged are fused to obtain the fused statement that matches the target statement.
[0012] On the other hand, this application provides a statement processing apparatus, the apparatus comprising: an acquisition unit, a segmentation unit, a determination unit, and a fusion unit;
[0013] The acquisition unit is used to acquire the statement similarity between the target statement and the multiple first candidate statements respectively;
[0014] The segmentation unit is used to segment the multiple first candidate statements to obtain multiple second candidate statements if it is determined based on the statement similarity that none of the multiple first candidate statements match the target statement.
[0015] The determining unit is configured to determine a plurality of first statements to be merged from the plurality of second candidate statements based on the importance parameter value of the second candidate statement to the target statement;
[0016] The fusion unit is used to perform fusion processing on the plurality of first statements to be fused based on the dependency relationship between each word in the plurality of first statements to be fused to obtain a fused statement that matches the target statement.
[0017] On the other hand, this application provides an apparatus for statement processing, the apparatus including a processor and a memory:
[0018] The memory is used to store program code and transmit the program code to the processor;
[0019] The processor is configured to execute the statement processing method described above according to the instructions in the program code.
[0020] On the other hand, embodiments of this application provide a computer-readable storage medium for storing a computer program, which, when executed by a processor, performs the statement processing method described above.
[0021] On the other hand, embodiments of this application provide a computer program product, which includes a computer program or instructions; when the computer program or instructions are executed by a processor, the statement processing method described above is performed.
[0022] As can be seen from the above technical solution, for the target statement and multiple first candidate statements, the statement similarity between each first candidate statement and the target statement is calculated; when it is determined that multiple first candidate statements do not match the target statement based on the statement similarity, the multiple first candidate statements are segmented to obtain multiple second candidate statements; multiple first statements to be fused are determined from the multiple second candidate statements by using the importance parameter value of each second candidate statement to the target statement; and the multiple first statements to be fused are fused according to the dependency relationship between each word in the multiple first statements to be fused to obtain the fused statement that matches the target statement.
[0023] This method, when multiple candidate statements do not match the target statement based on statement similarity, segments and determines the importance of these candidate statements to the target statement, resulting in multiple first statements to be merged. Then, based on the dependencies between words, these multiple first statements are merged into a matching statement for the target statement. Therefore, even when multiple candidate statements do not match the target statement, this method can still meet the practical need for obtaining a matching statement, thereby improving the processing performance in question-answering systems, search systems, and other application scenarios. Attached Figure Description
[0024] 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 of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a schematic diagram illustrating an application scenario of a statement processing method provided in an embodiment of this application;
[0026] Figure 2 A flowchart illustrating a statement processing method provided in this application embodiment;
[0027] Figure 3 A schematic diagram of the syntactic structure of a first candidate statement provided in an embodiment of this application;
[0028] Figure 4 A flowchart illustrating a method for obtaining statement similarity provided in an embodiment of this application;
[0029] Figure 5 A flowchart illustrating another method for obtaining statement similarity provided in an embodiment of this application;
[0030] Figure 6 A schematic diagram of the input and output of a convolutional neural network model architecture provided in an embodiment of this application;
[0031] Figure 7 A schematic diagram of a statement processing apparatus provided in an embodiment of this application;
[0032] Figure 8 This application provides a schematic diagram of the structure of a server according to an embodiment of the present application.
[0033] Figure 9 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Detailed Implementation
[0034] The embodiments of this application will now be described with reference to the accompanying drawings.
[0035] At present, in application scenarios such as question-answering systems and search systems, for the target statement and multiple candidate statements, the similarity between each candidate statement and the target statement is first calculated by using the word features of each candidate statement and the word features of the target statement; then, based on the statement similarity, the candidate statement that matches the target statement is determined from the multiple candidate statements, which is used as the processing result of the question-answering system, search system and other scenarios.
[0036] For example, taking a question-answering system as an example, for a question statement and multiple first answer statements, firstly, the similarity between each first answer statement and the question statement is calculated by using the word features of each first answer statement and the word features of the question statement; then, based on the similarity, the first answer statement that matches the question statement is determined from the multiple first answer statements, and this is taken as the question-answering result of the question-answering system.
[0037] However, in practical applications, there are situations where multiple candidate statements do not match the target statement. In such cases, the above method cannot determine the candidate statement that matches the target statement from among multiple candidate statements, which fails to meet the actual requirement of obtaining the matching statement of the target statement. As a result, the processing effect of application scenarios such as question-answering systems and search systems is poor.
[0038] Based on the above example, in practical applications, there are situations where multiple first answer statements do not match the question statements. In such cases, the above method cannot determine the first answer statement that matches the question statement from among the multiple first answer statements, which fails to meet the actual requirement of obtaining the answer statement that matches the target statement, resulting in poor question-answering performance of the question-answering system.
[0039] In view of this, this application proposes a method and related apparatus for sentence processing. When multiple first candidate sentences do not match the target sentence based on sentence similarity, the method obtains multiple first sentences to be fused that are important to the target sentence through segmentation and importance determination. Then, according to the dependencies between words, the multiple first sentences to be fused are merged into a fused sentence that matches the target sentence. Therefore, even when multiple first candidate sentences do not match the target sentence, this method can still meet the practical need to obtain a matching sentence for the target sentence, thereby improving the processing performance in application scenarios such as question-answering systems and search systems.
[0040] In other words, when multiple first-answer statements do not match the question statement based on statement similarity, this method segments and determines the importance of these first-answer statements to the question statement, resulting in multiple first-to-be-fused statements. Then, based on the dependencies between words, these multiple first-to-be-fused statements are merged into an answer statement that matches the question statement. Therefore, even when multiple first-answer statements do not match the question statement, this method can still meet the practical requirement of obtaining an answer statement that matches the question statement, thereby improving the question-answering effect of the question-answering system.
[0041] To facilitate understanding of the technical solution of this application, the statement processing method provided in the embodiments of this application will be introduced below in conjunction with actual application scenarios.
[0042] See Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario of a statement processing method provided in an embodiment of this application. Figure 1 The application scenario shown includes a terminal device 101 and a server 102. The terminal device 101 is used as a device to input target statements, and the server 102 is used as a device to process statements. The server 102 stores multiple first candidate statements.
[0043] In response to the input of the target statement, terminal device 101 acquires the target statement and sends it to server 102; server 102 acquires the statement similarity scores of multiple first candidate statements with the target statement. As an example, the statement processing method is applied to a question-and-answer system, where the target statement is the question statement, and the multiple first candidate statements are multiple first answer statements. In response to the input of the question statement, terminal device 101 acquires the question statement and sends it to server 102; server 102, for the question statement and the multiple first answer statements, can first acquire the statement similarity score between each first answer statement and the question statement.
[0044] If server 102 determines, based on statement similarity, that multiple first candidate statements do not match the target statement, it performs segmentation on the multiple first candidate statements to obtain multiple second candidate statements. Building upon the above example, if server 102 determines, based on statement similarity, that multiple first answer statements do not match the question statement, it can segment the multiple first answer statements to obtain multiple second answer statements, where the number of second answer statements is greater than the number of first answer statements.
[0045] Server 102 determines multiple first statements to be merged from multiple second candidate statements based on the importance parameter values of the second candidate statements to the target statement. Building upon the above example, server 102 can filter multiple second candidate statements to obtain multiple first statements to be merged using the importance parameter values of multiple second answer statements to the question statements.
[0046] Server 102, based on the dependencies between words in multiple first statements to be merged, performs fusion processing on these statements to obtain a merged statement matching the target statement. Server 102 then sends the merged statement to terminal device 101, which displays the merged statement corresponding to the target statement. Building upon the above example, server 102 can also merge multiple first statements to be merged using the dependencies between words to obtain an answer statement matching the question statement. Server 102 then sends the answer statement to terminal device 101, which displays the answer statement corresponding to the question statement.
[0047] As can be seen, when multiple candidate statements based on statement similarity do not match the target statement, this method obtains multiple first-paragraph statements that are important to the target statement by segmenting and determining their importance. Then, according to the dependencies between words, these multiple first-paragraph statements are merged into a matching statement for the target statement. Therefore, even when multiple candidate statements do not match the target statement, this method can still meet the practical need to obtain a matching statement for the target statement, thereby improving the processing performance in application scenarios such as question-answering systems and search systems.
[0048] In other words, when multiple first-answer statements do not match the question statement based on statement similarity, this method segments and determines the importance of these first-answer statements to the question statement, resulting in multiple first-to-be-fused statements. Then, based on the dependencies between words, these multiple first-to-be-fused statements are merged into an answer statement that matches the question statement. Therefore, even when multiple first-answer statements do not match the question statement, this method can still meet the practical requirement of obtaining an answer statement that matches the question statement, thereby improving the question-answering effect of the question-answering system.
[0049] The statement processing method provided in this application can be applied to statement processing devices with data processing capabilities, such as servers and terminal devices. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services, but is not limited to these. Terminal devices include, but are not limited to, mobile phones, tablets, computers, smart cameras, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft, but are not limited to these. Terminal devices and servers can be directly or indirectly connected via wired or wireless communication, and this application does not impose any restrictions on this connection.
[0050] The statement processing method provided in this application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, vehicle scenarios, intelligent transportation, and assisted driving.
[0051] The following describes in detail the statement processing method provided in the embodiments of this application, using a server as the statement processing device.
[0052] See Figure 2 This figure is a flowchart of a statement processing method provided in an embodiment of this application. Figure 2 As shown, the method for processing this statement includes the following steps:
[0053] S201: Obtain the statement similarity between multiple first candidate statements and the target statement.
[0054] In this embodiment of the application, after obtaining the target statement, for the target statement and multiple first candidate statements, it is first necessary to obtain the statement similarity between each first candidate statement and the target statement, so that in subsequent steps, the statement similarity can be used to determine whether each first candidate statement matches the target statement, thereby determining whether there is a first candidate statement among the multiple first candidate statements that matches the target statement.
[0055] In the implementation of S201, obtaining the sentence similarity between the first candidate sentence and the target sentence by using the word features of the first candidate sentence and the target sentence only represents calculating the sentence similarity from the word dimension, which has the problem of a single dimension, resulting in an inaccurate sentence similarity. Therefore, based on the word features of the first candidate sentence and the word features of the target sentence, the sentence similarity between the first candidate sentence and the target sentence is obtained by combining the first sentence feature of the first candidate sentence and the second sentence feature of the target sentence. This method calculates the sentence similarity between the first candidate sentence and the target sentence from both the word dimension and the sentence dimension, making the obtained sentence similarity more accurate.
[0056] That is, this application provides a possible implementation method, S201 for example can be: for each first candidate statement, perform similarity calculation based on the first word feature of the first candidate statement, the first statement feature of the first candidate statement, the second word feature of the target statement and the second statement feature of the target statement to obtain the statement similarity between the first candidate statement and the target statement.
[0057] As an example, in a question-answering system, the target statement is the question statement, and the first candidate statement is the first answer statement. S201 can be, for example, as follows: For each first answer statement, perform similarity calculation based on the first word feature of the first answer statement, the first statement feature of the first answer statement, the second word feature of the question statement, and the second statement feature of the question statement to obtain the statement similarity between the first answer statement and the question statement.
[0058] For a detailed explanation of the specific implementation of S201, please refer to the following embodiment of the method for obtaining statement similarity, which will not be described in detail here.
[0059] S202: If multiple first candidate statements are determined to be mismatched with the target statement based on statement similarity, the multiple first candidate statements are segmented to obtain multiple second candidate statements.
[0060] Since after obtaining the similarity between each first candidate statement and the target statement in S201, it is possible to determine whether each first candidate statement matches the target statement based on the statement similarity. However, research has found that in practical applications such as question-answering systems and search systems, there are situations where multiple first candidate statements do not match the target statement. In such cases, the implementation methods in related technologies cannot determine the first candidate statement that matches the target statement from multiple first candidate statements, which fails to meet the actual requirement of obtaining the matching statement of the target statement. As a result, the processing effect of application scenarios such as question-answering systems and search systems is poor.
[0061] Therefore, in this embodiment of the application, when it is determined that multiple first candidate statements do not match the target statement based on statement similarity, it is possible to consider integrating the multiple first candidate statements into a new statement as the matching statement for the target statement. Based on this, for multiple first candidate statements, since there are relatively complex first candidate statements, it is first necessary to decompose the multiple first candidate statements into multiple simpler second candidate statements through a segmentation method.
[0062] In the specific implementation of S202, it is necessary to consider segmenting the first candidate statement according to its syntactic structure; and the syntactic structure of the first candidate statement can be obtained by performing syntactic structure analysis on the first candidate statement. Therefore, this application provides a possible implementation method, and S202 may include, for example, the following S2021-S2022:
[0063] S2021: Perform syntactic structure analysis on multiple first candidate statements to obtain the syntactic structure of multiple first candidate statements.
[0064] S2021 can be, for example, performing syntactic structure analysis on multiple first candidate statements through a Language Technology Platform (LTP) to obtain the syntactic structure of multiple first candidate statements.
[0065] As an example, the first candidate statement is "I am an algorithm engineer and I come from company A". Using LTP (Linguistic Programming) to perform syntactic structure analysis on the first candidate statement "I am an algorithm engineer and I come from company A", we obtain the syntactic structure of the first candidate statement "I am an algorithm engineer and I come from company A". See [link to LTP]. Figure 3 The diagram illustrates the syntactic structure of a first candidate statement. The dependencies between "I" and "is" are subject-verb (SBV), between "is" and "engineer" is verb-object (VOB), between "algorithm" and "engineer" is attribute (VOB), between "I" and "from" is SBV, between "from" and "company A" is VOB, between "and" and "from teacher" is adverbial (ADV), between "is" and "from teacher" is coordinate (COO), and "is" represents the head (HED) relation.
[0066] S2022: Based on the syntactic structure of multiple first candidate statements, the multiple first candidate statements are segmented to obtain multiple second candidate statements.
[0067] As an example, based on the above example, the syntactic structure of the first candidate statement "I am an algorithm engineer and I come from company A" indicates that the SBV-VOB link recurs twice. Therefore, the first candidate statement "I am an algorithm engineer and I come from company A" is divided into two second candidate statements, namely the second candidate statement "I am an algorithm engineer" and the second candidate statement "from company A".
[0068] For S2021-S2022, as an example, in a question-answering system, the first candidate statement is the first answer statement. Syntactic structure analysis is performed on multiple first answer statements to obtain the syntactic structure of multiple first answer statements. Based on the syntactic structure of multiple first answer statements, multiple first answer statements are segmented to obtain multiple second answer statements.
[0069] S203: Based on the importance parameter value of the second candidate statement to the target statement, determine multiple first statements to be merged from multiple second candidate statements.
[0070] In this embodiment, after segmenting multiple first candidate statements into multiple second candidate statements in S202, it is necessary to measure the importance of each second candidate statement to the target statement, and select the second candidate statements with higher importance to the target statement from among the multiple second candidate statements as multiple first statements to be merged. The importance of the second candidate statement to the target statement is represented by the importance parameter value of the second candidate statement to the target statement.
[0071] In a specific implementation of S203, the importance parameter value of the second candidate statement to the target statement can be obtained, for example, by summing the importance parameter values of each word in the second candidate statement to the target statement. The importance parameter value of each word in the second candidate statement to the target statement can be obtained, for example, by inputting the second candidate statement into a trained importance detection model. The importance detection model is obtained by iteratively training a preset neural network to learn the importance label data of each word in the second training statement to the first training statement, based on the first and second training statements. Based on this, a lower limit value representing importance is preset as a threshold value. By using the importance parameter value of the second candidate statement to the target statement and the preset threshold, second candidate statements with higher importance to the target statement can be selected from multiple second candidate statements as multiple first statements to be fused. Therefore, this application provides a possible implementation method, and S203 may include, for example, the following S2031-S2033:
[0072] S2031: Obtain the importance parameter values of each word in the second candidate sentence to the target sentence through the importance detection model; the importance detection model is obtained by training a preset neural network based on the importance label data of each word in the first training sentence, the second training sentence, and the second training sentence to the first training sentence.
[0073] The training process of the importance detection model refers to the following: First, acquiring training samples for training a pre-defined neural network, namely, the importance label data of each word in the first training statement, the second training statement, and the second training statement relative to the first training statement; second, inputting the first and second training statements into the pre-defined neural network to predict the importance of each word in the second training statement relative to the first training statement, and outputting the predicted label data of each word in the second training statement relative to the first training statement; then, determining whether the predicted label data matches the importance label data. If not, it indicates that the predicted label data does not meet the training objective, and the network parameters of the pre-defined neural network need to be iteratively trained using the loss function of the pre-defined neural network until a preset number of iterations is reached or the pre-defined neural network converges; finally, determining the pre-defined neural network after training as the importance detection model. Therefore, this application provides a possible implementation method, and the training method of this importance detection model includes the following S1-S4:
[0074] S1: Obtain the importance label data of each word in the first training statement, the second training statement, and the second training statement to the first training statement.
[0075] S2: Input the first training statement and the second training statement into a preset neural network for prediction processing, and output the predicted label data of each word in the second training statement for the first training statement;
[0076] S3: If the predicted label data does not match the importance label data, use the loss function of the preset neural network to iteratively train the network parameters of the preset neural network;
[0077] S4: The pre-trained neural network is identified as the importance detection model.
[0078] S2032: Sum the importance parameter values of each word in the second candidate statement to the target statement to determine the importance parameter value of the second candidate statement to the target statement.
[0079] As an example, the formula for calculating the importance parameter value of the second candidate statement to the target statement is shown below:
[0080]
[0081] In the above formula, I(w) k Q) represents w k Regarding the importance parameter value of Q, w k Let Q represent the i-th word in the second candidate statement C, and let Q represent the target statement.
[0082] S2033: Based on the importance parameter value of the second candidate statement to the target statement and the preset threshold, determine multiple first statements to be merged from multiple second candidate statements.
[0083] S2033 can be, for example, the following: according to the importance parameter value of the second candidate statement to the target statement, select second candidate statements from multiple second candidate statements whose importance parameter value is greater than or equal to a preset threshold, and use them as multiple first statements to be merged.
[0084] For S2031-S2033, based on the above example, in the question-answering system, the target statement is the question statement, and the second candidate statement is the second answer statement. First, an importance detection model is used to obtain the importance parameter values of each word in the second answer statement relative to the question statement. This importance detection model is obtained by training a preset neural network based on the question training statement, the answer training statement, and the importance label data of each word in the answer training statement relative to the question training statement. Then, the importance parameter values of each word in the second answer statement relative to the question statement are summed to determine the importance parameter value of the second answer statement relative to the question statement. Finally, based on the importance parameter value of the second answer statement relative to the question statement, second answer statements with importance parameter values greater than or equal to a preset threshold are selected from multiple second answer statements as multiple first statements to be fused.
[0085] S204: Based on the dependency relationships between words in multiple first statements to be merged, perform fusion processing on multiple first statements to be merged to obtain a merged statement that matches the target statement.
[0086] In this embodiment of the application, after determining multiple first statements to be merged from multiple second candidate statements in S202, it is also necessary to merge multiple first statements to be merged through the dependency relationship between each word in the multiple first statements to be merged to obtain the merged statement that matches the target statement.
[0087] In the specific implementation of S204, firstly, the multiple first statements to be merged have certain redundant information. To reduce the redundant information, it is necessary to process the multiple first statements to be merged using word alignment to obtain multiple second statements to be merged; then, based on the dependencies between the words in the multiple second statements to be merged, the multiple second statements to be merged are merged to obtain the merged statement matching the target statement. Therefore, this application provides a possible implementation method, and S204 may include, for example, the following S2041-S2042:
[0088] S2041: Perform word alignment processing on multiple first sentences to be merged to obtain multiple second sentences to be merged.
[0089] Word alignment means that the syntactic structures of two words must be the same, and the two words must be identical or similar; word alignment processing in S2041 can transform sentences of unequal length into sentences of equal length in a certain sense.
[0090] As an example, among the multiple first statements to be merged, the first statement to be merged is "UserA bought books" and the first statement to be merged is "UserA purchase books". Word alignment is performed on the first statement to be merged, "UserA bought books" and the first statement to be merged, "UserA purchase books". Since "bought" and "purchase" are equivalent in grammar and semantics, word alignment can be achieved for the first statement to be merged, "UserA bought books" and the first statement to be merged, "UserA purchase books". The resulting multiple second statements to be merged include either the first statement to be merged, "UserA bought books" or the first statement to be merged, "UserA purchase books".
[0091] S2042: Based on the dependency relationships between words in multiple second statements to be merged, perform fusion processing on multiple second statements to be merged to obtain a merged statement that matches the target statement.
[0092] In the specific implementation of S2042, the fusion order of words in multiple second sentences to be fused affects the readability and fluency of the fused sentence. The idea of integer linear programming can be applied, treating the fusion of multiple second sentences as a goal problem combining sentence fusion and optimization. Based on this, firstly, the design variable is determined as the fusion order of words in multiple second sentences to be fused; secondly, based on the design variable, the dependencies between words in multiple second sentences to be fused are considered, and an objective function representing the maximization problem is constructed to maximize the readability and fluency of the fused sentence; then, the optimal solution of the objective function is obtained, i.e., the target fusion order of words in multiple second sentences to be fused; finally, the words in multiple second sentences to be fused are fused according to the target fusion order to obtain the fused sentence matching the target sentence. Therefore, this application provides a possible implementation method, and S2042 may include, for example, the following S5-S8:
[0093] S5: Determine the fusion order of each word in multiple second statements to be merged as a design variable.
[0094] S6: Based on the design variables and the dependencies between words in multiple second statements to be merged, construct an objective function representing the maximization problem.
[0095] In the specific implementation of S6, when constructing the objective function, it is also necessary to further consider the importance parameter values of each word in the multiple second sentences to be merged to the target sentence. This ensures that words with higher importance to the target sentence occupy important positions in the merged sentence, thereby maximizing the importance of the merged sentence. Therefore, this application provides a possible implementation method, where S6 may include, for example, constructing the objective function based on design variables, the dependencies between words in the multiple second sentences to be merged, and the importance parameter values of each word in the multiple second sentences to be merged to the target sentence.
[0096] As an example, the formula for the objective function is shown below:
[0097]
[0098] In the above formula, n represents the number of each word in the multiple second sentences to be merged, I(w i Q) represents w i Regarding the importance parameter value of Q, w i Let P(d) represent the i-th word, Q represent the target sentence, and P(d) represent the target word. i |h i ) represents h i Under the condition d i The probability, h i Indicates w i The parent node, d i h i and w i The dependency relationship between them, P(w) j |w i ) indicates w i Under the condition w j The probability, w j Representing the (j=i+1)th word, I(w) j Q) represents w j The importance parameter value for Q.
[0099] S7: Solve for design variables based on the objective function to obtain the target fusion order of each word in multiple second sentences to be fused.
[0100] S8: Perform fusion processing on each word in multiple second sentences to be fused according to the target fusion order to obtain the fused sentences.
[0101] For S5-S8, in the question-answering system, the target statement is the question statement. Based on the multiple first statements to be merged determined in the above example, word alignment is performed on these multiple first statements to be merged to obtain multiple second statements to be merged. First, the merging order of each word in the multiple second statements to be merged is determined as a design variable. Second, based on the design variable, the dependencies between each word in the multiple second statements to be merged, and the importance parameter values of each word in the multiple second statements to be merged for the question statement, an objective function representing maximizing the question is constructed. Then, the design variable is solved based on the objective function to obtain the target merging order of each word in the multiple second statements to be merged. Finally, the words in the multiple second statements to be merged are merged according to the target merging order to obtain the answer statement matching the question statement.
[0102] The statement processing method provided in the above embodiments calculates the statement similarity between each first candidate statement and the target statement for the target statement and multiple first candidate statements; when it is determined that multiple first candidate statements do not match the target statement based on the statement similarity, the multiple first candidate statements are segmented to obtain multiple second candidate statements; multiple first statements to be fused are determined from the multiple second candidate statements by using the importance parameter value of each second candidate statement to the target statement; and the multiple first statements to be fused are fused according to the dependency relationship between each word in the multiple first statements to be fused to obtain the fused statement that matches the target statement.
[0103] This method, when multiple candidate statements do not match the target statement based on statement similarity, segments and determines the importance of these candidate statements to the target statement, resulting in multiple first statements to be merged. Then, based on the dependencies between words, these multiple first statements are merged into a matching statement for the target statement. Therefore, even when multiple candidate statements do not match the target statement, this method can still meet the practical need for obtaining a matching statement, thereby improving the processing performance in question-answering systems, search systems, and other application scenarios.
[0104] Regarding the first specific implementation of S201 in the above embodiments, the similarity calculation based on the first word feature of the first candidate statement, the first sentence feature of the first candidate statement, the second word feature of the target statement, and the second sentence feature of the target statement can be divided into two parts according to the difference between word dimension and sentence dimension. One part is to obtain the word literal similarity between the first candidate statement and the target statement through the similarity calculation of the first word feature of the first candidate statement and the second word feature of the target statement; since considering that the core words in the statement play a decisive role, the first word feature of the first candidate statement is determined by the core words in the first candidate statement, and correspondingly, the second word feature of the target statement is also determined by the core words in the target statement.
[0105] The other part is to obtain the semantic similarity between the first candidate statement and the target statement by using the first statement feature of the first candidate statement and the second statement feature of the target statement through similarity calculation. Since the words corresponding to the syntactic structure of the statement have a great influence on the semantics of the statement, the first semantic feature of the first candidate statement is determined by the words corresponding to the syntactic structure of the first candidate statement. Correspondingly, the second word feature of the target statement is also determined by the words corresponding to the syntactic structure of the target statement.
[0106] Based on this, by combining the word-based similarity and the semantic similarity between the first candidate statement and the target statement, the statement similarity between the two statements can be obtained. The method for obtaining this statement similarity is described below with reference to the attached diagram.
[0107] See Figure 4 , Figure 4 This is a flowchart illustrating a method for obtaining statement similarity according to an embodiment of this application. Figure 4 As shown, the method for obtaining the similarity of this statement includes the following steps:
[0108] S401: Based on the core words in the first candidate statement, determine the first word features of the first candidate statement; based on the core words in the target statement, determine the second word features of the target statement.
[0109] The core words in the first candidate statement can be obtained, for example, by extracting the core of the first candidate statement using a natural language processing knowledge base (HowNet); the first word feature of the first candidate statement includes the core words in the first candidate statement. Similarly, the core words in the target statement can be obtained, for example, by extracting the core of the target statement using HowNet; the second word feature of the target statement includes the core words in the target statement.
[0110] S402: Perform similarity calculation on the first word feature and the second word feature to obtain the word literal similarity between the first candidate sentence and the target sentence.
[0111] In S402, the similarity operation can be, for example, the Jaccard similarity operation. The Jaccard similarity operation refers to calculating the ratio of the intersection of two sets A and B to the union of A and B, given two sets A and B. When the first word feature of the first candidate statement includes the core words in the first candidate statement, and the first word feature of the target statement includes the core words in the target statement, S402 can be implemented in the following ways: determining the size of the intersection between the core words in the first candidate statement and the core words in the target statement; determining the size of the union between the core words in the first candidate statement and the core words in the target statement; and performing a ratio operation based on the size of the intersection and the size of the union to obtain the word literal similarity between the first candidate statement and the target statement.
[0112] As an example, the formula for calculating the word-for-word similarity between the first candidate statement and the target statement is as follows:
[0113]
[0114] In the above formula, S represents the first candidate statement, S′ represents the core words in the first candidate statement S, Q represents the target statement, and Q′ represents the core words in the target statement Q.
[0115] S403: Based on the words corresponding to the syntactic structure of the first candidate statement, determine the first statement feature of the first candidate statement; based on the words corresponding to the syntactic structure of the target statement, determine the second statement feature of the target statement.
[0116] The first statement feature of the first candidate statement is obtained by encoding and concatenating the words corresponding to the syntactic structure of the first candidate statement. That is, the first statement feature of the first candidate statement includes the first statement vector of the first candidate statement. The second statement feature of the target statement is obtained by encoding and concatenating the words corresponding to the syntactic structure of the target statement. The second statement feature of the target statement includes the second statement vector of the target statement.
[0117] Furthermore, since different words in the syntactic structure of a statement have varying degrees of influence on its semantics, different weights are needed to represent these different influences during the concatenation process. Therefore, the first statement feature of the first candidate statement is determined by combining the words in the syntactic structure of the first candidate statement with the first weight, and the second statement feature of the target statement is determined by combining the words in the syntactic structure of the target statement with the second weight. Thus, this application provides a possible implementation, where S403 may include, for example, determining the first statement feature based on the words in the syntactic structure of the first candidate statement and the first weight; and determining the second statement feature based on the words in the syntactic structure of the target statement and the second weight.
[0118] S404: Perform similarity calculation on the first statement features and the second statement features to obtain the semantic similarity between the first candidate statement and the target statement.
[0119] In S404, the similarity operation can be, for example, a cosine similarity operation. When the first statement feature of the first candidate statement includes the first statement vector of the first candidate statement, and the second statement feature of the target statement includes the second statement vector of the target statement, the specific implementation of S404 may include, for example, performing a cosine similarity operation on the first statement vector of the first candidate statement and the second statement vector of the target statement to obtain the statement semantic similarity between the first candidate statement and the target statement.
[0120] As an example, based on the above example, the formula for calculating the semantic similarity between the first candidate statement and the target statement is as follows:
[0121]
[0122]
[0123]
[0124]
[0125] In the above formula, V S V represents the first statement feature of the first candidate statement S. Q w represents the second statement characteristic of the target statement Q. a Let tf_idf(w) represent the a-th word corresponding to the syntactic structure of the first candidate statement S. a ) indicates w in the first candidate statement S a Document-inverse document frequency, w b V represents the b-th word corresponding to the syntactic structure of the target statement Q, |Q| represents the number of words corresponding to the syntactic structure of the target statement Q, and V wa Indicates wa Word vectors, V wb Indicates w b Word vectors.
[0126] In addition, N(w a ) indicates w a TN(W) represents the number of times each word appears in multiple first-candidate statements S, TN(S) represents the total number of words in multiple first-candidate statements S, and S(w) represents the total number of words in multiple first-candidate statements S. a ) indicates that multiple first candidate statements S include w a The number of statements in the first candidate statement S.
[0127] S405: The word literal similarity and sentence semantic similarity are fused to obtain the sentence similarity between the first candidate sentence and the target sentence.
[0128] As an example, based on the above example, the formula for calculating the similarity between the first candidate statement and the target statement is as follows:
[0129] SC(S,Q)=αJ(S,Q)+βT(S,Q)
[0130] In the above formula, α represents the weight of the word literal similarity J(S,Q) between the first candidate statement S and the target statement Q, and β represents the weight of the semantic similarity T(S,Q) between the first candidate statement S and the target statement Q.
[0131] The fusion process can be, for example, a weighted process. In a specific implementation of S405, it can include, for example, weighting the word literal similarity between the first candidate statement and the target statement, as well as the statement semantic similarity between the first candidate statement and the target statement, to obtain the statement similarity between the first candidate statement and the target statement.
[0132] The sentence similarity acquisition method provided in the above embodiments, when acquiring the sentence similarity between the first candidate sentence and the target sentence, not only considers the literal similarity of words based on the word dimension, especially the literal similarity of the core words in the sentence, but also considers the semantic similarity of sentences based on the sentence dimension, especially the semantic similarity of the sentence's syntactic structure, making the acquired sentence similarity between the first candidate sentence and the target sentence more accurate.
[0133] Regarding S401-S405 above, in the question-answering system, the target statement is the question statement, and the first candidate statement is the first answer statement. First, the first answer statement is processed by extracting its core words, and the first word feature of the first answer statement is identified as the core words in the first answer statement. Then, the question statement is processed by extracting its core words, and the second word feature of the question statement is identified as the core words in the question statement.
[0134] Secondly, determine the size of the intersection between the core words in the first answer statement and the core words in the question statement; determine the size of the union between the core words in the first answer statement and the core words in the question statement; and perform a ratio operation based on the size of the intersection and the size of the union to obtain the word literal similarity between the first answer statement and the question statement.
[0135] Then, the words corresponding to the syntactic structure of the first candidate statement are encoded and concatenated to obtain the first statement feature of the first answer statement, which is the first statement vector of the first answer statement; the words corresponding to the syntactic structure of the question statement are encoded and concatenated to obtain the second statement feature of the question statement, which is the second statement vector of the question statement.
[0136] Next, a cosine similarity operation is performed on the first statement vector of the first answer statement and the second statement vector of the question statement to obtain the semantic similarity between the first answer statement and the question statement.
[0137] Finally, the word-to-word similarity and the semantic similarity between the first answer statement and the question statement are weighted to obtain the statement similarity between the first answer statement and the question statement.
[0138] Regarding the second specific implementation of S201 in the above embodiment, considering that it is necessary to calculate the sentence similarity between the first candidate sentence and the target sentence from both the word dimension and the sentence dimension, and that the convolutional neural network has a strong feature extraction capability, before performing convolution processing, pooling processing and similarity-based prediction processing on the first word features of the first candidate sentence and the second word features of the target sentence through the convolutional neural network, it is also necessary to fuse the first sentence features of the first candidate sentence and the second sentence features of the target sentence into the first word features of the first candidate sentence and the second word features of the target sentence to obtain a feature matrix. This feature matrix fuses sentence word information and sentence semantic information.
[0139] The first word feature of the first candidate statement and the second word feature of the target statement are obtained by encoding each word in the first candidate statement and each word in the target statement; the first statement feature of the first candidate statement and the second statement feature of the target statement are obtained by encoding the first candidate statement and the target statement.
[0140] Based on this, convolution is performed on the feature matrix to obtain convolutional features, pooling is performed on the convolutional features to obtain pooled features, and similarity-based prediction is performed on the pooled features to obtain the sentence similarity between the first candidate sentence and the target sentence. The method for obtaining this sentence similarity is described below with reference to the attached figures.
[0141] See Figure 5 , Figure 5 This is a flowchart illustrating another method for obtaining statement similarity provided in an embodiment of this application. For example... Figure 5 As shown, the method for obtaining the similarity of this statement includes the following steps:
[0142] S501: Encode each word in the first candidate statement and each word in the target statement to obtain the first word feature of the first candidate statement and the second word feature of the target statement.
[0143] In S501, the encoding process can be, for example, based on a word vector model. The word vector model could be word2vec, and the first word feature of the first candidate sentence and the second word feature of the target sentence could be, for example, word vector matrices of the first candidate sentence and the target sentence. Based on this, in the specific implementation of S501, each word in the first candidate sentence and each word in the target sentence is encoded using a word vector model to obtain the first word feature of the first candidate sentence and the second word feature of the target sentence as word vector matrices of the first candidate sentence and the target sentence.
[0144] S502: Encode the first candidate statement and the target statement to obtain the first statement feature of the first candidate statement and the second statement feature of the target statement.
[0145] In S502, the encoding process can be, for example, based on a sentence vector model. The sentence vector model could be, for example, FastText. The first sentence feature of the first candidate sentence and the second sentence feature of the target sentence can be, for example, the sentence vectors of the first candidate sentence and the target sentence. Based on this, in the specific implementation of S502, the first candidate sentence and the target sentence are encoded using a sentence vector model to obtain the first sentence feature of the first candidate sentence and the second sentence feature of the target sentence as the sentence vectors of the first candidate sentence and the target sentence, respectively.
[0146] S503: The first word feature, the second word feature, the first sentence feature, and the second sentence feature are fused to obtain the feature matrix of the first candidate sentence and the target sentence.
[0147] In S503, the fusion process can be, for example, a concatenation process. When the first word feature of the first candidate statement and the second word feature of the target statement are the word vector matrices of the first candidate statement and the target statement, and the first sentence feature of the first candidate statement and the second sentence feature of the target statement are the sentence vectors of the first candidate statement and the target statement, S503 can be specifically implemented as follows: concatenating the word vector matrices of the first candidate statement and the target statement, as well as the sentence vectors of the first candidate statement and the target statement, to obtain the feature matrices of the first candidate statement and the target statement.
[0148] As an example, if the word vector matrix of the first candidate statement and the target statement is in the form of n×k, and the statement vector of the first candidate statement and the target statement is in the form of 1×k, then the feature matrix of the first candidate statement and the target statement is in the form of (n+1)×k.
[0149] S504: Perform convolution processing on the feature matrix to obtain multiple convolutional features.
[0150] S505: Pooling multiple convolutional features to obtain the target feature.
[0151] S506: Perform similarity-based prediction processing on the target features to obtain the sentence similarity between the first candidate sentence and the target sentence.
[0152] The sentence similarity acquisition method provided in the above embodiments obtains a feature matrix by fusing word features based on word dimension and sentence features based on sentence dimension when acquiring the sentence similarity between the first candidate sentence and the target sentence. This feature matrix has both sentence word information and sentence semantic information. The semantic similarity of the sentence is calculated by processing the feature matrix through convolution, pooling and similarity-based prediction, so that the obtained sentence similarity between the first candidate sentence and the target sentence is more accurate.
[0153] Regarding S501-S506 above, in a question-answering system, the target statement is the question statement, and the first candidate statement is the first answer statement. See also... Figure 6 The diagram illustrates the input and output of a convolutional neural network model architecture, which includes an input layer, convolutional layers, pooling layers, and fully connected layers. First, the first answer statement and the target statement are input into the input layer. Each word in the first answer statement and each word in the question statement are encoded using a word vector model, outputting word vector matrices for the first answer statement and the question statement. Then, the first answer statement and the question statement are encoded using a sentence vector model, outputting sentence vectors for the first answer statement and the question statement.
[0154] Then, the word vector matrices of the first answer statement and the question statement, as well as the statement vectors of the first answer statement and the question statement, are concatenated to obtain the feature matrices of the first answer statement and the question statement.
[0155] Finally, the feature matrices of the first answer statement and the question statement are input into a convolutional layer for convolution processing to output multiple convolutional features; the multiple convolutional features are input into a pooling layer for pooling processing to output target features; the target features are input into a fully connected layer for similarity-based prediction processing to output the statement similarity between the first answer statement and the question statement.
[0156] In addition to the statement processing method provided in the above embodiments, this application also provides a statement processing apparatus.
[0157] See Figure 7 , Figure 7 This is a schematic diagram of a statement processing apparatus provided in an embodiment of this application. Figure 7 As shown, the statement processing apparatus 700 includes: an acquisition unit 701, a segmentation unit 702, a determination unit 703, and a fusion unit 704;
[0158] The acquisition unit 701 is used to acquire the statement similarity between multiple first candidate statements and the target statement;
[0159] The segmentation unit 702 is used to segment multiple first candidate statements to obtain multiple second candidate statements if it is determined based on statement similarity that multiple first candidate statements do not match the target statement.
[0160] The determining unit 703 is used to determine multiple first statements to be merged from multiple second candidate statements based on the importance parameter values of the second candidate statements to the target statement;
[0161] The fusion unit 704 is used to perform fusion processing on multiple first statements to be fused based on the dependency relationship between each word in multiple first statements to be fused to obtain a fused statement that matches the target statement.
[0162] As one possible implementation, the determining unit 703 includes: a first acquisition subunit, a summation subunit, and a first determining subunit;
[0163] The first acquisition subunit is used to acquire the importance parameter values of each word in the second candidate sentence to the target sentence through an importance detection model; the importance detection model is obtained by training a preset neural network based on the importance label data of each word in the first training sentence, the second training sentence, and the second training sentence to the first training sentence;
[0164] The summation subunit is used to sum the importance parameter values of each word in the second candidate statement to the target statement, and to determine the importance parameter value of the second candidate statement to the target statement.
[0165] The first determining subunit is used to determine multiple first statements to be merged from multiple second candidate statements based on the importance parameter value of the second candidate statements to the target statement and a preset threshold.
[0166] As one possible implementation, the device also includes a training unit, which is used for:
[0167] Obtain the importance label data of each word in the first training statement, the second training statement, and the second training statement to the first training statement;
[0168] The first training statement and the second training statement are input into a preset neural network for prediction processing, and the predicted label data of each word in the second training statement for the first training statement is output.
[0169] If the predicted label data does not match the importance label data, the network parameters of the preset neural network are iteratively trained using the loss function of the preset neural network.
[0170] The pre-trained neural network is selected as the importance detection model.
[0171] As one possible implementation, the fusion unit 704 includes: a word alignment subunit and a first fusion subunit;
[0172] The word alignment subunit is used to perform word alignment processing on multiple first sentences to be merged to obtain multiple second sentences to be merged.
[0173] The first fusion subunit is used to perform fusion processing on multiple second statements to be fused based on the dependency relationship between each word in multiple second statements to be fused to obtain a fused statement that matches the target statement.
[0174] As one possible implementation, the first fusion subunit includes: a determination module, a construction module, a solution module, and a fusion module;
[0175] The determination module is used to determine the fusion order of each word in multiple second sentences to be fused as a design variable;
[0176] The building module is used to construct an objective function representing the maximization problem based on design variables and the dependencies between words in multiple second statements to be merged.
[0177] The solution module is used to solve for the design variables based on the objective function, and obtain the target fusion order of each word in multiple second sentences to be fused.
[0178] The fusion module is used to fuse the words in multiple second sentences to be fused according to the target fusion order to obtain the fused sentences.
[0179] As one possible implementation, building modules are used for:
[0180] Based on design variables, the dependencies between words in multiple second sentences to be merged, and the importance parameter values of each word in multiple second sentences to be merged to the target sentence, a target function is constructed.
[0181] As one possible implementation, the segmentation unit 702 includes: an analysis subunit and a segmentation unit;
[0182] The analysis subunit is used to perform syntactic structure analysis on multiple first candidate statements to obtain the syntactic structure of multiple first candidate statements;
[0183] The segmentation unit is used to segment multiple first candidate statements based on their syntactic structure to obtain multiple second candidate statements.
[0184] As one possible implementation, the acquisition unit 701 is used for:
[0185] For each first candidate statement, a similarity calculation is performed based on the first word feature of the first candidate statement, the first statement feature of the first candidate statement, the second word feature of the target statement, and the second statement feature of the target statement to obtain the statement similarity between the first candidate statement and the target statement.
[0186] As one possible implementation, the acquisition unit 701 includes: a second determining subunit, a first operation subunit, a third determining subunit, a second operation subunit, and a second fusion subunit;
[0187] The second determining subunit is used to determine the first word feature based on the core words in the first candidate sentence; and to determine the second word feature based on the core words in the target sentence.
[0188] The first operation subunit is used to perform similarity calculation on the first word feature and the second word feature to obtain the word literal similarity between the first candidate sentence and the target sentence;
[0189] The third determining subunit is used to determine the first statement features based on the words corresponding to the syntactic structure of the first candidate statement; and to determine the second statement features based on the words corresponding to the syntactic structure of the target statement.
[0190] The second operation subunit is used to perform similarity calculation on the first statement features and the second statement features to obtain the statement semantic similarity between the first candidate statement and the target statement.
[0191] The second fusion subunit is used to fuse word literal similarity and sentence semantic similarity to obtain sentence similarity.
[0192] As one possible implementation, the third determining subunit is used for:
[0193] The first statement features are determined based on the words and first weights corresponding to the syntactic structure of the first candidate statement; the second statement features are determined based on the words and second weights corresponding to the syntactic structure of the target statement.
[0194] As one possible implementation, the acquisition unit 701 includes: a first encoding subunit, a second encoding subunit, a third fusion subunit, a convolution subunit, a pooling subunit, and a prediction subunit;
[0195] The first encoding subunit is used to encode each word in the first candidate sentence and each word in the target sentence to obtain the first word feature and the second word feature;
[0196] The second encoding subunit is used to encode the first candidate statement and the target statement to obtain the first statement features and the second statement features;
[0197] The third fusion subunit is used to fuse the first word features, the second word features, the first sentence features, and the second sentence features to obtain a feature matrix;
[0198] Convolutional subunits are used to perform convolution processing on the feature matrix to obtain multiple convolutional features;
[0199] The pooling subunit is used to perform pooling processing on multiple convolutional features to obtain the target feature;
[0200] The prediction subunit is used to perform similarity-based prediction processing on the target features to obtain sentence similarity.
[0201] The statement processing apparatus provided in the above embodiments calculates the statement similarity between each first candidate statement and the target statement for a target statement and multiple first candidate statements; when it is determined based on the statement similarity that none of the multiple first candidate statements match the target statement, the multiple first candidate statements are segmented to obtain multiple second candidate statements; multiple first statements to be fused are determined from the multiple second candidate statements using the importance parameter value of each second candidate statement to the target statement; and the multiple first statements to be fused are fused according to the dependency relationship between each word in the multiple first statements to be fused to obtain a fused statement that matches the target statement.
[0202] This method, when multiple candidate statements do not match the target statement based on statement similarity, segments and determines the importance of these candidate statements to the target statement, resulting in multiple first statements to be merged. Then, based on the dependencies between words, these multiple first statements are merged into a matching statement for the target statement. Therefore, even when multiple candidate statements do not match the target statement, this method can still meet the practical need for obtaining a matching statement, thereby improving the processing performance in question-answering systems, search systems, and other application scenarios.
[0203] In addition to the statement processing method described above, this application also provides a device for statement processing, so that the above statement processing method can be implemented and applied in practice. The computer device provided in this application will be described below from the perspective of hardware physicalization.
[0204] See Figure 8 , Figure 8 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 800 can vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 822 (e.g., one or more processors) and memory 832, and one or more storage media 830 (e.g., one or more mass storage devices) for storing application programs 842 or data 844. The memory 832 and storage media 830 can be temporary or persistent storage. The program stored in the storage media 830 may include one or more modules (not shown in the diagram), each module may include a series of instruction operations on the server. Furthermore, the CPU 822 may be configured to communicate with the storage media 830 and execute the series of instruction operations in the storage media 830 on the server 800.
[0205] Server 800 may also include one or more power supplies 826, one or more wired or wireless network interfaces 850, one or more input / output interfaces 858, and / or one or more operating systems 841, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0206] The steps performed by the server in the above embodiments can be based on this Figure 8 The server structure shown.
[0207] The CPU 822 is used to perform the following steps:
[0208] Obtain the statement similarity between multiple first candidate statements and the target statement;
[0209] If multiple first candidate statements are determined to be mismatched with the target statement based on statement similarity, the multiple first candidate statements are segmented to obtain multiple second candidate statements.
[0210] Based on the importance parameter value of the second candidate statement to the target statement, multiple first statements to be merged are determined from multiple second candidate statements;
[0211] Based on the dependencies between words in multiple first statements to be merged, the multiple first statements to be merged are merged to obtain the merged statement that matches the target statement.
[0212] Optionally, the CPU 822 may also execute method steps of any specific implementation of the statement processing method in the embodiments of this application.
[0213] See Figure 9 , Figure 9 This is a schematic diagram of a terminal device provided in an embodiment of this application. For ease of explanation, only the parts related to the embodiment of this application are shown; for specific technical details not disclosed, please refer to the method section of the embodiment of this application. The terminal device can be any terminal device including mobile phones, tablets, PDAs, etc. Taking a mobile phone as an example:
[0214] Figure 9 This diagram illustrates a partial structural representation of a mobile phone related to the terminal device provided in this embodiment. (Reference) Figure 9 The mobile phone includes components such as a radio frequency (RF) circuit 910, a memory 920, an input unit 930, a display unit 940, a sensor 950, an audio circuit 960, a Wi-Fi module 970, a processor 980, and a power supply 990. Those skilled in the art will understand that... Figure 9 The mobile phone structure shown does not constitute a limitation on the mobile phone and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0215] The following is combined with Figure 9 A detailed introduction to each component of a mobile phone:
[0216] RF circuit 910 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with processor 980; additionally, it transmits uplink data to the base station. Typically, RF circuit 910 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), and a duplexer. Furthermore, RF circuit 910 can also communicate wirelessly with networks and other devices. The aforementioned wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, and Short Messaging Service (SMS).
[0217] The memory 920 can be used to store software programs and modules. The processor 980 runs the software programs and modules stored in the memory 920 to realize various functions and data processing of the mobile phone. The memory 920 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 920 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0218] The input unit 930 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the mobile phone. Specifically, the input unit 930 may include a touch panel 931 and other input devices 932. The touch panel 931, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 931), and drive the corresponding connected devices according to a pre-set program. Optionally, the touch panel 931 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 980, and can also receive and execute commands sent by the processor 980. In addition, the touch panel 931 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 931, the input unit 930 may also include other input devices 932. Specifically, other input devices 932 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0219] The display unit 940 can be used to display information input by the user or information provided to the user, as well as various menus of the mobile phone. The display unit 940 may include a display panel 941, which may optionally be configured as a Liquid Crystal Display (LCD), Organic Light-Emitting Diode (OLED), or similar display panel. Further, a touch panel 931 may cover the display panel 941. When the touch panel 931 detects a touch operation on or near it, it transmits the information to the processor 980 to determine the type of touch event. Subsequently, the processor 980 provides corresponding visual output on the display panel 941 based on the type of touch event. Although in Figure 9 In this embodiment, the touch panel 931 and the display panel 941 are two separate components to realize the input and output functions of the mobile phone. However, in some embodiments, the touch panel 931 and the display panel 941 can be integrated to realize the input and output functions of the mobile phone.
[0220] The mobile phone may also include at least one sensor 950, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 941 according to the ambient light level, and the proximity sensor can turn off the display panel 941 and / or backlight when the phone is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity, which can be used for applications that recognize the phone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, taps), etc. Other sensors that may be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0221] Audio circuit 960, speaker 961, and microphone 962 provide an audio interface between the user and the mobile phone. Audio circuit 960 converts received audio data into electrical signals and transmits them to speaker 961, where speaker 961 converts them into sound signals for output. On the other hand, microphone 962 converts collected sound signals into electrical signals, which are received by audio circuit 960, converted into audio data, and then processed by processor 980 before being transmitted via RF circuit 910 to, for example, another mobile phone, or the audio data can be output to memory 920 for further processing.
[0222] WiFi is a short-range wireless transmission technology. Mobile phones, through the WiFi module 970, can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 9 The WiFi module 970 is shown, but it is understood that it is not an essential component of a mobile phone and can be omitted as needed without changing the essence of the invention.
[0223] The processor 980 is the control center of the mobile phone, connecting various parts of the phone through various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 920, and by calling data stored in the memory 920, thereby controlling the phone as a whole. Optionally, the processor 980 may include one or more processing units; preferably, the processor 980 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 980.
[0224] The mobile phone also includes a power supply 990 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 980 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0225] Although not shown, mobile phones may also include a camera, Bluetooth module, etc., which will not be described in detail here.
[0226] In this embodiment of the application, the memory 920 included in the mobile phone can store program code and transmit the program code to the processor.
[0227] The processor 980 included in the mobile phone can execute the statement processing method provided in the above embodiments according to the instructions in the program code.
[0228] This application also provides a computer-readable storage medium for storing a computer program that executes the statement processing method provided in the above embodiments.
[0229] This application also provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the statement processing methods provided in the various optional implementations of the above aspects.
[0230] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium can be at least one of the following media: read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc., and other media capable of storing program code.
[0231] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments. The device and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the solution in this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0232] The above description is merely one specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for processing statements, characterized in that, The method includes: Obtain the statement similarity between multiple first candidate statements and the target statement; If it is determined based on the statement similarity that none of the multiple first candidate statements match the target statement, the multiple first candidate statements are segmented to obtain multiple second candidate statements; Based on the importance parameter value of the second candidate statement to the target statement, a plurality of first statements to be merged are determined from the plurality of second candidate statements; Word alignment processing is performed on the plurality of first sentences to be merged to obtain a plurality of second sentences to be merged; The fusion order of each word in the plurality of second sentences to be fused is determined as a design variable; Based on the design variables and the dependencies between the words in the multiple second statements to be merged, a target function representing the maximization problem is constructed. Based on the objective function, the design variables are solved to obtain the target fusion order of each word in the plurality of second sentences to be fused; The words in the plurality of second sentences to be merged are merged according to the target fusion order to obtain the fused sentence that matches the target sentence.
2. The method according to claim 1, characterized in that, The step of determining multiple first statements to be merged from the multiple second candidate statements based on the importance parameter value of the second candidate statements to the target statement includes: The importance parameter values of each word in the second candidate sentence to the target sentence are obtained through an importance detection model; the importance detection model is obtained by training a preset neural network based on the importance label data of the first training sentence, the second training sentence, and each word in the second training sentence to the first training sentence; The importance parameter values of each word in the second candidate statement to the target statement are summed to determine the importance parameter value of the second candidate statement to the target statement. Based on the importance parameter value of the second candidate statement to the target statement and the preset threshold, the plurality of first statements to be merged are determined from the plurality of second candidate statements.
3. The method according to claim 2, characterized in that, The training steps of the importance detection model include: Obtain the importance label data of each word in the first training statement, the second training statement, and the second training statement to the first training statement; The first training statement and the second training statement are input into the preset neural network for prediction processing, and the predicted label data of each word in the second training statement for the first training statement is output. If the predicted label data does not match the importance label data, the network parameters of the preset neural network are iteratively trained using the loss function of the preset neural network. The trained preset neural network is determined as the importance detection model.
4. The method according to claim 1, characterized in that, The construction of an objective function representing the maximization problem, based on the design variables and the dependencies between words in the plurality of second statements to be merged, includes: The target function is constructed based on the design variables, the dependencies between words in the plurality of second sentences to be merged, and the importance parameter values of each word in the plurality of second sentences to be merged to the target sentence.
5. The method according to claim 1, characterized in that, The step of segmenting the plurality of first candidate statements to obtain a plurality of second candidate statements includes: Syntactic structure analysis is performed on the plurality of first candidate statements to obtain the syntactic structure of the plurality of first candidate statements; Based on the syntactic structure of the plurality of first candidate statements, the plurality of first candidate statements are segmented to obtain the plurality of second candidate statements.
6. The method according to claim 1, characterized in that, The step of obtaining the statement similarity between the multiple first candidate statements and the target statement includes: For each first candidate statement, a similarity calculation is performed based on the first word feature of the first candidate statement, the first statement feature of the first candidate statement, the second word feature of the target statement, and the second statement feature of the target statement to obtain the statement similarity between the first candidate statement and the target statement.
7. The method according to claim 6, characterized in that, The step of performing similarity calculation based on the first word features of the first candidate statement, the first statement features of the first candidate statement, the second word features of the target statement, and the second statement features of the target statement to obtain the statement similarity between the first candidate statement and the target statement includes: Based on the core words in the first candidate statement, the first word features are determined; based on the core words in the target statement, the second word features are determined. A similarity calculation is performed on the first word features and the second word features to obtain the word literal similarity between the first candidate statement and the target statement; Based on the words corresponding to the syntactic structure of the first candidate statement, the features of the first statement are determined; based on the words corresponding to the syntactic structure of the target statement, the features of the second statement are determined. A similarity calculation is performed on the first statement features and the second statement features to obtain the statement semantic similarity between the first candidate statement and the target statement; The literal similarity of the words and the semantic similarity of the sentences are fused to obtain the sentence similarity.
8. The method according to claim 7, characterized in that, The step of determining the features of the first statement based on the words corresponding to the syntactic structure of the first candidate statement includes: Based on the words and first weights corresponding to the syntactic structure of the first candidate statement, the features of the first statement are determined; The process of determining the features of the second statement based on the words corresponding to the syntactic structure of the target statement includes: The features of the second statement are determined based on the words and second weights corresponding to the syntactic structure of the target statement.
9. The method according to claim 6, characterized in that, The step of performing similarity calculation based on the first word features of the first candidate statement, the first statement features of the first candidate statement, the second word features of the target statement, and the second statement features of the target statement to obtain the statement similarity between the first candidate statement and the target statement includes: Encode each word in the first candidate statement and each word in the target statement to obtain the first word features and the second word features; The first candidate statement and the target statement are encoded to obtain the first statement features and the second statement features; The first word features, the second word features, the first sentence features, and the second sentence features are fused to obtain a feature matrix; The feature matrix is convolved to obtain multiple convolutional features; The target feature is obtained by pooling the multiple convolutional features. The target features are subjected to similarity-based prediction processing to obtain the sentence similarity.
10. A statement processing apparatus, characterized in that, The device includes: an acquisition unit, a segmentation unit, a determination unit, and a fusion unit; The acquisition unit is used to acquire the statement similarity between multiple first candidate statements and the target statement; The segmentation unit is used to segment the plurality of first candidate statements to obtain a plurality of second candidate statements if it is determined based on the statement similarity that none of the plurality of first candidate statements match the target statement. The determining unit is configured to determine a plurality of first statements to be merged from the plurality of second candidate statements based on the importance parameter values of the second candidate statements to the target statement; The fusion unit includes: The word alignment subunit is used to perform word alignment processing on the plurality of first sentences to be merged to obtain a plurality of second sentences to be merged. The determination module is used to determine the fusion order of each word in the plurality of second sentences to be fused as a design variable; The construction module is used to construct an objective function representing the maximization problem based on the design variables and the dependencies between the words in the plurality of second statements to be merged; The solution module is used to solve the design variables based on the objective function to obtain the target fusion order of each word in the plurality of second sentences to be fused; The fusion module is used to perform fusion processing on each word in the plurality of second statements to be fused according to the target fusion order, so as to obtain the fused statement matching the target statement.
11. The apparatus according to claim 10, characterized in that, The determining unit includes: The first acquisition subunit is used to acquire the importance parameter values of each word in the second candidate statement to the target statement through an importance detection model; the importance detection model is obtained by training a preset neural network based on the importance label data of the first training statement, the second training statement, and each word in the second training statement to the first training statement; The summation subunit is used to sum the importance parameter values of each word in the second candidate statement to the target statement, and to determine the importance parameter value of the second candidate statement to the target statement. The first determining subunit is used to determine the plurality of first statements to be merged from the plurality of second candidate statements based on the importance parameter value of the second candidate statement to the target statement and a preset threshold.
12. The apparatus according to claim 11, characterized in that, The device further includes a training unit; the training unit is used for: Obtain the importance label data of each word in the first training statement, the second training statement, and the second training statement to the first training statement; The first training statement and the second training statement are input into the preset neural network for prediction processing, and the predicted label data of each word in the second training statement for the first training statement is output. If the predicted label data does not match the importance label data, the network parameters of the preset neural network are iteratively trained using the loss function of the preset neural network. The trained preset neural network is determined as the importance detection model.
13. The apparatus according to claim 10, characterized in that, The construction module is used to construct the target function based on the design variables, the dependencies between words in the plurality of second sentences to be merged, and the importance parameter values of each word in the plurality of second sentences to be merged to the target sentence.
14. A computer device, characterized in that, The device includes a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the statement processing method according to any one of claims 1-9 based on the instructions in the program code.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program, which, when executed by a processor, performs the statement processing method according to any one of claims 1-9.
16. A computer program product, characterized in that, Includes a computer program or instructions; when the computer program or instructions are executed by a processor, the method of statement processing as described in any one of claims 1-9 is performed.