A method for probabilistically locating key classification positions in input samples of a text classification model

By using the concept of receptive field in a text classification model to map the contribution weights of high-level features to low-level positions, the interpretability problem of deep learning models is solved, and accurate visual interpretation of key positions in text is achieved.

CN115827873BActive Publication Date: 2025-12-02JIANGSU HONGXIN SYST INTEGRATION
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202211691731.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-28
Publication Date
2025-12-02
Estimated Expiration
2042-12-28

AI Technical Summary

Technical Problem

Existing interpretability methods for deep learning text classification models, especially locally interpretable methods such as attention mechanisms and word substitution comparison methods, suffer from insufficient accuracy and poor intuitiveness, failing to accurately reflect the model's decision-making process.

Method used

By employing the concept of receptive field, the contribution weights of high-level feature maps during feedforward propagation of the convolutional neural network model are mapped to the low-level input feature locations, forming a heatmap of probabilistic contribution values ​​to show the importance of each location in the text.

Benefits of technology

This study achieves interpretability for the text classification model, accurately displays the contribution of each position to the classification result, provides highly readable results with low computational complexity, and overcomes the shortcomings of existing methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115827873B_ABST
    Figure CN115827873B_ABST
Patent Text Reader

Abstract

This invention discloses a method for probabilistically locating key classification positions in input samples of a text classification model. The method includes: loading a text classification model; reading and preprocessing the text to be predicted to obtain a word segmentation sequence; mapping the word segmentation sequence to a vocabulary index sequence X; inputting X into the text classification model and performing forward propagation calculations to obtain the highest-dimensional feature vector matrix before the pooling layer; mapping the fully connected layer parameters of each classification category as weights onto the feature vector; mapping the probabilistic contribution values ​​of the classification prediction results on the highest-dimensional feature vector to each position of the lowest-dimensional input feature according to a one-to-one correspondence; and converting the probabilistic contribution values ​​mapped to the lowest-dimensional input feature into a heatmap and overlaying it onto the text sequence to create an interpretable visualization. This method addresses the problems of attention matrices not providing good model interpretability and the inaccuracy and intuition of the substitution comparison method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of interpretability technology of text classification models in natural language processing, and specifically relates to a method for probabilistically locating key classification positions in input samples of a text classification model. Background Technology

[0002] Interpretability of classification models has been a long-standing research hotspot in the field of deep learning. Applications of interpretability in text classification models include sensitive word localization and topic word extraction. Currently, the interpretability of deep learning classification models does not yet reach the level of traditional machine learning, leading to the perception that deep learning models are "black box" models. Currently, depending on the target and object of model interpretation, the industry mainly employs "global interpretability" and "local interpretability" techniques. "Global interpretability" requires that the neural network's model architecture and parameters be known and derivable, thus it is only suitable for shallow neural networks. When addressing the interpretability problem of deep learning classification models, due to the model's complexity and numerous nonlinear operations within the network, the model's decision-making process cannot be clearly derived. Therefore, "local interpretability" techniques for single samples are typically used.

[0003] Currently, the solutions for addressing the interpretability problem in natural language processing technology based on "local interpretability" include:

[0004] Option 1: Identify important features in the sequence representation through an attention mechanism, thereby analyzing the location of important features in the text sequence, such as the invention patent with publication number CN112925822A applied for by Shandong University.

[0005] Option 2: Select significant features by replacing words in the vocabulary with words from the vocabulary list and comparing them with the text to be classified. For example, replace a word in a certain position in the text with a substitute word. If the classification score is higher than a set threshold, the substitute word is considered a significant feature, thus obtaining interpretable results, such as the invention patent with publication number CN111597423A applied for by Jilin University.

[0006] The above solution has the following problems:

[0007] Scheme 1, which uses an attention mechanism to calculate the attention weight matrix, only considers the attention relationships between different elements in the sequence, according to the definition of attention mechanisms, without establishing a connection between the prediction result and the importance of each position in the sequence. Scheme 2, which replaces the text to be classified with words from a vocabulary, treats words that positively influence the model's decision as salient features. This method lacks proof that the replacement word is precisely at the decision boundary. Therefore, when replacing the original word with a replacement word, it introduces the decision bias of the replacement word. Consequently, the decision bias after replacement cannot reflect whether the model's decision bias in the replaced text is due to the absence of the replaced word. Therefore, the interpretability of the results obtained by this method is not accurate enough. Furthermore, this method cannot output the weights of different positions' influence on the results, making its interpretability insufficiently intuitive. Summary of the Invention

