Multi-task joint element identification method based on multi-head attention mechanism
Through the multi-head attention mechanism and multi-task joint learning method, the problems of incomplete semantic information extraction and inaccurate boundary positioning in traditional case element recognition methods are solved, and the accuracy of case element recognition is significantly improved.
Patent Information
- Application Number
- CN202411233255.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-09-04
AI Technical Summary
Traditional case element recognition methods based on convolutional neural networks (CNN) or recurrent neural networks (RNN) are difficult to fully extract text semantic information or cannot accurately locate feature boundary information when dealing with complex multi-source case documents, resulting in low recognition accuracy.
Using a multi-task joint learning method based on the multi-head attention mechanism, text features are dynamically extracted through the pre-trained language model of the multi-head attention mechanism, combined with a two-way long and short-term memory network and a conditional random field algorithm to construct Chinese word segmentation and text classification models, and then parallelize Train shared parameters and information to build a feature recognition model for multi-dimensional feature fusion.
It significantly improves the accuracy of case element recognition, overcomes the problems of incomplete text semantic extraction and inability to extract factor boundary information in traditional methods, and improves the recognition effect.
Smart Images

Figure CN118964858A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing, and specifically relates to a multi-task joint element recognition method based on a multi-head attention mechanism. Background Art
[0002] Against the backdrop of the rapid development of big data and artificial intelligence technologies, accurately extracting key case element information from massive, complex, and multi-source dossier documents has become a vital task. Traditional dossier material analysis often requires a lot of time and manpower to extract key case elements. The case element identification task is based on natural language processing and information extraction technology. It extracts key element information that can fully present the case from massive unstructured texts, which helps staff quickly clarify the relationship between key points of evidence and provides a strong basis for the identification of facts. At the same time, it provides structured data support for downstream tasks, such as knowledge graph construction, similar case retrieval and recommendation, thereby comprehensively improving the efficiency and quality of case handlers' work.
[0003] The identification of case elements in electronic case files is essentially equivalent to entity identification in general fields. This task occupies a pivotal position in the field of natural language processing. The research on entity identification methods includes methods based on rule matching technology, methods based on machine learning statistics, and methods based on deep learning models. At present, there are two main problems with element recognition technology: (1) The semantic information of the text is not fully captured. The case information of the case file is not only related to the context information, but may also exist in the global information of the document. Some case information may even be expressed across multiple pages, which will seriously affect the accuracy of element recognition; (2) The element boundary positioning is not accurate, resulting in inaccurate or unrecognizable problems in the nested entity recognition in the document text. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] The technical problem to be solved by the present invention is how to provide a multi-task joint element recognition method based on a multi-head attention mechanism to solve the problems faced by traditional case element recognition methods based on convolutional neural networks (CNN) or recurrent neural networks (RNN) when processing complex multi-source case documents, such as difficulty in fully extracting text semantic information or inability to accurately locate element boundary information.
[0006] (II) Technical solution
[0007] In order to solve the above technical problems, the present invention proposes a multi-task joint feature recognition method based on a multi-head attention mechanism, which comprises the following steps:
[0008] S1. Data preprocessing of electronic file documents: The original electronic file documents are in PDF format, which are converted into pure TXT text format, and regular expressions are used for data preprocessing;
[0009] S2. Construct a training data set for the multi-task joint learning factor recognition model and use the BIO annotation method to annotate the key case elements word by word; specifically, the following steps are included:
[0010] S3. Construct the input layer of the multi-task joint learning feature recognition model and use the pre-trained language model with multi-head attention mechanism to dynamically extract the feature vector of the input text;
[0011] S4. Construct the processing layer structure of the multi-task joint learning factor recognition model, including: Chinese word segmentation task, text classification task and factor recognition task; specifically includes the following sub-steps:
[0012] S41. Construct a Chinese word segmentation task based on a bidirectional long short-term memory neural network + conditional random field algorithm. The bidirectional long short-term memory neural network is used to better understand the relationship between the word segmentation sequence at the current position and the context. The conditional random field algorithm is combined to add word segmentation constraints, and the conversion rules and context semantics between sequences are considered. The entire Chinese word segmentation result is globally optimized to obtain the text segmentation vector.
[0013] S42. Construct a text classification task based on a text convolutional neural network. Add the character [CLS] at the beginning of each input text to indicate the classification. Use a pre-trained language model based on a multi-head attention mechanism to obtain the text representation vector of the input text. Use multiple convolution kernels of the text convolutional neural network to capture the local semantic information of the text. Use maximum pooling to capture the global important features of the text to obtain the text classification result.
[0014] S43, fusing the text segmentation vector obtained in the above sub-step S41 and the text representation vector with category information obtained in the sub-step S42 to obtain a multi-dimensional semantic representation vector; finally, combining the conditional random field algorithm to construct a feature recognition task based on multi-dimensional feature vector fusion;
[0015] S5. Design a joint loss function for the multi-task joint learning factor recognition model: construct the loss functions of the three tasks in step S4 respectively, and initialize the weight coefficients of the loss function of each task as the hyperparameters of the joint loss function. Optimize the model hyperparameters by minimizing the joint loss function, so that the model shares information and parameters on multiple tasks.
[0016] S6. Parallel training of the Chinese word segmentation task based on bidirectional long short-term memory neural network + conditional random field, the text classification task based on text convolutional neural network, and the feature recognition task based on multi-dimensional feature vector fusion. Optimize the model hyperparameters by minimizing the joint loss function until the model converges and saves the optimal model parameters. Finally, obtain the case feature recognition results by loading the trained model file.
[0017] (III) Beneficial effects
[0018] The present invention proposes a multi-task joint factor recognition method based on a multi-head attention mechanism. The innovation of the present invention lies in the four types of documents in the field of procuratorial business, using a pre-trained language model with a multi-head attention mechanism, dynamically obtaining the deep semantic information of the input text, and constructing a Chinese word segmentation model based on a bidirectional long short-term memory network + conditional random field algorithm, a text classification model based on a text convolutional network, and a factor recognition model based on multi-dimensional feature fusion. The use of a parallel training strategy to share the parameters and information of subtasks can significantly improve the learning efficiency and generalization ability of the model, effectively solve the problems of incomplete text semantic extraction and inability to extract factor boundary information in traditional entity recognition technology in the field of procuratorial business, and improve the accuracy of case factor recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 This is a structural diagram of the case element recognition model based on multi-task joint learning of the multi-head attention mechanism of the present invention;
[0020] Figure 2 Label examples for the training dataset of the feature recognition model;
[0021] Figure 3 This is a diagram of the model structure and internal module logic based on the multi-head attention mechanism. DETAILED DESCRIPTION
[0022] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.
[0023] The present invention aims to solve the problems faced by traditional case element recognition methods based on convolutional neural networks (CNN) or recurrent neural networks (RNN) when processing complex multi-source case documents, such as difficulty in fully extracting text semantic information or inaccurately locating element boundary information, and proposes a case element recognition method based on multi-task joint learning of a multi-head attention mechanism. This method effectively overcomes the defects of unclear element boundary recognition and incomplete capture of local and global semantic features of text, significantly improves the performance of case element recognition in file documents, and enhances the recognition effect.
[0024] In view of the above problems, the present invention proposes a case element recognition method based on multi-task joint learning of multi-head attention mechanism. First, the electronic file document is preprocessed, including document data format conversion and data preprocessing; secondly, a training data set of the element recognition model of multi-task joint learning is constructed, and the training data is labeled using the BIO labeling method; then, the pre-trained language model based on the multi-head attention mechanism dynamically obtains the deep semantic information of the text as the input layer of the element recognition model of multi-task joint learning; then, a Chinese word segmentation model based on bidirectional long short-term memory network + conditional random field is constructed to extract element boundary semantic features, and a text classification model based on text convolutional neural network is used to extract local and global semantic features of the text, and multi-dimensional text feature vectors are integrated, and a multi-task joint learning element recognition model is constructed in combination with the conditional random field algorithm; finally, a multi-task joint loss function is designed, and a parallel training strategy is adopted to share model parameters and information. Multiple subtasks are trained and optimized simultaneously by minimizing the joint loss function, thereby realizing accurate recognition of case elements.
[0025] The present invention proposes a case element recognition method based on multi-task joint learning of a multi-head attention mechanism, and the technical solution includes the following steps:
[0026] S1. Preprocessing of electronic file data: The original electronic file is in PDF format, which is converted into pure TXT text format, and data preprocessing is performed using regular expressions and other technologies. Specifically, it includes the following sub-steps:
[0027] S11. Use OCR recognition technology to convert electronic file data in PDF format into pure TXT text format;
[0028] S12. Screen four types of documents: prosecution opinion, arrest request, interrogation record, and inquiry record. The electronic file contains these four types of documents and other complex and diverse document types. The text characteristics of these four types of documents are that the document title and the first few lines of content have document type descriptions. Based on the first few lines of content, determine the documents containing the text of "prosecution opinion", "arrest request", "interrogation record", and "inquiry record";
[0029] S13. Perform data cleaning on the text data, use regular expressions to filter out characters other than Chinese characters, Chinese punctuation, English, English punctuation and English letters, remove stop words by loading a stop word dictionary, and perform other data deduplication and denoising processes.
[0030] S2. Construct a training data set for the multi-task joint learning factor recognition model and use the BIO (B-begin, I-inside, O-outside) annotation method to annotate key case elements word by word. The specific steps include:
[0031] S21, the target text data is divided into sentences. First, the text is segmented according to the period, and then the character length of the two sentences before and after is judged to determine whether to merge the sentences. If the total character length of sentence 1 and sentence 2 is less than 500, sentence 1 and sentence 2 are merged; otherwise, they are not merged.
[0032] S22, divide the model training set and test set data into 8:2 ratio;
[0033] S23, manually label the training set data using the BIO labeling method. The present invention labels and identifies eight case elements: a criminal suspect, a victim, a criminal act, and a criminal amount (including investment amount, loss amount, and return amount).
[0034] S3. Construct the input layer of the multi-task joint learning feature recognition model and use the pre-trained language model with multi-head attention mechanism to dynamically extract the feature vector of the input text.
[0035] S4. Construct the processing layer structure of the multi-task joint learning factor recognition model, including: Chinese word segmentation task, text classification task and factor recognition task. Specifically, it includes the following sub-steps:
[0036] S41. Construct a Chinese word segmentation task based on a bidirectional long short-term memory neural network + conditional random field algorithm, which can effectively model context information. The bidirectional long short-term memory neural network is used to better understand the relationship between the word segmentation sequence at the current position and the context before and after. The conditional random field algorithm is combined to add word segmentation constraints, and the conversion rules and context semantics between sequences are considered. The entire Chinese word segmentation result is globally optimized to obtain the text word segmentation vector;
[0037] S42. Construct a text classification task based on a text convolutional neural network. Add the character [CLS] at the beginning of each input text to indicate the classification. Use a pre-trained language model based on a multi-head attention mechanism to obtain the text representation vector of the input text. Use multiple convolution kernels of the text convolutional neural network to capture the local semantic information of the text. Use maximum pooling to capture the global important features of the text to obtain the text classification result.
[0038] S43, the text segmentation vector obtained in the above sub-step S41 and the text representation vector with category information obtained in sub-step S42 are fused to obtain a multi-dimensional semantic representation vector. Finally, a factor recognition task based on multi-dimensional feature vector fusion is constructed in combination with the conditional random field algorithm.
[0039] S5. Design the joint loss function of the multi-task joint learning factor recognition model. Construct the loss functions of the three tasks in step S4 respectively, and initialize the weight coefficients of the loss function of each task as the hyperparameters of the joint loss function. Optimize the model hyperparameters by minimizing the joint loss function, so that the model can share information and parameters on multiple tasks, thereby improving the learning efficiency and generalization ability of the model.
[0040] S6. Parallel training of Chinese word segmentation tasks based on bidirectional long short-term memory neural network + conditional random field, text classification tasks based on text convolutional neural network, and feature recognition tasks based on multi-dimensional feature vector fusion, optimizing model hyperparameters by minimizing the joint loss function until the model converges and saving the best model parameters. Finally, the case feature recognition results are obtained by loading the trained model file.
[0041] Embodiment 1:
[0042] Figure 1 The figure shows a model structure diagram of a case element recognition method based on multi-task joint learning of a multi-head attention mechanism, which mainly includes a pre-trained language model of a multi-head attention mechanism, a text classification task based on a text convolutional neural network (TextCNN), a Chinese word segmentation task based on a bidirectional long short-term memory network (BiLSTM) + CRF, and an element recognition task based on multi-dimensional feature vector fusion. The specific implementation steps are as follows:
[0043] Step 1 of the technical solution of the present invention: preprocessing the case electronic file document data. The original electronic file document is in PDF format, which is converted into a pure TXT text format, and data preprocessing is performed using regular expressions and other technologies. Specifically, it includes the following sub-steps:
[0044] S11. Use OCR recognition technology to convert electronic file data in PDF format into pure TXT text format;
[0045] S12. Screen four types of documents: prosecution opinion, arrest request, interrogation record, and inquiry record. The electronic file contains these four types of documents and other complex and diverse document types. The text characteristics of these four types of documents are that the document title and the first few lines of content have document type descriptions. Based on the first few lines of content, identify the documents containing the keywords "prosecution opinion", "arrest request", "interrogation record", and "inquiry record";
[0046] S13. Perform data cleaning on the text data, use regular expressions to filter out characters other than Chinese characters, Chinese punctuation, English, English punctuation and English letters, and perform other data deduplication and denoising processes, and remove frequently appearing but meaningless stop words by loading a stop word dictionary.
[0047] Step 2 of the technical solution of the present invention: construct a training data set for the multi-task joint learning factor recognition model. Use the BIO (B-begin, I-inside, O-outside) annotation method to annotate the key case elements word by word. Specifically, it includes the following steps:
[0048] S21, the target text data is divided into sentences. First, the text is segmented according to the period, and then the character length of the two sentences before and after is judged to determine whether to merge the sentences. If the total character length of sentence 1 and sentence 2 is less than 500, sentence 1 and sentence 2 are merged; otherwise, they are not merged.
[0049] S22, divide the model training set and test set data into 8:2 ratio;
[0050] S23. Use the BIO annotation method to manually annotate the training set data. The present invention annotates and identifies the case elements of a criminal suspect, a victim, a criminal act, and a criminal amount (including investment amount, loss amount, and return amount). Use the English name as the identifier of each case element, such as SUS to identify the criminal suspect, VIC to identify the victim, and ORG to identify the unit of employment. The abbreviations of all case elements are shown in Table 1. B represents the first character of the element entity, I represents the non-first character of the element entity, and O represents the character that is not outside the defined case element. For example, the annotation method for the criminal suspect is: B-SUS represents the first character of the criminal suspect's name, I-SUS represents the non-first character of the criminal suspect's act, and so on for the data annotation methods of other case elements. The identification of case elements is shown in Table 1 below. The annotation results of some training set data are shown in the following table. Figure 2 shown.
[0051] Table 1 Case element identification
[0052] Case elements Logo Name of a criminal suspect SUSPECT Name of a victim VICTIME A work unit ORGANIZATION A criminal act ACTION A suspected crime CHARGE Amount of investment DONATE Amount of loss LOSS Amount of return (repayment) BACK
[0053] Step 3 of the technical solution of the present invention: construct an input layer of the multi-task joint learning factor recognition model. Use a pre-trained language model with a multi-head attention mechanism to dynamically extract feature vectors of the input text.
[0054] First, the input text is segmented into characters, and each character token after segmentation is converted into a corresponding vocabulary index. By loading the pre-trained language model, the feature vector of each token mapped by the vocabulary index is obtained. The structure of the pre-trained language model of the multi-head attention mechanism used in the present invention is as follows: Figure 3 As shown in Figure 1, it consists of 12 stacked Encoder modules, each of which contains a multi-head self-attention mechanism layer and a feed-forward fully connected layer. The multi-head attention mechanism layer structure is shown in Figure 1. Figure 3As shown below, the input matrix X is linearly transformed to obtain Q, K, and V as follows:
[0055] Q=XW Q
[0056] K=XW K
[0057] V=XW V
[0058] Among them, W Q , W K , W V is a trainable parameter matrix.
[0059] Next, use Q, K, and V to calculate Scaled Dot-ProductAttention. Finally, the results of multiple attention mechanism layers are concatenated and sent to a fully connected layer. The corresponding mathematical formula of Scaled Dot-ProductAttention is as follows:
[0060]
[0061] Among them, d k is the dimension of vector K.
[0062] Assume that for a sentence, the text sequence after adding the sentence start [CLS] tag and the sentence end [SEP] is X = {[cls], x 0 ,x 1 ,x 2 ,...x n ,[sep]}, then the feature vector after the pre-trained language model of the multi-head attention mechanism is E={E [cls] ,E 0 ,E 1 ,...E n ,E [sep]},like Figure 1 shown.
[0063] Step 4 of the technical solution of the present invention is to construct a processing layer structure of a multi-task joint learning factor recognition model. Specifically, it includes the following sub-steps:
[0064] S41. Construct a Chinese word segmentation task based on bidirectional long short-term memory network + conditional random field algorithm.
[0065] After using the pre-trained language model with a multi-head attention mechanism to obtain the feature vector of the input text, a bidirectional long short-term memory network is used to further obtain the contextual semantic information of the text, and a conditional random field is connected to build a Chinese word segmentation model, which converts the local semantic feature learning into a sequence labeling task to obtain the feature boundary semantic information. For example, for X = {X 1 ,X 2 ,,...X n ,}, the probability of predicting the input sequence as a word segmentation label sequence is:
[0066]
[0067] Where Score(X,Y) represents the sum of all steps of the input sequence X predicted to be the observation sequence Y. represents any possible tag sequence, Z x Represents the set of all possible label sequences for the input sequence X.
[0068] Furthermore, through the negative log-likelihood loss function, the loss function of the feature boundary learning task based on the Chinese word segmentation model is defined as:
[0069]
[0070] Among them, X represents the input text sequence, Y 分词 Indicates the true word segmentation sequence, Score(X,Y 分词 ) represents the score of the true word segmentation sequence, Score(X,y) represents the score of a predicted sequence y, and Z x Represents the set of all possible predicted sequences outputted by the input sequence X.
[0071] Assume that the Chinese word segmentation model obtains the word segmentation result of the input text as Out = {S, B, M, M, E, S, ... B, M, E, S}, and uses the pre-trained language model of the multi-head attention mechanism to obtain the feature vector of each character in the word segmentation result as H = {E s ,E B ,E M ,...E E ,E s}, B, M, E represent the start position, middle position and end position of a segmentation, S represents the non-segmentation sequence, and the character vectors belonging to a segmentation in the segmentation result are merged to obtain the segmentation vector, see formula (3):
[0072]
[0073] Among them, p represents the current position, i represents the position of B in the current segmentation result, and j represents the position of E in the current segmentation result. Thus, the text segmentation vector with the same length as the input sequence is obtained as W p = {W [cls] ,W 0 ,W 1 ,...W n ,W [sep]}.
[0074] S42. Construct a text classification task based on a text convolutional neural network. Add the character [CLS] at the beginning of each input text to indicate the classification. Use a pre-trained language model based on a multi-head attention mechanism to obtain the text representation vector of the input text. Use multiple convolution kernels of the text convolutional neural network to capture the local semantic information of the text. Use maximum pooling to capture the global important features of the text to obtain the text classification result.
[0075] Add the character [CLS] at the beginning of each input text to indicate classification. Use a pre-trained language model based on a multi-head attention mechanism to obtain the representation vector of the input text. The obtained text representation vector H' has the global semantic information of the text and is used as the input of the text convolutional neural network. Then it enters the convolution layer for calculation. The text convolutional neural network uses "wide convolution" for calculation, that is, the definition of the convolution kernel only needs to set a different number of rows, and the number of columns remains consistent with the input vector dimension. By setting multiple convolution kernels, the feature vectors of texts of different dimensions are obtained. The output vector of the convolution layer is subjected to maximum pooling calculation, and the maximum value of all values in each column is taken to obtain the output of the pooling layer. Finally, according to the output of the pooling layer and the number of classification categories, a fully connected layer is constructed for dimensional conversion, and then the probability of each classification category is obtained through Softmax.
[0076] Assume that the text representation vector of the input text is H'={h [cls] ,h 0 ,h 1 ,...,h [sep]}, the output vector after passing through the text convolutional neural network is Y = [y 1 ,y 2 ,y 3 ,...,y c ], c is the number of classification categories. In the example of the present invention, it represents the corresponding categories of case elements, that is, it represents 8 categories such as a criminal suspect, a victim, a work unit, a criminal act, and a suspected crime.
[0077] The probability of each classification category is calculated by Softmax as follows:
[0078] P(y i|i=0,1,2,...c)=Softmax(y i ) (4)
[0079] Next, the cross entropy loss function (CE) is used to define the loss value of the text classification task as follows:
[0080]
[0081] Among them, y i It takes 0 or 1 to indicate whether the current category is the real category. i ) represents the probability of the model predicting category i, and c represents the category set of the current text.
[0082] S43: The text segmentation vector W obtained in the above sub-steps S41 and S42 is p The text representation vector H' with category information is fused to obtain a multi-dimensional semantic representation vector, and the factor recognition task based on multi-dimensional feature vector fusion is constructed in combination with the conditional random field.
[0083] The vector fusion method is: vector W p H and H' are connected to the fully connected layer respectively, and their output sequences are added to calculate the arithmetic mean, and the arithmetic mean is used as the input of the conditional random field algorithm.
[0084] Finally, the negative log-likelihood is used to define the loss function of the feature recognition task based on multi-dimensional feature vector fusion, as follows:
[0085]
[0086] Among them, Y true Indicates the entity sequence of the real feature recognition, Score(X,Y true ) represents the score of the actual entity sequence, Score(X,y) represents the score of the predicted entity sequence y, and Y x Represents all possible prediction sequences for the input sequence X.
[0087] Step 5 of the technical solution of the present invention: construct a joint loss function of the multi-task joint learning factor recognition model, and define the overall loss Loss through the above subtask loss function 总 , the calculation formula obtained from formula (2), (5) and (6) is as follows:
[0088] Loss 总 =αLoss 分词 +βLoss 分类 +γLoss 融合 (7)
[0089] Among them, α, β, and γ represent the weight coefficients corresponding to the loss function of the Chinese word segmentation task based on the bidirectional long short-term memory network + conditional random field, the loss function of the text classification network task based on the text convolutional neural network, and the loss function of the feature recognition task based on the multi-dimensional feature vector fusion, respectively. The value range is [0,1], and the sum of the three values is not greater than 2. They are added as hyperparameters of multi-task joint learning in the model training process for adjustment.
[0090] Step 6 of the technical solution of the present invention: training the factor recognition model of multi-task joint learning, by preprocessing the training set, inputting the text into the model, passing through the pre-trained language model input layer of the multi-head attention mechanism, the middle layer of the three sub-task joint learning, and the loss layer. To minimize the overall loss function Loss 总 The goal is to adjust and optimize the model hyperparameters so that the model reaches the final convergence state.
[0091] Finally, three evaluation indicators are used to test and verify the model effect, namely accuracy, recall rate and F score. The calculation expression of the evaluation indicators is as follows:
[0092]
[0093]
[0094]
[0095] The innovation of this invention lies in the four types of documents in the field of procuratorial business, using a pre-trained language model with a multi-head attention mechanism to dynamically obtain the deep semantic information of the input text, and construct a Chinese word segmentation model based on a bidirectional long short-term memory network + conditional random field algorithm, a text classification model based on a text convolutional network, and an element recognition model based on multi-dimensional feature fusion. The use of a parallel training strategy to share the parameters and information of subtasks can significantly improve the learning efficiency and generalization ability of the model, effectively solve the problems of incomplete text semantic extraction and inability to extract element boundary information in traditional entity recognition technology in the field of procuratorial business, and improve the accuracy of case element recognition.
[0096] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A multi-task joint feature recognition method based on a multi-head attention mechanism, characterized in that: The method comprises the following steps: S1. Electronic file document data preprocessing: The original electronic file document is in PDF format, which is converted into pure TXT text format, and regular expressions are used for data preprocessing; S2. Construct a training data set for the multi-task joint learning factor recognition model and use the BIO annotation method to annotate the key case elements word by word; specifically, the following steps are included: S3. Construct the input layer of the multi-task joint learning feature recognition model and use the pre-trained language model with multi-head attention mechanism to dynamically extract the feature vector of the input text; S4. Construct the processing layer structure of the multi-task joint learning factor recognition model, including: Chinese word segmentation task, text classification task and factor recognition task; specifically includes the following sub-steps: S41. Construct a Chinese word segmentation task based on a bidirectional long short-term memory neural network + conditional random field algorithm. The bidirectional long short-term memory neural network is used to better understand the relationship between the word segmentation sequence at the current position and the context. The conditional random field algorithm is combined to add word segmentation constraints, and the conversion rules and context semantics between sequences are considered. The entire Chinese word segmentation result is globally optimized to obtain the text segmentation vector. S42. Construct a text classification task based on a text convolutional neural network. Add the character [CLS] at the beginning of each input text to indicate the classification. Use a pre-trained language model based on a multi-head attention mechanism to obtain the text representation vector of the input text. Use multiple convolution kernels of the text convolutional neural network to capture the local semantic information of the text. Use maximum pooling to capture the global important features of the text to obtain the text classification result. S43, fusing the text segmentation vector obtained in the above sub-step S41 and the text representation vector with category information obtained in the sub-step S42 to obtain a multi-dimensional semantic representation vector; finally, combining the conditional random field algorithm to construct a feature recognition task based on multi-dimensional feature vector fusion; S5. Design a joint loss function for the multi-task joint learning factor recognition model: construct the loss functions of the three tasks in step S4 respectively, and initialize the weight coefficients of the loss function of each task as the hyperparameters of the joint loss function. Optimize the model hyperparameters by minimizing the joint loss function, so that the model shares information and parameters on multiple tasks. S6. Parallel training of the Chinese word segmentation task based on bidirectional long short-term memory neural network + conditional random field, the text classification task based on text convolutional neural network, and the feature recognition task based on multi-dimensional feature vector fusion. Optimize the model hyperparameters by minimizing the joint loss function until the model converges and saves the optimal model parameters. Finally, obtain the case feature recognition results by loading the trained model file.
2. The multi-task joint feature recognition method based on the multi-head attention mechanism as claimed in claim 1, characterized in that: The S1 specifically includes: S11. Use OCR recognition technology to convert electronic file data in PDF format into pure TXT text format; S12. Screen four types of documents: prosecution opinion, arrest request, interrogation record and inquiry record; the electronic file contains these four types of documents and other complex and diverse document types. The text characteristics of these four types of documents are that the document title and the first few lines of content have document type descriptions. According to the first few lines of content, determine the documents containing the text of "prosecution opinion", "arrest request", "interrogation record" and "inquiry record"; S13. Clean the text data, use regular expressions to filter out characters other than Chinese characters, Chinese punctuation, English, English punctuation and English letters, remove stop words by loading a stop word dictionary, and perform other data deduplication and denoising.
3. The multi-task joint element recognition method based on the multi-head attention mechanism as claimed in claim 1, characterized in that: The S2 specifically includes: S21, the target text data is divided into sentences: first, the text is cut according to the period, and then the character length of the two sentences before and after is judged to determine whether to merge the sentences. If the total character length of sentence 1 and sentence 2 is less than 500, sentence 1 and sentence 2 are merged; otherwise, they are not merged; S22, divide the model training set and test set data into 8:2 ratio; S23. Use the BIO annotation method to manually annotate the training set data.
4. The multi-task joint element recognition method based on the multi-head attention mechanism as claimed in claim 3 is characterized in that: In S23, a criminal suspect, a victim, a criminal act, and a criminal amount are marked and identified. The criminal amount includes an investment amount, a loss amount, and a returned amount.
5. The multi-task joint feature recognition method based on the multi-head attention mechanism according to any one of claims 1 to 4, characterized in that: The step S3 specifically includes: First, perform character segmentation on the input text, convert each character token after segmentation into a corresponding vocabulary index, and obtain the feature vector of each token mapped by the vocabulary index by loading the pre-trained language model; The structure of the pre-trained language model of the multi-head attention mechanism is: it consists of 12 stacked Encoder modules, each of which contains a multi-head self-attention mechanism layer and a feed-forward fully connected layer; the multi-head attention mechanism layer structure is: the input matrix X is linearly transformed to obtain Q, K, V, as shown below: Q=XW Q K=XW K V=XW V Among them, W Q , W K , W V is a trainable parameter matrix; Next, use Q, K, and V to calculate Scaled Dot-ProductAttention; Finally, the results of multiple attention mechanism layers are concatenated and sent to a fully connected layer; Among them, the corresponding mathematical formula of Scaled Dot-ProductAttention is as follows: Among them, d k is the dimension of vector K; Assume that for a sentence, the text sequence after adding the sentence start [CLS] tag and the sentence end [SEP] is X = {[cls], x0, x1, x2, ... x n ,[sep]}, then the feature vector after the pre-trained language model of the multi-head attention mechanism is E={E [cls] ,E0,E1,...E n ,E [sep] }.
6. The multi-task joint element recognition method based on the multi-head attention mechanism as claimed in claim 5, characterized in that: The S41 specifically includes: After obtaining the feature vector of the input text using the pre-trained language model with a multi-head attention mechanism, the bidirectional long short-term memory network is used to obtain the contextual semantic information of the text, and the conditional random field is connected to build a Chinese word segmentation model, which converts the local semantic feature learning into a sequence labeling task to obtain the semantic information of the element boundary; For X={X1,X2,,...X n ,}, the probability of predicting the input sequence as a word segmentation label sequence is: Among them, Score(X,Y) represents the sum of all steps of the input sequence X predicted to be the observation sequence Y. represents any possible tag sequence, Z x Represents the set of all possible label sequences whose input sequence is X; Through the negative log-likelihood loss function, the loss function of the feature boundary learning task based on the Chinese word segmentation model is defined as: Among them, X represents the input text sequence, Y 分词 Indicates the true word segmentation sequence, Score(X,Y 分词 ) represents the score of the true word segmentation sequence, Score(X,y) represents the score of a predicted sequence y, and Z x Represents the set of all possible predicted sequences outputted by the input sequence X; Assume that the Chinese word segmentation model obtains the word segmentation result of the input text as Out = {S, B, M, M, E, S, ... B, M, E, S}, and uses the pre-trained language model of the multi-head attention mechanism to obtain the feature vector of each character in the word segmentation result as H = {E s ,E B ,E M ,...E E ,E s }, B, M, E represent the start position, middle position and end position of a segmentation, S represents the non-segmentation sequence, and the character vectors belonging to a segmentation in the segmentation result are merged to obtain the segmentation vector, see formula (3): Among them, p represents the current position, i represents the position of B in the current segmentation result, and j represents the position of E in the current segmentation result; thus, the text segmentation vector with the same length as the input sequence is obtained as W p = {W [cls] ,W0,W1,...W n ,W [sep] }.
7. The multi-task joint element recognition method based on the multi-head attention mechanism as claimed in claim 6, characterized in that: The S42 specifically includes: Add the character [CLS] at the beginning of each input text to indicate the classification; use the pre-trained language model based on the multi-head attention mechanism to obtain the representation vector of the input text, and the obtained text representation vector H ’ The global semantic information of the text is used as the input of the text convolutional neural network, and then enters the convolution layer for calculation; the text convolutional neural network uses "wide convolution" for calculation, that is, the definition of the convolution kernel only needs to set different numbers of rows, and the number of columns remains consistent with the input vector dimension. By setting multiple convolution kernels, the feature vectors of texts of different dimensions are obtained; the output vector of the convolution layer is subjected to maximum pooling calculation, the maximum value of all values in each column is taken, and the output of the pooling layer is obtained; finally, according to the output of the pooling layer and the number of classification categories, a fully connected layer is constructed for dimensional conversion, and then the probability of each classification category is obtained through Softmax; Assume that the text representation vector of the input text is H'={h [cls] ,h0,h1,...,h [sep] }, and the output vector after passing through the text convolutional neural network is Y = [y1, y2, y3, ..., y c ], c is the number of classification categories; in the example of the present invention, it represents the corresponding category of the case element; The probability of each classification category is calculated by Softmax as follows: P(and i |i=0,1,2,...c)=Softmax(y i ) (4) Next, the cross entropy loss function is used to define the loss value of the text classification task, as follows: Among them, y i It takes 0 or 1 to indicate whether the current category is the real category. i ) represents the probability of the model predicting category i, and c represents the category set of the current text.
8. The multi-task joint element recognition method based on the multi-head attention mechanism as claimed in claim 7, characterized in that: The S43 specifically includes: The vector fusion method is: vector W p and H' are connected to the fully connected layer respectively, and their output sequences are added to obtain the arithmetic mean, and the arithmetic mean is used as the input of the conditional random field algorithm; Finally, the negative log-likelihood is used to define the loss function of the feature recognition task based on multi-dimensional feature vector fusion, as follows: Among them, Y true Indicates the entity sequence of the real feature recognition, Score(X,Y true ) represents the score of the actual entity sequence, Score(X,y) represents the score of the predicted entity sequence y, and Y x Represents all possible prediction sequences for the input sequence X.
9. The multi-task joint feature recognition method based on the multi-head attention mechanism as claimed in claim 9, characterized in that: The S5 specifically includes: Construct a joint loss function for the multi-task joint learning factor recognition model, and define the overall loss Loss through the above subtask loss functions 总 , the calculation formula obtained from formula (2), (5) and (6) is as follows: Loss 总 =αLoss 分词 +βLoss 分类 +γLoss 融合 (7) Among them, α, β, and γ represent the weight coefficients corresponding to the loss function of the Chinese word segmentation task based on the bidirectional long short-term memory network + conditional random field, the loss function of the text classification network task based on the text convolutional neural network, and the loss function of the feature recognition task based on the multi-dimensional feature vector fusion, respectively. The value range is [0,1]. The sum of the three values is not greater than 2. They are added as hyperparameters of multi-task joint learning in the model training process for adjustment.
10. The multi-task joint element recognition method based on the multi-head attention mechanism as claimed in claim 9, characterized in that: S6 specifically includes: training the factor recognition model of multi-task joint learning, preprocessing the training set, inputting the text into the model, passing through the pre-trained language model input layer of the multi-head attention mechanism, the middle layer of the three sub-task joint learning and the loss layer; minimizing the overall loss function Loss 总 As the goal, adjust and optimize the model hyperparameters so that the model reaches the final convergence state; Finally, three evaluation indicators are used to test and verify the model effect, namely accuracy, recall rate and F score; the calculation expression of the evaluation indicators is as follows:
Citation Information
Patent Citations
A case element identification method for an electronic file record text
CN109886270A
Case public opinion multi-document generation type abstract method based on element graph attention
CN114969304A
Judicial document case factor entity identification method based on graph neural network
CN115017144A
Text processing method and device based on attention enhancement, equipment and medium
CN117291187A
Intelligent analysis method and system for audio and video electronic file elements
CN118193789A
Cited By
Conference report-based event theme classification method and system
CN119271813A
Method and device for training identification model
CN119597927A
Large-scale cloud node anomaly identification method oriented to computing power network, electronic equipment and storage medium
CN120162719A
Image element extraction method and device fusing large language model and neural network, equipment and storage medium
CN121095958A
Urban construction archive intelligent paper creation and classification method based on natural language processing
CN121479460A
