Method and device for explaining model, storage medium and electronic equipment

By introducing the decision-making information of the model to be explained and multiple rounds of dialogue optimization into the deep learning model, high-quality counterfactual explanations are generated, which solves the problem of difficulty in interpreting the prediction results of the deep learning model and improves the transparency of the model.

CN118569392APending Publication Date: 2024-08-30ANT GROUP CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410993517.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

The "black box" nature of deep learning models in natural language processing tasks makes their prediction results difficult to interpret, and existing counterfactual generation methods cannot effectively explain specific models.

Method used

By introducing the decision-making information of the model to be explained, the editing model generates counterfactual explanations based on the decision boundaries of the model to be explained, and uses multi-round dialogue optimization to improve the quality of explanations and generate more accurate counterfactual explanations.

Benefits of technology

It increases the transparency of the model to be explained, helps business personnel understand the prediction results, and generates explanations that are more in line with needs and of higher quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569392A
    Figure CN118569392A
Patent Text Reader

Abstract

The embodiment of the invention discloses a method and device for explaining a model, a storage medium and electronic equipment, and the method comprises the steps: obtaining masked second text data corresponding to first text data, and constructing a first cue word according to the second text data, a second prediction result and model identification information of a to-be-explained model; inputting the first cue word into an editing model to obtain third text data output by the editing model, evaluating the third text data to obtain a corresponding evaluation result, generating a latest first cue word on the basis of the first cue word according to the third text data and the evaluation result, and inputting the latest first cue word into the editing model. Obtaining the latest third text data output by the editing model, and so on until a preset iteration ending condition is met; and determining target third text data in all third text data output by the editing model, and comparing the target third text data with the first text data to obtain interpretation information corresponding to the to-be-interpreted model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer technology, and in particular to a method, device, storage medium and electronic device for interpreting a model. Background Art

[0002] In recent years, with the increasing number of text-based applications, the scale of text content on the Internet has become larger and larger. It is very important to analyze these text contents. Typical NLP (Natural Language Processing) tasks involved in this analysis are sentiment analysis and news classification. Although deep learning models have achieved good performance in these fields, these models themselves are "black boxes" and people cannot fully understand the prediction principles of deep models. Summary of the invention

[0003] The purpose of the embodiments of this specification is to provide a method, device, storage medium and electronic device for interpreting a model.

[0004] The embodiments of this specification provide a method for explaining a model. By introducing the decision information of the model to be explained in the whole process, the editing model generates a counterfactual explanation based on the decision boundary of the model to be explained. By comparing the original input with the generated counterfactual, the prediction result of the original input is explained, thereby avoiding the problem that counterfactual generation only from the data perspective cannot be explained for a specific model. In order to comprehensively improve the instance quality of counterfactual generation, an optimization method based on multi-round dialogue is introduced to obtain a counterfactual explanation that is more in line with the needs and has a higher quality. The counterfactual explanation that more accurately reflects the prediction principle of the model to be explained can be generated, thereby increasing the transparency of the model to be explained and facilitating business personnel to understand the prediction results. The method includes: Obtaining a minimum masking quantity corresponding to first text data, masking the first text data according to the minimum masking quantity, obtaining masked second text data corresponding to the first text data, and constructing a first prompt word according to the second text data, a second prediction result, and model identification information of the model to be explained, wherein the second prediction result is different from a first prediction result obtained by inputting the first text data into the model to be explained; Input the first prompt word into the trained editing model, so that the trained editing model completes the second text data to generate third text data, and makes the third text data correspond to the second prediction result under the model to be interpreted, obtain the third text data output by the trained editing model, evaluate the third text data to obtain a corresponding evaluation result, generate the latest first prompt word based on the first prompt word, according to the third text data and the evaluation result, input the latest first prompt word into the trained editing model, obtain the latest third text data output by the trained editing model, and so on, until a preset end iteration condition is met; At least one target third text data is determined from all the third text data output by the trained editing model, and explanation information corresponding to the model to be explained is obtained by comparing the at least one target third text data with the first text data.

[0005] Furthermore, the method further comprises: Constructing a second prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be interpreted; Constructing first label information according to the second prompt word and the first prediction result; The editing model is trained according to the first prompt word and the first label information to obtain a trained editing model.

[0006] Furthermore, the second prompt word includes a placeholder corresponding to an output result obtained by inputting the first text data into the model to be explained; The step of constructing the first label information according to the second prompt word and the first prediction result includes: The placeholder in the second prompt word is completed into the first prediction result, and the completed second prompt word is used as the first label information.

[0007] Furthermore, the method further comprises: Attributing the first text data and the first prediction result to obtain one or more target text units whose corresponding attribution scores in the first text data are in the same direction as the attribution scores corresponding to the first prediction result; The step of performing text unit masking on the first text data according to the minimum masking quantity includes: At least one target text unit having the largest corresponding attribution score in the first text data is masked, wherein the number of the at least one target text unit is the minimum masking number.

[0008] Furthermore, obtaining the minimum masking quantity corresponding to the first text data includes: The one or more target text units are sorted according to the corresponding attribution scores, and the minimum masking quantity corresponding to the first text data is obtained according to the sorting result.

[0009] Furthermore, obtaining the minimum masking quantity corresponding to the first text data according to the sorting result includes: Based on the sorting result, the target text unit with the largest attribution score among the one or more target text units is masked to obtain the masked fourth text data corresponding to the first text data, and a third prompt word is constructed according to the fourth text data, the second prediction result and the model identification information of the model to be interpreted, and the third prompt word is input into the trained editing model. If the editing model does not output an output result that can correspond to the second prediction result under the model to be interpreted, the target text unit with the second largest attribution score among the one or more target text units continues to be masked based on the sorting result; otherwise, the current masked number of the fourth text data is used as the minimum masked number corresponding to the first text data, and so on, until the minimum masked number is obtained, or until the current masked number has reached the total number of the one or more target text units.

[0010] Furthermore, obtaining the minimum masking quantity corresponding to the first text data according to the sorting result includes: Based on the sorting result and the total number of the one or more target text units, a binary search method is used to determine the current target text unit to be masked, the current target text unit to be masked is masked, and the masked fifth text data corresponding to the first text data is obtained. A fourth prompt word is constructed according to the fifth text data, the second prediction result and the model identification information of the model to be interpreted, and the fourth prompt word is input into the trained editing model. According to whether the trained editing model outputs an output result corresponding to the second prediction result under the model to be interpreted, the minimum masking quantity corresponding to the first text data is obtained. Alternatively, a binary search method is used based on the current masking quantity to determine the latest target text unit to be masked, and the latest target text unit to be masked is masked, and so on, until the binary search method ends.

[0011] Further, the first prompt word includes the number of counterfactual text generation; The step of inputting the first prompt word into the trained editing model so that the trained editing model completes the second text data to generate third text data includes: The first prompt word is input into a trained editing model, so that the trained editing model completes the second text data to generate a third text data of the same number as the counterfactual text generation quantity.