[0008] The technical problem to be solved by this invention is to address the shortcomings of the prior art by providing a method for probabilistically locating key classification positions in the input samples of a text classification model. Inspired by the concept of "receptive field" in computer vision, that is, during the feedforward propagation of a convolutional neural network model, the high-dimensional vector of a certain region in the high-level feature map is obtained by aggregating the features of the corresponding position region in the low-level model. The correspondence between the positions can be mapped by a downsampling formula. This invention first calculates the contribution weight of each feature vector in the highest level based on the prediction results of the classification category, and then maps this contribution weight to each position of the low-dimensional input according to the correspondence between the high-dimensional features and the low-dimensional input features, thereby achieving the interpretability of the text classification model.

[0009] To achieve the above-mentioned technical objectives, the technical solution adopted by the present invention is as follows:

[0010] A method for probabilistically locating key classification positions in input samples of a text classification model includes:

[0011] S1: Load the already trained parallelized text classification model;

[0012] S2: Read the text to be predicted from the storage device;

[0013] S3: Preprocess the text to be predicted to obtain a word segmentation sequence.

[0014] S4: Map the word segmentation sequence to the vocabulary index sequence X;

[0015] S5: Input the vocabulary index sequence X into the text classification model;

[0016] S6: Perform forward propagation calculations for the classification model to obtain the highest-dimensional feature vector matrix E located before the pooling layer;

[0017] S7: Map the fully connected layer parameters of each classification category as weights onto the feature vector obtained in S6 to obtain the probabilistic contribution value of the classification prediction result on the highest dimension feature vector;

[0018] S8: Map the probabilistic contribution value of the classification prediction result on the highest dimension feature vector to each position of the lowest dimension input feature, i.e. the word index sequence X, in a one-to-one correspondence manner to obtain the probabilistic contribution value mapped to the lowest dimension input feature.

[0019] S9: The probabilistic contribution values ​​mapped to the lowest-dimensional input features are transformed into heatmaps and superimposed on the text sequence to create an interpretable visualization effect, thus completing the probabilistic localization of key classification positions in the input samples of the text classification model.

[0020] To optimize the above technical solution, the specific measures also include:

[0021] The parallelized text classification model loaded by S1 mentioned above is a Transformers model, Textcnn model, or Lstm sequence model.

[0022] The above-mentioned S2 performs stop word removal and word segmentation preprocessing on the text to be predicted.

[0023] Specifically, S4 above yields a word index sequence X of length T. The index value of the word segment at position t in the word index sequence X of length T is denoted as x. t .

[0024] The above S6 yields the highest-dimensional feature vector matrix E located before the pooling layer, where the dimension of matrix E is (T, H), T is the same as the length of the vocabulary index sequence, H is the number of hidden layer nodes, and the matrix elements E are... t This represents the feature vector obtained after forward propagation of the word segment at position t in a text sequence of length T.

[0025] The mapping formula for S7 above is:

[0026]

[0027] Among them, prob t This represents the importance of position t in the high-dimensional feature sequence to the classification result, i.e., the probabilistic contribution value of the classification prediction result on the highest-dimensional feature vector. t The larger the value of ∈(0,1), the higher the contribution of position t to the classification result;

[0028] sigmoid is a probabilistic function;

[0029] e T=tLet e ​​represent the feature vector corresponding to the t-th position in the text sequence. H=h,T=t ∈R;

[0030] w C=c w represents the parameter corresponding to category c in the fully connected layer. C=c,H=h ∈R.

[0031] The formula for calculating the above probabilistic function is as follows:

[0032]

[0033] Where z is the function input.

[0034] The S8 mentioned above represents the probabilistic contribution value (prob) of the classification prediction result on the highest-dimensional feature vector. t∈[1,T] It maps to each position of the lowest-dimensional input feature in a one-to-one correspondence manner.

[0035] The present invention has the following beneficial effects:

[0036] This invention addresses the scenario where a text classification model predicts the text to be classified. It directly associates the prediction results of the fully connected layer with the position of each word in the text. The fully connected layer parameters of each classification category are used as weights and mapped to a high-dimensional feature vector using a mapping formula. The probabilistic contribution value on the highest-dimensional feature vector is then mapped to each position of the lowest-dimensional input feature in a one-to-one correspondence manner. This achieves a probabilistic display of the direct mapping relationship between the model's prediction results and each word position in the text, thus achieving the goal of model interpretability.

