Classification model explanation method, text generation model training method, and related devices
Patent Information
- Application Number
- CN202211444216.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-18
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-11-18
AI Technical Summary
[0009]通过本申请实施例提供的文本生成模型的训练方法,在目标分类模型的训练阶段,基于目标分类模型执行的分类任务中包含的多个子任务,将目标分类模型划分为多个功能模块,每个功能模块对应一个子任务;接着,基于多个子任务之间的执行顺序,依次调用多个功能模块对训练文本在该分类任务下所属的预测类别,并获取当前被调用的功能模块对训练文本执行相应的子任务所得的第二执行结果;进一步,基于第二执行结果、训练文本在当前被调用的功能模块对应的参考执行结果以及训练文本所属的预测类别,对该功能模块进行解析,以解析得到第二执行结果与训练文本在分类任务下所属的预测类别之间的关联关系,并用解释文本来描述这种关联关系,得到该功能模块的样本解释文本;最后,以第二执行结果作为训练样本,以样本解释文本作为训练样本对应的标签,对待训练的文本生成模型进行训练,使得该功能模块的样本解释文本能够为文本生成模型提供监督信号,有利于文本生成模型在目标分类模型的训练过程中从该监督信号中,学习和总结该功能模块执行子任务所得的第二执行结果与训练文本在分类任务下所属的预测类别之间的关联关系,进而使得训练出的文本生成模型具备对这种关联关系进行总结而得到相应的解释文本的能力,由此实现在训练目标分类模型的过程中,同时训练出能够用于总结目标分类模型中各功能模块的表现的文本生成模型,以便用于生成对应的功能模块的解释文本,实现有效地、有针对性地对目标分类模型进行细粒度解释。
Smart Images