[0012] Further, the evaluating the third text data to obtain a corresponding evaluation result includes: Evaluate the third text data according to at least one preset evaluation dimension to obtain a corresponding evaluation result; The at least one preset evaluation dimension includes at least one of the following: Whether an output result obtained by inputting the third text data into the model to be explained is flipped relative to the first prediction result; The fluency level corresponding to the third text data; The degree of proximity between the third text data and the first text data.

[0013] Furthermore, the third text data is multiple, and the obtaining the third text data output by the trained editing model further includes: Obtain counterfactual text identification information corresponding to each third text data.

[0014] Wherein, determining at least one target third text data from all the third text data output by the trained editing model comprises: Obtaining at least one set of third text data sets from all the third text data output by the trained editing model according to the counterfactual text identification information corresponding to each third text data set, each set of third text data sets including at least one third text data set from all the third text data sets, and each third text data set is located only in one set of third text data sets from the at least one set of third text data sets; For each set of third text data, target third text data is determined in the set of third text data.

[0015] Furthermore, the latest first prompt word includes a plurality of third text data and counterfactual text identification information corresponding to each third text data.

[0016] Further, for each set of the third text data sets, determining the target third text data in the set of the third text data sets includes: For each group of third text data sets, the third text data with the latest generation time in the group of third text data sets is determined as the target third text data.

[0017] Further, for each set of the third text data sets, determining the target third text data in the set of the third text data sets includes: For each set of third text data sets, target third text data are determined in the set of third text data sets according to the evaluation result corresponding to each third text data in the set of third text data sets.

[0018] The embodiment of this specification also provides a device for interpreting a model, comprising: A construction module, used to obtain a minimum masking quantity corresponding to first text data, perform text unit masking on the first text data according to the minimum masking quantity, obtain masked second text data corresponding to the first text data, and construct a first prompt word according to the second text data, a second prediction result and model identification information of a model to be explained, wherein the second prediction result is different from a first prediction result obtained by inputting the first text data into the model to be explained; An editing module, used for inputting the first prompt word into a trained editing model, so that the trained editing model completes the second text data to generate third text data, and makes the third text data correspond to the second prediction result under the model to be interpreted, obtains the third text data output by the trained editing model, evaluates the third text data to obtain a corresponding evaluation result, generates a latest first prompt word based on the first prompt word and the third text data and the evaluation result, inputs the latest first prompt word into the trained editing model, obtains the latest third text data output by the trained editing model, and so on, until a preset end iteration condition is met; An interpretation module is used to determine at least one target third text data from all the third text data output by the trained editing model, and obtain interpretation information corresponding to the model to be interpreted by comparing the at least one target third text data with the first text data.

[0019] The embodiments of the present specification also provide a computer program product, wherein the computer program product stores at least one instruction, and the at least one instruction is suitable for being loaded by a processor and executing the above method steps.

[0020] The embodiments of the present specification also provide a storage medium, wherein the storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the steps of the above method.

[0021] An embodiment of the present specification also provides an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the above method.

[0022] In the embodiments of the present specification, by introducing the decision information of the model to be explained throughout the process, the editing model generates counterfactual explanations based on the decision boundary of the model to be explained, and by comparing the original input with the generated counterfactuals, the prediction results of the original input are explained, thereby avoiding the problem that counterfactual generation only from a data perspective cannot be explained for a specific model. In order to comprehensively improve the instance quality of counterfactual generation, an optimization method based on multi-round dialogues is introduced to obtain counterfactual explanations that are more in line with the needs and of higher quality, and can generate counterfactual explanations that more accurately reflect the prediction principles of the model to be explained, thereby increasing the transparency of the model to be explained and facilitating business personnel to understand the prediction results. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 A flowchart of a method for explaining a model provided in an embodiment of this specification; Figure 2 A flowchart of a method for explaining a model provided in an embodiment of this specification; Figure 3 A flowchart of a method for explaining a model provided as an example in an embodiment of this specification; Figure 4 A schematic diagram of a structure of a device for explaining a model provided in an embodiment of this specification; Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0025] See also Figure 1 , is a flow chart of a method for interpreting a model provided in an embodiment of this specification. In an embodiment of this specification, the method for interpreting a model is applied to a device for interpreting a model (hereinafter referred to as a "model interpretation device") or an electronic device equipped with a model interpretation device. Figure 1 The process shown is described in detail, and the method for explaining the model may specifically include the following steps: S102, obtaining a minimum masking quantity corresponding to first text data, masking text units of the first text data according to the minimum masking quantity, obtaining masked second text data corresponding to the first text data, and constructing a first prompt word according to the second text data, a second prediction result and model identification information of the model to be interpreted, wherein the second prediction result is different from the first prediction result obtained by inputting the first text data into the model to be interpreted.

[0026] In some embodiments, the first text data may be any type of text data. For example, the first text data is short text data (for example, "this movie is good"). It should be noted that the above first text data is only for example and not for limitation. Those skilled in the art should understand that any type of text data may be included in the protection scope of this specification, and this specification does not impose any limitation on this.

[0027] In some embodiments, the minimum masking number refers to the completed first text data obtained by inputting the prompt word constructed according to the masked first text data into the trained editing model, which can make the prediction result corresponding to the completed first text data under the model to be explained flip (i.e., change) relative to the prediction result corresponding to the first text data before masking under the model to be explained, and the minimum number of text units (tokens) that the first text data needs to mask, wherein the model to be explained can be any model that inputs text data and is used to predict the input text data, such as a short text classification model. It should be noted that the above-mentioned model to be explained is only an example and not a limitation. Those skilled in the art should understand that any model that inputs text data and is used to predict the input text data can be included in the protection scope of this specification, and this specification does not limit this. In some embodiments, the editing model can be any type of large language model that supports multi-round dialogues, for example, the editing model is an LLAMA model. It should be noted that the above-mentioned editing model is only an example and not a limitation. Those skilled in the art should understand that any large language model that supports multi-round dialogues can be included in the protection scope of this specification, and this specification does not limit this. In some embodiments, by obtaining the minimum masking number and masking the text units of the minimum masking number in the first text data based on the minimum masking number, the third text data output by the editing model, i.e., the counterfactual text, can be ensured to be as close as possible to the first text data.

[0028] In some embodiments, based on the total number of text units in the first text data, different numbers of text units in the first text data can be tried to be masked in sequence, prompt words can be constructed according to different masked first text data, and different prompt words can be input into the trained editing model respectively. By judging whether the editing model outputs the completed first text data that can flip the corresponding prediction result of the first text data before masking under the model to be interpreted, the minimum number of text units (tokens) that need to be masked for the first text data that can flip the corresponding prediction result of the completed first text data under the model to be interpreted relative to the corresponding prediction result of the first text data before masking under the model to be interpreted (i.e., the minimum masking number) can be determined. Alternatively, the minimum masking number can also be obtained by any other method, and this example embodiment does not specifically limit this.

