Visual analysis method and system for natural language processing neural network model
The visual analysis method and system for neural network models in natural language processing address the challenge of analyzing diverse architectures by calculating mutual information and visualizing word and sample importance, enhancing user understanding and model performance.
Patent Information
- Application Number
- CN202111014678.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-31
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2041-08-31
AI Technical Summary
Existing methods for analyzing neural network models in natural language processing are limited to specific structures and lack a universal method for comparing and analyzing models with different architectures, leading to poor user experience and difficulty in understanding and improving model performance.
A visual analysis method and system that calculates mutual information between words in a training corpus and semantic vectors to determine word importance, identifies abnormal words and samples, and performs hierarchical clustering to visualize grammatical structures, enabling comparative analysis of neural network models with different architectures.
Enables effective identification and diagnosis of problems in neural network models, improving user experience by allowing for comparative analysis and targeted improvements in model performance through multi-level visualization and interactive analysis.
Smart Images

Figure CN113792553B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language processing technology, and in particular to a visualization analysis method and system for a natural language processing neural network model. Background Art
[0002] In recent years, deep learning technology applied to natural language processing has developed rapidly. From convolutional neural network models (CNN) and long short-term memory neural network models (LSTM), to different deep models based on deep self-attention transformer networks (Transformer), the performance of natural language processing tasks has been continuously improved.
[0003] In order to improve the performance of natural language processing tasks, these deep neural network model architectures have become increasingly complex and diverse. For example, the recent BERT neural network model dedicated to natural language processing contains hundreds of millions of parameters. Compared with traditional neural network models such as convolutional neural network models and recurrent neural network models, the BERT neural network model does not require loops and convolution structures, but relies on attention mechanisms. These complex and diverse architectures make it a challenge to understand and compare the internal workings of these neural network models and seek further improvements when performing natural language processing tasks.
[0004] However, most existing interpretation methods for natural language processing neural network models are limited to certain specific network structures, and lack a consistent and universal method for analyzing neural network models with different architectures and parameters. For example, existing neural network model visualization tools for natural language processing can only provide users with analysis information for a specific structural neural network model used in natural language processing, but cannot support the analysis of neural network models with other structures, and cannot enable users to compare and analyze different neural network models, resulting in a poor user experience. Summary of the invention
[0005] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0006] To this end, the first purpose of this application is to propose a visual analysis method for natural language processing neural network models, so as to implement analysis of deep neural network models for natural language processing with different architectures and different working modes, so that users can effectively identify and diagnose problems from the neural network model and fix them, thereby establishing a deep neural network model with better performance.
[0007] The second objective of this application is to propose a visual analysis system for natural language processing neural network models.
[0008] The third objective of the present application is to provide a computer device.
[0009] A fourth object of the present application is to provide a non-transitory computer-readable storage medium.
[0010] To achieve the above-mentioned purpose, the second embodiment of the present application proposes a visualization analysis method for a natural language processing neural network model, the method comprising:
[0011] Receiving a neural network model and a training corpus, wherein the training corpus is used to train the neural network model;
[0012] Calculating a first mutual information between each word in the training corpus and a semantic vector output by an output layer in the neural network model, and obtaining the importance of each word in the training corpus to the neural network model according to the first mutual information;
[0013] Visualize each word in the training corpus and its importance to the neural network model.
[0014] Optionally, in the embodiment of the present application, after visually displaying each word in the training corpus and its importance to the neural network model, the method further includes:
[0015] Analyzing the importance to determine abnormal words in the training corpus, and using the importance of the abnormal words to the neural network model as a first abnormal value;
[0016] The abnormal phenomenon of sample skew in the neural network model is determined based on the first outlier value and is visualized.
[0017] Optionally, in the embodiment of the present application, after calculating the first mutual information between each word in the training corpus and the semantic vector output by the output layer in the neural network model, the method further includes:
[0018] The plurality of the first mutual information are combined into a first mutual information vector, wherein the first mutual information vector is obtained by the following steps:
[0019] Adding Gaussian noise to the training samples;
[0020] Constructing a loss function about the first mutual information vector according to the training sample and the Gaussian noise;
[0021] The loss function about the first mutual information vector is estimated by maximum likelihood to minimize the loss function, a first Gaussian noise is calculated, and the first mutual information vector is obtained according to the first Gaussian noise; wherein,
[0022] The expression of the loss function is:
[0023]
[0024] in, is the training sample after adding Gaussian noise, Represents ∈ i Yes Obedience Gaussian noise distributed, φ represents the neural network model, S represents the semantic vector output by the training sample in the output layer through the neural network model φ, represents the variance of the semantic vector output by the neural network model φ at the output layer for all training samples in the training corpus, Express The mathematical expectation of , K and λ are taken as empirical values between 0 and 1.
[0025] Optionally, in the embodiment of the present application, obtaining the importance of each word in the training corpus to the neural network model according to the first mutual information specifically includes:
[0026] Obtain the frequency of each word appearing in the training corpus, and the contribution of each word to the semantic vector output by the neural network model at the output layer;
[0027] The importance is calculated according to the word frequency and the word frequency; wherein the importance is calculated by the following formula:
[0028] M=log(C(w)+1.0)*G(w)
[0029] Wherein, M is the importance of each word to the neural network model, w is each word in the training corpus, C(w) is the frequency of each word appearing in the training corpus, and G(w) is the mean of the first mutual information between each word and the semantic vector output by the neural network model in the output layer.
[0030] Optionally, in the embodiment of the present application, after receiving the neural network model and the training corpus, the method further includes:
[0031] Calculating the prediction score of each training sample in the training corpus for the neural network model and the semantic vector output by the output layer;
[0032] The prediction score of the neural network model and the semantic vector output by the output layer are projected by projection technology to obtain the projection coordinates of each training sample and perform visual display.
[0033] Optionally, in the embodiment of the present application, after the prediction score of the neural network model and the semantic vector output by the output layer are projected by the projection technology to obtain the projection coordinates of each training sample and visualize them, the method further includes:
[0034] Analyzing the importance to determine abnormal samples in the training corpus, and using the projection coordinates of the abnormal samples on the neural network model as second abnormal values;
[0035] The abnormal phenomenon of sample skew in the neural network model is determined based on the second outlier value and is visualized.
[0036] Optionally, in the embodiment of the present application, after receiving the neural network model and the training corpus, the method further includes:
[0037] Calculating a second mutual information matrix between each training sample in the training corpus and each intermediate layer of the neural network model;
[0038] Extracting first multiple second mutual information column vectors between each training sample and multiple intermediate layers of the neural network model according to the second mutual information matrix, wherein each element in a second mutual information column vector indicates a second mutual information value of each word contained in a training sample for a certain intermediate layer;
[0039] Performing hierarchical clustering on the first plurality of second mutual information column vectors to obtain a grammatical structure of each training sample at each intermediate layer, and calculating the similarity between any two elements in the first plurality of second mutual information column vectors;
[0040] The similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors is visualized.
[0041] Optionally, in the embodiment of the present application, after visually displaying the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors, the method further includes:
[0042] Analyze the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors to determine abnormal grammatical structures and / or abnormal similarities among all the obtained grammatical structures and similarities, and use the abnormal grammatical structures and / or abnormal similarities as third abnormal values;
[0043] The abnormal phenomenon of sample skew in the neural network model is determined based on the third abnormal value and is visualized.
[0044] Optionally, in an embodiment of the present application, a second plurality of second mutual information column vectors corresponding to training samples containing the same word in the training corpus and the plurality of intermediate layers of the neural network model are obtained according to the second mutual information matrix, and the second mutual information between the same word and the semantic vector output by the output layer in the neural network model is calculated;
[0045] The words corresponding to the element values contained in the second plurality of second mutual information column vectors and being higher than the threshold value of the second mutual information are displayed.
[0046] Optionally, in the embodiment of the present application, words corresponding to element values higher than the threshold value of the second mutual information contained in the displayed second plurality of second mutual information column vectors are analyzed to determine abnormal words and use them as fourth abnormal values;
[0047] The abnormal phenomenon of sample skew in the neural network model is determined based on the fourth abnormal value and is visualized.
[0048] To achieve the above-mentioned purpose, the second embodiment of the present application proposes a visual analysis system for a natural language processing neural network model, the system comprising:
[0049] A receiving module, used for receiving a neural network model and a training corpus, wherein the training corpus is used for training the neural network model;
[0050] A processing module, used to calculate the first mutual information between each word in the training corpus and the semantic vector output by the output layer in the neural network model, and obtain the importance of each word in the training corpus to the neural network model according to the first mutual information;
[0051] The visualization module is used to visualize each word in the training corpus and its importance to the neural network model.
[0052] Optionally, in an embodiment of the present application, the visual analysis system further includes an abnormality determination module, the abnormality determination module being used to analyze the importance to determine abnormal words in the training corpus, and use the importance of the abnormal words to the neural network model as a first abnormal value;
[0053] The visualization module is also used to determine the abnormal phenomenon of sample skew in the neural network model based on the first abnormal value and perform a visual display.
[0054] Optionally, in the embodiment of the present application, the processing module is further used to:
[0055] The plurality of the first mutual information are combined into a first mutual information vector, wherein the first mutual information vector is obtained by the following steps:
[0056] Adding Gaussian noise to the training samples;
[0057] Constructing a loss function about the first mutual information vector according to the training sample and the Gaussian noise;
[0058] The loss function about the first mutual information vector is estimated by maximum likelihood to minimize the loss function, a first Gaussian noise is calculated, and the first mutual information vector is obtained according to the first Gaussian noise; wherein,
[0059] The expression of the loss function is:
[0060]
[0061] in, is the training sample after adding Gaussian noise, Represents ∈ i Yes Obedience Gaussian noise distributed, φ represents the neural network model, S represents the semantic vector output by the training sample in the output layer through the neural network model φ, represents the variance of the semantic vector output by the neural network model φ at the output layer for all training samples in the training corpus, Express The mathematical expectation of , K and λ are taken as empirical values between 0 and 1.
[0062] Optionally, in an embodiment of the present application, the processing module is further used to: calculate a second mutual information matrix between each training sample in the training corpus and each intermediate layer of the neural network model;
[0063] Extracting first multiple second mutual information column vectors between each training sample and multiple intermediate layers of the neural network model according to the second mutual information matrix, wherein each element in a second mutual information column vector indicates a second mutual information value of each word contained in a training sample for a certain intermediate layer;
[0064] Performing hierarchical clustering on the first plurality of second mutual information column vectors to obtain a grammatical structure of each training sample at each intermediate layer, and calculating the similarity between any two elements in the first plurality of second mutual information column vectors;
[0065] The visualization module is further used to visualize the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors.
[0066] Optionally, in the embodiment of the present application, the abnormality determination module is further used to: analyze the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors to determine abnormal grammatical structures and / or similarity anomalies among all the obtained grammatical structures and similarities, and use the abnormal grammatical structures and / or similarity anomalies as third abnormality values;
[0067] The visualization module is also used to determine the abnormal phenomenon of sample skew in the neural network model according to the third abnormal value and perform a visual display.
[0068] Optionally, in an embodiment of the present application, the processing module is further used to obtain a second plurality of second mutual information column vectors corresponding to the training samples containing the same word in the training corpus and the plurality of intermediate layers of the neural network model according to the second mutual information matrix, and calculate the second mutual information between the same word and the semantic vector output by the output layer in the neural network model;
[0069] The visualization module is further used to display words corresponding to element values contained in the second plurality of second mutual information column vectors and having values higher than a threshold value of the second mutual information.
[0070] Optionally, in the embodiment of the present application, the abnormality determination module is further used to analyze the words corresponding to the element values contained in the displayed second plurality of second mutual information column vectors that are higher than the threshold of the second mutual information, so as to determine the abnormal words and use them as the fourth abnormal values;
[0071] The visualization module is also used to determine the abnormal phenomenon of sample tilt in the neural network model according to the fourth abnormal value and perform a visual display.
[0072] To achieve the above-mentioned purpose, the third aspect embodiment of the present application proposes a computer device, characterized in that it includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, it implements the method described in the first aspect embodiment of the present application.
[0073] In order to achieve the above-mentioned objectives, the fourth aspect embodiment of the present application proposes a non-temporary computer-readable storage medium, on which a computer program is stored, characterized in that when the computer program is executed by a processor, it implements the method described in the first aspect embodiment of the present application.
[0074] In summary, the visualization analysis method, visualization analysis system, computer device and non-temporary computer-readable storage medium for natural language processing neural network model of the embodiment of the present application, the scheme receives a neural network model and a training corpus for training the neural network model; calculates the first mutual information between each word in the training corpus and the semantic vector output by the output layer in the neural network model, obtains the importance of each word in the training corpus to the neural network model according to the first mutual information; and visualizes each word in the training corpus and its importance to the neural network model. Therefore, the above method can realize comparative analysis and visualization of neural network models with different structures, thereby improving user experience.
[0075] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0077] Figure 1 A flowchart of a visual analysis method for a natural language processing neural network model provided in Example 1 of the present application;
[0078] Figure 2 A flowchart of the first visual analysis method for a natural language processing neural network model provided in Example 2 of the present application;
[0079] Figure 3 A flowchart of a second visual analysis method for a natural language processing neural network model provided in Example 2;
[0080] Figure 4 A flowchart of a third visual analysis method for a natural language processing neural network model provided in Example 2;
[0081] Figure 5 A schematic diagram of the structure of the first visual analysis system for a natural language processing neural network model provided in Example 3 of the present application;
[0082] Figure 6 A schematic diagram of the structure of a second visual analysis system for a natural language processing neural network model provided in Example 3; and
[0083] Figure 7 An exemplary two-dimensional plane diagram output by the visualization module of the system for visual analysis in Example 3. DETAILED DESCRIPTION
[0084] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0085] As mentioned above, in recent years, deep learning technology applied to natural language processing has developed rapidly. Convolutional neural network models (CNN), long short-term memory neural network models (LSTM), and different deep models based on deep self-attention transformer networks (Transformer) have been proposed, and the performance of natural language processing tasks has been continuously improved. In order to improve the performance of natural language processing tasks, the architectures of these deep neural network models have become more and more complex and diverse. For example, the recent BERT neural network model dedicated to natural language processing contains hundreds of millions of parameters. Compared with traditional neural network models such as convolutional neural network models and recurrent neural network models, the BERT neural network model does not require loops and convolution structures, but relies on attention mechanisms. These complex and diverse architectures make it a challenge to understand and compare the internal workings of these neural network models and seek further improvements when performing natural language processing tasks. However, most of the existing interpretation methods for natural language processing neural network models are limited to certain specific network structures, and lack a consistent and universal method for analyzing neural network models with different architectures and parameters. For example, existing neural network model visualization tools applied to natural language processing can only provide users with analysis information for a specific structural neural network model applied to natural language processing, but cannot support the analysis of other structural neural network models, and cannot enable users to compare and analyze different neural network models, resulting in poor user experience. Therefore, there is an urgent need for a unified method to help experts in the field of natural language processing analyze and compare different neural network models in order to deepen their understanding of the models and make targeted improvements.
[0086] In the embodiments of the present application, a method and system for visually analyzing a neural network model with no structural characteristics for natural language processing can be provided to the user, thereby improving the performance of the neural network model for natural language processing. In addition, the problems existing in the neural network model can be better displayed through visualization technology, and better interaction with the user can be performed to compare and analyze neural network models with different structures or different intermediate layers of the same neural network model, thereby improving the user experience.
[0087] In addition, when observing the performance of the neural network model in the training corpus, the embodiment of the present application receives the query condition input by the user, and when the query condition is determined to be to view the contribution information of the target sample to the prediction of the neural network model, the performance information of the target sample and the word corresponding to the sample to the prediction of the neural network model is displayed through the training sample visualization module; when the query condition is determined to be to view the contribution information of the target word to the prediction of the neural network model, the contribution information of the target word to the prediction of the neural network model in different contexts is displayed through the visualization module. The multi-level visualization view and interactive analysis can help users explore the limitations of the neural network model and determine the root causes of its poor performance.
[0088] The following describes a visualization analysis method and system for a natural language processing neural network model according to an embodiment of the present application with reference to the accompanying drawings.
[0089] Example 1
[0090] Figure 1 This is a flowchart of the visual analysis method for the natural language processing neural network model provided in Example 1 of the present application.
[0091] In view of the above problems, the present application provides a visualization analysis method for a natural language processing neural network model, such as Figure 1 As shown, the method 20 comprises the following steps:
[0092] Step 201, receiving a neural network model and a training corpus, wherein the training corpus is used to train the neural network model.
[0093] In an embodiment of the present application, a neural network model for natural language processing includes an input layer, multiple intermediate layers and an output layer. The training corpus used to train the neural network model includes multiple training samples, each training sample is a sentence or paragraph composed of multiple words, and the output layer outputs a semantic vector.
[0094] Specifically, the embodiments of the present application can receive uploaded deep neural network models for natural language processing and training corpora for training deep neural network models from users through a graphical user interface or user commands; the deep neural network models for natural language processing and training corpora for training deep neural network models can also be stored in internal or external storage media and directly read when needed; the deep neural network models for natural language processing and training corpora for training deep neural network models can also be obtained through network transmission. In addition, the deep neural network models for natural language processing and training corpora for training deep neural network models can also be obtained through other methods, which are not listed here one by one.
[0095] The neural network model for natural language processing in the embodiment of the present application includes an input layer, multiple intermediate layers and an output layer, wherein the multiple intermediate layers are regarded as functions f1, f2, ..., fn, and the neural network model 101 for natural language processing is regarded as function f, wherein function f is a composite function composed of functions f1, f2, ..., fn. The input layer receives an input vector obtained by encoding all words contained in a training sample (sentence / paragraph), and the output layer outputs the semantic vector defined in the training sample (sentence / paragraph). These methods of encoding, definition, and calculation of neural network functions are well known to those skilled in the art and will not be repeated here.
[0096] Step 202, calculate the first mutual information between each word in the training corpus and the semantic vector output by the output layer in the neural network model, and obtain the importance of each word in the training corpus to the neural network model according to the first mutual information.
[0097] In the embodiment of the present application, the first mutual information between each word in each training sample in the training corpus and the semantic vector output by the output layer of the neural network model is calculated, and the first mutual information ζ of each word in each training sample in the training corpus is calculated. i The meaning is the importance of each word to the semantic vector output by the output layer of the neural network model. Specifically, when the importance of the word to the semantic vector output by the output layer is high, the acceptable Gaussian noise that does not cause a significant change in the semantic vector output by the output layer is smaller; when the importance of the word to the semantic vector output by the output layer is low, the acceptable Gaussian noise that does not cause a significant change in the semantic vector output by the output layer is larger. The first mutual information between all words in each training sample in the training corpus and the semantic vector output by the output layer of the neural network model constitutes the first mutual information vector ζ, ζ i is the value of ζ in a certain dimension, is the first mutual information value of the semantic vector output by the output layer of each word of a specific training sample and the neural network model, ζ can be calculated as follows: first, Gaussian noise σ is added to a specific training sample, where σ is the Gaussian noise σ of each word in the specific training sample. i The vector is composed of, and then the loss function is set as:
[0098]
[0099] in, represents a specific training sample after adding Gaussian noise, Represents ∈ i Yes Obedience Gaussian noise distribution, represents the neural network model 101, and S represents the neural network model through which the specific training sample is trained. The semantic vector output at the output layer is Represents a neural network model The variance of the semantic vectors output by all training samples in the training corpus 102 at the output layer is: Express The mathematical expectation of K and λ can be taken as empirical values between 0 and 1; finally, the maximum likelihood estimation is used for L(σ) to minimize the loss function L(σ), and σ0 is calculated, then ζ=-log(σ0).
[0100] Further, in an embodiment of the present application, obtaining the importance of each word in the training corpus to the neural network model according to the first mutual information specifically includes:
[0101] Calculating the mean of all the first mutual information to obtain the first mutual information mean;
[0102] Obtain the frequency of each word appearing in the training corpus;
[0103] The importance is calculated by using the first mutual information mean and the word frequency; wherein the importance is calculated by the following formula:
[0104] M=log(C(w)+1.0)*G(w)
[0105] Wherein, M is the importance of each word to the neural network model, w is each word in the training corpus, C(w) is the frequency of each word appearing in the training corpus, and G(w) is the first mutual information mean.
[0106] Specifically, the importance of each word in all the words contained in the training corpus in the embodiment of the present application to the neural network model can be calculated using the following formula:
[0107] M1 = log (word frequency (w) = 1.0) * contribution (w)
[0108] M1 represents the importance of a specific word to the neural network model, the word frequency (w) represents the frequency of the specific word in the training corpus, and the contribution (w) represents the mean of the first mutual information between the specific word and the semantic vector output by the neural network model at the output layer in each training sample containing the specific word in the training corpus.
[0109] Step 203: Visually display each word in the training corpus and its importance to the neural network model.
[0110] In an embodiment of the present application, the size of each word displayed is determined by its importance to the neural network model, and word cloud technology is used to arrange the position of the words displayed on the screen. Word cloud technology has multiple definitions in the prior art, and any one of the definitions can be used here.
[0111] In summary, the method disclosed in the embodiment of the present application receives a neural network model and a training corpus for training the neural network model; calculates the first mutual information between each word in the training corpus and the semantic vector output by the output layer of the neural network model, obtains the importance of each word in the training corpus to the neural network model according to the first mutual information; and visualizes each word in the training corpus and its importance to the neural network model. Therefore, the above method can realize comparative analysis and visual display of neural network models with different structures, thereby improving user experience.
[0112] Example 2
[0113] Figure 2 This is a flowchart of the visual analysis method for the natural language processing neural network model provided in Example 2 of the present application.
[0114] like Figure 2 As shown, the visualization analysis method 300 provided in the embodiment of the present application includes the following steps:
[0115] Step 310, obtaining a neural network model for natural language processing and a training corpus for training the neural network model, wherein the neural network model comprises an input layer, multiple intermediate layers and an output layer, and the training corpus comprises multiple training samples, each training sample being a sentence or paragraph consisting of multiple words.
[0116] Step 320, calculating the first mutual information between each word in each training sample in the training corpus and the semantic vector output by the output layer of the neural network model.
[0117] Step 330, using the calculated first mutual information, obtain the importance of each word in all the words included in the training corpus to the neural network model.
[0118] Step 340 displays each word among all the words contained in the training corpus and its importance to the neural network model.
[0119] Step 350, in response to receiving and displaying that the importance of a certain word to the neural network model is an abnormal value, determining that an abnormal phenomenon of sample skew occurs in the neural network model.
[0120] In the embodiment of the present application, the first mutual information of all words in each training sample in the training corpus and the semantic vector output by the output layer of the neural network model constitutes a first mutual information vector ζ, ζ i is the value of ζ in a certain dimension, is the first mutual information value of the semantic vector output by the output layer of each word of the specific training sample and the output of the neural network model, and ζ is calculated as follows:
[0121] (1) Add Gaussian noise σ to a specific training sample, where σ is the Gaussian noise σ of each word in the specific training sample. i The vector composed of
[0122] (2) Set the loss function to:
[0123]
[0124] in, represents a specific training sample after adding Gaussian noise, Represents ∈ i Yes Obedience Gaussian noise distribution, represents the neural network model, and S represents the specific training sample through the neural network model The semantic vector output at the output layer is Represents a neural network model The variance of the semantic vector output by all training samples in the training corpus at the output layer, Express The mathematical expectation of , K and λ are taken as empirical values between 0 and 1; and
[0125] (3) Use maximum likelihood estimation for L(σ) to minimize the loss function L(σ), and calculate σ0, then ζ = -log(σ0).
[0126] In the embodiment of the present application, the following formula is used to calculate the importance of each word to the neural network model:
[0127] M = log(word frequency(w)+1.0)*contribution(w)
[0128] Where M represents the importance of a specific word to the neural network model, the word frequency (w) represents the frequency of the specific word in the training corpus, and the contribution (w) represents the mean of the first mutual information between the specific word and the semantic vector output by the neural network model at the output layer in each training sample containing the specific word in the training corpus.
[0129] Figure 3A flowchart of a method 400 for determining an abnormal phenomenon of sample labeling abnormality in a neural network model during deep neural network model training according to an embodiment of the present invention is shown, wherein method 400 is a subsequent preferred step of method 300, such as Figure 3 As shown, the following steps are included:
[0130] Step 410, calculating the prediction score of each training sample in the training corpus for the neural network model and the semantic vector output by the output layer.
[0131] Step 420: Use projection technology to obtain the projection coordinates of each training sample composed of the predicted score of each training sample in the training corpus for the neural network model and the semantic vector output by the output layer.
[0132] Step 430 : Display each training sample in a graphical form on a two-dimensional plane for display according to the projection coordinates of each training sample.
[0133] Step 440, in response to receiving and displaying that the projection coordinates of a certain training sample are abnormal values, determining that an abnormal phenomenon of sample labeling abnormality occurs in the neural network model.
[0134] Figure 4 A flowchart of a method 500 for determining an abnormal phenomenon of a network structure problem in a neural network model during a deep neural network model training process according to an embodiment of the present invention is shown. It can be understood that method 400 is Figure 2 or Figure 3 The subsequent preferred steps are as follows: Figure 4 As shown, the method 500 includes the following steps:
[0135] Step 510, calculating the second mutual information matrix between each training sample in the training corpus and all intermediate layers of the neural network model.
[0136] Step 520, using the calculated second mutual information matrix, extract the first multiple second mutual information column vectors between each training sample in the training corpus and multiple intermediate layers of the neural network model, wherein each element in a second mutual information column vector indicates the second mutual information value of each word contained in a training sample for a certain intermediate layer.
[0137] Step 530: Perform hierarchical clustering on the first plurality of second mutual information column vectors to obtain a grammatical structure of each training sample at each intermediate layer.
[0138] Step 540: Calculate the similarity between any two elements in the first plurality of second mutual information column vectors.
[0139] Step 550 , in response to receiving a selection of a training sample to be displayed, displaying the grammatical structure of the selected training sample at each intermediate layer and the similarity between any two elements in the first plurality of second mutual information column vectors.
[0140] Step 560, in response to receiving and displaying that a certain grammatical structure or element similarity of a certain training sample is an abnormal value, determining an abnormal phenomenon of a network structure problem in the neural network model.
[0141] Step 570, in response to receiving the threshold of the second mutual information and the selection of another specific word to be displayed, for all training samples in the training corpus containing the other specific word and the second multiple second mutual information column vectors of multiple intermediate layers of the neural network model, display the words corresponding to the element values contained in the second multiple second mutual information column vectors that are higher than the threshold of the second mutual information.
[0142] Step 580, in response to receiving and displaying that a certain word corresponding to an element value higher than the threshold of the second mutual information contained in the second plurality of second mutual information column vectors is an abnormal value, determining an abnormal phenomenon of a network structure problem in the neural network model.
[0143] In the embodiment of the present application, the second mutual information matrix τ, τ i,j The meaning of is the importance of the i-th word in each training sample to the j-th intermediate layer output vector of the neural network model. The second mutual information matrix τ is calculated as follows:
[0144] (1) Add Gaussian noise σ to a specific training sample, where σ is the Gaussian noise σ of each word in the specific training sample. i The vector composed of
[0145] Set the loss function to:
[0146]
[0147] in, represents the specific training sample after adding Gaussian noise, Represents ∈ i Yes Obedience Gaussian noise distribution, represents the function from the input layer of the neural network model 101 to the intermediate layer, Represents a neural network model The variance of the output vector of the intermediate layer for all training samples in the training corpus 102 is: Express The mathematical expectation of , K and λ can be taken as empirical values between 0 and 1;
[0148] (2) Use the maximum likelihood estimation to minimize the loss function L(σ) and calculate σ1. Then the mutual information column vector τ of all words in the training sample for the output vector of the intermediate layer is j = -log(σ1);
[0149] (3) Obtaining a second mutual information matrix τ of all training samples in the training corpus with respect to all intermediate layer output vectors of the neural network model.
[0150] By using the above-mentioned method for visual analysis of a deep neural network model for natural language processing, the user can observe the performance of the neural network model on the training corpus and receive the user's query conditions. When the query condition is determined to be to view the contribution information of the target sample to the prediction of the neural network model, the performance information of the target sample and the word corresponding to the sample to the prediction of the neural network model is displayed; when the query condition is determined to be to view the contribution information of the target word to the prediction of the neural network model, the contribution information of the target word to the prediction of the neural network model in different contexts is displayed. The above-mentioned method for visual analysis of a deep neural network model for natural language processing, wherein the multi-level visualization view and interactive analysis can help users explore the limitations of the neural network model and determine the root cause of the poor performance of the neural network model.
[0151] Example 3
[0152] In order to implement the above embodiments, the present application also proposes a visualization analysis system for a natural language processing neural network model.
[0153] Figure 5 A schematic diagram of the structure of the first visual analysis system for a natural language processing neural network model provided in Example 3 of the present application.
[0154] like Figure 5 As shown, the visualization analysis system 10 for natural language processing neural network model proposed in this application includes:
[0155] A receiving module 11 is used to receive a neural network model and a training corpus, wherein the training corpus is used to train the neural network model;
[0156] A processing module 12 is used to calculate the first mutual information between each word in the training corpus and the semantic vector output by the output layer in the neural network model, and obtain the importance of each word in the training corpus to the neural network model according to the first mutual information;
[0157] The visualization module 13 is used to visualize each word in the training corpus and its importance to the neural network model.
[0158] Furthermore, the visualization analysis system of the embodiment of the present application further includes an abnormality determination module, which is used to analyze the importance to determine abnormal words in the training corpus, and use the importance of the abnormal words to the neural network model as a first abnormal value;
[0159] The visualization module is also used to determine the abnormal phenomenon of sample skew in the neural network model based on the first abnormal value and perform a visual display.
[0160] Figure 6 The schematic diagram of the structure of the second visual analysis system for natural language processing neural network model provided in Example 3 is as follows: Figure 6 As shown, the visual analysis system 100 includes: a receiving module 110 , a processing module 120 , a visualization module 130 and an abnormality determination module 140 .
[0161] Further, in an embodiment of the present application, the receiving module 110 is configured to receive a neural network model 101 for natural language processing and a training corpus 102 for training the neural network model 101. The neural network model 101 for natural language processing comprises an input layer, a plurality of intermediate layers and an output layer, and the training corpus 102 for training the neural network model 101 comprises a plurality of training samples, each of which is a sentence or paragraph consisting of a plurality of words, and the output layer outputs a semantic vector. The processing module 120 is configured to calculate the first mutual information between each word in each training sample in the training corpus and the semantic vector output by the output layer of the neural network model 101, and to obtain the importance of each word in all words contained in the training corpus 102 to the neural network model 101 using the calculated first mutual information. The visualization module 130 is configured to display each word in all words in the training corpus 102 and its importance to the neural network model 101. In addition, the receiving module is further configured to receive the importance of a certain word to the neural network model 101 displayed by the visualization module 130 as an abnormal value. The abnormality determination module 140 is configured to determine that an abnormal phenomenon of sample skew occurs in the neural network model 101 in response to the reception module 110 receiving the importance of a certain word to the neural network model 101 displayed by the visualization module 130 as an abnormal value. The visual analysis system 100 for a deep neural network model for natural language processing can be implemented as an application on a general computer system, or as an application on a server system, or as a network application, or as an application on a cloud platform.
[0162] In an embodiment of the present application, the receiving module 110 may be configured to receive the uploaded deep neural network model 101 for natural language processing and the training corpus 102 for training the deep neural network model from the user through a graphical user interface or a user command. The receiving module 110 may also be configured to store the deep neural network model 101 for natural language processing and the training corpus 102 for training the deep neural network model in an internal or external storage medium, and read by the receiving module 110. The receiving module 110 may also be configured to obtain the deep neural network model 101 for natural language processing and the training corpus 102 for training the deep neural network model through network transmission, and so on.
[0163] In the embodiment of the present application, the neural network model 101 for natural language processing includes an input layer, multiple intermediate layers, and an output layer, wherein the multiple intermediate layers are regarded as functions f1, f2, ..., f n , the neural network model 101 for natural language processing is regarded as a function f, where function f is a function f1, f2, ..., f n The input layer receives the input vector obtained by encoding all the words contained in a training sample (sentence / paragraph), and the output layer outputs the semantic vector defined in the training sample (sentence / paragraph). These encoding, definition, and neural network function calculation methods are well known to those skilled in the art and will not be described in detail here.
[0164] In the embodiment of the present application, the processing module 120 can be configured to calculate the first mutual information between each word in each training sample in the training corpus 102 and the semantic vector output by the output layer of the neural network model 101, and the first mutual information ζ of each word in each training sample in the training corpus 102 is calculated. i The meaning is the importance of each word to the semantic vector output by the output layer of the neural network model 101. Specifically, when the importance of the word to the semantic vector output by the output layer is high, the acceptable Gaussian noise that does not cause a significant change in the semantic vector output by the output layer is smaller; when the importance of the word to the semantic vector output by the output layer is low, the acceptable Gaussian noise that does not cause a significant change in the semantic vector output by the output layer is larger. The first mutual information between all words in each training sample in the training corpus and the semantic vector output by the output layer of the neural network model constitutes a first mutual information vector ζ, ζ i is the value of ζ in a certain dimension, is the first mutual information value of the semantic vector output by the output layer of each word of a specific training sample and the neural network model, ζ can be calculated as follows: first, add Gaussian noise σ to a specific training sample, where σ is the Gaussian noise σ of each word in the specific training sample iThe vector is composed of, and then the loss function is set as:
[0165]
[0166] in, represents a specific training sample after adding Gaussian noise, Represents ∈ i Yes Obedience Gaussian noise distribution, represents the neural network model 101, and S represents the neural network model through which the specific training sample is trained. The semantic vector output at the output layer is Represents a neural network model The variance of the semantic vectors output by all training samples in the training corpus 102 at the output layer is: Express The mathematical expectation of K and λ can be taken as empirical values between 0 and 1; finally, the maximum likelihood estimation is used for L(σ) to minimize the loss function L(σ), and σ0 is calculated, then ζ=-log(σ0). These calculation methods are well known to those skilled in the art and will not be repeated here. The importance of each word in all the words contained in the training corpus 102 to the neural network model 101 can be calculated using the following formula:
[0167] M = log(word frequency(w)+1.0)*contribution(w)
[0168] Where M represents the importance of a specific word to the neural network model 101, the word frequency (w) represents the frequency of the specific word in the training corpus 102, and the contribution (w) represents the mean of the first mutual information between the specific word and the semantic vector output by the neural network model 101 at the output layer in each training sample containing the specific word in the training corpus 102.
[0169] The visualization module 130 may be configured to display each word contained in the training corpus 102 and its importance to the neural network model 101. In one embodiment, the display size of each word in the visualization module 130 is determined by its importance to the neural network model 101, and the word cloud technology is used to arrange the position of the word displayed on the screen. The word cloud technology has multiple definitions in the prior art. The present invention can adopt any definition. In addition, the receiving module 110 is also configured to receive the importance of a certain word displayed by the visualization module 130 to the neural network model 101 as an abnormal value. In one embodiment, the receiving module 110 may be configured to receive the importance of a certain word displayed by the visualization module 130 to the neural network model 101 as an abnormal value by clicking the mouse. In another embodiment, the receiving module 110 may also be configured to receive the importance of a certain word displayed by the visualization module 130 (for example, typing out the word) to the neural network model 101 as an abnormal value by keyboard tapping. In another embodiment, the receiving module 110 can also be configured to use a finger to select a word displayed on the display screen controlled by the visualization module 130 to be an outlier in terms of its importance to the neural network model 101, and so on.
[0170] In one embodiment, the processing module 120 may be further configured to calculate the prediction score of each training sample in the training corpus 102 for the neural network model 101 and the semantic vector output by the output layer.
[0171] In one embodiment, the visualization module 130 can be further configured to calculate the predicted score of each training sample in the training corpus 102 for the neural network model 101 and the semantic vector output by the output layer, and use the projection technology to obtain the projection coordinates composed of the two. The projection technology has multiple definitions in the prior art, and the present invention can adopt any one of the definitions. In a preferred embodiment, the t-SNE technology is used to project the semantic vector output by the output layer of each training sample in the training corpus 102 for the neural network model 101 to the horizontal coordinate, and the predicted score of each training sample in the training corpus 102 for the neural network model 101 is linearly projected to the vertical coordinate, and the horizontal coordinate and the vertical coordinate are combined to obtain a two-dimensional coordinate, and displayed in a two-dimensional plane for display as a graphic (such as a regular hexagon, a circle, etc.).
[0172] Figure 7An exemplary two-dimensional plane 200 output by the visualization module 130 of the system 100 for visually analyzing a deep neural network model for natural language processing according to an embodiment of the present invention is shown. The two-dimensional plane can be displayed on a display or on other output devices (such as a printer, etc.). The two-dimensional plane 200 shows several words in the training corpus 102, and the size of each word encodes its importance to the deep neural network model 101. The importance of a word to the deep neural network model 101 for natural language processing can be measured by the word frequency and average contribution of the word in the training corpus 102. The word "care" 210 appears in 3 different training samples in the training corpus 102. Assuming that its contributions in the three samples are 0.6, 0.7 and 0.5 respectively, the average contribution is (0.6+0.7+0.5) / 3=0.6, and its importance is log(3+1)*0.6=0.831; Figure 7 The largest word in the training corpus 102, "recommend", appears in 13 different training samples, with an average contribution of 0.55 and an importance of log(13+1)*0.55=1.45. Figure 7 The font size in is larger than "care". Figure 7 Also shown is a regular hexagon for representing each training sample, shown by the visualization module 130 of the system 100 for visually analyzing a deep neural network model for natural language processing according to an embodiment of the present invention. Among them, sample 220 represents a specific sample that appears in the training corpus 102, and its horizontal axis represents the one-dimensional projection coordinates of the semantic vector of the neural network model 101 of the training sample calculated by the t-SNE technology, and the normalized calculated value is 0.98 at this time; its vertical axis represents the one-dimensional projection coordinates of its predicted score of the neural network model 101 calculated by the t-SNE technology, and the normalized calculated value is 0.95 at this time; the calculated horizontal and vertical coordinates determine the sample 220 appears in Figure 7 The upper right corner position in the layout. In a preferred embodiment, when the calculated horizontal and vertical coordinates of multiple training samples are the same and the display appears to overlap, the corresponding multiple graphics can be merged into one graphic display. Those skilled in the art know that other projection methods can also be used.
[0173] In one embodiment, the receiving module 110 is further configured to receive the importance of a certain word displayed by the visualization module 130 as an abnormal value, and the abnormality determination module 140 is configured to determine that an abnormal phenomenon of sample skew occurs in the neural network model 101 in response to the receiving module 110 receiving the importance of a certain word displayed by the visualization module 130 as an abnormal value. Figure 7 In the example, if the visualization module 130 receives the user's input using the mouse / keyboard / touch screen finger to determine that the importance of the word "care" 210 is an abnormal value, the abnormality determination module 140 determines that the neural network model 101 has an abnormal phenomenon of sample tilt on the word "care" 210. In other words, in the neural network classifier shown for the sentiment classification task, the sample tilt phenomenon on the word "care" 210 indicates that the training samples in the training corpus 102 containing the word "care" are more labeled as negative sentiments, causing the neural network model 101 to mistakenly believe that the word "care" has negative sentiments.
[0174] In the embodiment of the present application, the visualization module 130 is further configured to receive the projection coordinates of the function composed of the prediction score of a certain sample displayed and the semantic vector output by the output layer as an abnormal value, and the abnormality determination module 140 is further configured to, in response to receiving the projection coordinates of the function composed of the prediction score of a certain sample displayed and the semantic vector output by the output layer as an abnormal value, determine that the abnormal phenomenon of sample labeling abnormality occurs in the neural network model 101. For example, Figure 7 In the example, if the visualization module 130 receives the user's input using the mouse / keyboard / touch screen finger to determine that the importance of sample 220 is an abnormal value, the abnormality determination module 140, in response to receiving the displayed importance of sample 220 as an abnormal value, determines that an abnormal phenomenon of sample labeling abnormality occurs on sample 220 in the neural network model 101. In other words, when the sample category label is inconsistent with the actual classification to which the sample belongs, it is considered that an abnormal phenomenon of sample labeling abnormality occurs.
[0175] In the embodiment of the present application, the processing module 120 is further configured to calculate the second mutual information matrix τ, τ of each training sample in the training corpus 102 and all intermediate layers of the neural network model 101. i,j The meaning of is the importance of the i-th word in each training sample to the output vector of the j-th intermediate layer of the neural network model 101. Specifically, when the importance of the word to the intermediate layer output vector is high, the acceptable Gaussian noise that does not cause a significant change in the intermediate layer output vector is smaller; when the importance of the word to the intermediate layer output vector is low, the acceptable Gaussian noise that does not cause a significant change in the intermediate layer output vector is larger. τ can be calculated as follows: First, add Gaussian noise σ to a specific training sample, where σ is the Gaussian noise σ of each word in the specific training sample i The loss function is set as:
[0176]
[0177] in, represents the specific training sample after adding Gaussian noise, Represents ∈ i Yes Obedience Gaussian noise distribution, represents the function from the input layer of the neural network model 101 to the intermediate layer, Represents a neural network model The variance of the output vector of the intermediate layer for all training samples in the training corpus 102 is: Express The mathematical expectation of K and λ can be taken as empirical values between 0 and 1. Use the maximum likelihood estimation to minimize the loss function L(σ) and calculate σ1. Then the mutual information column vector τ of all words in the training sample to the output vector of the intermediate layer is j =-log(σ1), thereby obtaining the second mutual information matrix τ of all training samples in the training corpus 102 for all intermediate layer output vectors of the neural network model 101.
[0178] In one embodiment, the processing module 120 is further configured to extract, using the calculated second mutual information matrix, a plurality of first second mutual information column vectors between each training sample in the training corpus 102 and a plurality of intermediate layers of the neural network model 101. For example, for a training sample "I like this movie" in the training corpus 102, which consists of 4 words, and the neural network model 101 consists of 6 intermediate layers, then the second mutual information matrix τ between the training sample "I like this movie" and all the intermediate layers of the neural network model 101 is a 4×6 matrix, τ 2,3The meaning is the second mutual information value between the second word "like" in the training sample and the third intermediate layer of the neural network model 101. The training sample and the six intermediate layers of the neural network model 101 have six second mutual information column vectors, and the vector lengths of the six second mutual information column vectors are all 4, indicating the second mutual information values of the four words in the training sample for the intermediate layer respectively. The processing module 120 is also configured to: perform hierarchical clustering on the first and second mutual information column vectors of each training sample in the training corpus 102 and the multiple intermediate layers of the neural network model 101, and obtain the hierarchical structure of each training sample in the training corpus 102 in the multiple intermediate layers of the neural network model 101, and the hierarchical structure is also considered to be the grammatical structure of each training sample in the training corpus 102 in the multiple intermediate layers of the neural network model 101. There are multiple definitions of hierarchical clustering methods in the prior art, and the present invention can adopt any one of the definitions. In a preferred embodiment, the first plurality of second mutual information column vectors are clustered using the Agglomerative Clustering technique to obtain a hierarchical clustering result, that is, the grammatical structure of each training sample in the training corpus 102 in multiple intermediate layers of the neural network model 101. The processing module 120 is also configured to: calculate the similarity of any two elements in the first plurality of second mutual information column vectors of multiple intermediate layers of the neural network model 101 for each training sample in the training corpus 102. . In a preferred embodiment, the cosine similarity can be used to calculate the similarity of any two elements in the first plurality of second mutual information column vectors. Those skilled in the art know that other calculation methods can also be used.
[0179] In an embodiment of the present application, the receiving module 110 is further configured to receive a selection of a training sample displayed by the visualization module; the visualization module 130 is further configured to, in response to the receiving module receiving the selection of a training sample, display the grammatical structure of the selected training sample in each intermediate layer of the neural network model 101 and the similarity of each training sample in the training corpus 102 to any two elements in the first and second mutual information column vectors of multiple intermediate layers of the neural network model 101; the receiving module 110 is also configured to receive a grammatical structure or element similarity of a training sample displayed by the visualization module 130 as an abnormal value; and the abnormality determination module 140 is further configured to determine that an abnormal phenomenon of a network structure problem has occurred in the neural network model 101 in response to receiving a grammatical structure or element similarity of a training sample displayed by the visualization module 130 as an abnormal value.
[0180] In an embodiment of the present application, the processing module 120 is further configured to use the calculated second mutual information matrix to obtain a second plurality of second mutual information column vectors of all training samples containing each word contained in the training corpus 102 and multiple intermediate layers of the neural network model 101.
[0181] In an embodiment of the present application, the visualization module 130 is further configured to, in response to receiving a threshold value of the second mutual information and selecting a word to be displayed, display all training samples containing each word contained in the training corpus 102 and words corresponding to element values contained in the second multiple second mutual information column vectors of multiple intermediate layers of the neural network model 101 that are higher than the threshold value of the second mutual information, and the abnormality determination module 140 is further configured to, in response to all training samples containing each word contained in the training corpus 102 and words corresponding to element values contained in the second multiple second mutual information column vectors of multiple intermediate layers of the neural network model 101 that are higher than the threshold value of the second mutual information, determine that an abnormal phenomenon of a network structure problem has occurred in the neural network model 101.
[0182] In summary, by using the above-mentioned system 100 for visual analysis of the deep neural network model for natural language processing, the user can observe the performance of the neural network model on the training corpus, and receive the user's query conditions through the receiving module 110. When the query condition is determined to be to view the contribution information of the target sample to the prediction of the neural network model, the performance information of the target sample and the word corresponding to the sample to the prediction of the neural network model is displayed through the visualization module 130; when the query condition is determined to be to view the contribution information of the target word to the prediction of the neural network model, the contribution information of the target word to the prediction of the neural network model in different contexts is displayed through the visualization module 130. The above-mentioned system 100 for visual analysis of the deep neural network model for natural language processing, wherein the multi-level visualization view and interactive analysis can help users explore the limitations of the neural network model 101 and determine the root cause of the poor performance of the neural network model 101.
[0183] In order to implement the above embodiments, the present application also proposes a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in the above embodiments is implemented.
[0184] In order to implement the above embodiments, the present application also proposes a non-temporary computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described in the above embodiments is implemented.
[0185] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0186] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0187] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0188] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0189] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0190] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0191] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0192] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A visual analysis method for a natural language processing neural network model, characterized in that: include: Receiving a neural network model and a training corpus, wherein the training corpus is used to train the neural network model; Calculate the first mutual information between each word in the training corpus and the semantic vector output by the output layer of the neural network model, obtain the word frequency of each word in the training corpus, and the contribution of each word to the semantic vector output by the output layer of the neural network model, and calculate the importance of each word in the training corpus to the neural network model according to the word frequency and the contribution, wherein the importance is calculated by the following formula: Wherein, M is the importance of each word to the neural network model, w is each word in the training corpus, C(w) is the frequency of each word appearing in the training corpus, and G(w) is the mean of the first mutual information between each word and the semantic vector output by the neural network model in the output layer; Visually display each word in the training corpus and its importance to the neural network model; After calculating the first mutual information between each word in the training corpus and the semantic vector output by the output layer in the neural network model, a plurality of the first mutual information are combined into a first mutual information vector, wherein the first mutual information vector is obtained by the following steps: Adding Gaussian noise to the training samples; Constructing a loss function about the first mutual information vector according to the training sample and the Gaussian noise; The loss function about the first mutual information vector is estimated by maximum likelihood to minimize the loss function, a first Gaussian noise is calculated, and the first mutual information vector is obtained according to the first Gaussian noise; wherein, The expression of the loss function is: in, is the training sample after adding Gaussian noise, express Yes Obedience Gaussian noise, represents the neural network model, S represents the training sample through the neural network model The semantic vector output at the output layer is Represents the neural network model The variance of the semantic vectors outputted by all training samples in the training corpus at the output layer, Express The mathematical expectation, K and Take the experience value between 0-1.
2. The visualization analysis method according to claim 1, characterized in that: After visually displaying each word in the training corpus and its importance to the neural network model, the method further includes: Analyzing the importance to determine abnormal words in the training corpus, and using the importance of the abnormal words to the neural network model as a first abnormal value; The abnormal phenomenon of sample skew in the neural network model is determined based on the first outlier value and is visualized.
3. The visualization analysis method according to claim 1, characterized in that: After receiving the neural network model and the training corpus, the method further includes: Calculating the prediction score of each training sample in the training corpus for the neural network model and the semantic vector output by the output layer; The prediction score of the neural network model and the semantic vector output by the output layer are projected by projection technology to obtain the projection coordinates of each training sample and perform visual display.
4. The visualization analysis method according to claim 3, characterized in that: After the prediction score of the neural network model and the semantic vector output by the output layer are projected by the projection technology to obtain the projection coordinates of each training sample and visualize them, the method further includes: Analyzing the importance to determine abnormal samples in the training corpus, and using the projection coordinates of the abnormal samples on the neural network model as second abnormal values; The abnormal phenomenon of sample skew in the neural network model is determined based on the second outlier value and is visualized.
5. The visualization analysis method according to claim 1 or 2, characterized in that: After receiving the neural network model and the training corpus, the method further includes: Calculating a second mutual information matrix between each training sample in the training corpus and each intermediate layer of the neural network model; Extracting first multiple second mutual information column vectors between each training sample and multiple intermediate layers of the neural network model according to the second mutual information matrix, wherein each element in a second mutual information column vector indicates a second mutual information value of each word contained in a training sample for a certain intermediate layer; Performing hierarchical clustering on the first plurality of second mutual information column vectors to obtain a grammatical structure of each training sample at each intermediate layer, and calculating the similarity between any two elements in the first plurality of second mutual information column vectors; The similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors is visualized.
6. The visualization analysis method according to claim 5, characterized in that: After visually displaying the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors, the method further includes: Analyze the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors to determine abnormal grammatical structures and / or abnormal similarities among all the obtained grammatical structures and similarities, and use the abnormal grammatical structures and / or abnormal similarities as third abnormal values; The abnormal phenomenon of sample skew in the neural network model is determined based on the third abnormal value and is visualized.
7. The visualization analysis method according to claim 5, characterized in that: include: According to the second mutual information matrix, a second plurality of second mutual information column vectors corresponding to the training samples containing the same word in the training corpus and the plurality of intermediate layers of the neural network model are obtained, and the second mutual information between the same word and the semantic vector output by the output layer in the neural network model is calculated; The words corresponding to the element values contained in the second plurality of second mutual information column vectors and being higher than the threshold value of the second mutual information are displayed.
8. The visualization analysis method according to claim 6, characterized in that: include: Analyze the words corresponding to the element values contained in the second plurality of displayed second mutual information column vectors and having values higher than the threshold value of the second mutual information to determine abnormal words and use them as fourth abnormal values; The abnormal phenomenon of sample skew in the neural network model is determined based on the fourth abnormal value and is visualized.
9. A visual analysis system for natural language processing neural network models, characterized in that: include: A receiving module, used for receiving a neural network model and a training corpus, wherein the training corpus is used for training the neural network model; A processing module is used to calculate the first mutual information between each word in the training corpus and the semantic vector output by the output layer of the neural network model, obtain the word frequency of each word in the training corpus, and the contribution of each word to the semantic vector output by the output layer of the neural network model, and calculate the importance of each word in the training corpus to the neural network model according to the word frequency and the contribution, wherein the importance is calculated by the following formula: Wherein, M is the importance of each word to the neural network model, w is each word in the training corpus, C(w) is the frequency of each word appearing in the training corpus, and G(w) is the mean of the first mutual information between each word and the semantic vector output by the neural network model in the output layer; A visualization module, used for visually displaying each word in the training corpus and its importance to the neural network model; The processing module is further configured to, after calculating the first mutual information between each word in the training corpus and the semantic vector output by the output layer in the neural network model, combine a plurality of the first mutual information into a first mutual information vector, wherein the first mutual information vector is obtained by the following steps: Adding Gaussian noise to the training samples; Constructing a loss function about the first mutual information vector according to the training sample and the Gaussian noise; The loss function about the first mutual information vector is estimated by maximum likelihood to minimize the loss function, a first Gaussian noise is calculated, and the first mutual information vector is obtained according to the first Gaussian noise; wherein, The expression of the loss function is: in, is the training sample after adding Gaussian noise, express Yes Obedience Gaussian noise, represents the neural network model, S represents the training sample through the neural network model The semantic vector output at the output layer is Represents the neural network model The variance of the semantic vectors outputted by all training samples in the training corpus at the output layer, Express The mathematical expectation, K and Take the experience value between 0-1.
10. The visual analysis system according to claim 9, characterized in that: The visual analysis system further includes an abnormality determination module, which is used to analyze the importance to determine abnormal words in the training corpus, and use the importance of the abnormal words to the neural network model as a first abnormal value; The visualization module is also used to determine the abnormal phenomenon of sample skew in the neural network model based on the first abnormal value and perform a visual display.
11. The visual analysis system according to claim 9 or 10, characterized in that: The processing module is further used to: calculate a second mutual information matrix between each training sample in the training corpus and each intermediate layer of the neural network model; Extracting first multiple second mutual information column vectors between each training sample and multiple intermediate layers of the neural network model according to the second mutual information matrix, wherein each element in a second mutual information column vector indicates a second mutual information value of each word contained in a training sample for a certain intermediate layer; Performing hierarchical clustering on the first plurality of second mutual information column vectors to obtain a grammatical structure of each training sample at each intermediate layer, and calculating the similarity between any two elements in the first plurality of second mutual information column vectors; The visualization module is further used to visualize the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors.
12. The visual analysis system according to claim 11, characterized in that: The abnormality determination module is further used to: analyze the similarity between the grammatical structure and any two elements in the first plurality of second mutual information column vectors to determine abnormal grammatical structures and / or similarity anomalies among all the obtained grammatical structures and similarities, and use the abnormal grammatical structures and / or similarity anomalies as third abnormal values; The visualization module is also used to determine the abnormal phenomenon of sample tilt in the neural network model according to the third abnormal value and perform a visual display.
13. The visual analysis system according to claim 11, characterized in that: The processing module is further used to obtain a second plurality of second mutual information column vectors corresponding to the training samples containing the same word in the training corpus and the plurality of intermediate layers of the neural network model according to the second mutual information matrix, and calculate the second mutual information between the same word and the semantic vector output by the output layer in the neural network model; The visualization module is further used to display words corresponding to element values contained in the second plurality of second mutual information column vectors and having values higher than a threshold value of the second mutual information.
14. The visual analysis system according to claim 13, characterized in that: include: The abnormality determination module is further used to analyze the words corresponding to the element values contained in the displayed second plurality of second mutual information column vectors and having values higher than the threshold value of the second mutual information, so as to determine the abnormal words and use them as the fourth abnormal values; The visualization module is also used to determine the abnormal phenomenon of sample tilt in the neural network model according to the fourth abnormal value and perform a visual display.
15. A computer device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
16. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
