Chapter-level relation extraction method and system based on dependency syntax pre-training model
By introducing dependency syntax information into the pre-training model to guide the flow of attention, it solves the problems of difficulty in long text processing and weak dependencies in the existing technology, improves the accuracy of chapter-level relationship extraction, and explores the auxiliary role of graph structures.
Patent Information
- Application Number
- CN202210045155.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-14
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-01-14
AI Technical Summary
Existing chapter-level relationship extraction methods have difficulties in processing long texts. In particular, the attention mechanism fails to fully consider the position information and dependency relationships between tokens, resulting in limited effects.
Introduce dependency syntax information into the pre-training model, convert it into an adjacency matrix through the dependency syntax tree, guide the flow of attention, enhance the attention value between entities with dependencies, and combine direct transformation, biaffine transformation or decomposed linear transformation , improve the attention calculation of pre-trained models.
It alleviates the difficulties caused by long-distance text, improves the performance of chapter-level relationship extraction tasks, generates entity feature representations that are closer to actual meaning, solves the problem of polysemy, and explores the auxiliary role of graph structures in pre-training models. .
Smart Images

Figure CN114417824B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a method and system for extracting paragraph-level relations based on dependency syntax and training models. Background Art
[0002] Relation extraction is to extract unknown relational facts from plain text, which is a very important step in text mining. Relation extraction has many very critical real-world applications, such as question answering tasks and text analysis tasks. Most relation extractions only focus on relational facts within a single sentence, and many relational facts do not exist only in a single sentence, but are distributed in multiple sentences. Therefore, the relation extraction task has gradually developed to the paragraph level.
[0003] At present, the mainstream chapter-level relationship extraction methods can be roughly divided into three categories:
[0004] (1) Based on designing different levels of feature extractors. This method uses feature extractors of different levels to extract token-level, sentence-level, and paragraph-level features respectively, but this method still has great challenges in dealing with long text problems.
[0005] (2) Graph structure-based method: This method makes full use of the unique advantages of graph convolutional neural networks in mining structural features. In this method, the graph structure is generally placed after the encoding structure. Due to the essential structural differences between the graph structure and the encoding structure, the effect of this method is seriously affected.
[0006] (3) Methods based on pre-trained models. Although the Transformer-based pre-trained model can implicitly solve long-distance dependencies, the attention mechanism does not take into account the position information or other relevant information of the two tokens in the input sequence when modeling the dependency between any two tokens. This is one of the reasons why the pre-trained model still has great limitations in processing long texts. Summary of the invention
[0007] In view of this, the present invention provides a method and system for extracting chapter-level relations based on a dependency syntax pre-training model. By introducing dependency syntax information into the pre-training model, it is used to guide the flow of attention of the pre-training model, enhance the attention value between two entities with a dependency relationship, and obtain an enhanced representation of the entity. In this process, the difficulties brought by long-distance text to the chapter-level relation extraction task are alleviated, and the model's ability to handle the chapter-level relation extraction task is improved; at the same time, the auxiliary role of the graph structure itself to the pre-training model is also explored.
[0008] To this end, the present invention provides the following technical solutions:
[0009] On the one hand, the present invention provides a method for extracting paragraph-level relations based on a dependency syntax pre-training model, the method comprising:
[0010] S1. Obtain a chapter-level relationship extraction data set, and process each article in the chapter-level relationship extraction data set to obtain a chapter-level dependency syntax tree representing the dependency relationship between each word in the entire article, and convert the chapter-level dependency syntax tree into a corresponding adjacency matrix; the data in the chapter-level relationship extraction data set includes a word sequence included in each article, entity information in the word sequence, and relationship information between entities;
[0011] S2, mapping the word sequence to the query vector, key vector and value vector space respectively; calculating the attention value between any two words; using direct conversion, biaffine conversion or decomposition linear transformation to introduce the adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained in S1 into the attention calculation, and obtaining the attention bias, and finally adding the obtained attention bias to the original attention value to obtain the final attention value guided by the dependency syntactic information, and obtaining the pre-training model guided by the dependency syntactic information;
[0012] S3, inputting the word sequence into the dependency syntax pre-training model obtained in S2, performing feature extraction on the data, and obtaining entity feature representation;
[0013] S4, calculating the relative distance between entities, and concatenating the relative distance between entities with the entity feature representation obtained in S3 to obtain an enhanced representation of the entity feature;
[0014] S5. Perform matrix transformation on the entity feature representation obtained in S4 to form a head entity and a tail entity. Input the head entity and the tail entity into a bilinear transformation to predict the relationship between any two entities, and finally obtain the probability distribution of the relationship between any two entities, thereby extracting the relationship between the entities.
[0015] Furthermore, the adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained after S1 processing is introduced into the attention calculation by direct conversion, including:
[0016] The adjacency matrix of the paragraph-level dependency syntactic information is directly applied to the query vector q and the key vector k, retaining only the attention value between two words with dependency relationships, and then adding a bias to each dependency:
[0017]
[0018] in, is the i-th word x on the l-th layer i The corresponding query vector, is the jth word x on the lth layerj The corresponding key vector, A ij Represents x i and x j If x i Dependency x j , A ij If yes, it is 1, otherwise it is 0. Increased bias.
[0019] Furthermore, the adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained after S1 processing is introduced into the attention calculation by using a double affine transformation, including:
[0020] The adjacency matrix corresponding to the paragraph-level dependency syntactic information is parameterized using a weight matrix to make it a trainable neural network layer, adding a bias to each dependency as with direct conversion:
[0021]
[0022] Among them, W bili As a trainable weight, its role is equivalent to parameterizing A ij , so that A ij Become a trainable neural network layer.
[0023] Furthermore, the adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained after S1 processing is introduced into the attention calculation by decomposing linear transformation, including:
[0024] Assign weights to the query vector and key vector respectively, parameterize the query vector and key vector:
[0025]
[0026] Among them, K l and Q l are the trainable weights assigned to the query vector and key vector respectively.
[0027] Further, each article in the chapter-level relationship extraction data set is processed to obtain a chapter-level dependency syntax tree representing the dependency relationship between each word in the entire article, and the chapter-level dependency syntax tree is converted into a corresponding adjacency matrix, including:
[0028] Use the dependency syntax parsing tool to perform dependency syntax parsing on each sentence to obtain a sentence-level dependency syntax parse tree;
[0029] Connect the root node of the dependency syntactic parse tree of the next sentence to the root node of the dependency syntactic parse tree of the previous sentence, so that the dependency syntactic tree corresponding to the next sentence becomes a branch of the dependency syntactic tree of the previous sentence, thereby enhancing the dependency relationship between sentences, and repeat the above steps to obtain the dependency syntactic tree of the entire article;
[0030] Convert the dependency syntax tree of the entire article into the corresponding adjacency matrix.
[0031] In another aspect, the present invention further provides a paragraph-level relationship extraction system based on a dependency syntax pre-training model, the system comprising:
[0032] A dependency syntax acquisition module is used to acquire a chapter-level relationship extraction data set, process each article in the chapter-level relationship extraction data set, acquire a chapter-level dependency syntax tree representing the dependency relationship between each word in the entire article, and convert the chapter-level dependency syntax tree into a corresponding adjacency matrix; the data in the chapter-level relationship extraction data set includes a word sequence included in each article, entity information in the word sequence, and relationship information between entities;
[0033] A pre-training model establishment module is used to map the word sequence to a query vector, a key vector and a value vector space respectively; calculate the attention value between any two words; use direct conversion, bi-affine conversion or decomposition linear transformation to introduce the adjacency matrix corresponding to the paragraph-level dependency syntax tree obtained by the dependency syntax acquisition module into the attention calculation to obtain the attention bias, and finally add the obtained attention bias to the original attention value to obtain the final attention value guided by the dependency syntax information, so as to obtain a pre-training model guided by the dependency syntax information;
[0034] A feature representation module, used for inputting the word sequence into the dependency syntax-based pre-training model obtained by the pre-training model building module, extracting features from the data, and obtaining entity feature representation;
[0035] An entity feature enhancement module, used for calculating the relative distance between entities, and concatenating the relative distance between entities with the entity feature representation obtained by the feature representation module to obtain an enhanced representation of the entity feature;
[0036] The relationship extraction module is used to perform matrix transformation on the entity feature representation obtained by the entity feature enhancement module to form a head entity and a tail entity; the head entity and the tail entity are input into a bilinear transformation, and the relationship between any two entities is predicted, and finally the probability distribution of the relationship between any two entities is obtained, so as to extract the relationship between the entities.
[0037] On the other hand, the present invention also provides a computer-readable storage medium, which stores a computer instruction set. When the computer instruction set is executed by a processor, it implements the above-mentioned method for extracting paragraph-level relations based on a pre-trained model of dependency syntax.
[0038] Compared with the prior art, the present invention has the following beneficial effects:
[0039] In the present invention, dependency syntactic information is introduced into the pre-training model to guide the flow of its attention; the pre-training model is improved, and the contextual representation of words (tokens) generated by the improved pre-training model is used, so that the words (tokens) have a vector representation that is closer to the actual meaning, which solves the problem of polysemy in the text and the problem of weak long-distance text dependency faced in the current chapter-level relationship extraction. It not only improves the accuracy of the chapter-level relationship extraction task performance, but also introduces the chapter-level dependency syntactic tree as a graph structure into the pre-training model to explore the auxiliary role of the graph structure itself on the pre-training model. Although the original pre-training model is used to generate the contextual representation of the entity, after the chapter-level dependency syntactic information is introduced into the pre-training model to guide the flow of attention, the attention between entities with dependency relationships is enhanced, implicitly alleviating the difficulty of long distances brought to the chapter-level relationship extraction task; at the same time, comparing the results of the three introduction methods is helpful to analyze the impact of the graph structure on the pre-training model. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0041] Figure 1 Schematic diagram of the overall framework of the chapter-level relationship extraction model in an embodiment of the present invention;
[0042] Figure 2 Schematic diagram of a flow chart of a method for extracting paragraph-level relations based on a pre-trained model of dependency syntax in an embodiment of the present invention;
[0043] Figure 3 Schematic diagram of the principle of pre-training based on dependency syntactic information in an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0045] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0046] The present invention provides a method for extracting chapter-level relations based on a dependency syntax pre-training model. Figure 1 The chapter-level relation extraction model shown in the figure performs chapter-level relation extraction. The model mainly includes: input layer, pre-trained model layer, word (token) feature representation, entity feature representation, connection layer and relation classification layer. When performing chapter-level relation extraction, first input the document in the input layer, process the chapter-level relation extraction data, and obtain the corresponding chapter-level dependency syntax matrix; then introduce the dependency matrix into the pre-trained model in three optional ways in the pre-trained model layer to guide the attention flow of the pre-trained model and obtain a pre-trained model based on dependency syntax; then, in the word (token) feature representation layer and the entity feature representation layer, input the data into the pre-trained model based on dependency syntax to obtain the word (token) feature representation, and then obtain the high-quality entity feature representation; in the connection layer, connect the entity distance information to connect the feature representations of each entity to obtain the enhanced representation of the entity feature; finally, in the relation classification layer, put the entity into the bilinear transformation, predict the relationship between entities, and output the relationship probability between entities.
[0047] like Figure 2 As shown, it shows a schematic diagram of a method for extracting chapter-level relations based on a pre-trained model of dependency syntax provided by an embodiment of the present invention. The method specifically includes the following steps:
[0048] S1. Obtain a chapter-level relationship extraction dataset, and process each article in the chapter-level relationship extraction dataset to obtain a chapter-level dependency syntactic tree that can represent the dependency relationship between each word (token) in the entire article, and convert it into a corresponding adjacency matrix.
[0049] Among them, when obtaining a chapter-level relationship extraction dataset, a professional chapter-level relationship extraction dataset can be directly used. The data in the professional chapter-level relationship extraction dataset includes the original sentences (that is, word sequences) included in each article, the entity information in the original sentence (such as the name, type, specific location, etc. of the entity), and the relationship information between entities (relation triple <entity 1, entity 2, relationship type>). You can also first download various articles or sentences from the Internet, and perform data preprocessing on the downloaded articles or sentences, such as data cleaning and entity information identification and labeling. Through data cleaning, impurity information caused by download format and other reasons is removed, and entity information and relationship information between entities are obtained through entity information identification and labeling, forming the same data form as the professional chapter-level relationship extraction dataset.
[0050] Specifically, S1 is executed at the input layer of the paragraph-level relation extraction model. First, Stanford CoreNLP (a dependency syntactic parser developed by Stanford University) is used to perform dependency syntactic parsing on each sentence to obtain a sentence-level dependency syntactic parsing tree. Then, the root node of the dependency syntactic parsing tree of the next sentence is connected to the root node of the dependency syntactic parsing tree of the previous sentence. In this way, the dependency syntactic tree corresponding to the next sentence becomes a branch of the dependency syntactic tree of the previous sentence, and finally the dependency syntactic tree of the entire article is obtained. Finally, the dependency syntactic tree of the entire article is converted into the corresponding adjacency matrix A.
[0051] S2. Design a pre-training model guided by dependency syntactic information:
[0052] Specifically, S2 is executed at the pre-trained model layer of the chapter-level relation extraction model, such as Figure 3 As shown in the figure, the input is a sentence, that is, a sequence of words. However, different pre-trained models will segment some words to form tokens. Therefore, the words in the input part are actually tokens. According to the design of attention in the pre-trained model, first input x = (x1, x2, x3, ..., x n ), mapped to the query vector, key vector and value vector space respectively:
[0053]
[0054] Among them, W i Q , W i K and Wi V It is for Projected to the query vector Key Vector Sum value vector And the weight assigned.
[0055] Next, we calculate the attention value between any two words (tokens):
[0056]
[0057] Then, three optional methods are used to introduce the dependency syntactic information obtained by S1 into the attention calculation to obtain the attention bias Bias, and finally add it to the original attention value to obtain the final attention value guided by the dependency syntactic information:
[0058]
[0059] The following are three ways to calculate attention bias:
[0060] 1. Direct transformation. The adjacency matrix of the paragraph-level dependency syntactic information is directly applied to the query vector and the key vector, retaining only the attention value between two words (tokens) with dependency relationships, and adding a bias to each dependency:
[0061]
[0062] Among them, A ij Represents x i and x j If x i Dependency x j , A ij If yes, it is 1, otherwise it is 0. Increased bias.
[0063] 2. Double affine transformation. Use the weight matrix to parameterize the adjacency matrix corresponding to the paragraph-level dependency syntactic information, making it a trainable neural network layer. Like direct conversion, it adds a bias to each dependency:
[0064]
[0065] Among them, W bili as trainable weights.
[0066] 3. Decompose the linear transformation. Assign weights to the query vector and key vector respectively, which can also be regarded as the adjacency matrix corresponding to the parameterized paragraph-level dependency syntactic information:
[0067]
[0068] Among them, K l and Q l are the trainable weights assigned to the query vector and key vector respectively.
[0069] Finally, the attention value guided by the dependency syntactic information is applied to the value vector and updated through residual connection and forward propagation
[0070]
[0071] in, is x j The corresponding value vector, yes The updated vector.
[0072] In the specific implementation, the three methods are executed separately to determine the best method. Three optional methods are used to introduce dependency syntactic information into the pre-trained model, and the characteristics of different introduction methods are compared, which is conducive to analyzing the role of dependency syntactic information on the pre-trained model.
[0073] In addition, six structures between entities are introduced into the pre-training model like dependency syntactic information to guide the flow of attention. These six structures are: two entities are in the same sentence and are the same entity; two entities are in the same sentence and are different entities; two entities are not in the same sentence and are the same entity; two entities are not in the same sentence and are different entities; entities and non-entities in the same sentence; and the relationship between non-entities in different sentences.
[0074] Using dependency syntactic information to guide the pre-trained model can enhance the attention between entities with dependencies and further solve the problem of long-distance weak dependencies faced by paragraph-level relationship extraction.
[0075] S3. Extract features from data:
[0076] Specifically, S3 is executed in the word (token) feature representation layer and entity feature representation layer of the chapter-level relationship extraction model. The original corpus of the chapter-level relationship extraction (the original sentences in the chapter-level relationship extraction dataset, that is, the word sequence) is input into the pre-training model designed by S2 based on the guidance of dependency syntactic information, and the feature representation of the entity is obtained (the entity feature refers to the final vector representation of the entity that aggregates the context and other information). In this process, the information of the entity obtained from the model is improved to obtain the corresponding entity feature representation e′ i .
[0077] The contextual representation of words (tokens) generated by the pre-trained model is used so that the words (tokens) have vector representations that are closer to the actual meaning, solving the problem of polysemy in the text.
[0078] S4. Connect entity distance information to form an enhanced representation of the entity:
[0079] Specifically, S4 is executed in the connection layer of the chapter-level relationship extraction model. It first calculates the relative distance between entities. Then it converts it into a vector representation of the distance between entities that can be accepted by the deep learning network model. Finally, it is concatenated with the feature representation of the entity obtained in S3 to further obtain an enhanced representation of the entity feature:
[0080]
[0081] Among them, e′ i is the entity feature representation obtained from the pre-trained model based on dependency syntactic information, d ij Represents the relative distance feature vector between the i-th entity and the j-th entity.
[0082] The entity feature representation is concatenated with the distance feature between entities to enhance the entity information and facilitate the subsequent relationship extraction task.
[0083] S5. Prediction of relations between entities:
[0084] Specifically, S5 is executed at the relation classification layer of the chapter-level relation extraction model, and the entity feature representation obtained by S4 is matrix transformed to form a head entity and a tail entity. The head entity and the tail entity are input into the bilinear transformation, and the relationship between any two entity pairs is predicted. Finally, the probability distribution of the relationship between any two entity pairs is obtained, thereby extracting the relationship between the entities:
[0085] P r (e s ,e o )=sigmoid(e s W r e o ) (9)
[0086] Among them, W r is the weight parameter, and r is the relationship type. In addition, the cross entropy loss function is used as the loss function of the proposed model.
[0087] In an embodiment of the present invention, dependency syntactic information is introduced into the pre-trained model to guide the flow of its attention; the pre-trained model is improved, and the contextual representation of words (tokens) generated by the improved pre-trained model is used, so that the words (tokens) have a vector representation that is closer to the actual meaning, which solves the current problem of difficulty in solving long texts and weak dependencies in the pre-trained model in the paragraph-level relationship extraction task, enhances the reasoning ability of the pre-trained model, and at the same time improves the accuracy of its performance in the paragraph-level relationship extraction task, and also explores the auxiliary role of the graph structure itself on the pre-trained model.
[0088] Corresponding to the chapter-level relationship extraction method based on the pre-trained model of dependency syntax in the present invention, the present invention also provides a chapter-level relationship extraction system based on the pre-trained model of dependency syntax, the system comprising:
[0089] A dependency syntax acquisition module is used to acquire a chapter-level relationship extraction data set, process each article in the chapter-level relationship extraction data set, acquire a chapter-level dependency syntax tree representing the dependency relationship between each word in the entire article, and convert the chapter-level dependency syntax tree into a corresponding adjacency matrix; the data in the chapter-level relationship extraction data set includes a word sequence included in each article, entity information in the word sequence, and relationship information between entities;
[0090] A pre-training model establishment module is used to map the word sequence to a query vector, a key vector and a value vector space respectively; calculate the attention value between any two words; use direct conversion, bi-affine conversion or decomposition linear transformation to introduce the adjacency matrix corresponding to the paragraph-level dependency syntax tree obtained by the dependency syntax acquisition module into the attention calculation to obtain the attention bias, and finally add the obtained attention bias to the original attention value to obtain the final attention value guided by the dependency syntax information, so as to obtain a pre-training model guided by the dependency syntax information;
[0091] A feature representation module, used for inputting the word sequence into the dependency syntax-based pre-training model obtained by the pre-training model building module, extracting features from the data, and obtaining entity feature representation;
[0092] An entity feature enhancement module, used for calculating the relative distance between entities, and concatenating the relative distance between entities with the entity feature representation obtained by the feature representation module to obtain an enhanced representation of the entity feature;
[0093] The relationship extraction module is used to perform matrix transformation on the entity feature representation obtained by the entity feature enhancement module to form a head entity and a tail entity; the head entity and the tail entity are input into a bilinear transformation, and the relationship between any two entities is predicted, and finally the probability distribution of the relationship between any two entities is obtained, so as to extract the relationship between the entities.
[0094] For a chapter-level relationship extraction system based on a pre-trained model of dependency syntax in an embodiment of the present invention, since it corresponds to a chapter-level relationship extraction method based on a pre-trained model of dependency syntax in the above embodiment, the description is relatively simple. For relevant similarities, please refer to the description of a chapter-level relationship extraction method based on a pre-trained model of dependency syntax in the above embodiment, which will not be described in detail here.
[0095] An embodiment of the present invention also discloses a computer-readable storage medium, which stores a computer instruction set. When the computer instruction set is executed by a processor, a method for extracting paragraph-level relations based on a pre-trained model of dependency syntax as provided in any of the above embodiments is implemented.
[0096] In the several embodiments provided by the present invention, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0097] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0098] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0099] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0100] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for extracting paragraph-level relations based on a dependency syntax pre-training model, characterized in that: The method comprises: S1. Obtain a chapter-level relationship extraction data set, and process each article in the chapter-level relationship extraction data set to obtain a chapter-level dependency syntax tree representing the dependency relationship between each word in the entire article, and convert the chapter-level dependency syntax tree into a corresponding adjacency matrix; the data in the chapter-level relationship extraction data set includes a word sequence included in each article, entity information in the word sequence, and relationship information between entities; S2, mapping the word sequence to the query vector, key vector and value vector space respectively; calculating the attention value between any two words; using direct conversion, biaffine conversion or decomposition linear transformation to introduce the adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained in S1 into the attention calculation, and obtaining the attention bias, and finally adding the obtained attention bias to the original attention value to obtain the final attention value guided by the dependency syntactic information, and obtaining the pre-training model guided by the dependency syntactic information; S3, inputting the word sequence into the dependency syntax pre-training model obtained in S2, performing feature extraction on the data, and obtaining entity feature representation; S4, calculating the relative distance between entities, and concatenating the relative distance between entities with the entity feature representation obtained in S3 to obtain an enhanced representation of the entity feature; S5. Perform matrix transformation on the entity feature representation obtained in S4 to form a head entity and a tail entity. Input the head entity and the tail entity into a bilinear transformation to predict the relationship between any two entities, and finally obtain the probability distribution of the relationship between any two entities, thereby extracting the relationship between the entities.
2. According to claim 1, a method for extracting paragraph-level relations based on a dependency syntax pre-training model is characterized in that: The adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained after S1 processing is introduced into the attention calculation by direct conversion, including: The adjacency matrix of the paragraph-level dependency syntactic information is directly applied to the query vector q and the key vector k, retaining only the attention value between two words with dependency relationships, and then adding a bias to each dependency: in, is the i-th word x on the l-th layer i The corresponding query vector, is the jth word x on the lth layer j The corresponding key vector, A ij Represents x i and x j If x i Dependency x j , A ij If yes, it is 1, otherwise it is 0. Increased bias.
3. According to claim 1, a method for extracting paragraph-level relations based on a dependency syntax pre-training model is characterized in that: The adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained after S1 processing is introduced into the attention calculation by using a double affine transformation, including: The adjacency matrix corresponding to the paragraph-level dependency syntactic information is parameterized using a weight matrix to make it a trainable neural network layer, adding a bias to each dependency as with direct conversion: Among them, W bili As a trainable weight, its role is equivalent to parameterizing A ij , so that A ij Become a trainable neural network layer.
4. According to claim 1, a method for extracting paragraph-level relations based on a dependency syntax pre-training model is characterized in that: The adjacency matrix corresponding to the paragraph-level dependency syntactic tree obtained after S1 processing is introduced into the attention calculation by decomposing linear transformation, including: Assign weights to the query vector and key vector respectively, parameterize the query vector and key vector: Among them, K l and Q l are the trainable weights assigned to the query vector and key vector respectively.
5. According to claim 1, a method for extracting paragraph-level relations based on a dependency syntax pre-training model is characterized in that: Processing each article in the chapter-level relationship extraction data set to obtain a chapter-level dependency syntax tree representing the dependency relationship between each word in the entire article, and converting the chapter-level dependency syntax tree into a corresponding adjacency matrix, including: Use the dependency syntax parsing tool to perform dependency syntax parsing on each sentence to obtain a sentence-level dependency syntax parse tree; Connect the root node of the dependency syntactic parse tree of the next sentence to the root node of the dependency syntactic parse tree of the previous sentence, so that the dependency syntactic tree corresponding to the next sentence becomes a branch of the dependency syntactic tree of the previous sentence, thereby enhancing the dependency relationship between sentences, and repeat the above steps to obtain the dependency syntactic tree of the entire article; Convert the dependency syntax tree of the entire article into the corresponding adjacency matrix.
6. A paragraph-level relation extraction system based on a dependency syntax pre-training model, characterized in that: The system comprises: A dependency syntax acquisition module is used to acquire a chapter-level relationship extraction data set, process each article in the chapter-level relationship extraction data set, acquire a chapter-level dependency syntax tree representing the dependency relationship between each word in the entire article, and convert the chapter-level dependency syntax tree into a corresponding adjacency matrix; the data in the chapter-level relationship extraction data set includes a word sequence included in each article, entity information in the word sequence, and relationship information between entities; A pre-training model establishment module is used to map the word sequence to a query vector, a key vector and a value vector space respectively; calculate the attention value between any two words; use direct conversion, bi-affine conversion or decomposition linear transformation to introduce the adjacency matrix corresponding to the paragraph-level dependency syntax tree obtained by the dependency syntax acquisition module into the attention calculation to obtain the attention bias, and finally add the obtained attention bias to the original attention value to obtain the final attention value guided by the dependency syntax information, so as to obtain a pre-training model guided by the dependency syntax information; A feature representation module, used for inputting the word sequence into the dependency syntax-based pre-training model obtained by the pre-training model building module, extracting features from the data, and obtaining entity feature representation; An entity feature enhancement module, used for calculating the relative distance between entities, and concatenating the relative distance between entities with the entity feature representation obtained by the feature representation module to obtain an enhanced representation of the entity feature; The relationship extraction module is used to perform matrix transformation on the entity feature representation obtained by the entity feature enhancement module to form a head entity and a tail entity; the head entity and the tail entity are input into a bilinear transformation, and the relationship between any two entities is predicted, and finally the probability distribution of the relationship between any two entities is obtained, so as to extract the relationship between the entities.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer instruction set, which, when executed by a processor, implements a method for extracting paragraph-level relations based on a pre-trained model of dependency syntax as described in any one of claims 1 to 5.