[0029] In some embodiments, at least one text unit (token) in the first text data is masked, and the number of the at least one text unit is equal to the minimum masked number, that is, the text units with the minimum masked number in the first text data are masked to obtain the masked second text data. In some embodiments, the text units with the minimum masked number that need to be masked are determined among all the text units corresponding to the first text data. For example, the text units with the minimum masked number that need to be masked can be randomly determined among all the text units. For another example, the text units with the minimum masked number can be determined according to preset conditions among all the text units corresponding to the first text data and used as the text units that need to be masked. The preset condition can be that the text units with the minimum masked number with the highest corresponding importance are used as the text units that need to be masked, or the text units with the minimum masked number with the greatest influence on the prediction results are used as the text units that need to be masked. This example embodiment does not make any special limitation on this. For example, the first text data is "the movie is good", the minimum masking number is not 1, and the text unit "good" in the first text data has a greater impact on the prediction result. The text unit is masked to obtain the masked second text data "the movie is [MASK]".

[0030] In some embodiments, a first prompt is constructed based on the second text data, the second prediction result and the model identification information of the model to be explained. The first prompt is used to prompt the completion of the second text data so that the output result corresponding to the completed second text data under the model corresponding to the model identification information (i.e., the prediction result of the model) is the second prediction result, wherein the second prediction result is different from the first prediction result obtained by inputting the first text data into the model to be explained, that is, the second prediction result is different from the first prediction result. For example, the first prediction result and the second prediction result are two different prediction results that may be output by the model to be explained. For example, if the model to be explained is a sentiment analysis model, the prediction results that it may output include "positive" and "negative". For another example, if the model to be explained is a classification task model, the prediction results that it may output include labels contained in the label range corresponding to the classification task. This example embodiment does not make any special limitation on this. For example, the second text data is "the movie is [MASK]", the first prediction result is "positive", the second prediction result is "negative" which is different from "positive", and the model identification information is "M1", then the first prompt word constructed is "Please complete the following sentence: the movie is [MASK] and make its prediction result under the M1 model negative".

[0031] S104, inputting the first prompt word into the trained editing model, so that the trained editing model completes the second text data to generate third text data, and makes the third text data correspond to the second prediction result under the model to be interpreted, obtaining the third text data output by the trained editing model, evaluating the third text data to obtain a corresponding evaluation result, and generating the latest first prompt word based on the first prompt word and the third text data and the evaluation result, inputting the latest first prompt word into the trained editing model, obtaining the latest third text data output by the trained editing model, and so on, until the preset end iteration condition is met.

[0032] In some embodiments, the first prompt word is input into the trained editing model, so that the editing model completes one or more masked text units in the masked second text data in the first prompt word to generate one or more third text data, and makes the corresponding output result of the one or more third text data under the model to be interpreted be the second prediction result, and then the editing model will output the one or more third text data (i.e., counterfactual text). For example, the second text data is "the movie is [MASK]", then the editing model completes the masked text unit "[MASK]" in the second text data and generates one or more third text data including "the movie is not good", "the movie is bad", etc.

[0033] In some embodiments, the quality of each of the one or more third text data output by the editing model is evaluated to obtain the evaluation result corresponding to the third text data, and the evaluation result includes but is not limited to the evaluation results of various quality indicators (for example, fluency, degree of proximity to the original text, etc.) such as good quality, poor quality, poor fluency, and low degree of proximity to the original text, and this example embodiment does not make special restrictions on this. In some embodiments, based on the first prompt word, according to the third text data and the evaluation result, the latest first prompt word is generated, that is, on the basis of the current first prompt word, the content of each of the one or more third text data output by the editing model and the evaluation result corresponding to the third text data are added, or, the content of each third text data output by the editing model and the optimization information corresponding to the third text data determined according to the evaluation result corresponding to the third text data are added, and the latest first prompt word is generated, and the optimization information includes but is not limited to "keep it unchanged", "change it to make it more fluent", etc., and this example embodiment does not make special restrictions on this. For example, the editing model outputs three third text data, namely C1, C2, and C3, then "keep C2 unchanged, change C1 and C3 to make it smoother" is added after the current first prompt word to obtain the latest first prompt word.

[0034] In some embodiments, the latest first prompt word is re-input into the trained editing model to further optimize various quality indicators of the third text data output by the editing model (for example, fluency, closeness to the original text, etc.), the latest one or more third text data output by the editing model are obtained again, and the quality of each of the new one or more third text data is continuously evaluated to obtain the corresponding evaluation results, and so on, until a preset end iteration condition is met, wherein the preset end iteration condition may refer to the third text data having generated a preset number of rounds, or it may also be that the evaluation result corresponding to the latest third text data currently output by the editing model meets the preset quality requirements. It should be noted that the above-mentioned end iteration condition is only for example and not for limitation. Those skilled in the art should understand that any end iteration condition may be included in the protection scope of this specification, and this specification does not limit this.

[0035] S106, determining at least one target third text data from all the third text data output by the trained editing model, and obtaining interpretation information corresponding to the model to be interpreted by comparing the at least one target third text data with the first text data.

[0036] In some embodiments, after the iteration is completed, at least one target third text data is determined from all the third text data output by the trained editing model during the iteration process. For example, at least one target third text data can be determined from all the third text data according to the generation time corresponding to each third text data. For example, a preset number of third text data with the latest generation time among all the third text data can be used as the target third text data, or the third text data generated in the last round can be used as the target third text data. For another example, at least one target third text data can be determined from all the third text data according to the evaluation result corresponding to each third text data. For example, a preset number of third text data with the best quality among all the third text data can be used as the target third text data. The above-mentioned method of determining at least one target third text data from all the third text data is only an example and not a limitation. Those skilled in the art should understand that any determination method can be included in the protection scope of this specification, and this specification does not limit this. In some embodiments, by comparing the at least one target third text data (i.e., counterfactual text) with the first text data, the model to be explained is interpreted according to the comparison result to obtain corresponding explanation information (i.e., counterfactual explanation), or, by comparing the at least one target third text data and the second prediction result with the first text data and the first prediction result, the model to be explained is interpreted according to the comparison result to obtain explanation information corresponding to the model to be explained, and the model prediction principle and prediction result of the model to be explained are explained, thereby helping model users or business personnel understand the internal principles of the prediction of the model to be explained.

[0037] In some embodiments, the method further includes: attributing the first text data and the first prediction result, and obtaining one or more target text units in the first text data whose corresponding attribution scores are in the same direction as the attribution scores corresponding to the first prediction result; wherein, the text unit masking of the first text data according to the minimum masking number includes: masking at least one target text unit with the largest corresponding attribution score in the first text data, wherein the number of the at least one target text unit is the minimum masking number. In some embodiments, a preset attribution method is used to attribute the first text data and the first prediction result, and the attribution score corresponding to the first prediction result and the attribution score corresponding to each text unit (token) in the first text data are obtained. The attribution method includes but is not limited to LIME, SHAP, IG, etc., and this example embodiment does not specifically limit this. In some embodiments, one or more target text units in the first text data whose corresponding attribution scores are in the same direction as the attribution scores corresponding to the first prediction result are obtained. In some embodiments, at least one target text unit of the minimum masking number with the largest corresponding attribution score among the one or more target text units in the first text data is masked to obtain the masked second text data.

