Explainable text semantic matching method and device, electronic equipment and storage medium
By extracting features and analyzing keywords from long texts, calculating similarity and providing explanatory information, the problem of users not understanding the semantic matching results of long texts is solved, thus improving the user experience.
Patent Information
- Application Number
- CN202211592751.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2042-12-13
AI Technical Summary
Existing semantic matching methods cannot explain why long texts are similar or dissimilar, leading to users' incomprehension of the matching results and affecting user experience.
By extracting features from the text to be identified and the text database, candidate text fragments and sentences are obtained, keyword analysis is performed, similarity is calculated, and the most similar text fragment is used as explanatory information to explain the reasons for text similarity.
It improves users' understanding of text matching results, enhances user experience, and reduces the burden on users to understand text similarity.
Smart Images

Figure CN115905537B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, specifically to an interpretable text semantic matching method, apparatus, electronic device, and storage medium. Background Technology
[0002] Current semantic matching methods generally fall into three paradigms: The first is a string-based approach, which only calculates the degree of string matching without considering semantic information, and determines the similarity of texts by calculating the Hamming distance between sentences; the second is a corpus-based approach, which segments the input sentence into words, calculates the similarity of each word in the sentence to other sentences, and finally performs a weighted sum; the third is a deep learning-based approach, which treats the semantic matching problem directly as a binary classification problem, with categories divided into "match" and "not match", and then fine-tunes the pre-trained model to obtain the final result.
[0003] However, for semantic matching of long texts (i.e., texts with more than a threshold of characters), existing semantic matching methods, such as deep learning algorithms, while able to determine whether two long texts are similar or dissimilar, cannot explain why they are similar or dissimilar, leaving users confused about the matching results. Therefore, improving user understanding of the matching results for long texts, and thus enhancing the user experience, is a pressing issue that needs to be addressed. Summary of the Invention
[0004] This application provides an interpretable text semantic matching method, apparatus, electronic device, and storage medium. By determining the interpretation information to explain the reason why the text to be identified and the target text are similar, the user's understanding of the matching result (i.e., the text to be identified semantically matches the most similar text to the target text) is increased, thereby improving the user's experience.
[0005] In a first aspect, embodiments of this application provide an interpretable text semantic matching method, the method comprising:
[0006] Obtain the text to be recognized, wherein the number of characters in the text to be recognized is greater than a threshold;
[0007] Feature extraction is performed on the text to be identified, resulting in multiple first candidate text fragments and multiple first sentences;
[0008] Feature extraction is performed on the first candidate text in the text database to obtain multiple second candidate text fragments and multiple second sentences, wherein the first candidate text is any one of the multiple candidate texts in the text database;
[0009] Keyword analysis is performed on each first candidate text fragment to obtain multiple first target text fragments;
[0010] Keyword analysis is performed on each second candidate text fragment to obtain multiple second target text fragments;
[0011] Based on each first target text fragment and each second target text fragment, multiple first similarities are obtained for each first target text fragment;
[0012] Based on multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text segment, the target text is determined from multiple candidate texts;
[0013] Each first target text fragment and the second target text fragment associated with each first target text fragment in the target text are determined as explanatory information. The second target text fragment associated with each first target text fragment is the second target text fragment corresponding to the largest first similarity among the multiple first similarities corresponding to the first target text fragment. The explanatory information is used to explain the reason why the text to be identified and the target text are similar.
[0014] Secondly, embodiments of this application provide an interpretable text semantic matching device, which includes: an acquisition unit and a processing unit;
[0015] The acquisition unit is used to acquire the text to be recognized, wherein the number of characters in the text to be recognized is greater than a threshold.
[0016] The processing unit is used to extract features from the text to be recognized, and obtain multiple first candidate text fragments and multiple first sentences;
[0017] The processing unit is used to extract features from the first candidate text in the text database to obtain multiple second candidate text fragments and multiple second sentences, wherein the first candidate text is any one of the multiple candidate texts in the text database;
[0018] The processing unit is used to perform keyword analysis on each first candidate text fragment to obtain multiple first target text fragments;
[0019] The processing unit is used to perform keyword analysis on each second candidate text fragment to obtain multiple second target text fragments;
[0020] The processing unit is configured to obtain multiple first similarities corresponding to each first target text segment based on each first target text segment and each second target text segment;
[0021] The processing unit is used to determine the target text from multiple candidate texts based on multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text segment;
[0022] The processing unit is configured to determine each first target text fragment and the second target text fragment associated with each first target text fragment in the target text as explanatory information, wherein the second target text fragment associated with each first target text fragment is the second target text fragment corresponding to the largest first similarity among the multiple first similarities corresponding to the first target text fragment, and the explanatory information is used to explain the reason why the text to be identified and the target text are similar.
[0023] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory, so that the electronic device performs the method as described in the first aspect.
[0024] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that causes a computer to perform the method as described in the first aspect.
[0025] Fifthly, embodiments of this application provide a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and is operable to cause the computer to perform the method as described in the first aspect.
[0026] Implementing the embodiments of this application has the following beneficial effects: First, the text to be identified is obtained, wherein the number of characters in the text to be identified is greater than a threshold; then, feature extraction is performed on the text to be identified to obtain multiple first candidate text segments and multiple first sentences; and feature extraction is performed on the first candidate texts in the text database to obtain multiple second candidate text segments and multiple second sentences, wherein the first candidate text is any one of the multiple candidate texts in the text database; then, keyword analysis is performed on each first candidate text segment to obtain multiple first target text segments, and keyword analysis is performed on each second candidate text segment to obtain multiple second target text segments; then, based on each first target text segment and each second target text segment, each first target text segment is obtained. The system identifies multiple first similarities corresponding to each first target text fragment. Then, based on these first similarities, multiple first sentences, and multiple second sentences, the target text is determined from multiple candidate texts, improving matching accuracy. Each first target text fragment and the second target text fragment associated with it within the target text are defined as explanatory information. The second target text fragment associated with each first target text fragment is the second target text fragment corresponding to the largest first similarity among the multiple first similarities corresponding to that first target text fragment. This explanatory information explains why the text to be identified and the target text are similar, enabling users to understand why they are similar and thus improving the user experience. Attached Figure Description
[0027] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0028] Figure 1 A schematic diagram illustrating a scenario of an interpretable text semantic matching method provided in an embodiment of this application;
[0029] Figure 2 A flowchart illustrating an interpretable text semantic matching method provided in this application embodiment;
[0030] Figure 3 A schematic diagram illustrating multiple first similarities corresponding to each first target text fragment, provided as an embodiment of this application;
[0031] Figure 4 A flowchart illustrating a multi-task model training method provided in an embodiment of this application;
[0032] Figure 5 A schematic diagram of a multi-task model provided in an embodiment of this application;
[0033] Figure 6 A functional unit block diagram of an interpretable text semantic matching device provided in an embodiment of this application;
[0034] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0035] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0036] The terms "first," "second," "third," and "fourth," etc., used in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0037] In this document, the term "embodiment" means that a particular feature, result, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0038] See Figure 1 , Figure 1 This is a schematic diagram of a scenario for an interpretable text semantic matching method provided in an embodiment of this application. The scenario includes a terminal 101 and a server 102, wherein the terminal 101 can be a smartphone, tablet computer, laptop computer, etc.
[0039] When a user wants to perform semantic matching on the text to be recognized, they can upload the text to be recognized to the server 102 through terminal 101. After obtaining the text to be recognized, the server 102 performs semantic matching on the text to be recognized according to the interpretable text semantic matching method provided in this application, and obtains the target text and the reason why the text to be recognized and the target text are similar, i.e., the explanation information, as follows:
[0040] Server 102 obtains the text to be recognized from terminal 101. The number of characters in the text to be recognized exceeds a threshold, and the characters can be one or more of English words, numbers, Chinese characters, and symbols, etc. This application does not limit the type of characters. Then, server 102 performs feature extraction on the text to be recognized, obtaining multiple first candidate text fragments and multiple first sentences. It also performs feature extraction on the first candidate texts in the text database, obtaining multiple second candidate text fragments and multiple second sentences. The first candidate texts are any one of the multiple candidate texts in the text database. Then, server 102 performs keyword analysis on each first candidate text fragment, obtaining multiple first target text fragments, and performs keyword analysis on each second candidate text fragment, obtaining multiple second target text fragments. Finally, server 102 obtains based on each first target text fragment and each second target text fragment... Each first target text fragment corresponds to multiple first similarities; then, server 102 determines the target text from multiple candidate texts based on the multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text fragment; then, server 102 determines each first target text fragment and the second target text fragment associated with each first target text fragment in the target text as explanation information, wherein the second target text fragment associated with each first target text fragment is the second target text fragment corresponding to the largest first similarity among the multiple first similarities corresponding to the first target text fragment, and the explanation information is used to explain the reason why the text to be identified and the target text are similar; optionally, server 102 can send the target text and the explanation information corresponding to the target text to terminal 101, so that the user of terminal 101 can understand the reason why the text to be identified and the target text are similar based on the explanation information.
[0041] To facilitate understanding, this application will describe the understandable text semantic matching method provided in this application in conjunction with specific application scenarios, as follows:
[0042] First, in terms of application scenarios in the legal field. If a user wants to match criminal judgment document A with a similar criminal judgment document B, the user can upload criminal judgment document A to server 102 through terminal 101. Then, server 102 performs feature extraction on criminal judgment document A, obtaining multiple first candidate text fragments and multiple first sentences; similarly, it performs feature extraction on any candidate text in a text database (such as a judgment document database), obtaining multiple second candidate text fragments and multiple second sentences; then, it performs keyword analysis on each first candidate text fragment, obtaining multiple first target text fragments. That is, it determines whether each first candidate text fragment is a key feature fragment, such as the charge, facts of the crime, legal basis, judgment result, etc., and identifies the first candidate text fragment belonging to the key feature fragment as the first target text fragment; similarly, it performs keyword analysis on each second candidate text fragment, obtaining multiple second... The target text fragment is identified; then, based on each first target text fragment and each second target text fragment, multiple first similarities are obtained for each first target text fragment; then, based on the multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text fragment, criminal judgment document B (i.e., the target text) similar to criminal judgment document A is identified from multiple candidate texts in the text database; and each first target text fragment and the second target text fragment associated with each first target text fragment in the target text are identified as explanatory information, so as to explain the reasons for the similarity between criminal judgment document A and criminal judgment document B based on the explanatory information, such as the reason that criminal judgment document A and criminal judgment document B are similar because they have the same charges and the same criminal facts, so that users such as judicial staff can know the reasons for the similarity between criminal judgment document A and criminal judgment document B, and reduce the burden on judicial staff.
[0043] Secondly, regarding applications in the financial sector. If a user wants to find an inquiry letter B similar to inquiry letter A, the user can upload inquiry letter A to server 102 via terminal 101. Server 102 then extracts features from inquiry letter A, obtaining multiple first candidate text fragments and multiple first sentences. Similarly, it extracts features from any inquiry letter in a text database (such as an inquiry letter database), obtaining multiple second candidate text fragments and multiple second sentences. Then, it performs keyword analysis on each first candidate text fragment to obtain multiple first target text fragments. That is, it determines whether each first candidate text fragment is a key feature fragment. For example, key feature fragments could be major asset purchase issues, debt issues, equity investment issues, monetary funds issues, etc., and the first candidate text fragments belonging to key feature fragments are determined as first target text fragments. Similarly, it performs keyword analysis on each second candidate text fragment to obtain multiple second target text fragments. This section describes a process involving several steps. First, based on each first target text fragment and each second target text fragment, multiple first similarities are obtained for each first target text fragment. Then, based on the multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text fragment, inquiry letter B (i.e., the target text) similar to inquiry letter A is identified from multiple inquiry letters in the inquiry letter database. Each first target text fragment and the second target text fragment associated with each first target text fragment are defined as explanatory information. This explanatory information explains the reasons for the similarity between inquiry letter A and inquiry letter B. For example, the reason for the similarity between inquiry letter A and inquiry letter B is that both involve issues such as major asset purchases and monetary funds. This allows users, such as financial professionals, to understand this explanatory information and analyze and classify inquiry letter A and inquiry letter B, reducing the burden on financial professionals.
[0044] It should be noted that the specific application scenarios applicable to the understandable text semantic matching method provided in this application are not limited to the two application scenarios listed above.
[0045] As can be seen, in this embodiment, the process involves obtaining the text to be identified, wherein the number of characters in the text to be identified is greater than a threshold; then, feature extraction is performed on the text to be identified to obtain multiple first candidate text segments and multiple first sentences; feature extraction is also performed on the first candidate texts in the text database to obtain multiple second candidate text segments and multiple second sentences, wherein the first candidate text is any one of the multiple candidate texts in the text database; then, keyword analysis is performed on each first candidate text segment to obtain multiple first target text segments, and keyword analysis is performed on each second candidate text segment to obtain multiple second target text segments; finally, based on each first target text segment and each second target text segment, multiple first target text segments corresponding to each first target text segment are obtained. First, a similarity score is calculated. Then, based on multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text fragment, the target text is determined from multiple candidate texts. Combining the similarity scores across multiple dimensions improves the accuracy of the matching. Each first target text fragment and the second target text fragment associated with each first target text fragment are defined as explanatory information. The second target text fragment associated with each first target text fragment is the second target text fragment corresponding to the largest first similarity score among the multiple first similarities corresponding to that first target text fragment. The explanatory information is used to explain why the text to be identified and the target text are similar, enabling users to understand why the text to be identified and the target text are similar, thereby improving the user experience.
[0046] See Figure 2 , Figure 2 A flowchart illustrating an interpretable text semantic matching method provided in this application embodiment, the method including but not limited to steps 201-208:
[0047] 201: Obtain the text to be recognized.
[0048] The text to be identified has more than a threshold number of characters, or it can be understood that the text to be identified is a long text at the chapter level, such as legal judgment documents in the legal field, inquiry letters in the financial field, etc. This application does not limit the specific value of the threshold.
[0049] 202: Perform feature extraction on the text to be identified to obtain multiple first candidate text fragments and multiple first sentences.
[0050] For example, the text to be identified is subjected to segment extraction to obtain multiple first candidate text segments. The first candidate text segment can be a proper noun, such as a crime in the legal field, or a sentence, such as the facts of a crime in a legal judgment. The text to be identified is subjected to sentence extraction to obtain multiple first sentences. The first sentence can include any first candidate text segment. For example, the first sentence includes a proper noun, or when the first candidate text segment is a sentence, the first sentence is the same as the first candidate text segment. Of course, the first sentence can also be a sentence that neither includes any first candidate text segment nor is the same as the first candidate text segment.
[0051] 203: Extract features from the first candidate text in the text database to obtain multiple second candidate text fragments and multiple second sentences.
[0052] The first candidate text is any one of the multiple candidate texts in the text database. Similarly, to avoid redundancy, the principle of extracting features from the first candidate text in step 203 to obtain multiple second candidate text fragments and multiple second sentences can be referred to the description in step 202, and will not be explained here.
[0053] 204: Perform keyword analysis on each first candidate text fragment to obtain multiple first target text fragments.
[0054] For example, when determining the similarity of two texts at the chapter level, key feature segments within them affect their overall similarity. For instance, key feature segments in legal judgments (such as the charge, facts of the crime, and judgment) influence the overall similarity of two legal judgments; similarly, key feature segments in financial inquiry letters (such as questions regarding significant asset purchases) affect the overall similarity of two inquiry letters. Therefore, keyword analysis of each first candidate text segment can be understood as determining whether each first candidate text segment is a key feature segment, and then identifying the first candidate text segments that are key feature segments as the first target text segments, thus obtaining multiple first target text segments.
[0055] 205: Perform keyword analysis on each second candidate text fragment to obtain multiple second target text fragments.
[0056] Similarly, to avoid redundancy, the principle of performing keyword analysis on each second candidate text fragment in step 205 to obtain multiple second target text fragments can be referred to the description in step 204, and will not be repeated here.
[0057] 206: Based on each first target text fragment and each second target text fragment, obtain multiple first similarities corresponding to each first target text fragment.
[0058] For example, see Figure 3 , Figure 3 This application provides an embodiment of a diagram illustrating multiple first similarities corresponding to each first target text fragment, as shown below. Figure 3 As shown, there are m first target text fragments and n second target text fragments. Then, the similarity between each first target text fragment and each second target text fragment is calculated to obtain n first similarity values corresponding to each first target text fragment. This application does not limit the method for calculating the similarity between each first target text fragment and each second target text fragment, such as calculating Euclidean distance, cosine similarity, etc.
[0059] 207: Based on multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text segment, the target text is determined from multiple candidate texts.
[0060] In an optional embodiment, step 207 includes, but is not limited to, steps A11-A14:
[0061] A11: Combine the first sentences of multiple first sentences that include any one of the first target text segments into a first text.
[0062] For example, when the first target text fragment is a proper noun or a sentence, the first sentence, which includes any one of the first target text fragments (proprietary noun or sentence), is combined to obtain the first text.
[0063] A12: Combine multiple second sentences that include any one of the second target text segments into a second text.
[0064] Similarly, when the second target text fragment is a proper noun or a sentence, the second sentence, which includes any second target text fragment, is combined to obtain the second text.
[0065] A13: Based on the first text and the second text, obtain the second similarity between the text to be identified and the first candidate text.
[0066] For example, the similarity between the first text and the second text is calculated, and the similarity is determined as the second similarity between the text to be identified and the first candidate text. This application does not limit the method for calculating the similarity between the first text and the second text.
[0067] A14: Based on the multiple first similarities corresponding to each first target text segment and the second similarity between the text to be identified and the first candidate text, the target text is determined from multiple candidate texts.
[0068] In an optional embodiment, step A14 may be: obtaining the target similarity between the text to be identified and the first candidate text based on the multiple first similarities corresponding to each first target text segment, the second similarity between the text to be identified and the first candidate text, wherein the target similarity between the text to be identified and the first candidate text can be obtained by formula (1):
[0069]
[0070] Where K represents the target similarity, B represents the number of first target text segments, C represents the number of multiple first similarities corresponding to the i-th first target text segment, and S represents the number of first similarities. z Let X represent the z-th first similarity corresponding to the i-th first target text segment, Y represent the second similarity, A represent the first weight coefficient, D represent the second weight coefficient, and X > 1.
[0071] Then, based on the target similarity between the text to be identified and each candidate text, the target text is determined from multiple candidate texts. For example, the candidate text with the highest target similarity can be determined as the target text. This application does not limit the method of determining the target text from multiple candidate texts based on target similarity.
[0072] It should be noted that, in the semantic matching of the text to be identified (or long text at the document level, i.e., the number of characters is greater than the threshold) in this application embodiment, the matching accuracy requirement is higher compared to the semantic matching of short text. This application first extracts features from the text to be identified to obtain multiple first candidate text segments and multiple first sentences. Then, it determines whether each first candidate text segment is a key feature segment (i.e., a segment that affects the overall similarity between the text to be identified and the candidate texts). First candidate text segments with key feature segments are identified as first target text segments, filtering out segments that have little impact on the overall similarity between the text to be identified and the candidate texts, thus improving matching efficiency. Then, it calculates the similarity between each first target text segment and each second target text segment to obtain the multiple first target text segments corresponding to each first target text segment. The system calculates a first similarity and a second similarity between the text to be identified and the candidate text based on the first and second texts. Then, it determines the target similarity based on the multiple first and second similarities corresponding to each first target text segment. In other words, it judges whether the text to be identified and the candidate text are similar from the text segment dimension (i.e., multiple first similarities corresponding to each first target text segment) and the combined text dimension (i.e., multiple sentences combined). Or, it first judges whether each first target text segment and each second target text segment are similar, and then judges whether the first text composed of a first sentence including any first target text segment and the second text composed of a second sentence including any second target text segment are similar. Finally, it combines the similarity of the two dimensions to determine the target text, thus improving the accuracy of matching.
[0073] 208: Identify each first target text fragment and the second target text fragment associated with each first target text fragment in the target text as explanatory information.
[0074] In this context, the second target text segment associated with each first target text segment is the second target text segment corresponding to the largest first similarity among multiple first similarities corresponding to that first target text segment. Explanatory information is used to explain the reason for the similarity between the text to be identified and the target text. For example, assuming there are m first target text segments and k second target text segments in the target text, then the number of first similarities corresponding to each first target text segment is k. Then, the largest first similarity among the k first similarities corresponding to each first target text segment is determined, and the second target text segment corresponding to the largest first similarity of each first target text segment can be determined, thus obtaining a relationship of one first target text segment corresponding to one second target text segment. Finally, the second target text segment corresponding to the largest first similarity of each first target text segment is determined as the text segment associated with each first target text segment.
[0075] Then, each first target text fragment and the second target text fragment associated with each first target text fragment in the target text are identified as explanatory information. For example, in the legal field, taking any first target text fragment as an example, if the first target text fragment is "sentenced to imprisonment for A years for committing fraud", and the second target text fragment associated with the first target text fragment is "sentenced to imprisonment for B years for committing fraud", then based on this explanatory information, it can be explained that the reason why the text to be identified and the target text are similar is that the criminals were both convicted of fraud, one was sentenced to imprisonment for A years, and the other was sentenced to imprisonment for B years. Therefore, users (such as judicial staff) can perform case analysis and other work based on the matched target text and explanatory information, which can reduce the workload of staff.
[0076] It should be noted that, in this embodiment of the application, by determining each first target text fragment and the second target text fragment associated with each first target text fragment in the target text as explanatory information, users can understand why the text to be identified and the target text are similar based on the explanatory information. Users do not need to spend their own effort to understand why they are similar, which reduces the burden on users and improves the user experience.
[0077] Furthermore, the interpretable text semantic matching method provided in this application embodiment is executed through a multi-task model, which includes a feature extraction network, a first sub-task network, a second sub-task network, and a third sub-task network. Therefore, see [link to relevant documentation]. Figure 4 , Figure 4 This is a flowchart illustrating a multi-task model training method provided in an embodiment of this application. The multi-task model training method includes, but is not limited to, steps 401-406:
[0078] 401: Obtain the first training text and the standard text.
[0079] It should be noted that the first training text and the standard text can be understood as a training text pair. The standard text is the text in the text database that is most similar to the first training text. The number of characters in the first training text can be greater than a threshold, and the number of characters in the standard text can also be greater than a threshold.
[0080] 402: Input the first training text into the feature extraction network to obtain multiple third candidate text fragments and multiple third sentences.
[0081] For example, this feature extraction network employs a hidden layer parameter sharing mechanism, such as a hard-sharing mechanism, to perform similar feature extraction tasks on the first training text and the standard text. This also reduces the risk of overfitting in subsequent first, second, and third sub-task networks when performing their respective tasks. The first training text is input into the feature extraction network to extract segments, resulting in multiple third candidate text segments, and sentences, resulting in multiple third sentences.
[0082] 403: Input standard text into the feature extraction network to obtain multiple fourth candidate text fragments and multiple fourth sentences.
[0083] Similarly, by inputting the standard text into the feature extraction network described above, fragment extraction is performed on the standard text to obtain multiple fourth candidate text fragments, and sentence extraction is performed on the standard text to obtain multiple fourth sentences.
[0084] 404: Based on multiple third candidate text fragments, multiple fourth candidate text fragments, multiple third sentences, and multiple fourth sentences, the first loss corresponding to the first subtask network, the second loss corresponding to the second subtask network, and the third loss corresponding to the third subtask network are obtained.
[0085] In an optional embodiment, step 404 may specifically include: First, inputting multiple third candidate text segments and multiple fourth candidate text segments into a first subtask network to obtain a first predicted value for each third candidate text segment and a second predicted value for each fourth candidate text segment. That is, the first subtask network is a binary classification task, which determines whether each third candidate text segment and each fourth candidate text segment is a key feature segment, and outputs the probability that each third candidate text segment and each fourth candidate text segment is a key feature segment, that is, outputting the first predicted value for each third candidate text segment and the second predicted value for each fourth candidate text segment.
[0086] Then, a first loss is obtained based on the first predicted value of each third candidate text segment and the second predicted value of each fourth candidate text segment. For example, a first candidate loss is obtained based on the first predicted value of each third candidate text segment and a pre-labeled first label for each third candidate text segment; a second candidate loss is obtained based on the second predicted value of each fourth candidate text segment and a pre-labeled second label for each fourth candidate text segment; and a first loss is obtained based on the first candidate loss and the second candidate loss. For example, the first candidate loss and the second candidate loss can be weighted to obtain the first loss, or the larger of the first candidate loss and the second candidate loss can be determined as the first loss. This application does not limit the method of obtaining the first loss based on the first candidate loss and the second candidate loss.
[0087] Finally, based on the first predicted value of each first candidate text segment, the second predicted value of each second candidate text segment, multiple third sentences, and multiple fourth sentences, the second loss and the third loss are obtained. For example, firstly, based on the first predicted value of each third candidate text segment, multiple third target text segments are determined from the multiple third candidate text segments. For instance, if the first predicted value of a third candidate text segment is greater than a first threshold, then the third candidate text segment can be determined as a key feature segment, and the third candidate text segment of the key feature segment is determined as the third target text segment, thus determining multiple third target text segments. Similarly, based on the second predicted value of each fourth candidate text segment, multiple fourth target text segments are determined from the multiple fourth candidate text segments. Then, the multiple third target text segments and the multiple fourth target text segments are input into the second subtask network to obtain multiple third predicted values corresponding to each third target text segment, that is to say... Each third predicted value for each third target text segment represents the similarity between each third target text segment and each fourth target text segment. Then, based on multiple third predicted values corresponding to each third target text segment and the pre-annotated second labels between each third target text segment and each fourth target text segment, a second loss is obtained. Third sentences that include any third target text segment from multiple third sentences are combined into a third text. Fourth sentences that include any fourth target text segment from multiple fourth sentences are combined into a fourth text. Then, the third text and the fourth text are input into the third subtask network to obtain a fourth predicted value. Based on the fourth predicted value and the pre-annotated third labels between the third text and the fourth text, a third loss is obtained.
[0088] It should be noted that during model training, multiple third candidate text segments are screened for whether they are key feature segments, and multiple third target text segments are determined from these segments. Similarly, multiple fourth candidate text segments are screened for whether they are key feature segments, and multiple fourth target text segments are determined from these segments. This reduces the amount of data and improves the efficiency of model training.
[0089] 405: Based on the first loss, the second loss, and the third loss, the target loss is obtained.
[0090] For example, firstly, the first task noise of the first subtask network, the second task noise of the second subtask network, and the third task noise of the third subtask network are obtained. It should be noted that if the loss corresponding to a task is larger, it indicates that the task is more difficult and the corresponding task noise is also larger. Then, based on the first task noise, the second task noise, the third task noise, the first loss, the second loss, and the third loss, the target loss is obtained, whereby the target loss can be obtained by formula (2):
[0091]
[0092] Where L is the target loss, σ1 is the noise of the first task, σ2 is the noise of the second task, σ3 is the noise of the third task, L1 is the first loss, L2 is the second loss, and L3 is the third loss. From this formula, we can see that the magnitude of the target loss depends on the loss and task noise corresponding to each sub-task network. For example, the smaller the first loss, the simpler the task performed by the first sub-task network, and the smaller the first noise. Therefore, the weight of the first loss (i.e., ...) The larger the first loss, the more important the task will be, meaning that the importance of the task will not be ignored just because the task performed by the first sub-task network is simple. Similarly, the larger the first loss, the more difficult the task performed by the first sub-task network, and the greater the first noise, thus increasing the weight of the first loss (i.e., the higher the first noise). The smaller the weight of the task performed by the first sub-task network, the less likely it is to overemphasize that task due to its difficulty, thus preventing the target loss from being dominated by that task. Therefore, this method, which eliminates the need to manually set the weights of the tasks performed by each sub-task network, but instead dynamically adjusts the weights of the tasks performed by each sub-task network based on their respective losses, ensures that the tasks performed by each sub-task network are equally important during training, thereby improving the model training effect.
[0093] 406: The initial multi-task model is iteratively trained based on the target loss to obtain the multi-task model.
[0094] For example, the parameters corresponding to each sub-task network in the initial multi-task model can be adjusted based on the target loss until the target loss meets the target condition, at which point iterative training can be stopped to obtain the above multi-task model. This application does not limit the target condition.
[0095] based on Figure 4 A multi-task model training method is shown below. Figure 5 , Figure 5This is a schematic diagram of a multi-task model provided in an embodiment of this application. The multi-task model includes a feature extraction network, a first sub-task network, a second sub-task network, and a third sub-task network. The output layer of the first sub-task network can be a linear fully connected layer, and the output layers of the second and third sub-task networks can be a fully connected neural network (FNN) containing multiple hidden layers. It should be noted that this application does not limit the output layers of the first, second, and third sub-task networks. Therefore, the first training text and the standard text are input into the feature extraction network to obtain multiple third candidate text segments and multiple third sentences corresponding to the first training text, and multiple fourth candidate text segments and multiple fourth sentences corresponding to the standard text. Then, the multiple third candidate text segments and multiple fourth candidate text segments are input into the first sub-task network to obtain the first predicted value of each third candidate text segment and the second predicted value of each fourth candidate text segment. Then, the first loss is obtained based on the first predicted value of each third candidate text segment and the second predicted value of each fourth candidate text segment. Then, multiple third target text segments that are key feature segments among the multiple third candidate text segments and multiple fourth target text segments that are key feature segments among the multiple fourth candidate text segments are input into the second sub-task network to obtain the second loss. Then, the third text composed of any third target text segment among the multiple third sentences and the fourth text composed of any fourth target text segment among the multiple fourth sentences are input into the third sub-task network to obtain the third loss. Finally, the target loss can be obtained based on the first loss, the second loss, and the third loss.
[0096] See Figure 6 , Figure 6 This is a functional unit block diagram of an interpretable text semantic matching device provided in an embodiment of this application. The interpretable text semantic matching device 600 includes: an acquisition unit 601 and a processing unit 602;
[0097] The acquisition unit 601 is used to acquire the text to be recognized, wherein the number of characters in the text to be recognized is greater than a threshold.
[0098] Processing unit 602 is configured to: extract features from the text to be identified to obtain multiple first candidate text segments and multiple first sentences; extract features from the first candidate texts in the text database to obtain multiple second candidate text segments and multiple second sentences, wherein the first candidate text is any one of the multiple candidate texts in the text database; perform keyword analysis on each first candidate text segment to obtain multiple first target text segments; perform keyword analysis on each second candidate text segment to obtain multiple second target text segments; obtain multiple first similarities corresponding to each first target text segment based on each first target text segment and each second target text segment; determine the target text from the multiple candidate texts based on the multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text segment; and determine each first target text segment and the second target text segments associated with each first target text segment in the target text as explanatory information, wherein the second target text segment associated with each first target text segment is the second target text segment corresponding to the largest first similarity among the multiple first similarities corresponding to the first target text segment, and the explanatory information is used to explain the reason for the similarity between the text to be identified and the target text.
[0099] In one embodiment of this application, interpretable text semantic matching is performed through a multi-task model, which includes a feature extraction network, a first sub-task network, a second sub-task network, and a third sub-task network. The processing unit 602 is further specifically used for:
[0100] Obtain the first training text and the standard text;
[0101] The first training text is input into the feature extraction network to obtain multiple third candidate text fragments and multiple third sentences;
[0102] By inputting standard text into the feature extraction network, multiple fourth candidate text segments and multiple fourth sentences are obtained;
[0103] Based on multiple third candidate text fragments, multiple fourth candidate text fragments, multiple third sentences, and multiple fourth sentences, we obtain the first loss corresponding to the first subtask network, the second loss corresponding to the second subtask network, and the third loss corresponding to the third subtask network.
[0104] Based on the first loss, the second loss, and the third loss, the target loss is obtained;
[0105] The initial multi-task model is iteratively trained based on the target loss to obtain the multi-task model.
[0106] In one embodiment of this application, in obtaining a first loss corresponding to a first sub-task network, a second loss corresponding to a second sub-task network, and a third loss corresponding to a third sub-task network based on multiple third candidate text segments, multiple fourth candidate text segments, multiple third sentences, and multiple fourth sentences, the processing unit 602 is specifically used for:
[0107] Multiple third candidate text segments and multiple fourth candidate text segments are input into the first subtask network to obtain the first predicted value of each third candidate text segment and the second predicted value of each fourth candidate text segment, respectively.
[0108] The first loss is obtained based on the first predicted value of each third candidate text segment and the second predicted value of each fourth candidate text segment;
[0109] The second loss and the third loss are obtained based on the first predicted value of each first candidate text segment, the second predicted value of each second candidate text segment, multiple third sentences, and multiple fourth sentences.
[0110] In one embodiment of this application, in obtaining a first loss based on a first predicted value for each first candidate text segment and a second predicted value for each second candidate text segment, the processing unit 602 is specifically configured to:
[0111] Based on the first predicted value of each third candidate text segment and the first pre-labeled first label of each third candidate text segment, the first candidate loss is obtained;
[0112] The second candidate loss is obtained based on the second predicted value of each fourth candidate text segment and the second pre-labeled second label of each fourth candidate text segment;
[0113] The first loss is obtained based on the first candidate loss and the second candidate loss.
[0114] In one embodiment of this application, in obtaining a second loss and a third loss based on a first predicted value for each first candidate text segment, a second predicted value for each second candidate text segment, a plurality of third sentences, and a plurality of fourth sentences, the processing unit 602 is specifically configured to:
[0115] Based on the first prediction value of each third candidate text fragment, multiple third target text fragments are determined from multiple third candidate text fragments;
[0116] Based on the second prediction value of each fourth candidate text segment, multiple fourth target text segments are determined from multiple fourth candidate text segments;
[0117] Multiple third-target text fragments and multiple fourth-target text fragments are input into the second subtask network to obtain multiple third-target prediction values corresponding to each third-target text fragment.
[0118] The second loss is obtained based on multiple third predicted values corresponding to each third target text segment and the pre-labeled second label between each third target text segment and each fourth target text segment.
[0119] The third text is composed of multiple third sentences that include any third target text fragment.
[0120] The fourth text is composed of multiple fourth sentences that include any fourth target text segment;
[0121] The third and fourth texts are input into the third subtask network to obtain the fourth prediction value;
[0122] The third loss is obtained based on the fourth predicted value, the third text, and the third label pre-annotated between the third and fourth texts.
[0123] In one embodiment of this application, in obtaining the target loss based on the first loss, the second loss, and the third loss, the processing unit 602 is specifically used for:
[0124] Obtain the first task noise of the first subtask network, the second task noise of the second subtask network, and the third task noise of the third subtask network;
[0125] Based on the noise from the first task, the noise from the second task, the noise from the third task, the first loss, the second loss, and the third loss, the target loss is obtained;
[0126] The target loss can be expressed by formula (3):
[0127]
[0128] Where L is the target loss, σ1 is the first task noise, σ2 is the second task noise, σ3 is the third task noise, L1 is the first loss, L2 is the second loss, and L3 is the third loss.
[0129] See Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 7 As shown, the electronic device 700 includes a transceiver 701, a processor 702, and a memory 703. These are connected via a bus 704. The memory 703 stores computer programs and data, and can transfer data stored in the memory 703 to the processor 702.
[0130] Processor 702 is used to read the computer program in memory 703 and perform the following operations:
[0131] The transceiver 701 is controlled to acquire the text to be recognized, wherein the number of characters in the text to be recognized is greater than a threshold.
[0132] Feature extraction is performed on the text to be identified, resulting in multiple first candidate text fragments and multiple first sentences;
[0133] Feature extraction is performed on the first candidate text in the text database to obtain multiple second candidate text fragments and multiple second sentences, wherein the first candidate text is any one of the multiple candidate texts in the text database;
[0134] Keyword analysis is performed on each first candidate text fragment to obtain multiple first target text fragments;
[0135] Keyword analysis is performed on each second candidate text fragment to obtain multiple second target text fragments;
[0136] Based on each first target text fragment and each second target text fragment, multiple first similarities are obtained for each first target text fragment;
[0137] Based on multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text segment, the target text is determined from multiple candidate texts;
[0138] Each first target text fragment and the second target text fragment associated with each first target text fragment in the target text are determined as explanatory information. The second target text fragment associated with each first target text fragment is the second target text fragment corresponding to the largest first similarity among the multiple first similarities corresponding to the first target text fragment. The explanatory information is used to explain the reason why the text to be identified and the target text are similar.
[0139] In one embodiment of this application, in determining the target text from multiple candidate texts based on multiple first similarities, multiple first sentences, and multiple second sentences corresponding to each first target text fragment, the processor 702 is specifically configured to perform the following steps:
[0140] The first text is composed of multiple first sentences that include any one of the first target text segments.
[0141] The second text is composed of multiple second sentences that include any one of the second target text segments.
[0142] Based on the first text and the second text, the second similarity between the text to be identified and the first candidate text is obtained;
[0143] The target text is determined from multiple candidate texts based on the multiple first similarities corresponding to each first target text fragment and the second similarity between the text to be identified and the first candidate text.
[0144] In one embodiment of this application, interpretable text semantic matching is performed through a multi-task model, which includes a feature extraction network, a first sub-task network, a second sub-task network, and a third sub-task network. The processor 702 is further specifically configured to perform the following steps:
[0145] Obtain the first training text and the standard text;
[0146] The first training text is input into the feature extraction network to obtain multiple third candidate text fragments and multiple third sentences;
[0147] By inputting standard text into the feature extraction network, multiple fourth candidate text segments and multiple fourth sentences are obtained;
[0148] Based on multiple third candidate text fragments, multiple fourth candidate text fragments, multiple third sentences, and multiple fourth sentences, we obtain the first loss corresponding to the first subtask network, the second loss corresponding to the second subtask network, and the third loss corresponding to the third subtask network.
[0149] Based on the first loss, the second loss, and the third loss, the target loss is obtained;
[0150] The initial multi-task model is iteratively trained based on the target loss to obtain the multi-task model.
[0151] In one embodiment of this application, in obtaining a first loss corresponding to a first subtask network, a second loss corresponding to a second subtask network, and a third loss corresponding to a third subtask network based on multiple third candidate text segments, multiple fourth candidate text segments, multiple third sentences, and multiple fourth sentences, the processor 702 is specifically configured to perform the following steps:
[0152] Multiple third candidate text segments and multiple fourth candidate text segments are input into the first subtask network to obtain the first predicted value of each third candidate text segment and the second predicted value of each fourth candidate text segment, respectively.
[0153] The first loss is obtained based on the first predicted value of each third candidate text segment and the second predicted value of each fourth candidate text segment;
[0154] The second loss and the third loss are obtained based on the first predicted value of each first candidate text segment, the second predicted value of each second candidate text segment, multiple third sentences, and multiple fourth sentences.
[0155] In one embodiment of this application, regarding obtaining a first loss based on a first predicted value for each first candidate text segment and a second predicted value for each second candidate text segment, the processor 702 is specifically configured to perform the following steps:
[0156] Based on the first predicted value of each third candidate text segment and the first pre-labeled first label of each third candidate text segment, the first candidate loss is obtained;
[0157] The second candidate loss is obtained based on the second predicted value of each fourth candidate text segment and the second pre-labeled second label of each fourth candidate text segment;
[0158] The first loss is obtained based on the first candidate loss and the second candidate loss.
[0159] In one embodiment of this application, in obtaining a second loss and a third loss based on a first predicted value for each first candidate text segment, a second predicted value for each second candidate text segment, a plurality of third sentences, and a plurality of fourth sentences, the processor 702 is specifically configured to perform the following steps:
[0160] Based on the first prediction value of each third candidate text fragment, multiple third target text fragments are determined from multiple third candidate text fragments;
[0161] Based on the second prediction value of each fourth candidate text segment, multiple fourth target text segments are determined from multiple fourth candidate text segments;
[0162] Multiple third-target text fragments and multiple fourth-target text fragments are input into the second subtask network to obtain multiple third-target prediction values corresponding to each third-target text fragment.
[0163] The second loss is obtained based on multiple third predicted values corresponding to each third target text segment and the pre-labeled second label between each third target text segment and each fourth target text segment.
[0164] The third text is composed of multiple third sentences that include any third target text fragment.
[0165] The fourth text is composed of multiple fourth sentences that include any fourth target text segment;
[0166] The third and fourth texts are input into the third subtask network to obtain the fourth prediction value;
[0167] The third loss is obtained based on the fourth predicted value, the third text, and the third label pre-annotated between the third and fourth texts.
[0168] In one embodiment of this application, in obtaining the target loss based on the first loss, the second loss, and the third loss, the processor 702 is specifically configured to perform the following steps:
[0169] Obtain the first task noise of the first subtask network, the second task noise of the second subtask network, and the third task noise of the third subtask network;
[0170] Based on the noise from the first task, the noise from the second task, the noise from the third task, the first loss, the second loss, and the third loss, the target loss is obtained;
[0171] The target loss can be obtained using formula (4):
[0172]
[0173] Where L is the target loss, σ1 is the first task noise, σ2 is the second task noise, σ3 is the third task noise, L1 is the first loss, L2 is the second loss, and L3 is the third loss.
[0174] Specifically, the transceiver 701 described above can be... Figure 6 The processor 702 can be an acquisition unit 601 of the interpretable text semantic matching device 600 in the embodiment. Figure 6 The processing unit 602 of the interpretable text semantic matching device 600 in the embodiment.
[0175] It should be understood that the electronic devices mentioned in this application may include smartphones (such as Android phones, iOS phones, Windows Phones, etc.), tablet computers, PDAs, laptops, mobile internet devices (MIDs), or wearable devices. The above-mentioned electronic devices are merely examples and not exhaustive, and include, but are not limited to, the electronic devices described above. In practical applications, the above-mentioned electronic devices may also include: intelligent in-vehicle terminals, computer equipment, etc.
[0176] This application also provides a computer-readable storage medium storing a computer program that is executed by a processor to implement some or all of the steps of any of the interpretable text semantic matching methods described in the above method embodiments.
[0177] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the interpretable text semantic matching methods described in the above method embodiments.
[0178] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0179] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0180] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0181] The units described as separate components may or may not be physically separate. 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 units can be selected to achieve the purpose of this embodiment according to actual needs.
[0182] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software program module.
[0183] If the integrated unit is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0184] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0185] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An interpretable text semantic matching method, characterized in that, The method comprises: acquiring a text to be identified, wherein the number of characters of the text to be identified is greater than a threshold value; performing feature extraction on the text to be identified to obtain a plurality of first candidate text segments and a plurality of first sentences; performing feature extraction on a first candidate text in a text database to obtain a plurality of second candidate text segments and a plurality of second sentences, wherein the first candidate text is any one of a plurality of candidate texts in the text database; performing keyword analysis on each first candidate text segment to obtain a plurality of first target text segments; performing keyword analysis on each second candidate text segment to obtain a plurality of second target text segments; obtaining, according to each first target text segment and each second target text segment, a plurality of first similarities corresponding to each first target text segment; determining a target text from the plurality of candidate texts according to the plurality of first similarities corresponding to each first target text segment, the plurality of first sentences, and the plurality of second sentences; determining, as explanation information, each first target text segment and a second target text segment associated with each first target text segment in the target text, wherein the second target text segment associated with each first target text segment is a second target text segment corresponding to the maximum first similarity in the plurality of first similarities corresponding to the first target text segment, and the explanation information is used to explain the reason why the text to be identified and the target text are similar.
2. The method of claim 1, wherein, The method further comprises: composing a first text by using a first sentence in the plurality of first sentences that includes any one first target text segment; composing a second text by using a second sentence in the plurality of second sentences that includes any one second target text segment; obtaining a second similarity between the text to be identified and the first candidate text according to the first text and the second text; determining the target text from the plurality of candidate texts according to the plurality of first similarities corresponding to each first target text segment and the second similarity between the text to be identified and the first candidate text.
3. The method according to claim 1 or 2, characterized in that, The method further comprises: acquiring a first training text and a standard text; inputting the first training text into the feature extraction network to obtain a plurality of third candidate text segments and a plurality of third sentences; inputting the standard text into the feature extraction network to obtain a plurality of fourth candidate text segments and a plurality of fourth sentences; obtaining a first loss corresponding to the first sub-task network, a second loss corresponding to the second sub-task network, and a third loss corresponding to the third sub-task network based on the plurality of third candidate text segments, the plurality of fourth candidate text segments, the plurality of third sentences, and the plurality of fourth sentences; and training the multi-task model based on the first loss, the second loss, and the third loss. obtaining a target loss based on the first loss, the second loss, and the third loss; iteratively training an initial multi-task model based on the target loss to obtain the multi-task model.
4. The method of claim 3, wherein, The obtaining, based on the plurality of third candidate text segments, the plurality of fourth candidate text segments, the plurality of third sentences, and the plurality of fourth sentences, of the first loss corresponding to the first sub-task network, the second loss corresponding to the second sub-task network, and the third loss corresponding to the third sub-task network includes: inputting the plurality of third candidate text segments and the plurality of fourth candidate text segments into the first sub-task network to respectively obtain a first prediction value of each third candidate text segment and a second prediction value of each fourth candidate text segment; obtaining the first loss based on the first prediction value of each third candidate text segment and the second prediction value of each fourth candidate text segment; obtaining the second loss and the third loss according to the first prediction value of each first candidate text segment, the second prediction value of each second candidate text segment, the plurality of third sentences, and the plurality of fourth sentences.
5. The method of claim 4, wherein, The obtaining, based on the first prediction value of each third candidate text segment and the second prediction value of each fourth candidate text segment, of the first loss includes: obtaining a first candidate loss based on the first prediction value of each third candidate text segment and a first label pre-labeled for each third candidate text segment; obtaining a second candidate loss based on the second prediction value of each fourth candidate text segment and a second label pre-labeled for each fourth candidate text segment; obtaining the first loss according to the first candidate loss and the second candidate loss.
6. The method of claim 5, wherein, The obtaining, according to the first prediction value of each first candidate text segment, the second prediction value of each second candidate text segment, the plurality of third sentences, and the plurality of fourth sentences, of the second loss and the third loss includes: determining, from the plurality of third candidate text segments, a plurality of third target text segments according to the first prediction value of each third candidate text segment; determining, from the plurality of fourth candidate text segments, a plurality of fourth target text segments according to the second prediction value of each fourth candidate text segment; inputting the plurality of third target text segments and the plurality of fourth target text segments into the second sub-task network to obtain a plurality of third prediction values corresponding to each third target text segment; obtaining the second loss based on the plurality of third prediction values corresponding to each third target text segment and a second label pre-labeled between each third target text segment and each fourth target text segment; a third sentence in the plurality of third sentences including any one third target text segment is a third text; a fourth sentence in the plurality of fourth sentences including any one fourth target text segment is a fourth text; inputting the third text and the fourth text into the third sub-task network to obtain a fourth prediction value; obtaining the third loss based on the fourth prediction value, a third label pre-labeled between the third text and the fourth text.
7. The method of claim 6, wherein, The target loss is obtained based on the first loss, the second loss, and the third loss, including: obtaining the first task noise of the first sub-task network, the second task noise of the second sub-task network, and the third task noise of the third sub-task network; obtaining the target loss based on the first task noise, the second task noise, the third task noise, the first loss, the second loss, and the third loss; The target loss satisfies the following formula: wherein, is the target loss, is the first task noise, is the second task noise, is the third task noise, is the first loss, is the second loss, is the third loss.
8. An interpretable text semantic matching apparatus, characterized by, The device comprises an acquisition unit and a processing unit. The acquisition unit is configured to acquire a to-be-recognized text, wherein the number of characters in the to-be-recognized text is greater than a threshold. The processing unit is configured to perform feature extraction on the to-be-recognized text to obtain a plurality of first candidate text segments and a plurality of first sentences. The processing unit is configured to perform feature extraction on a first candidate text in a text database to obtain a plurality of second candidate text segments and a plurality of second sentences, wherein the first candidate text is any one of a plurality of candidate texts in the text database. The processing unit is configured to perform keyword analysis on each first candidate text segment to obtain a plurality of first target text segments. The processing unit is configured to perform keyword analysis on each second candidate text segment to obtain a plurality of second target text segments. The processing unit is configured to obtain, according to each first target text segment and each second target text segment, a plurality of first similarities corresponding to each first target text segment. The processing unit is configured to determine a target text from the plurality of candidate texts according to the plurality of first similarities corresponding to each first target text segment, the plurality of first sentences, and the plurality of second sentences. The processing unit is configured to determine, as explanation information, each first target text segment and a second target text segment associated with each first target text segment in the target text, wherein the second target text segment associated with each first target text segment is a second target text segment corresponding to a maximum first similarity in the plurality of first similarities corresponding to the first target text segment, and the explanation information is used to explain the reason why the to-be-recognized text is similar to the target text.
9. An electronic device, comprising: including: A processor and a memory, the processor being connected with the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory to enable the electronic device to perform the method in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method in any one of claims 1-7.
Citation Information
Patent Citations
Semantic recognition method and device, computer equipment and storage medium
CN112149410A
Statement processing method and device, electronic equipment and storage medium
CN112164391A