Figure CN116127369B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of natural language processing technology, and in particular to a classification model interpretation method, a text generation model training method, and related equipment. Background Technology
[0002] Currently, research and classification models in Natural Language Processing (NLP) focus on deep learning. Compared to dataset acquisition, model structure optimization, and performance improvements (such as model miniaturization), the interpretability of classification models (i.e., the basis for the classification results) is becoming increasingly important. Advances in this area will reduce communication costs between algorithm developers and business stakeholders, and will also help algorithm developers better analyze misclassification cases and optimize classification models more effectively.
[0003] Therefore, there is an urgent need for a solution that can effectively explain classification models, which will facilitate more targeted optimization of classification models. Summary of the Invention
[0004] The purpose of this application is to provide a classification model interpretation method, a text generation model training method, and related equipment for effectively interpreting classification models, thereby facilitating more targeted optimization of classification models.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] In a first aspect, embodiments of this application provide a classification model interpretation method, comprising: dividing the target classification model into multiple functional modules based on multiple sub-tasks included in a classification task executed by a target classification model, each functional module corresponding to a sub-task; sequentially calling the multiple functional modules based on the execution order among the multiple sub-tasks to execute the sub-task corresponding to the called functional module on test texts in a test text set, thereby obtaining the predicted category to which the test text belongs under the classification task; obtaining a first execution result obtained by the target functional module executing the sub-task on the test text, wherein the target functional module is the currently called functional module among the multiple functional modules; and parsing the target functional module through a text generation model corresponding to the target functional module, based on the first execution result and the predicted category to which the test text belongs, to obtain an interpretation text of the target functional module, wherein the interpretation text is used to describe the correlation between the first execution result of the test text and the predicted category to which the test text belongs.
[0007] The classification model interpretation method provided in this application, during the testing phase of the target classification model, divides the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task executed by the target classification model. Each functional module corresponds to a sub-task. Then, based on the execution order of the multiple sub-tasks, the multiple functional modules are sequentially called to predict the category to which the test text belongs under the classification task, and the first execution result obtained by the currently called functional module executing the corresponding sub-task on the test text is obtained. Further, using the text generation model corresponding to the currently called functional module and employing text generation technology, the first execution result and the predicted category of the test text are used to predict the category to which the test text belongs. The predicted category is analyzed for this functional module to obtain the correlation between the first execution result and the predicted category of the test text under the classification task. This correlation is described using explanatory text, which is then used to obtain the explanatory text of this functional module. Thus, by using the explanatory texts of each functional module in the target classification model, we can intuitively and accurately understand the correlation between the execution result of each functional module in the target classification model and the final predicted text category. In other words, we can understand how the performance of each functional module affects the classification result output by the target classification model, thereby achieving effective and targeted fine-grained interpretation of the target classification model.
[0008] Secondly, embodiments of this application provide a method for training a text generation model, comprising: dividing the target classification model into multiple functional modules based on multiple sub-tasks included in a classification task performed by a target classification model, each functional module corresponding to a sub-task; sequentially calling the multiple functional modules based on the execution order among the multiple sub-tasks to execute the sub-task corresponding to the called functional module on training text in a training text set, thereby obtaining the predicted category to which the training text belongs under the classification task; obtaining a second execution result obtained by the target functional module executing the corresponding sub-task on the training text, wherein the target functional module is the currently called functional module among the multiple functional modules; parsing the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category to which the training text belongs, thereby obtaining sample explanation text corresponding to the target functional module, wherein the sample explanation text is used to describe the correlation between the second execution result and the predicted category to which the training text belongs under the classification task; and training the text generation model to be trained using the second execution result as a training sample and the sample explanation text as the label corresponding to the training sample, thereby obtaining the text generation model corresponding to the target functional module.
[0009] The text generation model training method provided in this application, during the training phase of the target classification model, divides the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task performed by the target classification model. Each functional module corresponds to a sub-task. Then, based on the execution order of the multiple sub-tasks, the multiple functional modules are sequentially called to predict the category to which the training text belongs under the classification task, and the second execution result obtained by the currently called functional module performing the corresponding sub-task on the training text is obtained. Further, based on the second execution result, the reference execution result corresponding to the training text in the currently called functional module, and the predicted category to which the training text belongs, the functional module is parsed to obtain the correlation between the second execution result and the predicted category to which the training text belongs under the classification task. This correlation is described using explanatory text to obtain the sample explanation for the functional module. Finally, using the second execution result as a training sample and the sample explanation text as the label corresponding to the training sample, the text generation model to be trained is trained. This allows the sample explanation text of this functional module to provide a supervision signal for the text generation model. This is beneficial for the text generation model to learn and summarize the correlation between the second execution result obtained by the functional module in performing the sub-task and the predicted category of the training text in the classification task from this supervision signal during the training of the target classification model. In this way, the trained text generation model has the ability to summarize this correlation and obtain the corresponding explanation text. Thus, during the training of the target classification model, a text generation model that can be used to summarize the performance of each functional module in the target classification model is trained at the same time, so as to generate the explanation text of the corresponding functional module and achieve effective and targeted fine-grained explanation of the target classification model.
[0010] Thirdly, embodiments of this application provide a classification model interpretation device, comprising: a first partitioning unit, configured to partition the target classification model into multiple functional modules based on multiple sub-tasks included in a classification task executed by the target classification model, each functional module corresponding to a sub-task; a first invocation unit, configured to sequentially invoke the multiple functional modules based on the execution order among the multiple sub-tasks, to execute the sub-task corresponding to the invoked functional module on test texts in a test text set, thereby obtaining the predicted category to which the test texts in the test text set belong under the classification task; a first acquisition unit, configured to acquire a first execution result obtained by the target functional module executing the sub-task on the test texts in the test text set, wherein the target functional module is the currently invoked functional module among the multiple functional modules; and a first parsing unit, configured to parse the target functional module based on the first execution result and the predicted category to which the test text belongs, using a text generation model corresponding to the target functional module, to obtain an interpretation text of the target functional module, wherein the interpretation text is used to describe the correlation between the first execution result of the test text and the predicted category to which the test text belongs.
[0011] Fourthly, embodiments of this application provide a training apparatus for a text generation model, comprising: a second partitioning unit, configured to partition the target classification model into multiple functional modules based on multiple sub-tasks included in a classification task performed by the target classification model, each functional module corresponding to a sub-task; a second invocation unit, configured to sequentially invoke the multiple functional modules based on the execution order among the multiple sub-tasks, to execute the sub-task corresponding to the invoked functional module on training texts in a training text set, thereby obtaining the predicted category to which the training texts belong under the classification task; and a second acquisition unit, configured to acquire a second execution result obtained by a target functional module executing the corresponding sub-task on the training text, wherein the target functional module is the... The currently invoked functional module among multiple functional modules; a second parsing unit, used to parse the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category to which the training text belongs, to obtain sample explanation text corresponding to the target functional module, the sample explanation text being used to describe the correlation between the second execution result and the predicted category to which the training text belongs under the classification task; a training unit, used to train the text generation model to be trained using the second execution result as a training sample and the sample explanation text as the label corresponding to the training sample, to obtain the text generation model corresponding to the target functional module.
[0012] Fifthly, embodiments of this application provide an electronic device, including: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method as described in the first aspect; or, the processor is configured to execute the instructions to implement the method as described in the second aspect.
[0013] In a sixth aspect, embodiments of this application provide a computer-readable storage medium that, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method described in the first aspect; or, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the method described in the second aspect. Attached Figure Description
[0014] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0015] Figure 1 A flowchart illustrating a classification model interpretation method provided in one embodiment of this application;
[0016] Figure 2 A schematic diagram of the structure of a classification model provided in one embodiment of this application;
[0017] Figure 3 A flowchart illustrating a classification model interpretation method provided for another embodiment of this application;
[0018] Figure 4 A flowchart illustrating a training method for a text generation model provided in one embodiment of this application;
[0019] Figure 5 A flowchart illustrating a training method for a text generation model, provided for another embodiment of this application;
[0020] Figure 6 A schematic diagram of a classification model interpretation device provided in one embodiment of this application;
[0021] Figure 7 A schematic flowchart of a training apparatus for a text generation model provided in one embodiment of this application;
[0022] Figure 8 This is a schematic diagram of the structure of an electronic device provided in one embodiment of this application. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] The terms "first," "second," etc., used in this specification and claims are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, in this specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0025] Explanation of some concepts:
[0026] Natural Language Processing (NLP) is an important field in computer science and artificial intelligence. It studies various theories and methods that enable effective communication between humans and computers using natural language.
[0027] BERT, short for Bidirectional Encoder Representation from Transformers, is a pre-trained language model. It emphasizes a departure from traditional unidirectional language models or shallow concatenation of two unidirectional language models for pre-training. Instead, it employs a novel Masked Language Model (MLM) to generate deep, bidirectional language representations.
[0028] To effectively interpret classification models and thus facilitate more targeted optimization, this application proposes a classification model interpretation method. During the testing phase of the target classification model, based on the multiple sub-tasks included in the classification task performed by the target classification model, the model is divided into multiple functional modules, each corresponding to a sub-task. Then, based on the execution order of the sub-tasks, the functional modules are sequentially called to predict the category of the test text under the classification task, and the first execution result obtained by the currently called functional module in performing the corresponding sub-task on the test text is obtained. Further, the text generation model corresponding to the currently called functional module is used to generate... The technology, based on the first execution result and the predicted category of the test text, parses the functional module to obtain the correlation between the first execution result and the predicted category of the test text under the classification task. It then uses explanatory text to describe this correlation, thus obtaining the explanatory text of the functional module. By using the explanatory texts of each functional module in the target classification model, we can intuitively and accurately understand the correlation between the execution result of each functional module in the target classification model and the final predicted text category. In other words, we can understand how the performance of each functional module affects the classification result output by the target classification model, thereby achieving effective and targeted fine-grained interpretation of the target classification model.
[0029] This application also proposes a training method for a text generation model. During the training phase of a target classification model, based on the multiple sub-tasks included in the classification task performed by the target classification model, the target classification model is divided into multiple functional modules, each corresponding to a sub-task. Then, based on the execution order of the multiple sub-tasks, multiple functional modules are sequentially called to predict the category of the training text under the classification task, and the second execution result obtained by the currently called functional module performing the corresponding sub-task on the training text is obtained. Further, based on the second execution result, the reference execution result corresponding to the training text in the currently called functional module, and the predicted category of the training text, the functional module is parsed to obtain the correlation between the second execution result and the predicted category of the training text under the classification task. This correlation is described using explanatory text to obtain the sample explanation for the functional module. Finally, using the second execution result as a training sample and the sample explanation text as the label corresponding to the training sample, the text generation model to be trained is trained. This allows the sample explanation text of this functional module to provide a supervision signal for the text generation model. This is beneficial for the text generation model to learn and summarize the correlation between the second execution result obtained by the functional module in performing the sub-task and the predicted category of the training text in the classification task from this supervision signal during the training of the target classification model. In this way, the trained text generation model has the ability to summarize this correlation and obtain the corresponding explanation text. Thus, during the training of the target classification model, a text generation model that can be used to summarize the performance of each functional module in the target classification model is trained at the same time, so as to generate the explanation text of the corresponding functional module and achieve effective and targeted fine-grained explanation of the target classification model.
[0030] It should be understood that the classification model interpretation method and the text generation model training method provided in the embodiments of this application can both be executed by electronic devices or software installed in electronic devices. The term "electronic device" here may include terminal devices, such as smartphones, tablets, laptops, desktop computers, smart voice interaction devices, smart home appliances, smartwatches, vehicle terminals, aircraft, etc.; or, the electronic device may also include a server, such as a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0031] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0032] Please refer to Figure 1 The following is a flowchart illustrating a classification model interpretation method according to an embodiment of this application. The method may include the following steps:
[0033] S102, based on the multiple sub-tasks contained in the classification task performed by the target classification model, divides the target classification model into multiple functional modules.
[0034] Here, the target classification model refers to the classification model to be interpreted. The classification task performed by the target classification model can also be a sub-category classification task under the text classification task, such as intent recognition task, sentiment classification task, spam detection task, etc.
[0035] Different classification tasks can contain different subtasks. For example, such as... Figure 2 As shown, a text classification task may include multiple subtasks such as preprocessing the text (e.g., text segmentation, stop word removal), word segmentation, encoding words in the text into word vectors, fusing word vectors into semantic representation vectors based on an attention mechanism, calculating the classification loss of the target classification model, and classifying the text based on the semantic representation vectors of words in the text. Similarly, an image classification task may include multiple subtasks such as preprocessing the image (e.g., balancing, filtering, determining regions of interest), extracting image features, encoding image features into corresponding feature vectors, calculating the classification loss of the target classification model, and classifying the image based on the image feature vectors, and so on.
[0036] After identifying the multiple subtasks included in the classification task performed by the target classification model, the code of the target classification model can be parsed and divided into multiple parts based on these subtasks. Each part is a functional module, and each functional module corresponds to a subtask. In other words, each functional module is used to execute its corresponding subtask.
[0037] For example, with Figure 2 Taking the target classification model shown as an example for performing text classification tasks, the text classification task performed based on this target classification model includes multiple sub-tasks. The target classification model can be divided into multiple functional modules such as a preprocessing module, a word segmentation module, an encoding module, an attention module, a loss determination module, and a classification module. Among them, the preprocessing module is used to preprocess the text, the word segmentation module is used to segment the text into words, the encoding module is used to encode the words in the text into word vectors, the attention module is used to fuse the word vectors into semantic representation vectors based on the attention mechanism, the loss determination module is used to calculate the classification loss of the target classification model during the training process, and the classification module is used to classify the text based on the semantic representation vectors of the words in the text, and so on.
[0038] S104. Based on the execution order of multiple subtasks, multiple functional modules are called sequentially to execute the subtasks corresponding to the called functional modules on the test texts in the test text set, so as to obtain the predicted category of the test texts in the test text set under the classification task.
[0039] The test text set contains multiple test texts, which are used to test the target classification model.
[0040] Specifically, during the testing of the target classification model, the functional modules corresponding to each subtask can be called sequentially according to the execution order of multiple subtasks to execute the subtask for each test text in the test text set, and finally the predicted category of each test text under the classification task can be obtained.
[0041] For example, let's continue using the above. Figure 2 The target classification model and the text classification task it performs can be executed in the following order: preprocessing -> word segmentation -> encoding -> attention mechanism -> classification. The preprocessing module, word segmentation module, encoding module, attention module, and classification module are called sequentially to perform corresponding sub-tasks on each test text, ultimately obtaining the predicted category of each test text under that text classification task. For example, if the text classification task is intent recognition, then the predicted intent of each test text can be obtained after all functional modules have been called; similarly, if the text classification task is sentiment recognition, then the predicted sentiment of each test text can be obtained after all functional modules have been called, and so on.
[0042] S106, Obtain the first execution result obtained by the target functional module from performing subtasks on the test texts in the test text set.
[0043] The target functional module is the currently invoked functional module among multiple functional modules. In other words, when each functional module is invoked, the first execution result obtained by that functional module in performing the subtask on the test text will be obtained.
[0044] For example, let's continue using the above. Figure 2The target classification model and its multiple functional modules, as shown, perform the following operations: When the preprocessing module is called, it preprocesses the test text, and the first execution result is the preprocessed text corresponding to the test text; when the word segmentation module is called, it segments the test text, and the first execution result is the set of words contained in the test text; when the encoding module is called, it encodes each word in the set of words contained in the test text, and the first execution result is the word vector of each word in the set of words contained in the test text; when the attention module is called, it aggregates the word vectors of the first word and the word vectors of the second word based on the attention mechanism, and the first execution result is the semantic representation vector of the first word, where the semantic representation vector of the first word is used to represent the semantics of the first word, the first word is any word in the set of words contained in the test sample, and the second word is any word in the set other than the first word; when the classification module is called, it classifies the test text based on the semantic representation vector of each word in the test text, and obtains the predicted category to which the test text belongs in this text classification task.
[0045] S108, using the text generation model corresponding to the target functional module, based on the first execution result and the prediction category to which the test text belongs, the target functional module is parsed to obtain the explanatory text of the target functional module.
[0046] The explanatory text describes the relationship between the first execution result of the test text and the predicted category to which the test text belongs in the classification task.
[0047] In this embodiment, each functional module has a corresponding text generation model. For each functional module, the text generation model is trained during the training process of the target classification model, based on the second execution result obtained by performing corresponding sub-tasks on the training texts in the training text set by that functional module, and the sample explanation text corresponding to that functional module. The sample explanation text corresponding to each functional module describes the correlation between the second execution result obtained by performing corresponding sub-tasks on the training texts by that functional module and the predicted category to which the training text belongs in the classification task.
[0048] It is worth noting that the training of the text generation model corresponding to each functional module can be pre-trained. During subsequent testing of the target classification model, it is not necessary to train the text generation model for each functional module every time. Alternatively, for each functional module, the text generation model can be updated periodically based on the first execution result obtained from performing the corresponding sub-task on the test texts in the test text set for that functional module. The training method for the text generation model corresponding to each functional module will be explained in detail later and will not be elaborated upon here.
[0049] In S108 above, after obtaining the first execution result of the target functional module performing the sub-task on the test text, the first execution result of the test text can be input into the text generation model corresponding to the target functional module. The target functional module uses the summarizing and interpreting capabilities learned during training to summarize the relationship between the first execution result of the test text and the predicted category to which the test text belongs under the above classification task, and describes this relationship in text form to obtain the explanatory text of the target functional module. Thus, through the explanatory texts of each functional module in the target classification model, the relationship between the execution result of each functional module performing the sub-task and the final predicted text category can be intuitively and accurately obtained. That is, how the performance of each functional module affects the classification result output by the target classification model, thereby achieving effective fine-grained interpretation of the target classification model.
[0050] Specifically, in one optional implementation, S108 can be implemented as follows: using the text generation model corresponding to the target functional module, based on the first execution result of the test text and the reference execution result of the test text in the target functional module, the target functional module is parsed to obtain the influence information of the first execution result of the test text on the prediction category to which the test text belongs, and using the text generation model corresponding to the target functional module, a correspondence between the influence information and the prediction category to which the test text belongs is constructed, and text describing the correspondence is generated as the explanatory text for the target functional module.
[0051] In other words, in S108 above, the first execution result of the test text and the reference execution result of the test text in the target functional module are input into the pre-trained text generation model. The text generation model can first analyze the target functional module based on the first execution result of the test text and the reference execution result of the test text in the target functional module to obtain the influence information of the first execution result of the test text on the prediction category to which the test text belongs. Then, through the text generation model corresponding to the target functional module, the model constructs the correspondence between the influence information and the prediction category to which the test text belongs, and generates text to describe the correspondence as the explanatory text for the target functional module.
[0052] The reference execution result refers to the expected execution result obtained by performing the sub-task corresponding to the target functional module on the test text. Specifically, it can be the execution result that should be obtained theoretically after performing the sub-task corresponding to the target functional module on the test text. For example, the reference execution result corresponding to the preprocessing module is the reference segmented text that should be obtained theoretically after performing word segmentation on the test text. Alternatively, it can be determined based on the first execution result of other test texts in the test text set, such as the first execution result of other texts selected from the test text set that have high similarity to the test text but different prediction categories.
[0053] For each test text, the impact information of the first execution result of the test text on the prediction category to which the test text belongs refers to the information used to represent the impact of the first execution result on the prediction category to which the test text belongs. Specifically, it can be a certain data in the first execution result, or it can be an intermediate result related to the first execution result generated during the execution of sub-tasks by the target functional module on the test text, and so on.
[0054] In this embodiment, the first execution results obtained by different functional modules from performing subtasks on the same test text have different impact information on the prediction category to which the test text belongs. The correlation described by the explanatory texts of different functional modules can be described in different ways, and can be set according to actual needs. This embodiment does not limit this.
[0055] For example, let's continue using the above. Figure 2The target classification model shown includes several functional modules. For the preprocessing module, considering that the quality of the preprocessing method directly impacts the quality of the resulting preprocessed text (e.g., improper text segmentation directly affects the quality of the resulting sub-texts, leading to inaccurate predicted categories), the text generation model corresponding to the preprocessing module summarizes the preprocessing methods used and the resulting preprocessed texts. This includes the impact of the first execution result of the preprocessing module's sub-tasks on the predicted categories of the test texts, as well as the preprocessed texts. Furthermore, it constructs the correspondence between the preprocessing methods, the resulting preprocessed texts, and the predicted categories of the test texts, and describes this correspondence in text form, obtaining the explanatory text for the preprocessing module. Therefore, by examining the explanatory text corresponding to the preprocessing module, one can intuitively and accurately determine the quality of the preprocessing of the test text by the preprocessing module, and thus understand the impact of the preprocessing module on the classification results of the test text.
[0056] For the word segmentation module, considering that the semantics of text are expressed through its words, the quality of the word segmentation results directly affects the semantic accuracy of the text, leading to inaccurate predicted categories. Therefore, the text generation model corresponding to the word segmentation module analyzes the word set contained in the segmented test text, summarizing words that are difficult for the segmentation module to distinguish, words that are missegmented, and other words that affect the accuracy of the predicted categories. This information serves as the first execution result of the segmentation module's subtask on the test text, influencing the predicted category of the test text. Furthermore, a correspondence is constructed between this influence information and the predicted category of the test text in the classification task, and this correspondence is described in text form, resulting in the explanatory text for the word segmentation module. Thus, through the explanatory text, one can intuitively and accurately understand the quality of word segmentation in the test text, thereby understanding the impact of the word segmentation module on the classification results of the test text.
[0057] For the encoding module, considering that the meaning of words is represented in vector form, the quality of the word vectors encoded by the encoding module directly affects the semantic accuracy of the text, leading to inaccurate predictions of the final text's category. Therefore, the text generation model corresponding to the encoding module analyzes the word vectors of each word in the word set contained in the test text, summarizing which word vectors in the word set might affect the accuracy of the test text's classification results. These word vectors are then used as the impact information of the first execution result obtained by the encoding module in performing subtasks on the test text on the predicted category of the test text. Furthermore, a correspondence between this impact information and the predicted category of the test text is constructed, and this correspondence is described in text form, resulting in the explanatory text corresponding to the encoding module. Thus, through the explanatory text corresponding to the encoding module, the quality of the encoding module's word encoding in the test text can be intuitively and accurately determined, thereby revealing the impact of the encoding module on the classification results of the test text.
[0058] For the attention module, considering that in the processing of the attention module, the semantic representation vector of each word is obtained by fusing the word vector of the word with the word vectors of other words based on the importance of the word to the word (i.e., the context information of the word), the quality of the semantic representation vector obtained by the attention module in fusing the word vectors of words in the word set directly affects the semantic accuracy of the text, thus leading to inaccurate prediction of the final text category. Based on this, the text generation model corresponding to the attention module can analyze the semantic representation vector of each word in the word set contained in the test text, summarize the semantic contribution of the words in the test text set to the test text, and use the semantic contribution of these words to the test text as the influence information of the first execution result obtained by the attention module in performing the sub-task on the test text on the prediction category of the test text. Further, the correspondence between this influence information and the prediction category of the test text is constructed, and this correspondence is described in the form of text to obtain the text used to describe the correspondence, which serves as the explanatory text corresponding to the attention module. Therefore, by examining the explanatory text corresponding to the attention module, we can intuitively and accurately determine the quality of the attention module's semantic representation of words in the test text, and thus understand the impact of the attention module on the classification results of the test text.
[0059] For the classification module, considering that the input text is the raw data used to judge the performance of the target classification model (e.g., text that should be classified as category A is not classified as category A, and text that should not be classified as category A is classified as category A), these texts can explain the performance of the target classification model. Based on this, the text generation model corresponding to the classification module can analyze the semantic representation vectors of words in the test text and their predicted categories under the classification task, summarizing the semantic representation vectors of words in the test text. This serves as the impact information of the first execution result obtained by the classification module in performing the sub-task on the test text on the predicted category of the test text. Furthermore, it constructs the correspondence between this impact information and the predicted category of the test text, and describes this correspondence in text form, obtaining the explanatory text for the classification module. Thus, through the explanatory text corresponding to the classification module, one can intuitively and accurately know whether the classification module correctly classified the test text, thereby understanding the impact of the classification module on the classification result of the test text.
[0060] Optionally, since the input test text is the raw data used to judge the performance of the target classification model, in order to more intuitively and accurately reflect the impact of each functional module on the classification results of the test text, such as... Figure 3 As shown, after S108 above, the classification model interpretation method provided in one or more of the above embodiments may further include:
[0061] S110, compare the first execution result of the test text with the reference execution result of the test text under the target functional module to obtain the comparison result.
[0062] The reference execution result of the test text under the target functional module refers to the expected execution result obtained by performing the sub-tasks corresponding to the target functional module on the test text.
[0063] S112, Select at least one test text from the test text set whose comparison result satisfies the first preset abnormal condition as the target text corresponding to the target functional module.
[0064] The first preset abnormal conditions corresponding to different functional modules may be the same or different. The specific settings can be made according to actual needs, and this application embodiment does not limit this.
[0065] S114, construct the correspondence between the target text and the explanatory text of the target functional module, and generate the associated text to describe the correspondence.
[0066] For example, if the target functional module is a preprocessing module, the first execution result of the test text includes the preprocessed text corresponding to the test text, and the reference execution result of the test text under the target functional module includes the reference preprocessed text corresponding to the test text. The first preset anomaly condition may include the similarity between the preprocessed text corresponding to the test text and the reference preprocessed text being less than or equal to a preset similarity threshold. Accordingly, the preprocessed text corresponding to the test text can be compared with the reference preprocessed text to obtain a comparison result indicating the similarity between the two. If the comparison result indicates that the similarity between the two is less than or equal to the preset similarity threshold, it is determined that the test text does not meet the first preset anomaly condition. Further, the N test texts with the lowest similarity can be selected from the test text set as the target text corresponding to the preprocessing module, and a correspondence between the target text and the explanatory text of the preprocessing module can be constructed, as well as an associated text used to describe the correspondence. Thus, through the associated text, the impact of the preprocessing module on the classification result of the test text can be intuitively and accurately understood.
[0067] If the target functional module is a word segmentation module, the first execution result of the test text includes the set of words contained in the test text, and the reference execution result corresponding to the test text under the target functional module includes the set of reference words contained in the test text. The first preset anomaly condition may include that the similarity between the set of words contained in the test text and the set of reference words is less than or equal to a preset similarity threshold. Accordingly, the set of words contained in the test text can be compared with the set of reference words contained in the test text to obtain a comparison result indicating the similarity between the two. If the comparison result indicates that the similarity between the two is less than or equal to the preset threshold, it is determined that the test text does not meet the first preset anomaly condition. Further, the N test texts with the lowest similarity can be selected from the test text set as the target text corresponding to the word segmentation module, and a correspondence between the target text and the explanatory text of the word segmentation module can be constructed, as well as an associated text used to describe the correspondence. Thus, through the associated text corresponding to the word segmentation module, the impact of the word segmentation module on the classification result of the test text can be intuitively and accurately understood.
[0068] If the target functional module is an encoding module, the first execution result of the test text includes the word vector of each word in the word set contained in the test text. The reference execution result of the test text under the target functional module includes the word vector of each word in the reference word set contained in the test text. The first preset anomaly condition may include the similarity between the word vectors of the words in the word set contained in the test text and the word vectors of the words in the reference word set being less than or equal to a preset similarity threshold. Accordingly, the word vectors of the words in the word set contained in the test text can be compared with the word vectors of the words in the reference word set contained in the test text to obtain a comparison result indicating the similarity between the two. If the comparison result indicates that the similarity between the two is less than or equal to the preset threshold, it is determined that the test text does not meet the first preset anomaly condition. Further, the N test texts with the lowest similarity can be selected from the test text set as the target texts corresponding to the encoding module, and a correspondence between the target texts and the explanatory texts of the encoding module can be constructed, as well as an associated text used to describe the correspondence. Thus, through the associated texts corresponding to the encoding module, the impact of the encoding module on the classification result of the test text can be intuitively and accurately understood.
[0069] If the target functional module is an attention module, the first execution result of the test text includes the semantic representation vector of each word in the word set contained in the test text. The reference execution result of the test text under the target functional module includes the semantic representation vector of each word in the reference word set contained in the test text. The first preset anomaly condition may include the similarity between the semantic representation vectors of the words in the word set contained in the test text and the semantic representation vectors of the words in the reference word set being less than or equal to a preset similarity threshold. Accordingly, the semantic representation vectors of the words in the word set contained in the test text can be compared with the semantic representation vectors of the words in the reference word set contained in the test text to obtain a comparison result indicating the similarity between the two. If the comparison result indicates that the similarity between the two is less than or equal to the preset threshold, it is determined that the test text does not meet the first preset anomaly condition. Further, the N test texts with the lowest similarity can be selected from the test text set as the target texts corresponding to the attention module, and a correspondence between the target texts and the explanatory texts of the attention module can be constructed, as well as associated texts used to describe the correspondence. Thus, through the associated texts corresponding to the attention module, the impact of the attention module on the classification results of the test text can be intuitively and accurately understood.
[0070] If the target functional module is a classification module, the first execution result of the test text includes the predicted category to which the test text belongs under the classification task. In this case, test texts with a similarity exceeding a preset similarity threshold to the first test text can be selected from the test text set as reference test texts, and the predicted category to which the reference test text belongs under the classification task is determined as the reference execution result corresponding to the first test text under the classification module, wherein the first test text is any test text in the test text set; furthermore, if the predicted category to which the first test text belongs under the classification task is different from the reference execution result, the first test text and its reference test text are used as target texts, and a correspondence between the target text and the explanatory text of the classification module is constructed, and an associated text describing the correspondence is generated.
[0071] For example, for test text 1 in the test text set, if the output of the classification module indicates that test text 1 belongs to category A, and test text 2 in the test text set has a similarity to test text 1 that exceeds a preset similarity threshold, then the predicted category output by the classification module for test text 2 is used as the reference execution result for test text 1; if test text 2 belongs to category B, then both test text 1 and test text 2 are used as target texts, and a correspondence between these target texts and the explanation text of the classification module is constructed, as well as an associated text used to describe the correspondence is generated.
[0072] Understandably, texts with similar features but actually classified into different categories are often the prediction challenge for classification models and are also prone to prediction errors. By using similar test texts in the test text set that are classified into different categories by the classification module as the target texts for the classification module, relevant personnel can understand the misclassified test texts in the test text set in a timely and intuitive way, so as to conduct error analysis and optimize the design of the solution in advance. On this basis, by associating the explanatory text and target texts corresponding to the classification module, relevant personnel can intuitively and accurately understand the impact of the classification module on the classification results of the test texts.
[0073] Optionally, such as Figure 3 As shown, after S108 above, the classification model interpretation method provided in one or more of the above embodiments may further include:
[0074] S116, based on text-to-speech technology, converts the parsed text of the target functional module into speech data.
[0075] It is worth noting that the text-to-speech (TTS) technology used in S116 above can employ various speech recognition technologies commonly used in this field.
[0076] Understandably, converting the parsed text of each functional module into speech data makes it easier for relevant personnel to understand the impact of the attention module on the classification results of the test text, thereby improving the user experience.
[0077] The classification model interpretation method provided by one or more embodiments of this application, in the testing phase of the target classification model, divides the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task executed by the target classification model, with each functional module corresponding to a sub-task; then, based on the execution order among the multiple sub-tasks, the multiple functional modules are sequentially called to predict the category to which the test text belongs under the classification task, and the first execution result obtained by the currently called functional module in executing the corresponding sub-task on the test text is obtained; further, through the text generation model corresponding to the currently called functional module, using text generation technology, based on the first execution result and the test text... The prediction category to which this function module belongs is analyzed to obtain the correlation between the first execution result and the predicted category of the test text under the classification task. This correlation is described using explanatory text, resulting in the explanatory text of this function module. Thus, by using the explanatory texts of each function module in the target classification model, we can intuitively and accurately understand the correlation between the execution result of each function module in the target classification model and the final predicted text category. In other words, we can understand how the performance of each function module affects the classification result output by the target classification model, thereby achieving effective and targeted fine-grained interpretation of the target classification model.
[0078] This application also provides a method for training a text generation model, which is used to simultaneously train the text generation model corresponding to each functional module in the target classification model during the training process of the target classification model. The trained text classification model can be used to explain the relationship between the execution result of the corresponding functional module performing the corresponding sub-task on the input text and the predicted category to which the text belongs.
[0079] Please refer to Figure 4 The following is a flowchart illustrating a training method for a text generation model, provided as an embodiment of this application. The method may include the following steps:
[0080] S402, based on the classification task performed by the target classification model, includes multiple sub-tasks, dividing the target classification model into multiple functional modules.
[0081] Each functional module corresponds to a subtask.
[0082] The specific implementation of S402 is the same as described above. Figures 1 to 3The specific implementation of step S102 in the classification model parsing method shown is similar. For details, please refer to the detailed explanation of step S102 above, which will not be repeated here.
[0083] S404, based on the execution order among multiple subtasks, multiple functional modules are called sequentially to execute the subtasks corresponding to the called functional modules on the training texts in the training text set, so as to obtain the predicted category to which the training texts belong under the classification task.
[0084] The training text set includes multiple training texts. This training text set is used to train the target classification model.
[0085] The specific implementation of S404 mentioned above is the same as described above. Figures 1 to 3 The specific implementation of step S104 in the classification model parsing method shown is similar. For details, please refer to the detailed explanation of step S104 above, which will not be repeated here.
[0086] S406, Obtain the second execution result obtained by the target function module performing the corresponding sub-task on the training text.
[0087] The target functional module is the currently invoked functional module among multiple functional modules.
[0088] The specific implementation of S406 mentioned above is the same as described above. Figures 1 to 3 The specific implementation of step S106 in the classification model parsing method shown is similar. For details, please refer to the detailed explanation of step S106 above, which will not be repeated here.
[0089] S408. Based on the second execution result, the reference execution result of the training text in the target functional module, and the prediction category to which the training text belongs, the target functional module is parsed to obtain the sample explanation text corresponding to the target functional module.
[0090] The sample explanation text is used to describe the relationship between the second execution result and the predicted category to which the training text belongs under the classification task.
[0091] More specifically, S408 can be implemented as follows: based on the second execution result of the training text and the reference execution result of the training text in the target functional module, the target functional module is parsed to obtain the influence information of the second execution result of the training text on the prediction category to which the training text belongs, and the correspondence between the influence information and the prediction category to which the training text belongs is constructed, and text describing the correspondence is generated as the sample explanation text for testing the target functional module.
[0092] For each training text, the impact information of the second execution result of the training text on the prediction category to which the training text belongs refers to the information used to represent the impact of the second execution result on the prediction category to which the training text belongs. Specifically, it can be a certain data in the second execution result, or it can be an intermediate result related to the second execution result generated during the process of the target functional module performing a sub-task on the training text, and so on.
[0093] For example, with Figure 5 Taking the target classification model shown as an example, the target classification model may include a preprocessing module, a word segmentation module, an encoding module, an attention module, a loss determination module, and a classification module.
[0094] For the preprocessing module, considering that the quality of the preprocessing method used by the preprocessing module to preprocess the text directly affects the quality of the preprocessed text, such as unreasonable text segmentation, which will directly affect the quality of the segmented subtexts and thus lead to inaccurate prediction of the final text category, if the target functional module is the preprocessing module, then the subtask performed by the target functional module on the training text is to preprocess the training text, and the second execution result includes the preprocessed text corresponding to the training text.
[0095] In this case, S408 can be specifically implemented as follows: compare the training text with its corresponding preprocessed text to obtain the comparison result; analyze the comparison result to obtain the preprocessing method performed by the preprocessing module on the training text; further, the preprocessing method performed by the preprocessing module on the training text and the obtained preprocessed text can be used as the influence information of the second execution result obtained by the preprocessing module in performing the sub-task on the training text on the prediction category to which the training text belongs; then, construct the correspondence between this influence information and the prediction category to which the training text belongs, that is, construct the correspondence between the preprocessing method, the preprocessed text and the prediction category to which the training text belongs, and generate text to describe the correspondence as the sample explanation text corresponding to the preprocessing module.
[0096] Specifically, by comparing the training text with its corresponding preprocessed text, the differences between them can be obtained. Analyzing these differences reveals the preprocessing methods used by the preprocessing module to preprocess the training text. For example, comparing the training text with the segmented subtext and analyzing the comparison results can determine whether the preprocessing module performed segmentation processing on the training text and the specific segmentation method. Similarly, comparing the training text with the stop-word-removed subtext and analyzing the comparison results can determine whether the preprocessing module performed stop-word removal processing on the training text and the stop words removed from the training text, and so on.
[0097] Since the training text set contains multiple training texts, by performing correlation analysis on the preprocessing method used by the preprocessing module for each training text and the corresponding preprocessed text, the mapping relationship between the preprocessing method used by the preprocessing module and the obtained preprocessed text can be determined. Furthermore, by constructing the correspondence between the preprocessing method used by the preprocessing module, the obtained preprocessed text, and the prediction category to which the training text belongs, and by using text to describe this correspondence, the sample explanation text corresponding to the preprocessing module can be obtained.
[0098] Understandably, the sample explanation text from the preprocessing module can provide a supervision signal for the text generation model corresponding to the preprocessing module. This helps the text generation model learn and summarize the correspondence between the preprocessing method used by the preprocessing module on the training text in the training text set, the obtained preprocessed text, and the predicted category to which the training text belongs, from the supervision signal during the training process of the target classification model. In this way, it can summarize this correspondence and obtain the corresponding explanation text.
[0099] For the word segmentation module, considering that the semantics of text are expressed through its words, the quality of the word segmentation results obtained by the word segmentation module will directly affect the semantic accuracy of the text, thus leading to inaccurate prediction of the final text category. Based on this, if the target functional module is the word segmentation module, then the subtask performed by the target functional module on the training text is to perform word segmentation on the training text. The second execution result includes the set of words contained in the training text, and the reference execution result includes the set of reference words contained in the training text.
[0100] In this case, S408 can be specifically implemented as follows: matching each word in the word set with the corresponding reference word in the reference word set; based on the matching results between each word in the word set and the corresponding reference word in the reference word set, selecting target words that meet the second preset anomaly condition from the word set, and selecting the corresponding reference words from the reference word set, wherein the second preset anomaly condition includes the target word not matching the corresponding reference word in the reference word set; further, the target words contained in the training text and the corresponding reference words in the reference word set can be used as the influence information of the second execution result obtained by the word segmentation module in performing the sub-task on the training text on the predicted category to which the training text belongs; then, constructing the correspondence between this influence information and the predicted category to which the training text belongs, that is, constructing the correspondence between the target words and the corresponding reference words in the reference word set and the predicted category to which the training text belongs, and generating text to describe the correspondence as the sample explanation text corresponding to the word segmentation module.
[0101] Understandably, the sample explanation text from the word segmentation module can provide a supervisory signal for the text generation model corresponding to the word segmentation module. This helps the text generation model learn and summarize the impact of the word segmentation quality of the word segmentation module on the classification results of the training text during the training process of the target classification model. It can also summarize words in the input text that are not easily distinguished by the word segmentation module, words that are misclassified by the word segmentation module, and other words that affect the accuracy of text classification. In this way, it can summarize these words and obtain corresponding explanation text.
[0102] For the encoding module, considering that the meaning of words is represented in the form of vectors, the quality of the word vectors obtained by the encoding module will directly affect the semantic accuracy of the text, which will lead to inaccurate prediction of the final text category. Based on this, if the target functional module is the encoding module, the subtask performed by the target functional module on the training text is to encode each word in the word set contained in the training text, and the second execution result includes the word vector of each word in the word set.
[0103] In this case, S408 can be specifically implemented as follows: obtaining the antonyms of each word in the word set from the preset dictionary; encoding the antonyms of each word in the word set through the encoding module to obtain the word vectors of the antonyms of each word in the word set and using them as reference execution results; determining the distance between the word vector of the first word and the word vector of the antonym of the first word, where the first word is any word in the word set; selecting target words from the word set that satisfy the third preset anomaly condition, where the third preset anomaly condition includes the distance between the word vector of the target word and the word vector of the antonym of the target word exceeding a preset distance threshold; further, the target word and its word vector, as well as the antonym of the target word and its word vector, can be used as the influence information of the second execution result obtained by the encoding module in performing the sub-task on the training text on the predicted category to which the training text belongs; then, constructing the correspondence between this influence information and the encoding module, that is, constructing the correspondence between the target word and its word vector, the antonym of the target word and its word vector, and the predicted category to which the training text belongs, and generating text to describe the correspondence as the sample explanation text corresponding to the encoding module.
[0104] Specifically, the word vector of the target word can be used as the key, the word vector of the antonym of the target word and the predicted category of the training text can be used as the value to obtain the corresponding text, and this text can be used as the sample explanation text corresponding to the encoding module.
[0105] Understandably, the sample explanation text of the encoding module can provide supervision signals for the text generation model corresponding to the encoding module. This helps the text generation model learn and summarize the impact of the encoding quality of the encoding module on the classification results of the training text during the training process of the target classification model. It can also summarize the words in the input text that are not easily distinguished by the encoding module, their antonyms, and their respective word vectors, and thus have the ability to summarize these words and their word vectors to obtain the corresponding explanation text.
[0106] For the attention module, considering that in the processing of the attention module, the semantic representation vector of each word is obtained by fusing the word vector of the word with the word vectors of other words based on the importance of the word to the word (i.e., the context information of the word), the quality of the semantic representation vector obtained by the attention module in fusing the word vectors of words in the word set will directly affect the semantic accuracy of the text, thus leading to inaccurate prediction of the final text category. Based on this, if the target functional module is the attention module, the subtask performed by the target functional module on the training text is to aggregate the word vectors of the first word and the word vectors of the second word based on the attention mechanism. The second execution result includes the semantic representation vector of the first word, where the first word is any word in the word set contained in the training text, the second word is any word in the word set other than the first word, and the reference execution result is the expected semantic representation vector of the first word.
[0107] In this case, S408 can be specifically implemented as follows: Based on the semantic representation vector of the first word and the expected semantic representation vector of the first word, determine the attention weight between the first word and the second word, wherein the attention weight is used to represent the degree of influence of the semantics of the second word on the semantics of the first word; select words from the word set whose attention weight with the first word is greater than or equal to the preset weight as the target words corresponding to the first word; further, each word in the word set and its corresponding target word can be used as the influence information of the second execution result obtained by the attention module in performing the sub-task on the training text on the prediction category to which the training text belongs; then, construct the correspondence between this influence information and the prediction category to which the training text belongs, that is, construct the correspondence between each word in the word set contained in the training text and its corresponding target word and the prediction category to which the training text belongs, and generate text to describe the correspondence as the sample explanation text corresponding to the attention module.
[0108] Specifically, each word in the word set, the corresponding target word of each word, and the predicted category to which the training text belongs can be used as values to obtain the corresponding text, which can then be used as the sample explanation text for the encoding module.
[0109] Understandably, the sample explanation text of the attention module can provide a supervision signal for the text generation model corresponding to the attention module. This helps the text generation model learn and summarize the impact of the semantic representation quality of the attention module on the classification results of the training text during the training process of the target classification model. It can also summarize the degree of influence of each word in the input text on the meaning of other words, and thus have the ability to summarize each word in the input text and its semantic vector to obtain the corresponding explanation text.
[0110] For the loss determination module, considering that the loss determination module calculates the model loss of the target classification model based on the difference between the predicted category and the category label of the classification model, and the predicted category obtained by the target classification model for the training samples is affected by the model parameters of the target classification model, the quality of the model parameters of the target classification model will affect the execution result output by the loss determination module. Based on this, if the target functional module is the loss determination module, the subtask performed by the target functional module on the training text is to determine the model loss of the target classification model in the current training round based on the predicted category and the category label of the training text under the classification task. The second execution result obtained is the model loss of the target classification model in the current training round, and the reference execution result is the model loss of the target classification model in the historical training rounds.
[0111] In this case, S408 can be specifically implemented as follows: if the model loss of the current training round exceeds the model loss of the historical training round, the parameter difference between the model parameters of the target classification model in the current training round and the model parameters of the target classification model in the historical training round is obtained; further, the parameter difference is used as the influence information of the second execution result obtained by the loss determination module in performing the sub-task on the training text on the predicted category to which the training text belongs; then, the correspondence between this influence information and the predicted category to which the training text belongs is constructed, that is, the correspondence between the parameter difference and the predicted category to which the training text belongs is constructed, and text describing the correspondence is generated as the sample explanation text corresponding to the loss determination module.
[0112] Specifically, in each training round, the model parameters of the target classification model in the current training round can be recorded, and these model parameters can be compared with the model parameters of the target classification model in the previous training round to obtain the difference information between the two model parameters. Furthermore, this difference information, the predicted category obtained by the target classification model for the training text in the current round, and the predicted category obtained by the target classification model for the training text in the previous round are described in text form to obtain the sample explanation text corresponding to the loss determination module.
[0113] Understandably, the sample explanation text of the loss determination module can provide a supervision signal for the text generation model corresponding to the loss determination module. This helps the text generation model learn and summarize the impact of changes in model parameters on the classification results of the training text from this supervision signal during the training process of the target classification model. In turn, it has the ability to summarize the correlation between changes in model parameters and the classification results of the training text and obtain the corresponding explanation text.
[0114] For the classification module, if the target functional module is the classification module, then the subtask performed by the target functional module on the training text is to classify the training text based on the semantic representation vector of each word in the word set contained in the training text. The second execution result obtained includes the predicted category to which the training text belongs under the classification task, and the reference execution result includes the category label corresponding to the training text, which is used to indicate the actual category to which the training text belongs.
[0115] In this case, S408 can be implemented as follows: the predicted category of the training text under the classification task can be compared with the category label of the training text. If the two are inconsistent, the training text is determined to be a misclassified text. Then, misclassified texts are selected from the training text set. The semantic representation vector of each word in the word set contained in the misclassified text is used as the correspondence between the second execution result obtained by the classification module in performing the sub-task on the training text and the predicted category to which the training text belongs. That is, the correspondence between the semantic representation vector of each word in the word set contained in the misclassified text and the predicted category to which the misclassified text belongs under the classification task is constructed. The correspondence is described in the form of text to obtain the text used to describe the correspondence, which serves as the sample explanation text corresponding to the classification module.
[0116] Understandably, the sample explanation text of the classification module can provide supervision signals for the text generation model corresponding to the classification module. This helps the text generation model learn and summarize the relationship between the semantic representation vectors of words in the training text and the predicted category of the training text under the classification task from the supervision signals during the training process of the target classification model. In this way, it can generate explanation text for the classification module.
[0117] S410, using the second execution result as the training sample and the sample explanation text as the label corresponding to the training sample, train the text generation model to be trained to obtain the text generation model corresponding to the target functional module.
[0118] Specifically, the second execution result can be input into the text generation model to be trained to obtain the corresponding explanatory text; further, based on the explanatory text output by the text generation model and the sample explanatory text, the model loss of the text generation model is determined, and based on the model loss of the text generation model, the model parameters of the text generation model are adjusted.
[0119] The model loss of the text generation model represents the degree of difference between the explanatory text obtained by the text generation model from the second execution result of the input and the sample explanatory text. The model parameters of the text generation model may include the number of nodes (such as neurons) in each network layer of the text generation model, the connection relationships and edge weights between nodes in different network layers, and the biases corresponding to the nodes in each network layer.
[0120] More specifically, the backpropagation algorithm can be used to determine the loss caused by each module in the text generation model based on the model loss of the text generation model and the current model parameters of the text generation model; then, with the goal of reducing the prediction loss of the text generation model, the parameters of each network layer are adjusted layer by layer.
[0121] It should be noted that the above process is only a single adjustment process. In practical applications, multiple adjustments may be required. Therefore, the above process can be repeated multiple times until the preset training stopping condition is met. The text generation model that meets the preset training stopping condition is then identified as the text generation model corresponding to the target functional module. The preset training stopping condition can be set according to actual needs. For example, the preset training stopping condition may include the text generation model's loss being less than a preset loss threshold or the number of adjustments reaching a preset number. This application embodiment does not limit this.
[0122] The text generation model training method provided by one or more embodiments of this application, in the training phase of the target classification model, divides the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task performed by the target classification model, with each functional module corresponding to a sub-task; then, based on the execution order among the multiple sub-tasks, the multiple functional modules are sequentially called to predict the category to which the training text belongs under the classification task, and the second execution result obtained by the currently called functional module in performing the corresponding sub-task on the training text is obtained; further, based on the second execution result, the reference execution result corresponding to the training text in the currently called functional module, and the predicted category to which the training text belongs, the functional module is parsed to obtain the correlation between the second execution result and the predicted category to which the training text belongs under the classification task, and this correlation is described using explanatory text to obtain the sample of the functional module. This explanatory text; finally, using the second execution result as a training sample and the sample explanatory text as the label corresponding to the training sample, the text generation model to be trained is trained, so that the sample explanatory text of this functional module can provide a supervision signal for the text generation model. This is beneficial for the text generation model to learn and summarize the correlation between the second execution result obtained by the functional module in performing the sub-task and the predicted category of the training text in the classification task from the supervision signal during the training of the target classification model. In this way, the trained text generation model has the ability to summarize this correlation and obtain the corresponding explanatory text. Thus, in the process of training the target classification model, a text generation model that can be used to summarize the performance of each functional module in the target classification model is trained at the same time, so as to generate the explanatory text of the corresponding functional module, thereby achieving effective and targeted fine-grained explanation of the target classification model.
[0123] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0124] In addition, with the above Figure 1 Corresponding to the classification model interpretation method shown, this application also provides a classification model interpretation device. Please refer to... Figure 6 The diagram below illustrates the structure of a classification model interpretation device 600 according to an embodiment of this application. The device 600 may include:
[0125] The first partitioning unit 610 is used to divide the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task performed based on the target classification model, with each functional module corresponding to a sub-task.
[0126] The first calling unit 620 is used to sequentially call the multiple functional modules based on the execution order among the multiple sub-tasks, so as to execute the sub-tasks corresponding to the called functional modules on the test texts in the test text set, and obtain the predicted category to which the test texts in the test text set belong under the classification task.
[0127] The first acquisition unit 630 is used to acquire the first execution result obtained by the target functional module performing a subtask on the test texts in the test text set, wherein the target functional module is the currently invoked functional module among the plurality of functional modules;
[0128] The first parsing unit 640 is used to parse the target functional module based on the first execution result and the prediction category to which the test text belongs, using the text generation model corresponding to the target functional module, to obtain the explanatory text of the target functional module. The explanatory text is used to describe the correlation between the first execution result of the test text and the prediction category to which the test text belongs.
[0129] Optionally, the first parsing unit is specifically used to: parse the target functional module based on the first execution result of the test text and the reference execution result of the test text corresponding to the target functional module using the text generation model corresponding to the target functional module, to obtain the influence information of the first execution result of the test text on the prediction category to which the test text belongs; construct the correspondence between the influence information and the prediction category to which the test text belongs using the text generation model corresponding to the target functional module, and generate text describing the correspondence as explanatory text for the target functional module.
[0130] Optionally, the classification model parsing device further includes: a first comparison unit, configured to, after the first parsing unit obtains the explanatory text of the target functional module, compare the first execution result with the reference execution result corresponding to the test text under the target functional module to obtain a comparison result; a first selection unit, configured to select at least one test text from the test text set whose comparison result satisfies a first preset anomaly condition as the target text corresponding to the target functional module; and a construction unit, configured to construct the correspondence between the target text and the explanatory text of the target functional module, and generate associated text for describing the correspondence.
[0131] Optionally, the target functional module is a classification module, and the subtask performed by the classification module on the first test text is to classify the first test text. The first execution result includes a first test category, which is the predicted category to which the first test text belongs under the classification task. The first test text is any test text in the test text set.
[0132] The first determining unit compares the first execution result with the reference execution result corresponding to the test text in the test text set under the target functional module, including: selecting test texts from the test text set whose similarity to the first test text exceeds a preset similarity threshold as reference test texts; determining the second prediction category as the reference execution result corresponding to the first test text under the target functional module, wherein the second prediction category is the prediction category to which the reference test text belongs under the classification task; and comparing the first prediction category and the second prediction category to obtain the comparison result.
[0133] The first selection unit selects at least one test text from the test text set whose comparison result satisfies a first preset anomaly condition as the target text corresponding to the target functional module, including: if the first prediction category is different from the second prediction category, then the first test text and the reference test text are used as the target text.
[0134] Optionally, the classification model parsing device further includes a conversion unit, used to convert the parsed text of the target functional module into speech data based on text-to-speech technology.
[0135] Obviously, the classification model interpretation device provided in this application embodiment can serve as... Figure 1 The entity that executes the classification model interpretation method shown, for example, Figure 1 In the classification model interpretation method shown, step S102 can be derived from... Figure 6 The first division unit in the classification model interpretation device is executed, step S104 can be executed by the first calling unit in the classification model interpretation device, step S106 can be executed by the first acquisition unit in the classification model interpretation device, and step S108 can be executed by the first parsing unit in the classification model interpretation device.
[0136] According to another embodiment of this application, Figure 6The various units in the classification model interpretation device shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effects of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the classification model interpretation device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0137] According to another embodiment of this application, a general-purpose computing device, such as a computer, including processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can run an application capable of performing tasks such as... Figure 1 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 6 The diagram illustrates a classification model interpretation apparatus and a classification model interpretation method for implementing embodiments of this application. The computer program may be recorded on, for example, a computer-readable storage medium, and may be transferred to and executed in an electronic device via such a medium.
[0138] In addition, with the above Figure 4 Corresponding to the training method of the text generation model shown, this application also provides a training apparatus for a text generation model. Please refer to... Figure 7 The diagram below illustrates the structure of a text generation model training device 700 according to an embodiment of this application. The device 700 may include:
[0139] The second partitioning unit 710 is used to divide the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task performed by the target classification model, with each functional module corresponding to a sub-task.
[0140] The second calling unit 720 is used to sequentially call the multiple functional modules based on the execution order among the multiple sub-tasks, so as to execute the sub-tasks corresponding to the called functional modules on the training texts in the training text set, and obtain the predicted category to which the training texts belong under the classification task.
[0141] The second acquisition unit 730 is used to acquire the second execution result obtained by the target functional module performing the corresponding sub-task on the training text, wherein the target functional module is the currently invoked functional module among the plurality of functional modules;
[0142] The second parsing unit 740 is used to parse the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the prediction category to which the training text belongs, to obtain the sample explanation text corresponding to the target functional module. The sample explanation text is used to describe the relationship between the second execution result and the prediction category to which the training text belongs under the classification task.
[0143] The training unit 750 is used to train the text generation model to be trained by using the second execution result as a training sample and the sample explanation text as the label corresponding to the training sample, so as to obtain the text generation model corresponding to the target functional module.
[0144] Optionally, the target functional module is a preprocessing module, and the subtask performed by the target functional module on the training text is to preprocess the training text, and the second execution result includes the preprocessed text corresponding to the training text;
[0145] The second parsing unit is specifically used for: comparing the training text with its corresponding preprocessed text to obtain a comparison result; parsing the comparison result to obtain the preprocessing method performed by the preprocessing module on the training text; constructing a correspondence between the preprocessing method, the preprocessed text, and the prediction category to which the training text belongs, and generating text to describe the correspondence as the sample explanation text corresponding to the preprocessing module.
[0146] Optionally, the target functional module is a word segmentation module, and the subtask performed by the target functional module on the training text is to perform word segmentation on the training text. The second execution result includes the set of words contained in the training text, and the reference execution result includes the set of reference words contained in the training text.
[0147] The second parsing unit is specifically used for: matching each word in the word set with the corresponding reference word in the reference word set; based on the matching results between each word in the word set and the corresponding reference word in the reference word set, selecting a target word from the word set that meets a second preset anomaly condition, and selecting a reference word corresponding to the target word from the reference word set, wherein the second preset anomaly condition includes the target word not matching its corresponding reference word in the reference word set; constructing a correspondence between the target word, the corresponding reference word in the reference word set, and the prediction category to which the training text belongs, and generating text describing the correspondence as sample explanation text corresponding to the word segmentation module.
[0148] Optionally, the target functional module is an encoding module, and the subtask performed by the target functional module on the training text is to encode each word in the word set contained in the training text, and the second execution result includes the word vector of each word in the word set;
[0149] The second parsing unit is specifically used for: obtaining the antonyms of each word in the word set from a preset dictionary; encoding the antonyms of each word in the word set through the encoding module to obtain the word vectors of the antonyms of each word in the word set and using them as the reference execution result; determining the distance between the word vector of a first word and the word vector of the antonym of the first word, wherein the first word is any word in the word set; selecting target words from the word set that satisfy a third preset anomaly condition, wherein the third preset anomaly condition includes the distance between the word vector of the target word and the word vector of the antonym of the target word exceeding a preset distance threshold; constructing a correspondence between the target word and its word vector, the antonym of the target word and its word vector, and the prediction category to which the training text belongs, and generating text describing the correspondence as the sample explanation text corresponding to the encoding module.
[0150] Optionally, the target functional module is an attention module. The subtask performed by the target functional module on the training text is to aggregate the word vectors of the first word and the second word based on the attention mechanism to obtain the semantic representation vector of the first word. Here, the first word is any word in the word set contained in the training text, and the second word is other words in the word set except for the first word. The reference execution result is the expected semantic representation vector of the first word.
[0151] The second parsing unit is specifically used for: determining the attention weight between the first word and the second word based on the semantic representation vector of the first word and the expected semantic representation vector of the first word, wherein the attention weight is used to represent the degree of influence of the semantics of the second word on the semantics of the first word; selecting words from the word set whose attention weight with the first word is greater than or equal to a preset weight as the target words corresponding to the first word; constructing the correspondence between each word in the word set, its corresponding target word, and the prediction category to which the training text belongs, and generating text describing the correspondence as the sample explanation text corresponding to the attention module.
[0152] Optionally, the target functional module is a loss determination module. The subtask performed by the target functional module on the training text is to determine the model loss of the target classification model in the current training round based on the predicted category to which the training text belongs under the classification task and the category label corresponding to the training text. The second execution result is the model loss of the target classification model in the current training round, and the reference execution result is the model loss of the target classification model in the historical training rounds.
[0153] The second parsing unit is specifically used to: if the model loss of the current training round and the model loss of the historical training round exceed a preset loss threshold, then obtain the parameter difference between the model parameters of the target classification model in the current training round and the model parameters of the target classification model in the historical training round; construct the correspondence between the parameter difference and the predicted category to which the training text belongs, and generate text to describe the correspondence as the sample explanation text corresponding to the loss determination module.
[0154] Obviously, the training device for the text generation model provided in this application embodiment can be used as... Figure 4 The entity that performs the training method of the text generation model shown, for example, Figure 4 In the training method of the text generation model shown, step S402 can be performed by... Figure 7 The second partitioning unit in the training device of the text generation model shown is executed, step S404 can be executed by the second calling unit in the training device of the text generation model, step S406 can be executed by the second acquisition unit in the training device of the text generation model, step S408 can be executed by the second parsing unit in the training device of the text generation model, and step S410 can be executed by the training unit in the training device of the text generation model.
[0155] According to another embodiment of this application, Figure 7The units in the training device of the text generation model shown can be individually or entirely merged into one or more other units, or some of the units can be further divided into multiple functionally smaller units. This achieves the same operation without affecting the technical effect of the embodiments of this application. The above units are based on logical function division. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units can be implemented by one unit. In other embodiments of this application, the training device of the text generation model may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.
[0156] According to another embodiment of this application, a general-purpose computing device, such as a computer, including processing elements and storage elements such as a central processing unit, random access storage medium, and read-only storage medium, can be used to run an application capable of performing tasks such as... Figure 4 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 7 The diagram illustrates a training apparatus for a text generation model, and a training method for implementing the text generation model according to embodiments of this application. The computer program may be recorded on, for example, a computer-readable storage medium, and may be transferred to and run in an electronic device via such a medium.
[0157] Figure 8 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Please refer to it. Figure 8 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and memory. The memory may include main memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for other business operations.
[0158] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. This bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0159] Memory is used to store programs. Specifically, programs may include program code, which includes computer operation instructions. Memory may include main memory and non-volatile memory, and provides instructions and data to the processor.
[0160] The processor reads the corresponding computer program from non-volatile memory into main memory and then executes it, forming a classification model interpretation device at the logical level. The processor executes the program stored in memory and specifically performs the following operations:
[0161] The classification task performed by the target classification model includes multiple sub-tasks. The target classification model is divided into multiple functional modules, each corresponding to a sub-task. Based on the execution order of the multiple sub-tasks, the multiple functional modules are called sequentially to execute the sub-task corresponding to the called functional module on the test text in the test text set, so as to obtain the predicted category of the test text under the classification task. The first execution result obtained by the target functional module in executing the sub-task on the test text is obtained, and the target functional module is the currently called functional module among the multiple functional modules. Through the text generation model corresponding to the target functional module, based on the first execution result and the predicted category of the test text, the target functional module is parsed to obtain the explanatory text of the target functional module. The explanatory text is used to describe the correlation between the first execution result of the test text and the predicted category of the test text.
[0162] Alternatively, the processor reads the corresponding computer program from non-volatile memory into memory and runs it, serving as a training device for the text generation model at the logical level. The processor executes the program stored in memory and specifically performs the following operations:
[0163] The classification task performed by the target classification model includes multiple sub-tasks. The target classification model is divided into multiple functional modules, each corresponding to a sub-task. Based on the execution order of the multiple sub-tasks, the multiple functional modules are called sequentially to execute the sub-task corresponding to the called functional module on the training text in the training text set, so as to obtain the predicted category of the training text under the classification task. The second execution result obtained by the target functional module in executing the corresponding sub-task on the training text is obtained. The target functional module is the currently called functional module among the multiple functional modules. Based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category of the training text, the target functional module is parsed to obtain the sample explanation text corresponding to the target functional module. The sample explanation text is used to describe the correlation between the second execution result and the predicted category of the training text under the classification task. The second execution result is used as a training sample, and the sample explanation text is used as the label corresponding to the training sample to train the text generation model to be trained, so as to obtain the text generation model corresponding to the target functional module.
[0164] The above is as stated in this application. Figure 1 The illustrated embodiment discloses a method performed by a classification model interpretation apparatus, or as described in this application. Figure 4The method executed by the training device for the text generation model disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method.
[0165] The electronic device can also perform Figure 1 The method, and implement the classification model interpretation device in Figures 1 to 4 The illustrated embodiment may also perform the functions of the electronic device, or the electronic device may also perform the functions of the embodiment shown. Figure 4 The method, and the implementation of the training device for the text generation model in Figure 4 , Figure 5 The functions of the embodiments shown are not described in detail here.
[0166] Of course, in addition to software implementation, the electronic device of this application does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0167] This application also proposes a computer-readable storage medium that stores one or more programs, the programs including instructions that, when executed by a portable electronic device including multiple applications, enable the portable electronic device to perform... Figure 1 The method of the illustrated embodiment is specifically used to perform the following operations:
[0168] The classification task performed by the target classification model includes multiple sub-tasks. The target classification model is divided into multiple functional modules, each corresponding to a sub-task. Based on the execution order of the multiple sub-tasks, the multiple functional modules are called sequentially to execute the sub-task corresponding to the called functional module on the test text in the test text set, so as to obtain the predicted category of the test text under the classification task. The first execution result obtained by the target functional module in executing the sub-task on the test text is obtained, and the target functional module is the currently called functional module among the multiple functional modules. Through the text generation model corresponding to the target functional module, based on the first execution result and the predicted category of the test text, the target functional module is parsed to obtain the explanatory text of the target functional module. The explanatory text is used to describe the correlation between the first execution result of the test text and the predicted category of the test text.
[0169] Alternatively, when executed by a portable electronic device that includes multiple applications, the instruction can enable the portable electronic device to perform... Figure 4 The method of the illustrated embodiment is specifically used to perform the following operations:
[0170] The classification task performed by the target classification model includes multiple sub-tasks. The target classification model is divided into multiple functional modules, each corresponding to a sub-task. Based on the execution order of the multiple sub-tasks, the multiple functional modules are called sequentially to execute the sub-task corresponding to the called functional module on the training text in the training text set, so as to obtain the predicted category of the training text under the classification task. The second execution result obtained by the target functional module in executing the corresponding sub-task on the training text is obtained. The target functional module is the currently called functional module among the multiple functional modules. Based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category of the training text, the target functional module is parsed to obtain the sample explanation text corresponding to the target functional module. The sample explanation text is used to describe the correlation between the second execution result and the predicted category of the training text under the classification task. The second execution result is used as a training sample, and the sample explanation text is used as the label corresponding to the training sample to train the text generation model to be trained, so as to obtain the text generation model corresponding to the target functional module.
[0171] In summary, the above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
[0172] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0173] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0174] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0175] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
Claims
1. A classification model interpretation method, characterized in that, include: The classification task performed based on the target classification model contains multiple sub-tasks. The target classification model is divided into multiple functional modules, and each functional module corresponds to a sub-task. Based on the execution order of the multiple subtasks, the multiple functional modules are called sequentially to execute the subtasks corresponding to the called functional modules on the test texts in the test text set, so as to obtain the predicted category of the test texts in the test text set under the classification task. Obtain the first execution result obtained by the target functional module performing a subtask on the test texts in the test text set, wherein the target functional module is the currently invoked functional module among the plurality of functional modules; Using the text generation model corresponding to the target functional module, the target functional module is parsed based on the first execution result and the predicted category to which the test text belongs, to obtain the explanatory text of the target functional module. The explanatory text is text used to describe the correspondence, which is obtained in the following way: based on the first execution result and the reference execution result of the test text in the target functional module, the target functional module is parsed to obtain the influence information of the first execution result on the predicted category, and to construct the correspondence between the influence information and the predicted category.
2. The method according to claim 1, characterized in that, The step of parsing the target functional module using the text generation model corresponding to the target functional module, based on the first execution result and the predicted category to which the test text belongs, to obtain the explanatory text of the target functional module includes: Using the text generation model corresponding to the target functional module, based on the first execution result of the test text and the reference execution result of the test text corresponding to the target functional module, the target functional module is parsed to obtain the influence information of the first execution result of the test text on the prediction category to which the test text belongs; By using the text generation model corresponding to the target functional module, a correspondence is constructed between the influence information and the prediction category to which the test text belongs, and text describing the correspondence is generated as explanatory text for the target functional module.
3. The method according to claim 1, characterized in that, After obtaining the explanatory text of the target functional module, the method further includes: The first execution result is compared with the reference execution result corresponding to the test text in the test text set under the target functional module to obtain the comparison result; Select at least one test text whose comparison result satisfies the first preset anomaly condition from the test text set as the target text corresponding to the target functional module; Construct a correspondence between the target text and the explanatory text of the target functional module, and generate associated text to describe the correspondence.
4. The method according to claim 3, characterized in that, The target functional module is a classification module. The subtask performed by the classification module on the first test text is to classify the first test text. The first execution result includes a first predicted category. The first predicted category is the predicted category to which the first test text belongs under the classification task. The first test text is any test text in the test text set. The step of comparing the first execution result with the reference execution result corresponding to the test text in the test text set under the target functional module includes: Test texts with a similarity exceeding a preset similarity threshold to the first test text are selected from the test text set as reference test texts, and the second prediction category is determined as the reference execution result corresponding to the first test text under the target functional module, wherein the second prediction category is the prediction category to which the reference test text belongs under the classification task; The first predicted category and the second predicted category are compared to obtain the comparison result; Selecting at least one test text from the test text set whose comparison result satisfies the first preset anomaly condition as the target text corresponding to the target functional module includes: If the first predicted category is different from the second predicted category, then the first test text and the reference test text are used as the target text.
5. A training method for a text generation model, characterized in that, include: The classification task performed based on the target classification model includes multiple sub-tasks. The target classification model is divided into multiple functional modules, and each functional module corresponds to a sub-task. Based on the execution order of the multiple subtasks, the multiple functional modules are called sequentially to execute the subtasks corresponding to the called functional modules on the training texts in the training text set, so as to obtain the predicted category of the training texts under the classification task. Obtain the second execution result obtained by the target functional module performing the corresponding subtask on the training text, wherein the target functional module is the currently invoked functional module among the plurality of functional modules; Based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the prediction category to which the training text belongs, the target functional module is parsed to obtain the sample explanation text corresponding to the target functional module. The sample explanation text is text used to describe the correspondence. The correspondence is obtained in the following way: based on the second execution result and the reference execution result, the target functional module is parsed to obtain the influence information of the second execution result on the prediction category, and the correspondence between the influence information and the prediction category is constructed. Using the second execution result as a training sample and the sample explanation text as the label corresponding to the training sample, the text generation model to be trained is trained to obtain the text generation model corresponding to the target functional module.
6. The method according to claim 5, characterized in that, The target functional module is a word segmentation module. The subtask performed by the target functional module on the training text is to perform word segmentation on the training text. The second execution result includes the set of words contained in the training text, and the reference execution result includes the set of reference words contained in the training text. The step of parsing the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category to which the training text belongs, to obtain the sample explanation text corresponding to the target functional module, includes: Match each word in the word set with the corresponding reference word in the reference word set; Based on the matching results between each word in the word set and the corresponding reference word in the reference word set, a target word that meets the second preset anomaly condition is selected from the word set, and a reference word corresponding to the target word is selected from the reference word set, wherein the second preset anomaly condition includes that the target word does not match the corresponding reference word in the reference word set; A correspondence is constructed between the target word, the corresponding reference word in the reference word set, and the predicted category to which the training text belongs, and text describing the correspondence is generated as the sample explanation text corresponding to the word segmentation module.
7. The method according to claim 5, characterized in that, The target functional module is an encoding module. The subtask performed by the target functional module on the training text is to encode each word in the word set contained in the training text. The second execution result includes the word vector of each word in the word set. The step of parsing the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category to which the training text belongs, to obtain the sample explanation text corresponding to the target functional module, includes: Obtain the antonym of each word in the word set from the preset dictionary; The antonyms of each word in the word set are encoded by the encoding module to obtain the word vectors of the antonyms of each word in the word set, which are then used as the reference execution result. Determine the distance between the word vector of the first word and the word vector of the antonym of the first word, wherein the first word is any word in the word set; Select target words from the word set that satisfy a third preset anomaly condition, wherein the third preset anomaly condition includes the distance between the word vector of the target word and the word vector of the antonym of the target word exceeding a preset distance threshold; The correspondence between the target word and its word vector, the antonym of the target word and its word vector, and the predicted category to which the training text belongs is constructed, and text describing the correspondence is generated as the sample explanation text corresponding to the encoding module.
8. The method according to claim 5, characterized in that, The target functional module is an attention module. The subtask performed by the target functional module on the training text is to aggregate the word vectors of the first word and the second word based on the attention mechanism to obtain the semantic representation vector of the first word. The first word is any word in the word set contained in the training text, and the second word is any other word in the word set except the first word. The reference execution result is the expected semantic representation vector of the first word. The step of parsing the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category to which the training text belongs, to obtain the sample explanation text corresponding to the target functional module, includes: Based on the semantic representation vector of the first word and the expected semantic representation vector of the first word, the attention weight between the first word and the second word is determined, and the attention weight is used to represent the degree of influence of the semantics of the second word on the semantics of the first word. Select words from the word set whose attention weight to the first word is greater than or equal to a preset weight, and use them as target words corresponding to the first word; Construct a correspondence between each word in the word set, its corresponding target word, and the predicted category to which the training text belongs, and generate text describing the correspondence as the sample explanation text corresponding to the attention module.
9. The method according to claim 5, characterized in that, The target functional module is a loss determination module. The subtask performed by the target functional module on the training text is to determine the model loss of the target classification model in the current training round based on the predicted category to which the training text belongs under the classification task and the category label corresponding to the training text. The second execution result is the model loss of the target classification model in the current training round, and the reference execution result is the model loss of the target classification model in the historical training rounds. The step of parsing the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the predicted category to which the training text belongs, to obtain the sample explanation text corresponding to the target functional module, includes: If the model loss in the current training round exceeds a preset loss threshold compared to the model loss in the previous training round, then the parameter difference between the model parameters of the target classification model in the current training round and the model parameters of the target classification model in the previous training round is obtained. Construct a correspondence between the parameter differences and the predicted category to which the training text belongs, and generate text describing the correspondence as the sample explanation text corresponding to the loss determination module.
10. A classification model interpretation device, characterized in that, include: The first partitioning unit is used to divide the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task performed by the target classification model, with each functional module corresponding to a sub-task. The first calling unit is used to sequentially call the multiple functional modules based on the execution order among the multiple sub-tasks, so as to execute the sub-tasks corresponding to the called functional modules on the test texts in the test text set, and obtain the predicted category to which the test texts in the test text set belong under the classification task. The first acquisition unit is used to acquire the first execution result obtained by the target functional module performing a subtask on the test texts in the test text set, wherein the target functional module is the currently invoked functional module among the plurality of functional modules; The first parsing unit is configured to parse the target functional module using the text generation model corresponding to the target functional module, based on the first execution result and the prediction category to which the test text belongs, to obtain the explanatory text of the target functional module. The explanatory text is text used to describe the correspondence, which is obtained by parsing the target functional module based on the first execution result and the reference execution result of the test text in the target functional module, to obtain the influence information of the first execution result on the prediction category, and to construct the correspondence between the influence information and the prediction category.
11. A training device for a text generation model, characterized in that, include: The second partitioning unit is used to divide the target classification model into multiple functional modules based on the multiple sub-tasks included in the classification task performed by the target classification model, with each functional module corresponding to a sub-task. The second calling unit is used to sequentially call the multiple functional modules based on the execution order among the multiple sub-tasks, so as to execute the sub-tasks corresponding to the called functional modules on the training texts in the training text set, and obtain the predicted category to which the training texts belong under the classification task. The second acquisition unit is used to acquire the second execution result obtained by the target functional module performing the corresponding sub-task on the training text, wherein the target functional module is the currently invoked functional module among the plurality of functional modules; The second parsing unit is used to parse the target functional module based on the second execution result, the reference execution result of the training text corresponding to the target functional module, and the prediction category to which the training text belongs, to obtain sample explanation text corresponding to the target functional module. The sample explanation text is text used to describe the correspondence relationship, which is obtained by parsing the target functional module based on the second execution result and the reference execution result to obtain the influence information of the second execution result on the prediction category, and constructing the correspondence relationship between the influence information and the prediction category. The training unit is used to train the text generation model to be trained by using the second execution result as a training sample and the sample explanation text as the label corresponding to the training sample, so as to obtain the text generation model corresponding to the target functional module.
12. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the classification model interpretation method as described in any one of claims 1 to 4; or, the processor is configured to execute the instructions to implement the text generation model training method as described in any one of claims 5 to 9.
13. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the classification model interpretation method as described in any one of claims 1 to 4; or, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the text generation model training method as described in any one of claims 5 to 9.
Citation Information
Patent Citations
Interpretability analysis method based on CNN text classification model
CN112347252A
Text classification method and device, equipment and storage medium
CN113722474A