[0038] In some embodiments, the obtaining of the minimum masking quantity corresponding to the first text data includes: sorting the one or more target text units according to the corresponding attribution scores, and obtaining the minimum masking quantity corresponding to the first text data according to the sorting result. In some embodiments, the one or more target text units are sorted according to the corresponding attribution scores to obtain the corresponding sorting result, and the minimum masking quantity corresponding to the first text data is obtained according to the sorting result. For example, different numbers of text units with the largest corresponding attribution scores in the first text data can be tried to be masked in sequence according to the sorting result, and prompt words can be constructed according to different masked first text data, and different prompt words can be input into the trained editing model respectively. By judging whether the editing model outputs the completed first text data that can flip the corresponding prediction result under the model to be explained relative to the first text data before masking, the minimum value of the number of text units (tokens) that need to be masked for the first text data that can flip the corresponding prediction result under the model to be explained relative to the corresponding prediction result under the model to be explained of the first text data before masking (i.e., the minimum masking quantity) can be determined.

[0039] In some embodiments, obtaining the minimum masking quantity corresponding to the first text data according to the sorting result includes: masking the target text unit with the largest attribution score among the one or more target text units based on the sorting result to obtain the masked fourth text data corresponding to the first text data, constructing a third prompt word according to the fourth text data, the second prediction result and the model identification information of the model to be interpreted, inputting the third prompt word into the trained editing model, and if the editing model does not output an output result that can correspond to the second prediction result under the model to be interpreted, continuing to mask the target text unit with the second largest attribution score among the one or more target text units based on the sorting result; otherwise, taking the current masking quantity of the fourth text data as the minimum masking quantity corresponding to the first text data, and so on, until the minimum masking quantity is obtained, or until the current masking quantity has reached the total number of the one or more target text units. In some embodiments, based on the sorting result, the target text unit with the largest attribution score among the one or more target text units is masked to obtain the masked fourth text data, and a third prompt word is constructed according to the fourth text data, the second prediction result and the model identification information of the model to be explained, and the third prompt word is input into the trained editing model. If the editing model outputs an output result that can correspond to the second prediction result under the model to be explained, the current masked number of the fourth text data (that is, the number of text units currently masked in the fourth text data) is used as the minimum masked number corresponding to the first text data. If the editing model fails to output an output result that can correspond to the second prediction result under the model to be explained, the current masked number of the fourth text data (that is, the number of text units currently masked in the fourth text data) is used as the minimum masked number corresponding to the first text data. Based on the data, continue to mask the target text unit with the second largest attribution score in the one or more target text units based on the sorting result to obtain the latest masked fourth text data, construct the latest third prompt word according to the latest fourth text data, the second prediction result and the model identification information, input the latest third prompt word into the trained editing model, and judge whether the editing model outputs an output result that can correspond to the second prediction result under the model to be interpreted, and so on, until the minimum masking number is obtained, or until it is determined that the previous masking number of the latest fourth text data latest input into the editing model has reached the total number of the one or more target text units after obtaining the latest output result output by the editing model.For example, there are 5 target text units, and the target text unit sequence obtained after sorting them in descending order according to the corresponding attribution scores is token1, token2, token3, token4, and token5. Token1 with the largest attribution score is first masked to obtain the masked fourth text data. A third prompt word is constructed according to the fourth text data, the second prediction result, and the model identification information of the model to be interpreted. The third prompt word is input into the trained editing model. If the editing model outputs an output result that can correspond to the second prediction result under the model to be interpreted, the current masked number of the fourth text data is used as the minimum masked number corresponding to the first text data. If the editing model fails to output an output result that can correspond to the second prediction result under the model to be interpreted, then based on the current fourth text data, token2 with the second largest attribution score continues to be masked, and so on, until the minimum masked number is obtained, or until it is determined that the previous masked number of the latest fourth text data input into the editing model has reached 5 after the latest output result output by the editing model is obtained.

[0040] In some embodiments, obtaining the minimum masking quantity corresponding to the first text data according to the sorting result includes: based on the sorting result and the total number of the one or more target text units, using the binary search method to determine the current target text unit to be masked, masking the current target text unit to be masked, obtaining the masked fifth text data corresponding to the first text data, constructing a fourth prompt word according to the fifth text data, the second prediction result and the model identification information of the model to be interpreted, inputting the fourth prompt word into the trained editing model, and obtaining the minimum masking quantity corresponding to the first text data according to whether the trained editing model outputs an output result corresponding to the second prediction result under the model to be interpreted, or, based on the current masking quantity, using the binary search method to determine the latest target text unit to be masked, masking the latest target text unit to be masked, and so on, until the binary search method ends. In some embodiments, based on the sorting result and the total number of the one or more target text units (i.e., the maximum disturbance number), a binary search method is used to determine the current target text unit to be masked. Specifically, the current disturbance number is first determined by using a binary search method on the total number (i.e., the maximum disturbance number), and then, based on the current disturbance number and the sorting result, the target text unit of the current disturbance number with the largest corresponding attribution score is obtained as the target text unit to be masked. Then, based on the original first text data, the target text unit to be masked is masked to obtain the masked fifth text data, and a fourth prompt word is constructed according to the second text data, the second prediction result, and the model identification information. The fourth prompt word is input into the trained editing model to determine whether the editing model outputs an output result corresponding to the second prediction result under the model to be explained. According to the judgment result corresponding to the current disturbance quantity and the judgment results corresponding to other disturbance quantities obtained previously, it is determined based on the binary search whether there is a latest disturbance quantity. If not, it is directly determined that the binary search ends. If so, based on the latest disturbance quantity, the target text unit of the latest disturbance quantity with the largest corresponding attribution score is obtained as the latest target text unit to be masked, and then the latest target text unit to be masked is masked on the basis of the original first text data to obtain the latest masked fifth text data, and the latest fourth prompt word is constructed according to the latest fifth text data, the second prediction result and the model identification information, and the latest fourth prompt word is input into the trained editing model to determine whether the editing model outputs an output result corresponding to the second prediction result under the model to be explained, and so on until the binary search ends.For example, there are 5 target text units, and the target text unit sequence obtained after sorting in descending order according to the corresponding attribution scores is token1, token2, token3, token4, token5. The current disturbance number is determined to be 3 using the binary search method, that is, it is determined that the current target text unit to be masked includes token1, token2, and token3. After masking, the masked fifth text data is obtained. A fourth prompt word is constructed according to the fifth text data, the second prediction result, and the model identification information. The fourth prompt word is input into the trained editing model to determine whether the editing model outputs an output result corresponding to the second prediction result under the model to be explained. If so, the latest disturbance is determined forward using the binary search method based on the current disturbance number 3. The number is 2. If not, based on the current disturbance number 3, use the binary search method to determine the latest disturbance number as 4. If the latest disturbance number is 4, that is, the latest target text unit to be masked includes token1, token2, token3, and token4. If the latest disturbance number is 2, that is, the latest target text unit to be masked includes token1 and token2. After masking the latest target text unit to be masked, the latest fifth text data is obtained. According to the latest fifth text data, the second prediction result and the model identification information, the latest fourth prompt word is constructed. The latest fourth prompt word is input into the trained editing model to determine whether the editing model outputs an output result corresponding to the second prediction result under the model to be explained, and so on, until the binary search method ends.