[0037] This invention can interpret which elements in the sample are important for the classification result by calculating the weights of the fully connected layer and the high-level semantic vector for the predicted classification result of any sample that is distributed in the same way as the training set. The result is highly readable, interpretable, and the important calculation method is reasonable and has low computational complexity. It can solve the problems of existing technologies, such as the attention matrix not being able to interpret the model well and the substitution comparison method not being accurate and intuitive enough.

[0038] Compared to the interpretability methods of attention mechanisms, this invention realizes an interpretable method that associates classification results with input features, overcoming the problem that the interpretability methods of attention mechanisms can only explain the importance weights of elements at different positions in the sequence.

[0039] Compared to the interpretability operation achieved by the substitution comparison method, its computational complexity is O(C*T*V), where C is the number of categories, T is the length of the input text, and V is the vocabulary size. This invention overcomes the sensitivity of the substitution comparison method to word substitutions at the decision edge in the sample, exhibiting high robustness and low computational complexity of O(C*T). Furthermore, it can display the importance of each position with continuous probabilistic values, making it easier for users to capture important key factors in the sample. Attached Figure Description

[0040] Figure 1 This is a flowchart of the method of the present invention;

[0041] Figure 2 This is a schematic diagram of the method of the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0043] Although the steps in this invention are arranged by reference numerals, this is not intended to limit the order of the steps. Unless the order of the steps is explicitly stated or the execution of a step requires other steps as a basis, the relative order of the steps can be adjusted. It is understood that the term "and / or" as used herein refers to and covers any and all possible combinations of one or more of the associated listed items.

[0044] like Figure 1 and 2 As shown, the present invention provides a method for probabilistically locating key classification positions in input samples of a text classification model, comprising the following steps:

[0045] S1: Load a pre-trained parallelized text classification model, such as the Transformers model or the Textcnn model. Sequence models such as Lstm cannot be used for interpretability analysis using this method.

[0046] S2: Read the text to be predicted from the storage device;

[0047] S3: Preprocess the text to be predicted, including removing stop words and segmenting the text to obtain a segmented sequence.

[0048] S4: Map the word segmentation sequence to a word index sequence X, specifically obtaining a word index sequence X of length T. The index value of the word segment at position t in the word index sequence X of length T is denoted as x. t .

[0049] S5: Input the vocabulary index sequence X into the text classification model loaded in S1;

[0050] S6: Perform forward propagation calculations for the classification model to obtain the highest-dimensional feature vector matrix E located before the pooling layer;

[0051] Here, the dimension of this matrix E is (T, H), where T is the same as the length of the vocabulary index sequence, H is the number of hidden layer nodes, and E... t This represents the feature vector obtained after forward propagation of the word segment at position t in a text sequence of length T.

[0052] S7: Map the fully connected layer parameters of each classification category as weights onto the feature vector obtained in S6;

[0053] The mapping formula is:

[0054]

[0055]

[0056] Among them, prob t This represents the importance of position t in the high-dimensional feature sequence to the classification result, i.e., the probabilistic contribution value of the classification prediction result on the highest-dimensional feature vector. t ∈(0,1), the larger the value, the higher the contribution of position t to the classification result;

[0057] sigmoid is a probabilistic function;

[0058] e T=t Let e ​​represent the feature vector corresponding to the t-th position in the text sequence. H=h,T=t ∈R;

[0059] w C=c w represents the parameter corresponding to category c in the fully connected layer. C=c,H=h ∈R.

[0060] S8: The probabilistic contribution value (prob) of the classification prediction result on the highest-dimensional feature vector. t∈[1,T] Based on the one-to-one correspondence, the probability-based contribution value of the mapping to the lowest-dimensional input feature is obtained by mapping it to each position of the lowest-dimensional input feature, i.e., X in S3.

[0061] S9: The probabilistic contribution values ​​mapped to the lowest-dimensional input features are transformed into a heatmap and superimposed on the text sequence (i.e. the word segmentation sequence obtained in S3) to form an interpretable visualization effect, thus completing the probabilistic localization of the key classification positions in the input samples of the text classification model.

[0062] The present invention has the following beneficial effects:

[0063] This invention addresses the scenario where a text classification model predicts the text to be classified. It directly associates the prediction results of the fully connected layer with the position of each word in the text. The fully connected layer parameters of each classification category are used as weights and mapped to a high-dimensional feature vector using a mapping formula. The probabilistic contribution value on the highest-dimensional feature vector is then mapped to each position of the lowest-dimensional input feature in a one-to-one correspondence manner. This achieves a probabilistic display of the direct mapping relationship between the model's prediction results and each word position in the text, thus achieving the goal of model interpretability.

