Chinese event relation extraction model construction method
By constructing a Chinese event relationship extraction model that includes coding, a two-way built-in lightning attention loop unit and a learning table feature loop module, the problem of low efficiency and accuracy in event relationship extraction in Chinese texts is solved, and efficient and accurate event relationship extraction is achieved. , improving calculation efficiency.
Patent Information
- Application Number
- CN202410728900.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-09-20
AI Technical Summary
Existing technologies are difficult to effectively extract event relationships in Chinese texts, especially in terms of causal relationships, resulting in limited depth of text understanding, and existing methods are not efficient and accurate when processing Chinese texts.
A Chinese event relationship extraction model construction method is adopted, including an encoding module, a two-way built-in lightning attention loop unit, a loop module for learning table features, and a decoding module. Through preprocessing, encoding, contextual semantic capture, and mining event relationships and word associations, Form a set of triples and use the lightning attention mechanism to improve computing efficiency and extraction accuracy.
It achieves efficient and high-accuracy Chinese event relationship extraction. Compared with other models, the F1 score on public data sets is increased by 1% to 1.7%, the number of form filling is reduced, and the calculation efficiency is increased by about 3%, making it suitable for practical applications.
Smart Images

Figure CN118674037A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method for constructing a Chinese event relationship extraction model. Background Art
[0002] With the rapid development of science and technology, mankind has entered the information age, and the massive text data generated simultaneously has formed a natural "information gold mine". How to extract valuable structured information from complex and cumbersome unstructured data has become a research hotspot, and information extraction technology has emerged. As an important part of information extraction, event relationship extraction aims to extract knowledge in the form of triples from unstructured text and express it in the form of (event, relationship, event). Event relations include temporal relations, causal relations, co-reference relations, etc., among which causal relations can achieve a deep understanding of the text. Event relationship extraction can be widely used in event graphs, information retrieval, and intelligence analysis. At present, there is an urgent need for a solution to extract Chinese event relations. Summary of the invention
[0003] Based on this, it is necessary to provide a method for constructing a Chinese event relationship extraction model to address the above technical issues.
[0004] Obtaining a Chinese event relationship extraction model training set, wherein each training sample in the training set includes a feature value being Chinese text data, and a label value being an event relationship triplet annotated on the Chinese text data according to a preset form filling strategy;
[0005] The initial Chinese event relationship extraction model is trained using the Chinese event relationship extraction model training set to obtain a trained Chinese event relationship extraction model; wherein the Chinese event relationship extraction model includes an encoding module, a bidirectional built-in lightning attention loop unit, a loop module for learning table features, and a decoding module; the preprocessing module is used to preprocess the Chinese text data to obtain serialized Chinese text, the encoding module is used to encode the serialized Chinese text and output global features, the bidirectional built-in lightning attention loop unit is used to perform secondary context semantic capture on the full-text features to obtain subject event features and object event features; the loop module for learning table features is used to mine event relations and global associations between word pairs to obtain table features; the decoding module is used to extract triples from the table features, and decode the inverse relations of the relationship mapping to form a triple set;
[0006] The trained Chinese event relationship extraction model is evaluated, and if the performance of the trained Chinese event relationship extraction model meets the output condition, the trained Chinese event relationship extraction model is stored.
[0007] A Chinese event relationship extraction method is provided, which uses the Chinese event relationship extraction model constructed by the above-mentioned Chinese event relationship extraction model construction method to perform extraction, and the method comprises:
[0008] Inputting the Chinese text of the Chinese event relationship to be extracted into the Chinese event relationship extraction model;
[0009] The preprocessing module in the Chinese event relationship extraction model is used to preprocess the Chinese text data to obtain serialized Chinese text, and input the serialized Chinese text into the encoding module;
[0010] The encoding module in the Chinese event relationship extraction model is used to encode the serialized Chinese text and output global features, and input the global features into the bidirectional built-in lightning attention recurrent unit;
[0011] The bidirectional built-in lightning attention loop unit in the Chinese event relationship extraction model is used to perform secondary context semantic capture on global features to obtain subject event features and object event features;
[0012] The loop module for learning table features in the Chinese event relationship extraction model is used to mine event relationships and global associations between word pairs to obtain table features;
[0013] The decoding module in the Chinese event relation extraction model is used to extract triples from table features and decode the inverse relation of the relation mapping to form a triple set;
[0014] Obtain a set of triples output by the Chinese event relation extraction model.
[0015] A Chinese event relationship extraction model construction device, the device comprising:
[0016] An acquisition module is used to acquire a training set of a Chinese event relationship extraction model, wherein each training sample in the training set includes a feature value of Chinese text data and a label value of an event relationship triplet annotated on the Chinese text data according to a preset form filling strategy;
[0017] A training module is used to train the initial Chinese event relationship extraction model using the Chinese event relationship extraction model training set to obtain a trained Chinese event relationship extraction model; wherein the Chinese event relationship extraction model includes an encoding module, a bidirectional built-in lightning attention loop unit, a loop module for learning table features, and a decoding module; the preprocessing module is used to preprocess the Chinese text data to obtain serialized Chinese text, the encoding module is used to encode the serialized Chinese text and output global features, the bidirectional built-in lightning attention loop unit is used to perform secondary context semantic capture on the full-text features to obtain subject event features and object event features; the loop module for learning table features is used to mine event relations and global associations between word pairs to obtain table features; the decoding module is used to extract triples from the table features, and decode the inverse relations of the relationship mapping to form a triple set;
[0018] The storage module is used to evaluate the trained Chinese event relationship extraction model. If the performance of the trained Chinese event relationship extraction model meets the output condition, the trained Chinese event relationship extraction model is stored.
[0019] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned Chinese event relationship extraction model construction method or Chinese event relationship extraction method when executing the computer program.
[0020] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements a Chinese event relationship extraction model construction method or the steps of a Chinese event relationship extraction method.
[0021] The above method is used to construct a Chinese event relationship extraction model, and the constructed Chinese event relationship extraction model is used to extract event relations in Chinese texts, with high extraction efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A schematic diagram of a process for constructing a Chinese event relationship extraction model in one embodiment;
[0023] Figure 2 is a schematic diagram of a preset form filling strategy in one embodiment;
[0024] Figure 3 is a schematic diagram of the structure of a Chinese event relationship extraction model in one embodiment;
[0025] Figure 4 is a schematic structural diagram of a simple cycle unit SRU in one embodiment;
[0026] Figure 5 A schematic diagram of the structure of a bidirectional built-in lightning attention cycle unit in one embodiment;
[0027] Figure 6 is a schematic diagram of the structure of a lightning attention mechanism in one embodiment;
[0028] Figure 7 A schematic diagram of the structure of a Chinese event relationship extraction model building device in one embodiment;
[0029] Figure 8 is an internal structure diagram of a computer device in one embodiment;
[0030] Fig. 9 A scatter plot comparison of verification calculation efficiency in one embodiment;
[0031] Fig.10 A comparison chart of an effectiveness experiment in an embodiment. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0033] like Figure 1 As shown, in order to solve the above-mentioned problems, the present disclosure proposes a method for constructing a Chinese event relationship extraction model, the method comprising:
[0034] S101, obtaining a training set of a Chinese event relationship extraction model, wherein each training sample in the training set includes a feature value being Chinese text data, and a label value being an event relationship triplet annotated on the Chinese text data according to a preset form filling strategy;
[0035] S102, using the Chinese event relationship extraction model training set to train the initial Chinese event relationship extraction model to obtain the trained Chinese event relationship extraction model; wherein the Chinese event relationship extraction model includes an encoding module, a bidirectional built-in lightning attention loop unit, a loop module for learning table features, and a decoding module; the preprocessing module is used to preprocess the Chinese text data to obtain serialized Chinese text; the encoding module is used to encode the serialized Chinese text and output global features; the bidirectional built-in lightning attention loop unit is used to perform secondary context semantic capture on the full-text features to obtain subject event features and object event features; the loop module for learning table features is used to mine event relations and global associations between word pairs to obtain table features; the decoding module is used to extract triples from the table features, and decode the inverse relations of the relationship mapping to form a triple set;
[0036] S103, evaluating the trained Chinese event relationship extraction model. If the performance of the trained Chinese event relationship extraction model meets the output condition, the trained Chinese event relationship extraction model is saved.
[0037] The above method is used to construct a Chinese event relationship extraction model, and the constructed Chinese event relationship extraction model is used to extract event relations in Chinese texts, with high extraction efficiency and accuracy.
[0038] In one embodiment, the above-mentioned preset form filling strategy includes:
[0039] For each Chinese sentence, a table including only the upper triangular area is generated for each event relationship and the inverse relationship of each event relationship, wherein each cell in each table corresponds to two words, and the information in each cell is used to describe the association relationship between the two words corresponding to the cell, wherein the association relationship includes: there is no association relationship between the two words, both words are the head words of two events, and both words are the tail words of two events.
[0040] like Figure 2 As shown, for example, given a Chinese sentence S = [t1, t2, ..., t n ], create a table for each relation r r , where table r The size is n×n, and the relation r is included in the relation set R (the relation set R refers to all Chinese relations that need to be extracted, for example, the relation set includes temporal relations, causal relations, co-reference relations, etc.). Considering the multi-word characteristics of Chinese when encoding, multiple labels are designed for each cell in the table. The label set L is defined as follows:
[0041] L={"None","Head","Tail"}
[0042] The label "None" indicates that there is no i ,t j ) has no association, the label "Head" indicates that there is a i ,t j ) are the head words of two events, and the label "Tail" indicates the distance between the two words (t i ,tj) are the last words of the two events.
[0043] In addition, in the causal relationship of events, the more common situation is cause and effect, so for the table matrix, the labels of the lower triangular area are all "None", which makes the matrix sparse, wastes storage space and slows down the table filling. However, the lower triangular area cannot be directly discarded, because there may be a situation where the cause is later and the effect is earlier. Therefore, this application proposes to fill in the table for the later cause and the effect, and at the same time consider the label coverage problem caused by multiple pairs of cause and effect, and map an inverse relationship r' to each relationship r, and similarly make a table table r′ , table r The table cells in the lower triangle area are filled into table r′ The upper triangular area of , and discard the lower triangular area and diagonal area. The number of filled tables is (n 2 -n)R, the number of forms filled is lower than that of existing technologies, for example, lower than that of TPLinker and GRTE 2 R pieces.
[0044] In one embodiment, when the data set is used to generate the training set of the Chinese event relationship extraction model, a certain number of verification sets and test sets are also generated, so that the verification set can be used to verify the Chinese event relationship extraction model, and the test set can be used to test the performance of the Chinese event relationship extraction model.
[0045] In addition, when training the Chinese event relationship extraction model training set, in order to enable better training, the hyperparameters of the Chinese event relationship extraction initial model can also be set according to the data scale of the Chinese event relationship extraction model training set and the verification set, wherein the hyperparameters at least include the batch training size batch_size and the learning rate (learn_rate). In addition, other hyperparameters of the Chinese event relationship extraction model can also be set, for example, the text truncation length of the Chinese event relationship extraction model, the number of hidden layers of the bidirectional built-in lightning attention cycle unit Bi-FLASH-SRU (Bidirectional Built-in FlashAttention Simple Recurrent Unit), etc.
[0046] After the Chinese event relationship extraction model is trained, in order to ensure that the performance of the Chinese event relationship extraction model meets the output requirements, the performance of the trained Chinese event relationship extraction model can also be evaluated using the test set. For example, the accuracy, precision, recall rate, F1 score and other indicators obtained after the test can be used to evaluate the performance of the trained Chinese event relationship extraction model. If all indicators of the trained Chinese event relationship extraction model meet the requirements, the Chinese data relationship extraction model is stored. If not, the training set is expanded to continue training the Chinese data relationship extraction model.
[0047] After storing the Chinese event relationship extraction model that meets the performance requirements, the Chinese event relationship extraction model can be used to extract Chinese event relationships from Chinese text. Based on this, the present disclosure also proposes a Chinese event relationship extraction method, which includes:
[0048] Inputting the Chinese text of the Chinese event relationship to be extracted into the Chinese event relationship extraction model;
[0049] Among them, the preprocessing module in the Chinese event relationship extraction model is used to preprocess the Chinese text data to obtain serialized Chinese text, and input the serialized Chinese text into the encoding module; the encoding module in the Chinese event relationship extraction model is used to encode the serialized Chinese text and output global features, and input the global features into the bidirectional built-in lightning attention loop unit; the bidirectional built-in lightning attention loop unit in the Chinese event relationship extraction model is used to perform secondary context semantic capture on the global features to obtain subject event features and object event features; the loop module for learning table features in the Chinese event relationship extraction model is used to mine event relations and global associations between word pairs to obtain table features; the decoding module in the Chinese event relationship extraction model is used to extract triples from the table features, and decode the inverse relations of the relationship mapping to form a triple set;
[0050] Get the triple set output by the Chinese event relation extraction model.
[0051] Specifically, the structure of the Chinese event relationship extraction model is as follows Figure 3 As shown in the figure, it includes a preprocessing module, an encoding module, a bidirectional built-in lightning attention recurrent unit, a recurrent module for learning table features, and a decoding module. The following describes the role of each module in the Chinese event relationship extraction model.
[0052] Since the text data input to the model can be of various formats and lengths, in order to enable the subsequent encoding module to better process the text, the text data input to the model needs to be preprocessed. Therefore, the preprocessing module in the above Chinese event relationship extraction model can use a word segmenter to perform character-level word segmentation on the text, remove redundant information, and obtain serialized Chinese text.
[0053] For another example, the preprocessing module can also perform format conversion processing and long text truncation processing on the input text, etc. The present disclosure does not limit this, as long as the input text data can be processed according to requirements to obtain serialized Chinese text suitable for processing by the encoding module.
[0054] The encoding module in the Chinese event relationship extraction model is used to encode the serialized Chinese text output by the preprocessing module, and output a dynamic word vector composed of a character vector, a position vector, and a sentence vector as a global feature e.
[0055] The bidirectional built-in lightning attention recurrent unit (Bi-FLASH-SRU) in the Chinese event relation extraction model is used to use two independent bidirectional built-in lightning attention recurrent units to obtain the subject event feature e1 and the object event feature e2 respectively.
[0056] Specifically, in order to further obtain the subject event feature e1 and the object event feature e2, the bidirectional built-in lightning attention recurrent unit takes the global feature e output by the encoding module as input to perform secondary context semantic capture. Two independent Bi-FLASH-SRUs are used to obtain the subject and object event features, as shown in formula (1).
[0057] e1=Bi-FLASH-SRU(e)
[0058] e2=Bi-FLASH-SRU(e) (1)
[0059] The bidirectional built-in lightning attention recurrent unit is improved from the built-in attention simple recurrent unit (SRU++). The specific structure and calculation process of the simple recurrent unit SRU used by SRU++ are as follows: Figure 4 As shown in the figure, the scaled dot product attention used by the built-in attention layer of SRU++ will cause the calculation and storage matrix to grow geometrically in time and space complexity when the input sequence is longer. To address this problem, the Flash-attention mechanism is introduced, and a simple recurrent unit with built-in Flash-attention is proposed. The model structure is shown in the figure. Figure 5 As shown in the figure, 768 and 512 represent the input vector dimension and the attention dimension respectively. The lightning attention mechanism mainly reconstructs the attention calculation, calculates the input information in the form of blocks, and completes multiple runs on the input blocks to achieve softmax reduction; and stores the softmax normalization factor passed forward so as to quickly recalculate the attention on the chip in the backward pass. The structure of the lightning attention mechanism is shown in the figure. Figure 6 Therefore, by introducing the attention mechanism into the bidirectional built-in lightning attention recurrent unit, the space complexity and computational dimension can be reduced, and the computation speed is faster.
[0060] The loop module for learning table features in the Chinese event relationship extraction model can be used to loop through the iterative process when obtaining table features until the number of iterations is reached, wherein the following steps are performed in each iteration process:
[0061] In the first step, the following formula (2) is used to obtain the first table feature of the relationship between each word pair:
[0062]
[0063] in represents the Hadamard product operation, ReLU is the activation function, and are word t in the tth iteration respectively. i and t j The characteristics of W, namely the subject-object characteristics, re and b re They are training weights and training biases respectively; is the first table feature;
[0064] The second step is to concatenate the first table features obtained to form the table feature tf (t) Specifically, the first table feature is expanded, the global features of the table are deeply mined, and new table features are formed. All event relationships are spliced to form a large table feature tf (t) Then use maximum pooling and full connection to obtain the table features related to the subject and object events and That is, the second table feature related to the subject and object events is obtained using the following formula (3): and
[0065]
[0066]
[0067] Where W 1 / 2 and b 1 / 2 Represent training weights and training biases respectively;
[0068] The third step is to use the lightning attention mechanism to focus on the second table features related to the subject and object events. Perform calculations to obtain the first calculation result in, FMA is a lightning attention mechanism. The lightning attention mechanism is used to further calculate the global feature e and the table features related to the subject and object events mined by the lightning attention mechanism to obtain the second calculation result in, The second calculation result is calculated using the loop module, fully connected module and activation function of the learning table feature to obtain the third table feature related to the subject and object event in,
[0069] That is, the Transformer model is used to mine the global association between relations and word pairs. At the same time, considering that the traditional multi-head attention mechanism is too slow to calculate, the Flash-Multi-Attention mechanism is combined to introduce FMA (Flash-Multi-Attention). First, the association between event relations is mined, and the table features related to the subject and object events are FMA calculation is performed on the global feature e and the table features related to the subject and object events after FMA calculation are mined. FMA calculation is performed on the above; finally, the fully connected module and activation function are used to generate new subject and object event features, such as the third table feature obtained by using formula (4):
[0070]
[0071]
[0072]
[0073] The obtained third table features are used as the input of the next round of iteration to continue learning the table features.
[0074] In one embodiment, in order to alleviate the gradient disappearance, a residual connection is used to generate the final subject-object event features, as shown in formula (5):
[0075]
[0076] The decoding module in the above Chinese event relationship extraction model is specifically used to calculate the label results of the word pairs in the relationship table according to the output results of the loop module of the learning table feature according to the following formula (6);
[0077]
[0078] in and table r (i,j) represents the word pair in the relation table (t i ,t j )’s label results; Represents a positive relationship, table r Represents a reverse relationship. Using a preset table information decoding algorithm, triples are extracted from the obtained label results to form a triple set. The preset table information decoding algorithm may include the content shown in Table 1.
[0079]
[0080] Table 1
[0081] That is, when extracting event pairs for each event relationship during the decoding process, two parallel search paths are designed: one is forward search, which generates event pairs in sequence from the beginning of the word to the end of the word; the other is reverse search, which generates event pairs in sequence from the end of the word to the beginning of the word.
[0082] Based on the same inventive concept, Figure 7 As shown, the present disclosure also proposes a Chinese event relationship extraction model construction device, characterized in that the device includes:
[0083] An acquisition module 710 is used to acquire a training set of a Chinese event relationship extraction model, wherein each training sample in the training set includes a feature value of Chinese text data and a label value of an event relationship triple annotated on the Chinese text data according to a preset form filling strategy;
[0084] The training module 720 is used to train the initial Chinese event relationship extraction model using the Chinese event relationship extraction model training set to obtain the trained Chinese event relationship extraction model; wherein the Chinese event relationship extraction model includes an encoding module, a bidirectional built-in lightning attention loop unit, a loop module for learning table features, and a decoding module; the preprocessing module is used to preprocess the Chinese text data to obtain serialized Chinese text, the encoding is used to encode the serialized Chinese text, and output global features, the bidirectional built-in lightning attention loop unit is used to perform secondary context semantic capture on the full-text features to obtain subject event features and object event features; the loop module for learning table features is used to mine event relations and global associations between word pairs to obtain table features; the decoding module is used to extract triples from the table features, and decode the inverse relations of the relationship mapping to form a triple set;
[0085] The storage module 730 is used to evaluate the trained Chinese event relationship extraction model. If the performance of the trained Chinese event relationship extraction model meets the output condition, the Chinese event relationship extraction model is stored.
[0086] In one embodiment, the preset form filling strategy includes:
[0087] For each Chinese sentence, a table including only the upper triangular area is generated for each event relationship and the inverse relationship of each event relationship, wherein each cell in each table corresponds to two words, and the information in each cell is used to describe the association relationship between the two words corresponding to the cell, wherein the association relationship includes: there is no association relationship between the two words, both words are the head words of two events, and both words are the tail words of two events.
[0088] For the specific limitations of the Chinese event relationship extraction model construction device, please refer to the limitations of the Chinese event relationship extraction model construction method above, which will not be repeated here. The various modules in the above-mentioned Chinese event relationship extraction model construction device can be implemented in whole or in part through software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0089] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a Chinese event relationship extraction model construction method or a Chinese event relationship extraction method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0090] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0091] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the Chinese event relationship extraction model construction method or the Chinese event relationship extraction method described in any of the above embodiments are implemented.
[0092] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the Chinese event relationship extraction model construction method or the Chinese event relationship extraction method described in any of the above embodiments are implemented.
[0093] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0094] In order to verify the extraction effect of the Chinese event relation extraction model mentioned above on Chinese event relations, in one embodiment, the present application uses the following data set and method for verification.
[0095] The data comes from the public data sets of Tonghuashun's event causality extraction (THS) for the financial field and CCKS2021 financial field event causality extraction (CCKS2021). Tonghuashun's event causality extraction data set for the financial field is divided into 2000 training sets, 500 validation sets, and 500 test sets. The CCKS2021 financial field event causality extraction data set is divided into 5000 training sets, 1000 validation sets, and 1000 test sets.
[0096] The labeled Chinese event relationship extraction dataset is converted according to the form filling strategy, and the model parameters are set. The specific hyperparameter configuration of the model is shown in Table 2.
[0097]
[0098]
[0099] Table 2 Hyperparameter configuration
[0100] The experimental environment of this article is the operating system Ubuntu 18.04, GPU NVIDIA Tesla T4, RAM 32GB, hard disk 100GB, using Python 3.8.16, PyTorch 1.9 deep learning environment.
[0101] In order to evaluate the accuracy of the model, this example uses precision P, recall R, and F1 value to evaluate the model. The calculation formula of F1 value is as follows:
[0102]
[0103] Among them, the precision P is the ratio of the number of correct information items extracted to the number of information items extracted, and the recall R is the ratio of the number of correct information items extracted to the number of information items in the sample.
[0104] To extract event relations, in order to verify the superiority of the proposed model, this example compares many SOTA relation extraction models. The comparison models are selected as follows:
[0105] (1) copyRE is an end-to-end joint extraction model based on the replication mechanism, which can solve the problem of overlapping SEO and EPO relationships.
[0106] (2) CasRel first extracts the subject entity, and then extracts the relationship and its corresponding object entity based on the subject, which can also solve the problem of overlapping SEO and EPO triples.
[0107] (3) TPLinker is a single-step model that jointly extracts entities and overlapping relations without any interdependent steps, thus avoiding the exposure bias problem.
[0108] (4) SPN adopts a non-autoregressive parallel decoding method, which can directly output the final predicted triple set at one time.
[0109] (5) GRTE can mine global features and model associations between relations and between different word pairs.
[0110] (6)TEIFCR is an end-to-end joint extraction model that formalizes relations into conceptual labels, uses an attention mechanism to capture relational features, and outputs multiple relational labels through a relation classifier.
[0111] The experimental results of the above comparison models are generated under the conditions provided by open source code or reproduced according to the article, which is used to verify the advancedness of the proposed model. At the same time, this paper selected different word vector models, such as ELMO and Glove, for comparative experiments to verify the impact of different word vectors on the model of the present invention. Finally, under the same parameter conditions, different neural units were selected to experimentally verify the Chinese event relationship extraction model proposed in this application.
[0112] In order to ensure the credibility of the experimental results and reduce random errors, a random seed is set and the average result of 5 experiments is taken as the final experimental result. The experimental results are shown in Table 3, where TF-ChineseERE (Glove) The representation model uses Glove word vectors in the encoding module, TF-ChineseERE Bi-SRU++ It indicates that the model is replaced with Bi-SRU++ at the Bi-FLASH-SRU layer.
[0113]
[0114]
[0115] Table 3 Experimental results
[0116] As can be seen from Table 3, the model proposed in the present invention is very efficient. Compared with other SOTA relation extraction models, the highest F1 scores were achieved on both public datasets. Compared with similar tabular extraction models such as GRTE and TPLinker, the F1 values of the two public datasets increased by an average of 1% and 1.7%. At the same time, in terms of the table filling strategy, the number of tables filled by the model of the present invention is the least. In summary, it is very meaningful that the model of the present invention achieves good performance in relation extraction.
[0117] In order to verify the impact of different word vectors on the model of the present invention, Glove and ELMO were used for comparison. It can be seen from the middle section of Table 3 that both sets of data sets achieved the highest F1 score in the word vector model using Roberta as the encoding module. Although Roberta and ELMO can both generate dynamic word vectors, fine-tune according to the task, and integrate domain knowledge to solve the problem of polysemy, ELMO uses Bi-LSTM to obtain the contextual semantics of words, while Roberta based on Transformer has stronger feature extraction capabilities, so the effect is better. Compared with the static word vector Glove, which is only a feature tool based on global word frequency statistics, the effect is definitely inferior to the dynamic word vector. However, compared with some SOTA models in the upper section of Table 3, good results have been achieved.
[0118] Comparative analysis: In order to verify the influence of different recurrent neural units on the model, Bi-LSTM, Bi-GRU, and Bi-SRU++ were selected for comparative tests, as shown in the lower part of Table 3. As shown in Table 3, the F1 value of the model proposed in the present invention is the highest on both data sets, indicating that Bi-FLASH-SRU can fully extract the semantics of the context, and the built-in lightning attention can well perceive the dependencies between words, which helps to improve the performance of event relationship extraction. Although the F1 value of using Bi-SRU++ to obtain features in the model is similar to that of using Bi-FLASH-SRU, it still reflects the superiority of the built-in lightning attention. Bi-LSTM can only obtain contextual semantics, Bi-GRU cannot completely solve the problem of gradient disappearance, and cannot be calculated in parallel, so there is a big difference in F1 value.
[0119] Computational efficiency of Bi-FLASH-SRU: In order to verify the computational efficiency of Bi-FLASH-SRU, the time of training the model 5 times was recorded when compared with other recurrent neural units, and a scatter plot of the F1 value and the minimum average training time (Min_Time) and the average training time (Time) was plotted, as shown in Fig. 9 shown.
[0120] The neural unit with a smaller average training time has a larger horizontal axis value, with a maximum value of 1. The higher the vertical axis F1 value, the better the performance of the neural unit. Therefore, the neural unit in the upper right corner of the scatter plot has a higher evaluation.
[0121] Depend on Fig. 9 As far as we know, Bi-FLASH-SRU is significantly higher than other neural units. Compared with Bi-SRU++, it shows that lightning attention effectively improves the training speed. Although Bi-GRU simplifies the gate structure and cuts the number of parameters, it has the same problems as Bi-LSTM, such as non-parallel processing and no built-in attention, so the training speed and extraction performance are inferior to Bi-FLASH-SRU.
[0122] Experimental analysis of the impact of the number of Bi-FLASH-SRU layers and the effectiveness of the lightning attention mechanism: In order to verify the effectiveness of the built-in lightning attention mechanism and the impact of different numbers of Bi-FLASH-SRU layers on the model effect, a comparative experiment of the lightning attention mechanism with different numbers of layers and under different conditions was conducted based on the THS dataset. Fig.10 As shown in the figure, num_head represents the number of multi-head attentions, and attn_n_layers represents the built-in lightning attention for each N layers.
[0123] Depend on Fig.10It can be seen that when Bi-FLASH-SRU reaches 4 layers, the F1 value peaks under all four conditions. After that, when the number of layers is increased, the F1 value degrades, indicating that the number of model layers should not be too many, and the number of layers needs to be set according to the actual situation of the task. When num_head=16 and attn_n_layers=2, the model performs best, proving that the more attention mechanisms, the better, and the number of heads should also be set appropriately, so as to improve the migration and generalization capabilities of the model.
[0124] In order to further verify the independent effectiveness of each module of the model, three sets of ablation experiments were carried out on two public datasets based on the TF-ChineseERE model. The results are shown in Table 4, where w / o FLASH means removing the lightning attention mechanism layer in Bi-FLASH-SRU, w / o Bi-FLASH-SRU means removing the Bi-FLASH-SRU module that captures contextual semantics twice, and w / o Recurrent Module means removing the recurrent module that learns table features.
[0125]
[0126] Table 4 Ablation experiment results
[0127] The experimental results show that removing any part of the TF-ChineseERE model will lead to different degrees of reduction in effect, proving the gain effect of each module on the overall model. Further analysis shows that after removing the lightning attention mechanism layer in Bi-FLASH-SRU, the F1 value of the model on both public datasets decreased by 0.7%, which shows that the lightning attention mechanism can capture the word dependency relationship within the text and help improve the model performance; when the Bi-FLASH-SRU module is removed, the model lacks the ability to extract the contextual semantics of the text, resulting in a decrease of 1.6% and 1.5% in the F1 value on the two public datasets; in addition, when the loop module is removed, the F1 value of the model performance on the two public datasets decreases by 3.3% and 3.9% respectively, indicating that the loop module can effectively help the model learn the feature information in the table and mine the association between words and sentences, further illustrating that the loop module plays a vital role in the overall model.
[0128] Combined with the above content, it can be seen that the Chinese event relationship extraction model proposed in this invention has been tested on two public data sets and achieved good extraction results. Compared with the previous table extraction method, the method of relationship mapping and table cutting further reduces the number of forms to be filled in, which is reduced compared with TPLinker. Compared with GRTE, nR is reduced; Bi-FLASH-SRU fully obtains contextual semantics and captures the relationship between words. Compared with the baseline system, the F1 value on two public datasets is improved by 0.7% and 1.2% respectively, and the computational efficiency is also improved by about 3%, which can be applied in practice.
[0129] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0130] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for constructing a Chinese event relationship extraction model, characterized in that: The method comprises: Obtaining a Chinese event relationship extraction model training set, wherein each training sample in the training set includes a feature value being Chinese text data, and a label value being an event relationship triplet annotated on the Chinese text data according to a preset form filling strategy; The initial Chinese event relationship extraction model is trained using the Chinese event relationship extraction model training set to obtain a trained Chinese event relationship extraction model; wherein the Chinese event relationship extraction model includes an encoding module, a bidirectional built-in lightning attention loop unit, a loop module for learning table features, and a decoding module; the preprocessing module is used to preprocess the Chinese text data to obtain serialized Chinese text, the encoding module is used to encode the serialized Chinese text and output global features, the bidirectional built-in lightning attention loop unit is used to perform secondary context semantic capture on the full-text features to obtain subject event features and object event features; the loop module for learning table features is used to mine event relations and global associations between word pairs to obtain table features; the decoding module is used to extract triples from the table features, and decode the inverse relations of the relationship mapping to form a triple set; The trained Chinese event relationship extraction model is evaluated, and if the performance of the trained Chinese event relationship extraction model meets the output condition, the trained Chinese event relationship extraction model is stored.
2. The method according to claim 1, characterized in that The preset form filling strategy includes: For each Chinese sentence, a table including only the upper triangular area is generated for each event relationship and the inverse relationship of each event relationship, wherein each cell in each table corresponds to two words, and the information in each cell is used to describe the association relationship between the two words corresponding to the cell, wherein the association relationship includes: there is no association relationship between the two words, both words are the head words of two events, and both words are the tail words of two events.
3. The method according to claim 1, characterized in that Also includes: The hyperparameters of the Chinese event relationship extraction initial model are set according to the data scale of the training set and the validation set of the Chinese event relationship extraction model, and the hyperparameters include at least the batch training size and the learning rate.
4. A Chinese event relationship extraction method, characterized in that: Extraction is performed using the Chinese event relationship extraction model constructed by the Chinese event relationship extraction model construction method according to claim 1, the method comprising: Inputting the Chinese text of the Chinese event relationship to be extracted into the Chinese event relationship extraction model; The preprocessing module in the Chinese event relationship extraction model is used to preprocess the Chinese text data to obtain serialized Chinese text, and input the serialized Chinese text into the encoding module; The encoding module in the Chinese event relationship extraction model is used to encode the serialized Chinese text and output global features, and input the global features into the bidirectional built-in lightning attention recurrent unit; The bidirectional built-in lightning attention loop unit in the Chinese event relationship extraction model is used to perform secondary context semantic capture on global features to obtain subject event features and object event features; The loop module for learning table features in the Chinese event relationship extraction model is used to mine event relationships and global associations between word pairs to obtain table features; The decoding module in the Chinese event relation extraction model is used to extract triples from table features and decode the inverse relation of the relation mapping to form a triple set; Obtain a set of triples output by the Chinese event relation extraction model.
5. The method according to claim 4, characterized in that The preprocessing module is used to preprocess the Chinese text data to obtain serialized Chinese text, including: The preprocessing module is used to perform character-level word segmentation on the text using a word segmenter, removing redundant information to obtain serialized Chinese text.
6. The method according to claim 4, characterized in that The encoding module is used to encode the serialized Chinese text and output global features, including: The encoding module is used to encode the serialized Chinese text and output a dynamic word vector composed of a character vector, a position vector and a sentence vector as a global feature e.
7. The method according to claim 4, characterized in that The bidirectional built-in lightning attention loop unit is used to capture the global secondary context semantics, and obtain the subject event features and the object event features including: Two independent bidirectional built-in lightning attention recurrent units are used to obtain the subject event feature e1 and the object event feature e2 respectively.
8. The method according to claim 4, characterized in that The loop module for learning table features is used to mine event relationships and global associations between word pairs to obtain table features, including: The loop module for learning table features loops through the iterative process until the number of iterations is reached, wherein the following steps are performed in each round of iteration: The first table feature of the relationship between each word pair is obtained using the following formula: in represents the Hadamard product operation, ReLU is the activation function, and are respectively the word t in the tth round of iteration i and t j The characteristics of W re and b re They are training weights and training biases respectively; is the first table feature; The first table features obtained are concatenated to form the table features tf (t) , the second table feature tf1 related to the subject and object events is obtained using the following formula (t) and Where W 1 / 2 and b 1 / 2 Represent training weights and training biases respectively; Use the lightning attention mechanism to focus on the second table features related to the subject and object events Perform calculations to obtain the first calculation result in, FMA is the lightning attention mechanism; The lightning attention mechanism is used to further calculate the global feature e and the table features related to the subject and object events mined by the lightning attention mechanism to obtain the second calculation result in, The second calculation result is calculated using the loop module, fully connected module and activation function of the learning table feature to obtain a third table feature related to the subject and object event. in, The obtained third table features are used as input for the next round of iteration.
9. The method according to claim 4, characterized in that The decoding module is used to extract triples from table features and decode the inverse relationship of the relationship mapping to form a triple set, including: The label results of the word pairs in the relation table are calculated according to the output results of the loop module of the learning table feature according to the following formula; in and table r (i,j) represents the word pair in the relation table (t i ,t j )’s label results; The preset table information decoding algorithm is used to extract triples from the obtained label results to form a triple set.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 or 4 to 9 are implemented.