[0041] In some embodiments, the first prompt word includes the number of counterfactual texts generated; wherein, the step of inputting the first prompt word into the trained editing model so that the trained editing model completes the second text data to generate third text data comprises: inputting the first prompt word into the trained editing model so that the trained editing model completes the second text data to generate third text data of the counterfactual text generation number. In some embodiments, the number of counterfactual texts generated can be set in the first prompt word so that the editing model completes one or more masked text units in the masked second text data in the first prompt word to generate multiple different third text data of the set number of counterfactual texts generated.

[0042] In some embodiments, the evaluating the third text data to obtain the corresponding evaluation result includes: evaluating the third text data according to at least one preset evaluation dimension to obtain the corresponding evaluation result; wherein the at least one preset evaluation dimension includes at least one of the following: whether the output result obtained by inputting the third text data into the model to be explained is flipped relative to the first prediction result; the fluency corresponding to the third text data; the degree of proximity between the third text data and the first text data. In some embodiments, the quality of the third text data is evaluated according to at least one preset evaluation dimension to obtain the corresponding evaluation result, and the at least one preset evaluation dimension includes but is not limited to the fluency of the third text data, the degree of proximity between the third text data and the first text data, and whether the output result obtained by inputting the third text data into the model to be explained is flipped relative to the first prediction result (that is, whether the output result is different from the first prediction result). It should be noted that the above evaluation dimensions are only examples, not limitations. Those skilled in the art should understand that any evaluation dimension can be included in the protection scope of this specification, and this specification does not limit this. In the embodiments of this specification, an optimization method based on multi-round dialogues is introduced. It not only considers whether the counterfactual text has a flip or change in the predicted result, but also comprehensively considers multiple indicators such as fluency and closeness to the original text. This avoids the problem of other methods only using whether the predicted result has changed for screening, thereby obtaining a counterfactual explanation that better meets the needs and has higher quality.

[0043] In some embodiments, there are multiple third text data, and obtaining the third text data output by the trained editing model further includes: obtaining counterfactual text identification information corresponding to each third text data; wherein, determining at least one target third text data among all the third text data output by the trained editing model includes: obtaining at least one group of third text data sets according to the counterfactual text identification information corresponding to each third text data among all the third text data output by the trained editing model, each group of third text data sets containing at least one third text data among all the third text data, and each third text data is located only in one group of third text data sets among the at least one group of third text data sets; for each group of third text data sets, determining the target third text data in the group of third text data sets. In some embodiments, for multiple third text data output by the editing model in the first round, counterfactual text identification information of each third text data can be set. For multiple third text data output by the editing model in the second and subsequent rounds, the counterfactual text identification information of each third text data can be determined based on the latest first prompt word of the current input editing model corresponding to the multiple third text data (the latest first prompt word includes the content of the multiple third text data output by the editing model in the previous round), wherein the counterfactual text identification information is identification information used to uniquely identify each third text data. For example, the counterfactual text identification information is a specific number of the third text data (for example, "A1", "A2", "B1", "B3"). It should be noted that the above-mentioned counterfactual text identification information is only for example and not for limitation. Those skilled in the art should understand that any identification information used to uniquely identify the third text data can be included in the protection scope of this specification, and this specification does not limit this. In some embodiments, among all the third text data output by the trained editing model, the third text data corresponding to the counterfactual text identification information that are associated are aggregated according to the counterfactual text identification information corresponding to each third text data, to obtain at least one set of third text data sets. For example, the third text data corresponding to the counterfactual text identification information "A1", "A2", and "A3" that are associated are aggregated to form a set of third text data sets, which includes the third text data corresponding to "A1", the third text data corresponding to "A2", and the third text data corresponding to "A3". In some embodiments, each set of third text data sets contains at least one third text data among all the third text data output by the editing model, and each third text data among all the third text data is only located in one of the at least one set of third text data sets.

[0044] In some embodiments, the latest first prompt word includes multiple third text data and counterfactual text identification information corresponding to each third text data. In some embodiments, the latest first prompt word can be generated based on the first prompt word according to multiple third text data and their corresponding evaluation results, so that the latest first prompt word includes not only the multiple third text data but also the counterfactual text identification information corresponding to each third text data. When the latest first prompt word is subsequently input into the editing model, the counterfactual text identification information corresponding to each third text data can be obtained directly according to the latest first prompt word. In some embodiments, the latest first prompt word can also be generated based on the first prompt word according to multiple third text data and their corresponding evaluation results, so that the latest first prompt word includes the multiple third text data but does not include the counterfactual text identification information corresponding to each third text data, and the counterfactual text identification information corresponding to each third text data is saved in the preset storage area. When the latest first prompt word is subsequently input into the editing model, the counterfactual text identification information corresponding to each third text data that has been saved can be read from the preset storage area according to the multiple third text data in the latest first prompt word.

[0045] In some embodiments, for each set of the third text data set, determining the target third text data in the set of the third text data set includes: for each set of the third text data set, determining the third text data with the latest generation time in the set of the third text data set as the target third text data. In some embodiments, for each set of the third text data set, determining the third text data with the latest generation time in the set of the third text data set as the target third text data, for example, determining the third text data output by the editing model in the last round in the set of the third text data set as the target third text data.

[0046] In some embodiments, for each set of the third text data set, determining the target third text data in the set of the third text data set includes: for each set of the third text data set, according to the evaluation result corresponding to each third text data in the set of the third text data set, determining the target third text data in the set of the third text data set. In some embodiments, for each set of the third text data set, according to the evaluation result corresponding to each third text data in the set of the third text data set, determining the target third text data that meets the preset quality requirements among all the third text data in the set of the third text data set, for example, determining the third text data with the best quality in the set of the third text data set as the target third text data.

[0047] In the embodiments of the present specification, by introducing the decision information of the model to be explained throughout the process, the editing model generates counterfactual explanations based on the decision boundary of the model to be explained, and by comparing the original input with the generated counterfactuals, the prediction results of the original input are explained, thereby avoiding the problem that counterfactual generation only from a data perspective cannot be explained for a specific model. In order to comprehensively improve the instance quality of counterfactual generation, an optimization method based on multi-round dialogues is introduced to obtain counterfactual explanations that are more in line with the needs and of higher quality, and can generate counterfactual explanations that more accurately reflect the prediction principles of the model to be explained, thereby increasing the transparency of the model to be explained and facilitating business personnel to understand the prediction results.

[0048] Figure 2 A flowchart of another method for interpreting a model provided in an embodiment of this specification specifically includes the following steps: S202: construct a second prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be interpreted.