[0064] This invention can interpret which elements in the sample are important for the classification result by calculating the weights of the fully connected layer and the high-level semantic vector for the predicted classification result of any sample that is distributed in the same way as the training set. The result is highly readable, interpretable, and the important calculation method is reasonable and has low computational complexity. It can solve the problems of existing technologies, such as the attention matrix not being able to interpret the model well and the substitution comparison method not being accurate and intuitive enough.

[0065] Compared to the interpretability methods of attention mechanisms, this invention realizes an interpretable method that associates classification results with input features, overcoming the problem that the interpretability methods of attention mechanisms can only explain the importance weights of elements at different positions in the sequence.

[0066] Compared to the interpretability operation achieved by the substitution comparison method, its computational complexity is O(C*T*V), where C is the number of categories, T is the length of the input text, and V is the vocabulary size. This invention overcomes the sensitivity of the substitution comparison method to word substitutions at the decision edge in the sample, exhibiting high robustness and low computational complexity of O(C*T). Furthermore, it can display the importance of each position with continuous probabilistic values, making it easier for users to capture important key factors in the sample.

[0067] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or essential characteristics. Therefore, the embodiments should be considered in all respects as exemplary and non-limiting, and the scope of the invention is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention. No reference numerals in the claims should be construed as limiting the scope of the claims.

[0068] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

Claims

1. A method for probabilistically locating key classification positions in input samples of a text classification model, characterized in that, include: S1: Load the already trained parallelized text classification model; S2: Read the text to be predicted from the storage device; S3: Preprocess the text to be predicted to obtain a word segmentation sequence; S4: Map the word segmentation sequence to a vocabulary index sequence ; S5: Input the vocabulary index sequence X into the text classification model; S6: Perform forward propagation calculations for the classification model to obtain the highest-dimensional feature vector matrix located before the pooling layer. , where the matrix The dimension is (T, H), where T is the same length as the word index sequence, and H is the number of hidden layer nodes. matrix elements This represents the feature vector obtained after the word segmentation at position t in a text sequence of length T is computed through the forward propagation of the model; S7: Map the fully connected layer parameters of each classification category as weights onto the feature vector obtained in S6 to obtain the probabilistic contribution value of the classification prediction result on the highest-dimensional feature vector; the mapping formula is: (1) in, This represents the importance of position t in the high-dimensional feature sequence to the classification result, which is the probabilistic contribution value of the classification prediction result to the highest-dimensional feature vector. The larger the value, the higher the contribution of position t to the classification result; It is a probabilistic function; This represents the feature vector corresponding to the t-th position in the text sequence. ; This represents the parameters corresponding to category c in the fully connected layer. ; S8: Map the probabilistic contribution value of the classification prediction result on the highest dimension feature vector to each position of the lowest dimension input feature, i.e. the word index sequence X, in a one-to-one correspondence manner to obtain the probabilistic contribution value mapped to the lowest dimension input feature. S9: The probabilistic contribution values ​​mapped to the lowest-dimensional input features are transformed into heatmaps and superimposed on the text sequence to create an interpretable visualization effect, thus completing the probabilistic localization of key classification positions in the input samples of the text classification model.

2. The method for probabilistically locating key classification positions in input samples of a text classification model according to claim 1, characterized in that, The parallelized text classification model loaded by S1 is either a Transformers model, a Textcnn model, or an Lstm sequence model.

3. The method for probabilistically locating key classification positions in input samples of a text classification model according to claim 1, characterized in that, S2 performs stop word removal and word segmentation preprocessing on the text to be predicted.

4. The method for probabilistically locating key classification positions in input samples of a text classification model according to claim 1, characterized in that, Specifically, S4 yields a vocabulary index sequence of length T. A vocabulary index sequence of length T The index value of the word segment at position t in the vocabulary is denoted as... .

5. A method for probabilistically locating key classification positions in input samples of a text classification model according to claim 1, characterized in that, The formula for calculating the probabilistic function is as follows: (2) Where z is the function input.

6. The method for probabilistically locating key classification positions in input samples of a text classification model according to claim 1, characterized in that, S8 calculates the probabilistic contribution value of the classification prediction result on the highest-dimensional feature vector. It maps to each position of the lowest-dimensional input feature in a one-to-one correspondence manner.

Citation Information

Patent Citations

  • Performance evaluation method and device of text classification model interpretability method

    CN111597423A

  • Time sequence classification method, system, medium and device based on multi-representation learning

    CN112925822A

  • Text classification method and device and model training method

    CN111475642A

  • BERT-based multi-feature fine-grained Chinese short text sentiment classification method

    CN114443845A