A method for identifying the author of literary works based on a neural network framework
By combining CNN and Bi-LSTM models in the neural network framework, the spatial and temporal features of literary works are extracted, which solves the problem of inaccurate author identification in the existing technology and achieves high-accuracy author identity determination.
Patent Information
- Application Number
- CN202110386933.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-12
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-04-12
AI Technical Summary
Existing methods for identifying authors of literary works have the problem of inaccurate judgment through information entropy comparison, which cannot fully include all the styles of the author, affecting the accuracy of the results.
Using the Parallel_ARCNN model based on the neural network framework, through the spatial information extraction part, the temporal information extraction part and the spatiotemporal information combination part, the CNN model is used to train convolution kernels of different sizes, Attention mechanism and Bi-LSTM network in parallel to extract the space of literary works and temporal characteristics, combining temporal and spatial information to determine authorship.
It achieves accurate identification of authors of literary works, improves identification accuracy and recall rate, and provides a more reliable author attribution determination method.
Smart Images

Figure CN112926321B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of deep learning, and in particular to a method for identifying the author of a literary work based on a neural network framework. Background Art
[0002] A Chinese patent (application number CN201310043297.5, application date 20130202, publication number CN103106192B, publication date 20160203) discloses a method and device for identifying the author of a literary work, which segmented the input literary work to obtain the segmented phrases and their corresponding target occurrence frequencies, calculated the information entropy of the input literary work according to the target occurrence frequencies, obtained the author sample works corresponding to the target author and the information entropy of the author sample works; and identified whether the author of the input literary work is the target author by comparing the information entropy of the author sample works with the information entropy of the input literary work. However, the information entropy may not contain all the styles of the author, resulting in inaccurate judgment and affecting the final result. Summary of the invention
[0003] The technical problem to be solved by the present invention is: in order to solve the problems existing in the above-mentioned background technology, a method for identifying the author of literary works based on a neural network framework is provided, and the author identity determination of literary works is realized through the Parallel_ARCNN model.
[0004] The technical solution adopted by the present invention to solve the technical problem is: a method for identifying the author of a literary work based on a neural network framework, and the specific steps are as follows:
[0005] Step 1: Data cleaning: divide the text into samples and label the samples with positive and negative labels. Take the samples generated by the text written by one author as positive samples and the samples generated by the text written by another author as negative samples. Divide the samples into training sets and test sets, and embed the words in the samples into word vectors.
[0006] Step 2: Train the Parallel_ARCNN model through the training set. The Parallel_ARCNN model includes a spatial information extraction part, a temporal information extraction part and a spatiotemporal information combination part. The temporal information extraction part includes an Attention mechanism and two Bi-LSTM networks. The spatial information extraction part uses the CNN model to train three different sizes of convolution kernels in parallel. The convolution kernel uses a convolution kernel of size m*1, where m is a positive integer greater than 1, and extracts the spatial features of the literary text in parallel. The temporal information extraction part first highlights the local information of the literary text through the Attention mechanism, and then the two Bi-LSTM networks extract the temporal features of the literary text in parallel. The spatiotemporal information combination part splices the temporal features extracted by the two Bi-LSTM networks after maximum pooling processing and the spatial features extracted by the CNN model after maximum pooling processing and sends them to a fully connected layer with a sigmoid activation function. Update the parameters of the Parallel_ARCNN model, and obtain a Parallel_ARCNN model with better training results as a test model.
[0007] Step 3: Obtain the accuracy and loss rate of the model through the test set to determine whether the model can accurately identify the author of the work;
[0008] The accuracy of the Parallel-ARCNN model is characterized by the F1 value, which is:
[0009]
[0010] Among them, precision represents the accuracy rate; recall represents the recall rate.
[0011] The formula for precision is:
[0012] The formula for recall is:
[0013] Among them, TP refers to the number of samples with positive labels that are correctly predicted by the model; FP refers to the number of samples with positive labels that are incorrectly predicted by the model; FN refers to the number of samples with negative labels that are incorrectly predicted by the model.
[0014] To further specifically define, in the above technical solution, in step 2, the CNN model extracts sentence features by learning the weights of words of different sequence lengths in the text of literary works by using three convolution kernels of different sizes.
[0015] To further specifically define, in the above technical solution, in step 2, the Bi-LSTM is composed of two opposite unidirectional LSTMs, specifically including a forward LSTM and a backward LSTM; at each moment, the text information is simultaneously input into the forward LSTM and the backward LSTM; and the output of the Bi-LSTM is jointly determined by the forward LSTM and the backward LSTM, and the output of the backward LSTM is spliced behind the output of the forward LSTM, that is, the hidden layer results of the forward LSTM and the backward LSTM at the last moment are connected together as the output result of the Bi-LSTM.
[0016] The beneficial effects of the present invention are as follows: the present invention proposes a method for identifying the author of a literary work based on a neural network framework, uses a Parallel_ARCNN model based on a neural network framework to vectorize the text of the literary work, uses an Attention mechanism to highlight key local information of the text of the literary work, and then extracts the temporal information of the text content of the literary work in parallel through two Bi-LSTM networks; at the same time, the CNN model extracts the spatial information of the text content of the literary work in parallel by using three convolution kernels of different sizes; the temporal information and the spatial information are combined to accurately determine the authorship of the literary work, which provides a new idea for studying the problem of identifying the author of the literary work. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 This is the Parallel_ARCNN model framework diagram. DETAILED DESCRIPTION
[0019] In order to make the technical problems, technical solutions and beneficial effects solved by the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0020] See Figure 1 The present invention provides a method for identifying the author of a literary work based on a neural network framework, and the specific steps are as follows:
[0021] Step 1: Data cleaning: divide the text into samples and label the samples with positive and negative labels. Take the samples generated by the text written by one of the authors as positive samples, and the samples generated by the text written by another author as negative samples. Divide the samples into training sets and test sets, and embed the text of the samples into word vectors (convert words into vectors).
[0022] Step 2: Train the Parallel_ARCNN model using the training set. The Parallel_ARCNN model includes a spatial information extraction part, a temporal information extraction part, and a spatiotemporal information combination part. The temporal information extraction part includes an Attention mechanism and two Bi-LSTM networks. The spatial information extraction part uses the CNN model to train three different sizes of convolution kernels in parallel. The convolution kernel uses an m*1 size convolution kernel, where m is a positive integer greater than 1, to extract the spatial features of the text of literary works in parallel. The CNN model uses three different sizes of convolution kernels to learn the weights of words of different sequence lengths in the text of literary works, thereby extracting sentence features. In the temporal information extraction part, the local information of the literary text is first highlighted through the Attention mechanism, and then two Bi-LSTM networks are used to extract the temporal features of the literary text in parallel; in the spatiotemporal information combination part, the temporal features extracted by the two Bi-LSTM networks are processed by maximum pooling, and the spatial features extracted by the CNN model are processed by maximum pooling, and then concatenated and sent to the fully connected layer with the sigmoid activation function; the parameters of the Parallel_ARCNN model are updated, and the Parallel_ARCNN model with better training results is obtained as the test model.
[0023] CNN (Convolutional Neural Network) extracts sentence features by using convolution kernels of different sizes to learn the weights of words of different sequence lengths in literary texts. Convolution kernels of different sizes can extract different n-gram features of literary texts. Compared with the traditional bag-of-words model method, they can understand the semantic relationship between the context of literary texts. It should be noted that the convolution kernel extracts the n-gram features of the sentence and can be directly output. The n-gram features can express the author's writing style. The CNN equation is:
[0024] conv j =f(m T *s j-m+1:j +b) (1)
[0025] Among them, s represents a sample; s j-m+1:j YesS 1:n part of;
[0026] s 1:n =s1,s2,......s i......s n represents a sample; s i It represents the feature of the i-th word in the sample sequence, and also represents the vector input at the i-th moment; n represents the length of the sample; conv represents the convolution layer; f represents the activation function; m represents the convolution kernel of size m*1; T represents transpose; b represents offset; j represents the j-th position of the input.
[0027] CONV m =[conv1,conv2,......,conv n-m+1 ] (2)
[0028] Among them, CONV m Represents a convolutional layer whose convolution kernel size is m*1.
[0029] pool m =Maxpool(ReLu(CONV m )) (3)
[0030] Among them, pool m ReLu represents the pooling layer; ReLu represents the activation function; Maxpool represents the maximum pooling function, which is a nonlinear function. The pooling function operation is applied to convolution kernels of different sizes, and the outputs are finally merged:
[0031] concat conv =cat([pool3,pool4,pool5]) (4)
[0032] Among them, concat conv It means connecting convolutional layers of different sizes together.
[0033] It should be noted that any other three different convolution kernels of m*1 size can also be used.
[0034] The Attention mechanism calculates the probability weights of word vectors at different times by means of probability weight distribution, so that some words can get more attention, thereby improving the quality of hidden layer feature extraction.
[0035] The Attention mechanism is similar to the principle of human brain observing certain things. For example, when people observe a painting to describe its content, they first observe the words on it, and then observe the part of the painting that expresses the theme based on their judgment. When describing the painting, they often describe the most relevant content of the painting first, and then describe other aspects. The Attention mechanism is a mechanism that highlights local important information by allocating enough attention to key information.
[0036] The calculation formula of the Attention mechanism is:
[0037] e i =v i tanh(w i s i +b i ) (5)
[0038] Among them, e i represents the energy value of the input vector at the i-th moment; v i and w i represents the weight coefficient at the i-th moment; b i represents the corresponding offset at the i-th moment; tanh is the activation function; s i Represents the input vector at the i-th moment.
[0039]
[0040] Among them, α i represents the probability of the i-th input vector; exp is an exponential function in higher mathematics with the natural constant e as the base; e i represents the energy value of the input vector at the i-th moment; e j represents the energy value of the input vector at the jth moment; n represents the length of the sample; j represents the jth moment.
[0041] a i =α i *s i (7)
[0042] Among them, a i represents the new input vector after being processed by the Ateention mechanism; n represents n energy values; S i Represents the input vector at the i-th moment.
[0043] concat attention =cat(a 1:n ,S 1:n ) (8)
[0044] Among them, cat is the splicing function; a 1:n =a1,a2,a3,......,a n represents the sample after being processed by the Attention mechanism; S 1:n =S1,S2,S3,......,S n is the original sample. Sample a processed by the Attention mechanism 1:n Compared with the original sample S 1:n Splice into concat attentionAs shown in formula (8), after the word vector embedding is processed by the Attention mechanism, it is concat with the word vector embedding that has not been processed by the Attention mechanism, and then the concat attention Input to Bi-LSTM.
[0045] Bi-LSTM (Bidirectional Long Short-Term Memory Network), LSTM is a widely used classic variant of RNN variants. RNN is a special neural network used to process sequence data. It is a neural network born to solve the relationship between the current input and the current output and the output of the previous moment in the text of literary works. The basic algorithm idea of RNN is to propagate backwards over time, but in the process of backward propagation, problems such as gradient diffusion or gradient explosion are prone to occur. In order to solve this shortcoming, many variants of RNN have been proposed. The core idea of LSTM is to control a certain amount of time series data to enter the memory unit through the forget gate, and to control a certain amount of memory unit data to participate in the output calculation of the next moment through the output gate. In a unidirectional neural network structure, the state is always output from front to back. The equation of LSTM is as follows:
[0046]
[0047] Among them, i t represents the input gate; f t represents the forget gate; o t represents the output gate; represents the memory state of the current input; σ represents the activation function; tanh represents the activation function; w represents the weight coefficient; h represents the hidden layer; x t represents the input vector at time t; t represents the tth time.
[0048]
[0049] Among them, c t Indicates the memory status.
[0050] h t =o t otanh(q) (11)
[0051] Among them, the memory state c t and the hidden layer h t Updated with formulas (9) to (11).
[0052] If the output at the current moment can be connected to the state of the previous moment and the state of the next moment, then the time series information of the data will be fully extracted. Therefore, the bidirectional Bi-LSTM was proposed. Bi-LSTM consists of two opposite unidirectional LSTMs, specifically the forward LSTM and the backward LSTM. At each moment, the text information is input into the forward LSTM and the backward LSTM at the same time; and the output of Bi-LSTM is jointly determined by the forward LSTM and the backward LSTM. The output of the backward LSTM is spliced behind the output of the forward LSTM, that is, the hidden layer results of the forward LSTM and the backward LSTM at the last moment are connected together to represent the output result of Bi-LSTM. The output result of Bi-LSTM is as follows:
[0053] Bi_Lstm_out=cat([Maxpool(hidden forward ), (12)Maxpool(hidden bacward )])
[0054] Among them, Bi_Lstm_out represents the output of Bi-LSTM; hidden forward Represents the hidden layer of the forward LSTM; hidden bacward represents the hidden layer of the backward LSTM; cat represents connecting the hidden layer of the forward LSTM and the hidden layer of the backward LSTM.
[0055] The temporal and spatial information combination part combines the temporal features extracted by the two Bi-LSTM networks and the spatial features extracted by the CNN model through pooling and feeds them to the fully connected layer with the sigmoid activation function, which is the last layer. The functions of CNN and Bi-LSTM are combined in a parallel way, and this combination is called "Parallel". The loss function of the Parallel_ARCNN model is expressed as:
[0056] Loss=∑ i y′ i logy i (13)
[0057] Among them, Loss represents the loss function; i represents the i-th sample; y′ i represents the label of the i-th sample; y i Represents the model's prediction result for sample i.
[0058] Step 3: Use the test set to obtain the accuracy and loss rate of the model to determine whether the model can accurately identify the author of the work.
[0059] The accuracy of the Parallel-ARCNN model is characterized by the F1 value, which is expressed as:
[0060]
[0061] Among them, precision represents the accuracy rate; recall represents the recall rate.
[0062] The formula for precision is:
[0063] The recall formula is:
[0064] Among them, TP refers to the number of samples whose labels indicate positives and whose model predictions are correct; FP refers to the number of samples whose labels indicate positives and whose model predictions are wrong; and FN refers to the number of samples whose labels indicate negatives and whose model predictions are wrong.
[0065] Example:
[0066] First, data acquisition is performed: data sets are created using the works of Gu Long and Jin Yong, and after preprocessing, every 450 words represent a sample, which are divided into training set and test set. The training set is used for model training, and the test set is used for model testing. The specific division is shown in the following table:
[0067]
[0068] The experimental steps are as follows:
[0069] 1. Data cleaning: divide the text into samples and label the samples with positive and negative labels. The samples generated by the text written by the author Jin Yong are used as positive samples, and the samples generated by the text written by the author Gu Long are used as negative samples. The positive samples "The Demi-Gods and Semi-Devils" and the negative samples "The Sword of the Falling Star and the Butterfly" and "The Sword Washing with Flowers" are divided into the training set, and the ratio of positive samples to negative samples in the training set is 1588 / 1487; the positive samples "The Heaven Sword and the Dragon Saber" and the negative samples "The Swordsman" are divided into the test set, and the ratio of positive samples to negative samples in the test set is 1500 / 1500; embed the text of the sample into word vectors (convert the words into vectors);
[0070] Second, shuffle the samples of the training set, randomly select 80% of the samples of the training set and input them into the Parallel_ARCNN model. On the one hand, after the samples are processed by the attention mechanism, they are spliced with the original samples and input into two parallel Bi-LSTMs and subjected to maximum pooling to extract the time information of the samples; on the other hand, the samples are input into CNN to extract the spatial information of the samples through three different sizes of convolution kernels, 3*1, 4*1 and 5*1, and subjected to maximum pooling. After splicing with the samples processed by two parallel Bi-LSTMs and maximum pooling, they are input into the fully connected layer and the category of the samples is output through the sigmoid function, which represents the category predicted by the model. Then, the accuracy and loss function are calculated based on the predicted category of the samples and the true category of the samples, and the model parameters are updated through back propagation. The remaining 20% of the training set is used as the validation set and the above operations are performed in the same way, but there is no need to back propagate to update the model parameters. After 1000 cycles of training, the model with the highest accuracy in the validation set is selected as the best model. Experiments show that the accuracy and loss function of the validation set corresponding to the best model are: F1=98.03%, Loss=0.0352.
[0071] 3. Input the samples of the test set into the best Parallel_ARCNN model. On the one hand, after the samples are processed by the attention mechanism, they are spliced with the original samples and input into two parallel Bi-LSTMs and subjected to maximum pooling to extract the temporal information of the samples. On the other hand, the samples are input into CNN to extract the spatial information of the samples through three different sizes of convolution kernels, 3*1, 4*1 and 5*1, and subjected to maximum pooling. After being spliced with the samples processed by two parallel Bi-LSTMs and maximum pooling, they are input into the fully connected layer and the category of the samples is output through the sigmod function, which indicates the category predicted by the model. Then, the accuracy of the test set is calculated based on the predicted category of the samples and the true category of the samples. If the accuracy is high, the Parallel_ARCNN model can accurately identify the author of the work. According to the experiment, the accuracy of the test set is F1=98.15%.
[0072] The Parallel_ARCNN model can accurately distinguish between the works of Gu Long and Jin Yong. The Parallel_ARCNN model is effective in solving the problem of determining the author of literary works.
[0073] The above only represents the preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for identifying the author of a literary work based on a neural network framework, characterized by: The specific steps are as follows: Step 1: Data cleaning: divide the text into samples and label the samples with positive and negative labels. Take the samples generated by the text written by one author as positive samples and the samples generated by the text written by another author as negative samples. Divide the samples into training sets and test sets, and embed the words in the samples into word vectors. Step 2: Train the Parallel_ARCNN model using the training set. The Parallel_ARCNN model includes a spatial information extraction part, a temporal information extraction part, and a spatiotemporal information combination part. The temporal information extraction part includes an Attention mechanism and two Bi-LSTM networks. The spatial information extraction part uses the CNN model to train three different sizes of convolution kernels in parallel, and the convolution kernel uses a convolution kernel of size m*1, where m is a positive integer greater than 1, to extract the spatial features of the literary text in parallel; the temporal information extraction part first highlights the local information of the literary text through the Attention mechanism, and then the two Bi-LSTM networks extract the temporal features of the literary text in parallel; the spatiotemporal information combination part processes the temporal features extracted by the two Bi-LSTM networks and the spatial features extracted by the CNN model through maximum pooling, and then splices them to a fully connected layer with a sigmoid activation function; Update the parameters of the Parallel_ARCNN model and use the Parallel_ARCNN model with better training results as the test model; In step 2, the Bi-LSTM is composed of two opposite unidirectional LSTMs, specifically including a forward LSTM and a backward LSTM; At each moment, the text information is input into the forward LSTM and the backward LSTM at the same time; The output of Bi-LSTM is jointly determined by the forward LSTM and the backward LSTM. The output of the backward LSTM is spliced behind the output of the forward LSTM. That is, the hidden layer results of the forward LSTM and the backward LSTM at the last moment are connected together as the output result of Bi-LSTM. Step 3: Obtain the accuracy and loss rate of the model through the test set to determine whether the model can accurately identify the author of the work; The accuracy of the Parallel-ARCNN model is given by The value characterization formula is: in, Indicates accuracy; represents the recall rate; The formula is: The formula is: in, Refers to the number of model prediction pairs in samples with positive labels; Refers to the number of samples with positive labels that are predicted incorrectly by the model; Refers to the number of samples with negative labels that are incorrectly predicted by the model.
2. The method for identifying the author of a literary work based on a neural network framework according to claim 1, characterized in that: In step 2, the CNN model extracts sentence features by using three different sizes of convolution kernels to learn the weights of words of different sequence lengths in the text of literary works.