[0049] In some embodiments, the model identification information of the model to be interpreted is identification information used to uniquely identify the model to be interpreted. For example, the model identification information is a specific number of the model to be interpreted (for example, "M1"). It should be noted that the above-mentioned model identification information is only an example and not a limitation. Those skilled in the art should understand that any identification information used to uniquely identify a model can be included in the scope of protection of this specification, and this specification does not impose any limitations on this.

[0050] In some embodiments, a second prompt corresponding to the first text data is constructed based on the first text data and the model identification information of the model to be interpreted. The second prompt is used to prompt the first text data to be input into the model corresponding to the model identification information to obtain the corresponding output result (that is, the actual prediction result of the model). For example, if the first text data is "this movie is good" and the model identification information is "M1", then the constructed second prompt is "this movie is good. Sentiment classification is performed according to the prediction result of model M1".

[0051] S204: Construct first label information according to the second prompt word and the first prediction result.

[0052] In some embodiments, the output result of the model to be explained (i.e., the first prediction result) is obtained by inputting the first text data into the model corresponding to the model identification information (i.e., the model to be explained). For example, the first text data "this movie is good" is input into the model to be explained to obtain the corresponding first prediction result "positive". In some embodiments, the first label information is constructed according to the second prompt word and the first prediction result. The first label information is used to indicate that the corresponding output result obtained by inputting the first text data into the model corresponding to the model identification information is the first prediction result. For example, the second prompt word is "this movie is good. According to the prediction result of model M1, sentiment classification is performed", and the first prediction result is "positive". Then, the constructed first label information is "please classify the following sentence: this movie isgood according to the prediction result of model M1, and the classification result is positive".

[0053] S206: Train an editing model according to the first prompt word and the first label information to obtain a trained editing model.

[0054] In some embodiments, the editing model is fine-tuned by training multiple training data including the second prompt word and its corresponding first label information to obtain a fine-tuned editing model. The editing model is fine-tuned to make it classify as much as possible according to the actual prediction results of the model to be explained. In this way, the editing model learns the prediction principle of the model to be explained based on the prediction results of the model to be explained, laying the foundation for generating counterfactual explanations in the subsequent second stage. In some embodiments, since the model identification information (e.g., M1) of the model to be explained is continuously introduced when fine-tuning the editing model in the first stage, adding the model identification information to the prompt when generating counterfactuals will make the editing model generate as much as possible according to the data in the fine-tuning stage, so that the generated counterfactual text can more accurately reflect the decision boundary of the model to be explained.

[0055] In some embodiments, the second prompt word includes a placeholder corresponding to the output result obtained by inputting the first text data into the model to be explained; wherein, the first label information is constructed according to the second prompt word and the first prediction result, including: completing the placeholder in the second prompt word with the first prediction result, and using the completed second prompt word as the first label information. In some embodiments, the second prompt word includes a placeholder corresponding to the output result obtained by inputting the first text data into the model to be explained, and the placeholder can be any preset text unit, for example, the placeholder is "[BLANK]", which is not particularly limited in this example embodiment. For example, the second prompt word is "this movie is good According to the prediction result of model M1, sentiment classification is performed, and the classification result is [BLANK]". In some embodiments, the placeholder "[BLANK]" in the second prompt word is completed with the first prediction result "positive" corresponding to the first text data, and the completed second prompt word "this movie is good According to the prediction result of model M1, sentiment classification is performed, and the classification result is positive" is used as the first label information.

[0056] S208, obtaining the minimum masking quantity corresponding to the first text data, performing text unit masking on the first text data according to the minimum masking quantity, obtaining the masked second text data corresponding to the first text data, and constructing a first prompt word according to the second text data, the second prediction result and the model identification information of the model to be explained, wherein the second prediction result is different from the first prediction result obtained by inputting the first text data into the model to be explained. Step S208 is implemented in the same or similar manner as the aforementioned step 102, and will not be described in detail here.

[0057] S210, input the first prompt word into the trained editing model, so that the trained editing model completes the second text data to generate third text data, and makes the third text data correspond to the second prediction result under the model to be interpreted, obtain the third text data output by the trained editing model, evaluate the third text data to obtain the corresponding evaluation result, and generate the latest first prompt word based on the first prompt word and the third text data and the evaluation result, input the latest first prompt word into the trained editing model, obtain the latest third text data output by the trained editing model, and so on, until the preset end iteration condition is met. Step S210 is implemented in the same or similar manner as the aforementioned step 104, and will not be repeated here.

[0058] S212, determining at least one target third text data from all the third text data output by the trained editing model, and obtaining interpretation information corresponding to the model to be interpreted by comparing the at least one target third text data with the first text data. Step S212 is implemented in the same or similar manner as the aforementioned step 106, and will not be described in detail herein.

[0059] Figure 3 A flowchart of a method for interpreting a model is provided as an example in an embodiment of this specification.

