Non-abandoned text multi-classification prediction method based on multi-head attention and semantic features
Through a multi-classification prediction method of intangible cultural heritage text based on multi-head attention and semantic features, using technologies such as BERT and BiLSTM to extract global and local features of intangible cultural heritage text, the complexity and limitations of intangible cultural heritage text classification in the existing technology are solved. problem, improving classification accuracy and coverage.
Patent Information
- Application Number
- CN202410708984.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-06
AI Technical Summary
Due to semantic complexity and cultural differences, existing intangible cultural heritage text classification methods are difficult to fully cover the classification scope of intangible cultural resources. Moreover, traditional methods are limited to a certain type or region and cannot effectively manage and inherit intangible cultural resources.
A multi-class prediction method for intangible cultural heritage text based on multi-head attention and semantic features is adopted. By obtaining text data sets, the pre-trained model BERT and multi-head attention network are used for vector encoding, and BiLSTM and convolutional layers are combined to extract global and local features. Feature fusion and classification prediction generate classification results.
It improves the accuracy of intangible cultural heritage text classification, can better handle complex semantic information and local features, is suitable for classifying diversified intangible cultural resources, breaks through the limitations of traditional methods, and achieves wider classification coverage.
Smart Images

Figure CN118606469A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text recognition, and in particular to a multi-classification prediction method for intangible cultural heritage text based on multi-head attention and semantic features. Background Art
[0002] In 2003, UNESCO formally included intangible cultural heritage as an important topic in international conferences to promote the inheritance and exchange of international intangible culture. As a long-term form of cultural inheritance, intangible cultural heritage represents the cohesion of human wisdom in various periods and is a manifestation of cultural diversity. In recent years, the number of intangible cultural heritage collections has increased dramatically, and text mining and classification prediction of intangible culture have become hot topics. Domestic and foreign scholars are committed to combining traditional culture with deep learning, exploring the future development direction of intangible cultural heritage resources, and realizing the classified management of intangible cultural heritage resources. Intangible cultural heritage classification prediction can help researchers quickly understand the content and characteristics of intangible cultural heritage by distinguishing the types and basic connotations of intangible cultural heritage digital resources, and provide a scientific basis for the effective management and inheritance of cultural resources.
[0003] Due to the diversity and complexity of intangible cultural heritage, there are often different subcategories in the same category, and there are often problems such as fuzzy category attribution and complex semantics. In order to further analyze the current status of intangible cultural heritage resources, scholars have conducted classification prediction research from different perspectives such as data storage, deep learning, and semantic features. Multi-classification prediction of intangible cultural heritage text mines the potential information of intangible cultural heritage based on multi-dimensional semantic features, but limitations such as semantic disambiguation, concept limitations, and ontology fragility make it difficult for the classification scope to fully cover the categories to which intangible cultural heritage resources belong. The cultural differences between regions also make it difficult to apply the existing classification system to achieve the division of resources in other categories. Therefore, traditional intangible cultural heritage text classification methods are often limited to the classification research of intangible cultural heritage of a certain type or region.
[0004] To address the above problems, a multi-classification prediction method for intangible cultural heritage text based on multi-head attention and semantic features was proposed. Summary of the invention
[0005] The purpose of the present invention is to provide a multi-classification prediction method for intangible cultural heritage text based on multi-head attention and semantic features to improve the accuracy of intangible cultural heritage text classification prediction.
[0006] To achieve the above object, the present invention provides the following solutions:
[0007] The intangible cultural heritage text multi-classification prediction method based on multi-head attention and semantic features includes:
[0008] Get the text dataset to be classified and predicted;
[0009] The text data set to be classified and predicted is input into the intangible cultural heritage text classification prediction model to obtain the classification prediction result, wherein the intangible cultural heritage text classification prediction model is obtained by training with a training set, and the training set includes a text sequence and a type label. The intangible cultural heritage text classification prediction model is used to convert the text data set to be classified and predicted into a vector coding representation, extract global and local features according to the vector coding, fuse and classify the global and local features, and generate the classification prediction result.
[0010] Optionally, obtaining a training set including a text sequence and a type label includes: converting text categories of the text data set to be classified and predicted into digital labels, and obtaining the text sequence and the type label.
[0011] Optionally, training the intangible cultural heritage text classification prediction model through a training set includes:
[0012] The text sequence and the type label are jointly input into a text representation layer, and the vector encoding is obtained through a multi-head attention mechanism;
[0013] Input the vector code into the semantic feature extraction layer, and extract the global features and local features of the vector code by fusing the long short-term memory network and the convolution layer;
[0014] The global features and local features are input into the classification prediction layer to perform classification prediction and obtain the classification prediction result.
[0015] Optionally, the text representation layer includes a pre-trained model BERT and a multi-head attention network;
[0016] The pre-trained model BERT is used to represent the text sequence and type label with word vectors;
[0017] The multi-head attention network is used to perform multi-dimensional feature expression on the word vector representation to obtain the vector encoding.
[0018] Optionally, the semantic feature extraction layer includes a BiLSTM network and a convolutional layer;
[0019] The BiLSTM network is used to extract positive feature sequences and negative feature sequences from the vector code and concatenate them to obtain global features of the vector code, wherein the global features include text global features and type global features;
[0020] The convolution layer is used to extract local features of the vector encoding through a convolution layer, wherein the global features include text local features and type local features.
[0021] Optionally, inputting the global features and local features into a classification prediction layer for classification prediction includes: fusing the global features and local features through a fully connected layer, and performing multi-classification prediction of the intangible cultural heritage text on the fused features through an MLP layer.
[0022] Optionally, the optimization goal of the intangible cultural heritage text classification prediction model is:
[0023] minLoss=min(L relation +L prediction )
[0024] Among them, Loss is the joint loss function, L relation is the cross entropy loss in the training phase, L prediction is the cross entropy loss function in the prediction stage.
[0025] The beneficial effects of the present invention are as follows: based on the CAE-CGAN scenario generation model, the spatiotemporal correlation information of wind power in multiple regions is fully utilized, and the generated scenario can accurately describe the characteristics of wind power output. The K-Medoids clustering is used to effectively achieve scenario reduction, thereby improving the distribution network's ability to absorb wind power, and providing an excellent method for effectively reducing the operating cost of the distribution network and improving the economic benefits of the grid operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] 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 will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0027] Figure 1 A structural diagram of a text classification model based on multi-head attention semantic features according to an embodiment of the present invention;
[0028] Figure 2 A schematic diagram of a text representation layer according to an embodiment of the present invention;
[0029] Figure 3 A schematic diagram of global feature extraction according to an embodiment of the present invention;
[0030] Figure 4 Schematic diagram of a convolutional layer according to an embodiment of the present invention;
[0031] Figure 5 A schematic diagram of a classification prediction layer according to an embodiment of the present invention;
[0032] Figure 6 This is a performance comparison chart of a data set under 5 different learning rates according to an embodiment of the present invention;
[0033] Figure 7 This is a performance comparison chart of a data set in an embodiment of the present invention under 5 different batch processing;
[0034] Figure 8 The training conditions of each module in the embodiment of the present invention on the training set, where (a) is the train accuracy of each module on the training set and (b) is the train loss of each module on the training set;
[0035] Fig. 9 The basic situation of each module in the embodiment of the present invention on the validation set, where (a) is the validation accuracy of each module on the training set and (b) is the validation loss of each module on the training set;
[0036] Fig.10 The training conditions of each model in the embodiment of the present invention on the data set, where (a) is the train accuracy of each model on the training set, (b) is the train loss of each model on the training set, (c) is the train accuracy of each model on the training set, and (d) is the train loss of each model on the training set;
[0037] Fig.11 The performance comparison of each model in the embodiments of the present invention is shown in FIG. 1 , wherein (a) is the performance comparison of each model on the training set, (b) is the performance comparison of each model on the validation set, and (c) is the performance comparison of each model on the test set. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0040] like Figure 1 As shown, the present invention discloses a method for multi-classification prediction of intangible cultural heritage text based on multi-head attention and semantic features, including:
[0041] Obtain a text dataset to be classified and predicted; input the text dataset to be classified and predicted into the intangible cultural heritage text classification prediction model to obtain the classification prediction result, wherein the intangible cultural heritage text classification prediction model is obtained by training with a training set, and the training set includes a text sequence and a type label. The intangible cultural heritage text classification prediction model is used to convert the text dataset to be classified and predicted into a vector coding representation, extract global and local features according to the vector coding, fuse and classify the global and local features, and generate a classification prediction result.
[0042] Specifically, obtaining a training set including text sequences and type labels includes: converting text categories of a text data set to be classified and predicted into digital labels, and obtaining text sequences and type labels.
[0043] Specifically, training the intangible cultural heritage text classification prediction model through a training set including text sequences and type labels includes: jointly inputting the text sequence and type label into the text representation layer, and obtaining the vector code through the multi-head attention mechanism; inputting the vector code into the semantic feature extraction layer, and extracting the global and local features of the vector code by fusing the long short-term memory network and the convolution layer; inputting the global features and local features into the classification prediction layer for classification prediction, and obtaining the classification prediction results.
[0044] Specifically, the text representation layer includes the pre-trained model BERT and a multi-head attention network;
[0045] The pre-trained model BERT is used to represent text sequences and type labels using word vectors;
[0046] The multi-head attention network is used to express the multi-dimensional features of word vector representation and obtain vector encoding.
[0047] Specifically, the semantic feature extraction layer includes a BiLSTM network and a convolutional layer;
[0048] The BiLSTM network is used to extract positive feature sequences and negative feature sequences from the vector code and concatenate them to obtain the global features of the vector code, where the global features include text global features and type global features;
[0049] The convolution layer is used to extract local features of vector encoding through the convolution layer, wherein the global features include text local features and type local features.
[0050] Specifically, inputting the global features and the local features into the classification prediction layer for classification prediction includes: fusing the global features and the local features through a fully connected layer, and performing multi-classification prediction of the intangible cultural heritage text on the fused features through an MLP layer.
[0051] Specifically, the optimization objectives of the intangible cultural heritage text classification prediction model are: cross entropy loss in the training stage and cross entropy loss function in the prediction stage.
[0052] The present invention mainly designs a multi-head attention encoding layer using the pre-trained model BERT-TF from the perspective of attention mechanism and semantic features, and defines a multi-level feature extractor in combination with text features, adjusts the semantic extraction layer network structure, and performs feature fusion through the long short-term memory layer and the convolution layer to construct a classification prediction model for the intangible cultural heritage text sequence. The overall structure of the MASFM model (Multi-head Attention Semantic Features Model, a text classification model based on multi-head attention semantic features) of the present invention is as follows Figure 1 As shown in the figure, it mainly consists of three parts: text representation layer, semantic feature extraction layer, and classification prediction layer. The text representation layer uses the BERT-TF model of the deep bidirectional encoder as the basic part, and uses the multi-layer self-attention mechanism to obtain a more complex text vector representation. In the process of semantic feature extraction, global feature extraction and local semantic recognition are successively carried out, and the global dependency and local semantics are fused as the text features and category features of the lower layer. By extracting global semantic information and local information of different fine-grained levels, a richer text feature representation is provided for the model. The classification prediction layer is based on the text vector representation of feature fusion, introduces a fully connected layer and an attention mechanism, establishes the potential association between the text sequence and the type label feature, and selects sparse cross entropy to measure the loss, so as to continuously iterate and train the optimization model. Finally, the classification prediction result is obtained by matching the feature representation.
[0053] Since deep neural networks cannot directly translate text data types, the present invention performs vector representation of text sequences by stacking pre-trained models and attention mechanisms, and gradually learns and captures the complex semantic information in intangible cultural heritage texts.
[0054] In the multi-classification prediction of intangible cultural heritage, the model can use word vectors to represent the word features of various dimensions of intangible cultural heritage resources, such as semantic, grammatical or context-related features. Different from the traditional loop structure, the attention mechanism based on the pre-trained model can adjust the distance between any two words, effectively solving the long-term dependency problem in natural language processing. In the pre-training stage, BERT converts the input intangible cultural heritage text into vector encoding through word unit embedding, position embedding and fragment embedding, and then completes masked language model (MLM) or next sentence prediction (NSP) according to the specific data application scenario. The MLM method mainly focuses on the association between words and context. It predicts the masked part of the input text by randomly masking some words in the input text; the NSP task focuses more on discovering the association between sentences, which is also called predicting sequence sentences. One view is that text classification is to classify text data according to the similarity between words. When problems such as high data dimension, sparsity, and context arise, the traditional bag-of-words model cannot solve the limitations of clustering methods.
[0055] Therefore, the MASFM model chooses the text-type joint embedding method to jointly map each type label with the text sequence. Figure 2 As shown in the figure, the text representation part is based on the pre-trained bidirectional encoder, which mainly includes a text label layer, a multi-layer feedforward neural network and a multi-head attention mechanism. When processing the input sequence, the text label layer corresponds the input text sequence to the relevant intangible cultural heritage category label, while considering the text content and label information, so as to better handle the classification task of the intangible cultural heritage text sequence; the feedforward neural network obtains more semantic representation information through the nonlinear transformation of the fully connected layer; the self-attention mechanism processes the words of the input sequence one by one, and obtains the contextual representation of a single word through dot product operation and normalization; the added multi-head attention layer uses different independent self-attention mechanisms to process multiple words in parallel to obtain multi-dimensional feature expression, thereby capturing richer contextual information of each word and obtaining vector encoding; the stacked encoding layer is used to enhance the nonlinear representation ability of the BERT model.
[0056] The text sequence and type label are selected as the initial input, and converted into the corresponding word vector for text representation through joint embedding. In order to mark the filling and non-filling parts in the text sequence, an attention mark sequence is added to indicate the importance of each word in the model attention mechanism to ensure that the model pays attention to effective words in time during training. As the model continues to iterate, the word vector representation of the text also changes. Therefore, for each independent type label, there is a corresponding abstract mapping Token, and for any type T, a unique corresponding T[type] is generated. Assuming that the initial data is D and the maximum length of the sentence input is N, any data sample Xi , T i It can be expressed as:
[0057] D[X i , T i ]={X [CLS] , X1, X2, ..., X N , X [CLS] , T [SEP] , T1, ..., T m , T [SEP]} (1)
[0058] Among them, X i is the intangible cultural heritage text vector, T i is the intangible cultural heritage label vector, X [CLS] is the semantic representation of the text, T [SEP] Used to distinguish intangible cultural heritage text from corresponding labels. i , T i ] is a vector representation.
[0059] BERT constructs three matrices to represent the relationship between the current word and other words and the unit expression of the feature vector, and multiplies them with the initial input to obtain the training matrix (Q, K, V). In addition, the output T0[out] of the current encoding layer is calculated through the multi-head attention layer and used as the input T1[out] of the next encoding layer. The calculation process is shown in formula (2)-formula (3).
[0060]
[0061]
[0062] Among them, Q i For query, K i is the key, V i is the value, W q , W k and W v The weight matrix calculated for a single attention.
[0063] The semantic feature extraction layer integrates the structural features of the long short-term memory network and the convolution layer to achieve global and local feature extraction of text data. The bidirectional LSTM quickly captures the long-distance dependencies across sentences through bidirectional modeling, and is used to obtain the global semantic information of the intangible cultural heritage text. CNN focuses on analyzing local features and uses convolution operations to extract feature patterns within a local range, such as the correlation and similarity between words.
[0064] In the process of global feature extraction, the MASFM model uses the recurrent bidirectional neural network BiLSTM as the bottom layer, which includes basic units such as recurrent units, input gates, forget gates, and output gates. This part introduces a gated structure to achieve precise control of input data, helping the model to effectively choose to forget and remember effective information, and provides a new idea for processing long and short text data in the field of intangible cultural heritage. In addition, BiLSTM solves the problem of gradient explosion or gradient vanishing that may occur in traditional RNN networks when processing long sequences, and makes up for the limitation of capturing information in a single direction. As an improved recurrent network, bidirectional LSTM can solve the long-term dependency of processing sequence data and automatically learn the feature representation of input data without the defects of manual representation in traditional machine learning.
[0065] Therefore, on the basis of the bidirectional encoder, this embodiment adds a BiLSTM layer to perform feature extraction on the output sequence converted into vector encoding, and further converts the position mapping in the sequence into a vector representation of a fixed dimension. These vector information contains important information such as the vector representation, mask position, weight, etc. of the intangible cultural heritage text, paving the way for feature fusion. Compared with the unidirectional traversal method, the BiLSTM is composed of forward and reverse LSTMs. When reading data, it traverses the sequence from the front and back directions respectively, so as to quickly record the context information of each position. The forward LSTM records data according to the text data and passes it to the next moment, while the reverse LSTM transmits information from the opposite direction. The global feature extraction process is as follows. Figure 3 shown.
[0066] By splicing the output sequences of bidirectional reading, the contextual information of each position can be more comprehensively obtained. Each individual LSTM unit contains basic gating units including input gate, forget gate, output gate and cell state. In the process of extracting global features, the LSTM unit combines the input of the current time step with the information of the previous and next time steps, controls the importance of the current input through the input gate, and determines whether to retain the information of the previous moment through the forget gate. Finally, the form of the output information is determined from the output gate. Based on the premise of multiple attention mechanisms, the bidirectional LSTM can better handle long-distance dependencies and memory information when processing non-legacy texts, so as to improve the model's understanding and representation of the overall semantics of the text sequence.
[0067] Assume that the current input gate value is i t , the forget gate value is f t , the output gate value is o t , then the internal operation mechanism of a single long short-term memory unit can be expressed as formula (4) to formula (9). By calculating the hidden state h of the current time step tBy constantly adjusting the opening and closing of each gating unit and calculating the hidden state of the cell state, BiLSTM can effectively process text sequences and capture global semantic features.
[0068] f t =σ(W f ·[h t-1 ,x t ]+b f ) (4)
[0069] i t =σ(W i ·[h t-1 ,x t ]+b i ) (5)
[0070]
[0071]
[0072] o t =σ(W o ·[h t-1 ,x t ]+b o ) (8)
[0073] h t =o t *tanh(C t ) (9)
[0074] In order to make the classification prediction results more accurate, the model integrates the pre-training output of BERT to obtain the positive text feature sequence and the negative text feature sequence, and obtains the feature vector hw of BiLSTM by splicing. Represents vector concatenation, and the specific calculation process is from formula (10) to formula (12):
[0075]
[0076]
[0077]
[0078] For local feature extraction, the local semantic features of the intangible cultural heritage text are analyzed based on the network structure of the convolutional layer. When dealing with multi-classification problems, most of them consider the extraction of semantic features, but ignore the dependency problem of multiple categories. In order to solve this problem, the encoder and decoder are used to capture the correlation between any two labels, further strengthening the label dependency and text features.
[0079] When predicting the classification of intangible cultural heritage text, BERT accepts the input of the text sequence and outputs a vector representation containing global semantic information, such as the feature vector of each word or subword. Although the BERT model learns the semantic features of the text through the pre-trained model, it cannot capture the local information structure of the data well, such as the recognition of fixed phrases or association patterns, which is another important part of the research in the field of intangible cultural heritage, namely named entity recognition. In order to enhance the generalization ability of the model, MASFM introduces the Conv1D one-dimensional convolutional layer on the basis of the multi-head attention and long short-term memory network pre-training models to further capture the local information features of the text sequence, thereby improving the performance of the model when processing text data.
[0080] like Figure 4 As shown in the figure, the convolution layer is composed of several convolution layers, pooling layers, fully connected layers and activation layers. This part aims to use different convolution kernels to capture the N-gram feature representation of adjacent texts. First, the sliding window calculation of the convolution kernel is used to cover the word embedding or character embedding at each position to extract the local features in the text. At each position, convolution calculation is performed with the text subsequence, and the feature values of all positions are concatenated to form a feature map to record the local features of the position. Then, a pooling layer is added to reduce the feature map dimension by downsampling, reduce the number of parameters, and increase the translation invariance of the model, so that the MASFM model can better understand the structure and semantic information in the text. Among them, the convolution layer is related to the convolution kernel and the text sequence. Assuming that m is the length of the convolution kernel and k is the length of the input signal, the signal sequence x1,...,x m The convolution can be expressed as:
[0081]
[0082] In order to further improve the classification prediction performance, it is necessary to solve the potential problems of feature fusion. One method is to establish the potential association between text sequence features and type labels to perform feature fusion. When the model is not perfect, semantic feature extraction tends to ignore the semantic information contained in the intangible cultural heritage type label itself, insufficient feature representation or processing feature mismatch. Therefore, the category features are extracted according to the original intangible cultural heritage category to ensure that the fused features contain the semantic information of the intangible cultural heritage category. Secondly, the classification prediction part uses a fully connected layer to fuse the features of the category and the text sequence, and selects ReLU as the activation function to assist the iterative training of the entire model.
[0083] The structure of the classification prediction layer is as follows Figure 5As shown in the figure. The classification prediction layer consists of BiLSTM global features, CNN local features and MLP layers. The MASFM model fuses text features and type features through LSTM units and convolutional layers, and inputs them into the MLP. The MLP layer is usually located at the end of the neural network model. The MASFM model defines a multi-layer fully connected structure, selects ReLU as the activation function, integrates the text features extracted from the upper layer, and strengthens the associated features through multi-layer perceptrons and residual connections, and combines the activation function softmax to perform multi-classification prediction of non-legacy text.
[0084] In order to facilitate update iteration and parameter calculation, the Adam optimizer is selected to adjust parameters during model training. The Adam optimizer is essentially an optimization algorithm with an adaptive learning rate, where m t and v t It is the estimated value of the first and second moment of the sample. β is the estimated decay rate, which is usually 0.9 or 0.999. t+1 is the updated constant, then the optimizer dynamic update process can be expressed as formula (14)-formula (15).
[0085]
[0086]
[0087] In view of the multi-classification of text, the MASFM model uses the cross entropy loss function to measure the gap between the model prediction value and the true value, aiming to minimize the loss function Loss through repeated iterative training of the improved pre-training model. First, in the training stage, the multi-layer attention mechanism and global features are fully utilized to extract the hidden semantic information of the intangible cultural heritage, and the local features of the text and its category are obtained by combining the convolution layer. At the same time, the MASFM model fuses global features and local features to generate more accurate semantic features. The intangible cultural heritage text classification prediction model uses the association loss as the optimization target and continuously trains the model.
[0088] min Loss = min(L relation +L prediction ) (16)
[0089] During the training phase, the cross entropy loss L relation The loss function is related to the probability p of predicting sample i to belong to category j and the indicator variable y. The definition of the loss function is shown in (17):
[0090]
[0091] Among them, y represents the true type label, and p represents the predicted type label through the classification prediction layer. The MASFM model does not require category information in the prediction stage and only uses the loss function L in the text training stage.relation .
[0092] In the prediction stage, the loss function L_prediction needs to be redefined, where y is the real intangible cultural heritage type label, Predict categories for text sequence features through the classification prediction layer.
[0093]
[0094] Finally, the classification prediction layer successively goes through text representation, temporal feature extraction, and local feature capture, and maps the fused features to the target space through the fully connected layer and the output layer, thereby outputting the category probability distribution p(y=j|x) of the intangible cultural heritage text resource. Assuming that there is an input text feature x and the bias term is b, the predicted classification probability distribution can be defined as formula (19).
[0095]
[0096] The present invention combines the semantic features of intangible cultural heritage texts and constructs a MASFM intangible cultural heritage text classification prediction model based on a multi-attention pre-training model, which mainly includes a text representation layer, a feature extraction layer, and a prediction classification layer. The text representation layer converts the input intangible cultural heritage text sequence and the corresponding classification into a coding representation of a word vector through pre-training; in the feature extraction layer, the bidirectional LSTM layer further extracts the word order dependency in the text sequence and encodes the sequence; the convolution layer uses the convolution operation to extract local features in the text to improve the classification prediction performance of the model. Finally, the classification prediction layer performs feature fusion through the MLP layer to obtain the classification prediction result.
[0097] The specific process of the MASFM model can be divided into: text vector representation, semantic feature extraction and classification prediction.
[0098] Text vector representation. Preprocess the text data set for classification prediction, convert the text category into a digital label, and obtain the input text sequence and type label, denoted as X = (x1, x2, ..., x i , ..., x N ), where x i (i=1,...,N) represents the i-th word in the text sequence, and N is the maximum length defined. Based on the BERT pre-trained model, an attention mask is added. The text sequence is converted into a data format supported by the BERT model, and the BERT model with multi-head attention mechanism is loaded. After the bidirectional Transformer encoder, the input text features are extracted to obtain the vector representation of each sequence, which is recorded as w i =(w1, ..., w ni ). ni Represents the nth word vector of the i-th text sequence in the text.
[0099] Semantic feature extraction. First, based on BERT’s vector encoding, a bidirectional LSTM layer is constructed to capture the dependencies between the previous and next text sequences. The vector sequence generated by BERT is used as the input of BiLSTM to obtain the output of each time step as the global feature of the text sequence. Secondly, in order to reduce the feature dimension and retain important text information, the key information is mined through the maximum pooling operation. In addition, the size and number of convolution kernels of the one-dimensional convolution layer are adjusted to capture local features of different lengths.
[0100] Classification prediction. The pooled outputs of the BiLSTM and convolution layers are used to form a comprehensive feature vector. The feature vector is obtained by fusing the features of the category and the text sequence through the fully connected layer. The comprehensive feature vector is input into the MLP layer to combine the category semantic features and text features to perform multi-classification prediction of intangible cultural heritage. During the prediction process, the model outputs the corresponding probability distribution based on the feature vector of the text, thereby realizing the classification prediction of the intangible cultural heritage text.
[0101] This example mainly focuses on intangible cultural heritage texts, and compares and discusses the classification prediction performance of the MASFM model and the benchmark model from the aspects of experimental data, experimental environment, evaluation indicators and benchmark models, and performs a visual analysis of the model's pre-training process. In addition, in order to explore the impact of different parameters on the model's classification prediction performance, this example sets up three sets of parameter control experiments to verify the model's classification prediction ability. Finally, the experimental content is summarized.
[0102] This example selects the national representative intangible cultural heritage list information provided by the China Intangible Cultural Heritage Network as the data source, and combines the characteristics of intangible cultural heritage data to construct an experimental data set. In the process of data analysis and processing, this example carefully classifies the intangible cultural heritage data according to the characteristics of the application area and project, and constructs a multi-dimensional data index, thereby achieving in-depth mining of intangible cultural heritage text data.
[0103] In order to better classify and analyze intangible cultural heritage texts, the experimental data is subdivided into ten categories, including folk literature, traditional music, traditional skills, and folklore, with a total of 3,610 sub-items. The data index mainly includes project number, name, project category, publication time, application area or unit, and protection unit.
[0104] Considering that there are duplications of intangible cultural heritage lists between different regions in the dataset, this experiment selected the two fields of "project name" and "category" for classification prediction of intangible cultural heritage text resources. After preprocessing operations such as text cleaning and removal of duplicates, more than 1,000 items collected from the Internet were added and finally merged into the experimental dataset. The information of each category of intangible cultural heritage resources is shown in Table 1.
[0105] Table 1
[0106]
[0107] This experiment selected bidirectional long short-term memory neural network, convolutional neural network and recurrent neural network as benchmark models. In terms of experimental parameters, the maximum length of the sequence is defined as 32, the learning rate is 0.001, and the number of data categories is 10. During the model training process, the number of training iterations is 16, the number of batch samples is 512, the Adam optimizer is used to update the loss gradient function, and the weight decay is set to 0.001. In addition, the data set is divided into training set, validation set and test set in a ratio of 8:1:1. The detailed information of the experimental environment parameters is shown in Table 2.
[0108] Table 2
[0109]
[0110]
[0111] In order to solve the multi-classification prediction problem of intangible cultural heritage texts, this experiment selected accuracy and sparse categorical cross entropy loss (SCCL) as evaluation indicators to intuitively evaluate the performance of the training model.
[0112] (1) Accuracy
[0113] The accuracy rate is used to measure the proportion of samples that the model predicts as positive for intangible cultural heritage texts, which can be obtained by calculating the number of positive samples in the data. The value determines the accuracy of the algorithm. The larger the value, the more comprehensive the classification prediction information. When dealing with binary classification problems, the number of true positive examples, false positive examples, true negative examples, and false negative examples can be analyzed through the confusion matrix in Table 3 to evaluate the model.
[0114] Table 3
[0115]
[0116] For multi-classification text sequences, assume that a set contains M text data and K categories, there is a true sample set TP and a negative sample set TN, that is, the accuracy can be expressed as:
[0117]
[0118] (2) Sparse classification cross entropy loss
[0119] Due to the complexity of the categories of intangible cultural heritage resources, data samples may be unevenly classified. In order to reduce the complexity of calculation and storage, this experiment defines the intangible cultural heritage categories as integer codes, which are important parameters for calculating the sparse classification cross entropy loss. Assume that there are C categories, y is the integer code of the true type label, and p is the integer code of the true type label. i is the classification probability distribution predicted by the model. The cross entropy loss value SCCL for a single text can be expressed as:
[0120]
[0121] In order to verify the effectiveness and accuracy of the MASFM model, seven deep neural network models were selected as reference comparisons. The benchmark models include MLP, RNN, CNN, TFBERT, TextCNN, BiLSTM and Multi_LSTM.
[0122] The MASFM model uses the BERT pre-trained model to convert the input non-legacy text into a vector representation of fixed dimensions, and adds bidirectional LSTM and convolutional neural networks to capture the front-end dependencies and local key information in the text. The model divides the divided training set into several batches according to the set batch size, and passes the prediction value forward in each batch, and calculates the loss value backward to backpropagate to update the parameters. Usually, the model needs to be repeatedly trained to continuously adjust the network parameters to improve the classification prediction performance. Therefore, appropriately adjusting Epoch is one of the important parameters of the training model. However, if its value is too large or too small, underfitting and overfitting will occur. Therefore, it is necessary to observe based on the accuracy and loss value.
[0123] In order to comprehensively explore the deep classification prediction performance of the MASFM model for the association between intangible cultural heritage text sequences and categories under different hyperparameters, this embodiment adopts multiple training parameter settings and uses appropriate parameter tuning strategies to evaluate the generalization performance of the model and ultimately determine the best parameter combination to achieve the best classification effect. Figure 6 It can be seen that this embodiment conducts multiple experiments at different learning rates. And the average training status of the model in other 5 groups of experiments is displayed in a visual form when the learning rates are 0.001, 0.005, 0.01, 0.05, and 0.1. Figure 6 , Figure 7 The experimental results show that:
[0124] 1) When the learning rate is 0.001 and the batch size is 512, the training results of MASFM on specific hyperparameter groups are better than those on other parameters, which verifies the effectiveness of MASFM based on attention mechanism and text semantic features. At the same time, the consistency of multiple hyperparameter settings shows that the MASFM model can fully exploit the characteristics of intangible cultural heritage text sequences by taking advantage of the pre-trained model and deep learning structure.
[0125] 2) As the learning rate and batch size continue to increase, the average training time, prediction accuracy, and average training loss of the model are different. The average training loss increases with the learning rate, but when the batch size is 512, the average loss is significantly reduced by 2.92 compared with the previous column, indicating that the deep learning model is more sensitive to different training parameters.
[0126] In order to further verify the influence of each part of the MASFM model on the intangible cultural heritage classification prediction task, a series of ablation experiments were carried out on each module based on the constructed intangible cultural heritage dataset, including the attention module and the semantic extraction part.
[0127] From Table 4, this embodiment divides the data set and selects accuracy and sparse cross entropy as evaluation indicators to verify the effectiveness of each part of the intangible cultural heritage text classification prediction model. When analyzing the impact of different modules on the classification results, the evaluation results are marked in bold as the best effect, and Train, Val and Test represent the divided data sets.
[0128] Table 4
[0129]
[0130] According to the evaluation results of various indicators, it can be found that the BERT structure without multi-head attention mechanism has unsatisfactory classification prediction effect on the divided data set, and the accuracy is basically maintained below 20%. The SCCL of the test set is 2.1938, indicating that the model has the most serious data loss among many modules. Among the evaluation results of the training set, the BERT-BiLSTM model integrating bidirectional LSTM has the best classification effect, while the prediction accuracy and sparse cross entropy results of the other models are close. As the data ratio changes, the results of model prediction also change. On the validation set, BERT-MLP and MASFM have the same prediction accuracy, both 89.76%; BERT-CNN is second.
[0131] The BERT-MLP model with a fully connected layer can quickly learn text features and patterns, accelerate model training and classification prediction, and improve the accuracy of the validation set by 1.64%. By comparing the evaluation indicators of each module in the last three columns of Table 4, the BERT-BiLSTM model based on bidirectional long short-term memory has the best effect on the training set, with an accuracy of 99.19%. The latter's prediction accuracy on the test set is slightly lower than that of the MASFM model. Compared with the TFBERT model in a single neural network structure, the MASFM model that integrates the attention mechanism and semantic features has the best effect on the classification prediction of intangible cultural heritage text sequences. In addition, the model has the best prediction accuracy on the validation set and test set, which shows that the BERT-based pre-trained deep learning model can learn rich semantic representations through self-supervised learning and fine-tuning optimization, which improves the classification prediction performance of the MASFM model for intangible cultural heritage text.
[0132] In order to more intuitively compare the impact of each module on classification prediction, we draw graphs to show the changing trends of each model on the training set and validation set. Figure 8 (a)-(b), Fig. 9 From (a) to (b), the changes in the classification prediction accuracy of each module of the fusion pre-training model are basically the same. Among them, the classification effect of the single TFBERT structure is poor, and the prediction accuracy of BERT_CNN, BERT_BiLSTM and BERT_MLP on the training set is higher. The classification prediction effect of the MASFM model based on convolutional layer and bidirectional LSTM text features is the best, with an accuracy of 98.75%, which is much higher than the training effect of MLP and RNN. This shows that the BERT module alone may not be able to analyze the hidden information of the intangible cultural heritage text well. It is necessary to introduce neural network structures such as bidirectional LSTM, convolutional layer, and fully connected layer, optimize the classification prediction model, and adjust the generalization ability of the training, so as to fully capture the complex information in the intangible cultural heritage text and improve the accuracy of the classification results.
[0133] The performance of the MASFM model is further compared with that of the benchmark model. In order to reduce the error caused by the hyperparameters during the experiment, this embodiment adjusts the hyperparameters of the benchmark model with reference to the model parameters set in the experimental environment. During the experimental training process, this experiment uses 5 evaluation indicators as reference comparisons for model performance. During the model training process, the average training loss and average convergence accuracy of the model training are observed and recorded. In the model prediction stage, the average training time is used as the experimental test indicator.
[0134] Among these evaluation indicators, Accuracy_K represents the accuracy of the model tested on the training set, validation set, and test set, respectively. SCCL_K is used to evaluate the generalization ability of the model in the divided data set. The lower the loss value, the better the performance of the model in the intangible cultural heritage text prediction and classification task. In addition, the average training time represents the average time consumed by the training of a single node of the model, in seconds (s); the average training loss represents the average loss value of the model reaching the convergence state during the training process. The lower training loss indicates that the model has a higher fitting effect on the training data. The average convergence accuracy represents the accuracy of the model on the test set. The higher convergence accuracy indicates that the classification prediction performance of the model gradually improves during the training process. Table 5 shows the overall performance comparison of the model.
[0135] Table 5
[0136]
[0137] From Table 5, we can see the overall performance of each model. As the depth of the neural structure becomes more complex, the overall training time becomes longer, and the average training time corresponding to the convergence of the model. By comparing MLP and RNN, it can be concluded that the accuracy_1 values of these two methods on the training set are 99.39% and 92.56% respectively, but the classification prediction effect on the test set is lower than that of the MASFM model, and the corresponding loss values are 0.5188 and 1.0312. In particular, the RNN model did not achieve good classification prediction performance during the pre-training process. The prediction results of the Multi_LSTM and TextCNN models in the experimental data set are not ideal, and their prediction accuracy is only 19.68% and 19.85%, and the average training loss values are 2.1998 and 2.2023. This shows that the multi-time scale LSTM model has limited processing length for intangible cultural heritage texts, and some information may be lost when processing data; and the text convolution TextCNN model cannot accurately mine the text features of intangible cultural heritage data without introducing multi-head attention. At the same time, as the complexity of the model increases, the model training time and data loss increase accordingly. Comparing the first two columns in the table, after multiple rounds of training, the model showed high accuracy in the verification phase and the test phase. Compared with other benchmark models, MASFM has the highest values in the test set and the overall average convergence accuracy, indicating that the pre-trained model that integrates text features has better classification prediction effect in the classification task of intangible cultural heritage text sequences.
[0138] Fig.10It reflects the training status of each model on the divided data set. By comparing the four sub-graphs (a), (b), (c), and (d), it can be clearly seen that the accuracy of the single TextCNN and Multi_LSTM models on the pre-training and validation sets basically fluctuates around 0.2, indicating that it is difficult for these two models to fully learn the unique semantics and contextual information of the intangible cultural heritage text, resulting in insufficient training generalization ability, and the corresponding cross entropy loss is the most serious. On the contrary, although the multi-layer perceptron MLP model has a simple structure, it can adjust the number of neurons, the number of layers, and the activation function of the hidden layer according to the actual data of the intangible cultural heritage classification prediction. Its average convergence accuracy and loss are second only to the MASFM model. MLP pre-training usually uses the back propagation algorithm to reduce the loss function by continuously adjusting the weights and biases. Its flexible network structure is used to integrate the text features of the MASFM model in multiple layers. In addition, compared with models such as RNN and TextCNN, the overall accuracy and loss value of MASFM on the training set are better than other models, and the change of the curve tends to be stable after multiple iterations.
[0139] from Fig.11 From (a) to (c), due to the division of the data set, the expected effect of each model on the validation set is slightly lower than the preprocessing of the training set. Among them, sub-figure (a) shows that the classification effect of TextCNN and the multidimensional Multi_LSTM model is poor. With the increase of the number of iterations, the data loss of the recurrent neural network is alleviated, but the data loss is still higher than the previous two models. However, the prediction accuracy trend of the BERT model integrated with pre-training in this embodiment is basically stable above the baseline model, without much fluctuation, indicating that the MASFM model fully learns the potential characteristics of the intangible cultural heritage text, thereby improving the training accuracy of classification prediction.
[0140] In summary, through the comparison of the training results of multiple models, it can be found that BERT can better capture the front-end dependency of text through pre-training of large-scale text data, but the structure has high requirements for computing resources and cannot process long text sequences alone; BiLSTM solves the limitations of traditional LSTM unidirectional memory units and improves the model's classification and prediction ability for text sequences, but the training time is long and it cannot extract local information of the data; CNN stacks multiple convolutional layers to learn the expression ability of intangible cultural heritage text representation and improves the representation ability of the model layer by layer. Compared with recurrent neural networks and long short-term memory neural networks, it cannot directly analyze the temporal relationship in text sequences and has certain limitations in the classification and prediction tasks of intangible cultural heritage lists. Therefore, this study relies on the pre-trained BERT model, combined with bidirectional LSTM and one-dimensional convolutional layers, to make up for the problems of insufficient front-end dependency and local feature extraction of text sequences, and constructs the MASFM classification and prediction model. Through multiple experimental comparisons and verifications, compared with a single deep neural network model, the MASFM model shows better performance in the classification and prediction tasks of intangible cultural heritage text resources.
[0141] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. Multi-classification prediction method of intangible cultural heritage text based on multi-head attention and semantic features, It is characterized in that include: Get the text dataset to be classified and predicted; The text data set to be classified and predicted is input into the intangible cultural heritage text classification prediction model to obtain the classification prediction result, wherein the intangible cultural heritage text classification prediction model is obtained by training with a training set, and the training set includes a text sequence and a type label. The intangible cultural heritage text classification prediction model is used to convert the text data set to be classified and predicted into a vector coding representation, extract global and local features according to the vector coding, fuse and classify the global and local features, and generate the classification prediction result.
2. The intangible cultural heritage text multi-classification prediction method based on multi-head attention and semantic features according to claim 1, It is characterized in that Acquiring a training set including a text sequence and a type label includes: converting the text category of the text data set to be classified and predicted into a digital label, and acquiring the text sequence and the type label.
3. The intangible cultural heritage text multi-classification prediction method based on multi-head attention and semantic features according to claim 2, It is characterized in that Training the intangible cultural heritage text classification prediction model through the training set includes: The text sequence and the type label are jointly input into a text representation layer, and the vector encoding is obtained through a multi-head attention mechanism; Input the vector code into the semantic feature extraction layer, and extract the global features and local features of the vector code by fusing the long short-term memory network and the convolution layer; The global features and local features are input into the classification prediction layer to perform classification prediction and obtain the classification prediction result.
4. The intangible cultural heritage text multi-classification prediction method based on multi-head attention and semantic features according to claim 3, It is characterized in that The text representation layer includes a pre-trained model BERT and a multi-head attention network; The pre-trained model BERT is used to represent the text sequence and type label with word vectors; The multi-head attention network is used to perform multi-dimensional feature expression on the word vector representation to obtain the vector encoding.
5. The intangible cultural heritage text multi-classification prediction method based on multi-head attention and semantic features according to claim 3, It is characterized in that The semantic feature extraction layer includes a BiLSTM network and a convolutional layer; The BiLSTM network is used to extract positive feature sequences and negative feature sequences from the vector code and concatenate them to obtain global features of the vector code, wherein the global features include text global features and type global features; The convolution layer is used to extract local features of the vector encoding through a convolution layer, wherein the global features include text local features and type local features.
6. The intangible cultural heritage text multi-classification prediction method based on multi-head attention and semantic features according to claim 3, It is characterized in that Inputting the global features and the local features into the classification prediction layer for classification prediction includes: fusing the global features and the local features through a fully connected layer, and performing multi-classification prediction of the intangible cultural heritage text on the fused features through an MLP layer.
7. The intangible cultural heritage text multi-classification prediction method based on multi-head attention and semantic features according to claim 1, It is characterized in that The optimization goal of the intangible cultural heritage text classification prediction model is: min Loss=min(L relation +L prediction ) Among them, Loss is the joint loss function, L relation is the cross entropy loss in the training phase, L prediction is the cross entropy loss function in the prediction stage.
Citation Information
Cited By
Method for predicting antibacterial peptide in bacteria based on deep learning
CN119207573A