[0060] like Figure 3As shown in FIG. 1 , the first stage is used to fine-tune the editing model. In this stage, the first text data "The movie is great" is input into the to-be-explained model M1, and the prediction result obtained is positive. The input of the editing model is the prompt word "M1 predicts <input> is [BLANK]", <input> is the first text data "The movie is great", and the label information corresponding to the prompt word is "M1 predicts <input> is <prediction result>", <prediction result> is the prediction result corresponding to the first text data positive, that is, the output result obtained by inputting the first text data into the editing model is "M1 predicts 'The movie is great' great' is 'positive'", the editing model is fine-tuned through multiple training data including the prompt word and its corresponding label information to obtain the fine-tuned editing model. The second stage is used to explain the model to be explained. In this stage, the first text data and its corresponding prediction result are attributed based on the lime attribution method to obtain at least one target text unit in the first text data with the same direction as the attribution score of the prediction result. The at least one target text unit includes great. The optimal number of replacements (the minimum number of replacements that causes the prediction result to be flipped or changed) is determined to be 1 through binary search. The target text unit great with the largest attribution score in the first text data is masked to obtain the masked second text data "The movie is [MASK]", and the target label negative different from the prediction result positive is obtained. The prompt word constructed in this way is "complete <masked input> so that M1 predicts it as <target label>", <masked input> is the masked second text data "The movie is [MASK]", <target label> is the target label negative, the prompt word is input into the fine-tuned editing model, and the output of the editing model corresponding to the output under the interpretation model is a plurality of third text data with the target label negative, that is, a plurality of counterfactual texts (C1, C2, C3...), and the plurality of third text data are optimized for multiple rounds of dialogue (including optimization of fluency, predicted flipping, etc.), and the optimized plurality of counterfactual texts (C1', C2', C3'...) are compared with the first text data, and the model to be interpreted is interpreted according to the comparison result to obtain the interpretation information corresponding to the model to be interpreted.

[0061] Figure 4A schematic diagram of a device for interpreting a model provided in an embodiment of this specification, the device for interpreting a model (hereinafter referred to as "model interpretation device 1") can be implemented as all or part of an electronic device through software, hardware or a combination of both. According to some embodiments, the model interpretation device 1 includes a construction module 11, an editing module 12 and an interpretation module 13.

[0062] A construction module 11 is used to obtain a minimum masking quantity corresponding to first text data, perform text unit masking on the first text data according to the minimum masking quantity, obtain masked second text data corresponding to the first text data, and construct a first prompt word according to the second text data, a second prediction result and model identification information of the model to be explained, wherein the second prediction result is different from the first prediction result obtained by inputting the first text data into the model to be explained; The editing module 12 is used to input the first prompt word into the trained editing model, so that the trained editing model completes the second text data to generate third text data, and makes the third text data correspond to the second prediction result under the model to be interpreted, obtain the third text data output by the trained editing model, evaluate the third text data to obtain a corresponding evaluation result, generate the latest first prompt word based on the first prompt word and the third text data and the evaluation result, input the latest first prompt word into the trained editing model, obtain the latest third text data output by the trained editing model, and so on, until the preset end iteration condition is met; The interpretation module 13 is used to mask the text units of the first text data to obtain the masked second text data corresponding to the first text data, determine at least one target third text data from all the third text data output by the trained editing model according to the second text data, the second prediction result and the model identifier, and obtain the interpretation information corresponding to the model to be interpreted by comparing the at least one target third text data with the first text data.

[0063] In some embodiments, the model interpretation device 1 is further used for: Constructing a second prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be interpreted; Constructing first label information according to the second prompt word and the first prediction result; The editing model is trained according to the first prompt word and the first label information to obtain a trained editing model.

[0064] In some embodiments, the second prompt word includes a placeholder corresponding to an output result obtained by inputting the first text data into the model to be explained; The step of constructing the first label information according to the second prompt word and the first prediction result includes: The placeholder in the second prompt word is completed into the first prediction result, and the completed second prompt word is used as the first label information.

[0065] In some embodiments, the model interpretation device 1 is further used for: Attributing the first text data and the first prediction result to obtain one or more target text units whose corresponding attribution scores in the first text data are in the same direction as the attribution scores corresponding to the first prediction result; The step of performing text unit masking on the first text data according to the minimum masking quantity includes: At least one target text unit having the largest corresponding attribution score in the first text data is masked, wherein the number of the at least one target text unit is the minimum masking number.

[0066] In some embodiments, obtaining the minimum masking quantity corresponding to the first text data includes: The one or more target text units are sorted according to the corresponding attribution scores, and the minimum masking quantity corresponding to the first text data is obtained according to the sorting result.

[0067] In some embodiments, obtaining the minimum masking quantity corresponding to the first text data according to the sorting result includes: Based on the sorting result, the target text unit with the largest attribution score among the one or more target text units is masked to obtain the masked fourth text data corresponding to the first text data, and a third prompt word is constructed according to the fourth text data, the second prediction result and the model identification information of the model to be interpreted, and the third prompt word is input into the trained editing model. If the editing model does not output an output result that can correspond to the second prediction result under the model to be interpreted, the target text unit with the second largest attribution score among the one or more target text units continues to be masked based on the sorting result; otherwise, the current masked number of the fourth text data is used as the minimum masked number corresponding to the first text data, and so on, until the minimum masked number is obtained, or until the current masked number has reached the total number of the one or more target text units.

[0068] In some embodiments, obtaining the minimum masking quantity corresponding to the first text data according to the sorting result includes: Based on the sorting result and the total number of the one or more target text units, a binary search method is used to determine the current target text unit to be masked, the current target text unit to be masked is masked, and the masked fifth text data corresponding to the first text data is obtained. A fourth prompt word is constructed according to the fifth text data, the second prediction result and the model identification information of the model to be interpreted, and the fourth prompt word is input into the trained editing model. According to whether the trained editing model outputs an output result corresponding to the second prediction result under the model to be interpreted, the minimum masking quantity corresponding to the first text data is obtained. Alternatively, a binary search method is used based on the current masking quantity to determine the latest target text unit to be masked, and the latest target text unit to be masked is masked, and so on, until the binary search method ends.

[0069] In some embodiments, the first prompt word includes the counterfactual text generation quantity; The step of inputting the first prompt word into the trained editing model so that the trained editing model completes the second text data to generate third text data includes: The first prompt word is input into a trained editing model, so that the trained editing model completes the second text data to generate a third text data of the same number as the counterfactual text generation quantity.

[0070] In some embodiments, evaluating the third text data to obtain a corresponding evaluation result includes: Evaluate the third text data according to at least one preset evaluation dimension to obtain a corresponding evaluation result; The at least one preset evaluation dimension includes at least one of the following: Whether an output result obtained by inputting the third text data into the model to be explained is flipped relative to the first prediction result; The fluency level corresponding to the third text data; The degree of proximity between the third text data and the first text data.

[0071] In some embodiments, the third text data is multiple, and obtaining the third text data output by the trained editing model further includes: Obtaining counterfactual text identification information corresponding to each third text data; Wherein, determining at least one target third text data from all the third text data output by the trained editing model comprises: Obtaining at least one set of third text data sets from all the third text data output by the trained editing model according to the counterfactual text identification information corresponding to each third text data set, each set of third text data sets including at least one third text data set from all the third text data sets, and each third text data set is located only in one set of third text data sets from the at least one set of third text data sets; For each set of third text data, target third text data is determined in the set of third text data.

[0072] In some embodiments, the latest first prompt word includes a plurality of third text data and counterfactual text identification information corresponding to each third text data.

[0073] In some embodiments, for each set of the third text data sets, determining the target third text data in the set of the third text data sets includes: For each group of third text data sets, the third text data with the latest generation time in the group of third text data sets is determined as the target third text data.

[0074] In some embodiments, for each set of the third text data sets, determining the target third text data in the set of the third text data sets includes: For each set of third text data sets, target third text data are determined in the set of third text data sets according to the evaluation result corresponding to each third text data in the set of third text data sets.

[0075] The above device embodiments correspond to the method embodiments. For specific descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For specific descriptions, please refer to the corresponding method embodiments.

[0076] The embodiment of the present specification also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded by a processor to execute the method of the embodiment of the present specification.

[0077] The embodiments of the present specification also provide a computer program product, which stores at least one instruction, and the at least one instruction is loaded by the processor to execute the method of the embodiments of the present specification.

[0078] The embodiments of this specification also provide Figure 5 The structural diagram of the electronic device shown in FIG. Figure 5At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above-mentioned voice activity detection method.

[0079] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the executor of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0080] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with hardware entity modules. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0081] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.

[0082] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0083] For the convenience of description, the above device is described by dividing it into various units according to its functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0084] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0085] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0086] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0087] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0088] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0089] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0090] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0091] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0092] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0093] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0094] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0095] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.

Claims

1. A method for explaining a model, comprising: Obtaining a minimum masking quantity corresponding to first text data, masking the first text data according to the minimum masking quantity, obtaining masked second text data corresponding to the first text data, and constructing a first prompt word according to the second text data, a second prediction result, and model identification information of the model to be explained, wherein the second prediction result is different from a first prediction result obtained by inputting the first text data into the model to be explained; Input the first prompt word into the trained editing model, so that the trained editing model completes the second text data to generate third text data, and makes the third text data correspond to the second prediction result under the model to be interpreted, obtain the third text data output by the trained editing model, evaluate the third text data to obtain a corresponding evaluation result, generate the latest first prompt word based on the first prompt word, according to the third text data and the evaluation result, input the latest first prompt word into the trained editing model, obtain the latest third text data output by the trained editing model, and so on, until a preset end iteration condition is met; At least one target third text data is determined from all the third text data output by the trained editing model, and explanation information corresponding to the model to be explained is obtained by comparing the at least one target third text data with the first text data.

2. The method according to claim 1, further comprising: Constructing a second prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be interpreted; Constructing first label information according to the second prompt word and the first prediction result; The editing model is trained according to the first prompt word and the first label information to obtain a trained editing model.

3. The method according to claim 2, wherein the second prompt word comprises a placeholder corresponding to an output result obtained by inputting the first text data into the model to be explained; in, The constructing the first label information according to the second prompt word and the first prediction result includes: The placeholder in the second prompt word is completed into the first prediction result, and the completed second prompt word is used as the first label information.

4. The method according to claim 1, further comprising: Attributing the first text data and the first prediction result to obtain one or more target text units whose corresponding attribution scores in the first text data are in the same direction as the attribution scores corresponding to the first prediction result; The step of performing text unit masking on the first text data according to the minimum masking quantity includes: At least one target text unit having the largest corresponding attribution score in the first text data is masked, wherein the number of the at least one target text unit is the minimum masking number.

5. The method according to claim 4, wherein obtaining the minimum masking quantity corresponding to the first text data comprises: The one or more target text units are sorted according to the corresponding attribution scores, and the minimum masking quantity corresponding to the first text data is obtained according to the sorting result.

6. The method according to claim 5, wherein obtaining the minimum masking quantity corresponding to the first text data according to the sorting result comprises: Based on the sorting result, the target text unit with the largest attribution score among the one or more target text units is masked to obtain the masked fourth text data corresponding to the first text data, and a third prompt word is constructed according to the fourth text data, the second prediction result and the model identification information of the model to be interpreted, and the third prompt word is input into the trained editing model. If the editing model does not output an output result that can correspond to the second prediction result under the model to be interpreted, the target text unit with the second largest attribution score among the one or more target text units continues to be masked based on the sorting result; otherwise, the current masked number of the fourth text data is used as the minimum masked number corresponding to the first text data, and so on, until the minimum masked number is obtained, or until the current masked number has reached the total number of the one or more target text units.

7. The method according to claim 5, wherein obtaining the minimum masking quantity corresponding to the first text data according to the sorting result comprises: Based on the sorting result and the total number of the one or more target text units, a binary search method is used to determine the current target text unit to be masked, the current target text unit to be masked is masked, and the masked fifth text data corresponding to the first text data is obtained. A fourth prompt word is constructed according to the fifth text data, the second prediction result and the model identification information of the model to be interpreted, and the fourth prompt word is input into the trained editing model. According to whether the trained editing model outputs an output result corresponding to the second prediction result under the model to be interpreted, the minimum masking quantity corresponding to the first text data is obtained. Alternatively, a binary search method is used based on the current masking quantity to determine the latest target text unit to be masked, and the latest target text unit to be masked is masked, and so on, until the binary search method ends.

8. The method according to claim 1, wherein the first prompt word includes a counterfactual text generation quantity; in, The step of inputting the first prompt word into a trained editing model so that the trained editing model completes the second text data to generate third text data includes: The first prompt word is input into a trained editing model, so that the trained editing model completes the second text data to generate a third text data of the same number as the counterfactual text generation quantity.

9. The method according to claim 1, wherein evaluating the third text data to obtain a corresponding evaluation result comprises: Evaluate the third text data according to at least one preset evaluation dimension to obtain a corresponding evaluation result; The at least one preset evaluation dimension includes at least one of the following: Whether an output result obtained by inputting the third text data into the model to be explained is flipped relative to the first prediction result; The fluency level corresponding to the third text data; The degree of proximity between the third text data and the first text data.

10. The method according to claim 1, wherein the third text data is multiple, and the step of obtaining the third text data output by the trained editing model further comprises: Obtaining counterfactual text identification information corresponding to each third text data; Wherein, determining at least one target third text data from all the third text data output by the trained editing model comprises: Obtaining at least one set of third text data sets from all the third text data output by the trained editing model according to the counterfactual text identification information corresponding to each third text data set, each set of third text data sets including at least one third text data set from all the third text data sets, and each third text data set is located only in one set of third text data sets from the at least one set of third text data sets; For each set of third text data, target third text data is determined in the set of third text data. 11 . The method according to claim 10 , wherein the latest first prompt word comprises a plurality of third text data and counterfactual text identification information corresponding to each third text data.

12. The method according to claim 10, wherein for each set of the third text data sets, determining the target third text data in the set of the third text data sets comprises: For each group of third text data sets, the third text data with the latest generation time in the group of third text data sets is determined as the target third text data.

13. The method according to claim 10, wherein for each set of the third text data sets, determining the target third text data in the set of the third text data sets comprises: For each set of third text data sets, target third text data are determined in the set of third text data sets according to the evaluation result corresponding to each third text data in the set of third text data sets.

14. An apparatus for interpreting a model, comprising: A construction module, used to obtain a minimum masking quantity corresponding to first text data, perform text unit masking on the first text data according to the minimum masking quantity, obtain masked second text data corresponding to the first text data, and construct a first prompt word according to the second text data, a second prediction result and model identification information of a model to be explained, wherein the second prediction result is different from a first prediction result obtained by inputting the first text data into the model to be explained; An editing module, used for inputting the first prompt word into a trained editing model, so that the trained editing model completes the second text data to generate third text data, and makes the third text data correspond to the second prediction result under the model to be interpreted, obtains the third text data output by the trained editing model, evaluates the third text data to obtain a corresponding evaluation result, generates a latest first prompt word based on the first prompt word and the third text data and the evaluation result, inputs the latest first prompt word into the trained editing model, obtains the latest third text data output by the trained editing model, and so on, until a preset end iteration condition is met; An interpretation module is used to determine at least one target third text data from all the third text data output by the trained editing model, and obtain interpretation information corresponding to the model to be interpreted by comparing the at least one target third text data with the first text data.

15. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.

16. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method as claimed in any one of claims 1 to 13.

17. A computer program product having at least one instruction stored thereon, characterized in that: When the at least one instruction is executed by the processor, the steps of the method described in any one of claims 1 to 13 are implemented.

Citation Information

Patent Citations

  • Language model pre-training method, text processing method and related equipment

    CN116304081A

  • Sentiment classification model training method and sentiment classification method and device

    CN117312978A

  • Automatic optimization method and device for cue word, equipment and storage medium

    CN117520507A

  • Attribute prediction with masked language model

    US20240005096A1

  • Attribute prediction with masked language model

    WO2024005912A1