De-sampling-based document-level relationship extraction method and device, equipment and medium

By introducing technologies such as deresampling and multi-grained text encoding in the document-level relationship extraction method, the accuracy problem of traditional methods when dealing with unbalanced distribution of relationship categories is solved, and the accuracy of relationship extraction is significantly improved.

CN119807329AActive Publication Date: 2025-04-11深圳市规划和自然资源数据管理中心(深圳市空间地理信息中心) +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510309131.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-17
Publication Date
2025-04-11
Estimated Expiration
2045-03-17

AI Technical Summary

Technical Problem

When traditional document-level relationship extraction methods deal with documents with unbalanced distribution of relationship categories, they are prone to ignore low-frequency relationship categories, resulting in inaccurate results of relationship extraction.

Method used

The document-level relationship extraction method based on deresampling is adopted, and the marked documents are processed through the deresumption module, multi-grained text coding module, graph convolution neural network and hybrid expert system, deresampling and relationship extraction are performed to balance the relationship category distribution.

Benefits of technology

The impact of the unbalanced distribution of relationship categories on the relationship extraction results is reduced, and the accuracy of the relationship extraction results is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807329A_ABST
    Figure CN119807329A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of natural language processing. The invention discloses a document-level relation extraction method and device based on deduplication sampling, equipment and a medium, which can reduce the influence of relation category distribution imbalance on the accuracy of a relation extraction result so as to improve the precision of the relation extraction result. The document-level relation extraction method based on deduplication sampling comprises the following steps: acquiring a text document; a preset mark is adopted to mark the text document, a marked document is obtained, and the marked document comprises at least one group of entity pairs; and inputting the marked document into a document relationship extraction model, and performing de-resampling and relationship extraction processing on the marked document by the document relationship extraction model to obtain a relationship extraction result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing technology. More specifically, the present application relates to a document-level relationship extraction method, device, equipment and medium based on de-resampled. Background Art

[0002] The traditional document-level relationship extraction method is to obtain the document text, transform the document text to obtain the target entity pair vector and the non-target entity pair vector; combine the target entity pair vector and the non-target entity pair vector to obtain the entity pair combination vector; input the entity pair combination vector into the classifier to obtain the relationship extraction result. However, most document texts have the phenomenon of unbalanced relationship category distribution. In the process of converting the document text with unbalanced relationship category distribution into the target entity pair vector and the non-target entity pair vector, this method tends to ignore the low-frequency relationship category, which makes the relationship extraction result inaccurate. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide a document-level relationship extraction method, apparatus, device and medium based on de-resampled, which can reduce the impact of imbalanced relationship category distribution on the accuracy of relationship extraction results, thereby improving the accuracy of relationship extraction results. The embodiments of the present application are mainly implemented through the following technical solutions: A first aspect of an embodiment of the present application provides a document-level relationship extraction method based on de-resampled, comprising: Get the text document; Marking the text document with a preset mark to obtain a marked document, wherein the marked document includes at least one set of entity pairs; The marked document is input into a document relationship extraction model, and the document relationship extraction model performs de-resample and relationship extraction processing on the marked document to obtain a relationship extraction result.

[0004] According to an embodiment of the present application, the marked document is input into a document relationship extraction model, the document relationship extraction model performs de-resample and relationship extraction processing on the marked document, and the step of obtaining the relationship extraction result includes: Inputting the marked document into the deduplication module of the document relationship extraction model for deduplication sampling processing to obtain a set of entity pairs to be processed; Inputting the marked document into the multi-granularity text encoding module of the document relationship extraction model for encoding processing to obtain a context embedding vector; Inputting the set of entity pairs to be processed into the graph convolutional neural network of the document relationship extraction model for computational processing to obtain a first global embedding representation of the subject and a second global embedding representation of the object in the target entity pair, wherein the target entity pair is any entity pair in the set of entity pairs to be processed; Inputting the target entity pair and the context embedding vector into the context pooling module of the document relationship extraction model to perform local context pooling processing to obtain relationship features; Inputting the first global embedding representation, the second global embedding representation and the relationship feature into the hybrid expert system of the document relationship extraction model for score calculation processing to obtain a relationship score corresponding to the target entity pair; The relationship extraction result is obtained based on all relationship scores.

[0005] According to an embodiment of the present application, the step of inputting the marked document into the deduplication module of the document relationship extraction model for deduplication sampling processing, and obtaining a set of entity pairs to be processed includes: Set a first set to be processed, and initialize the first set to be processed to an empty set; Obtaining a set of related entity pairs and a set of unrelated entity pairs in the marked document; Randomly shuffle all entity pairs in the set of unrelated entity pairs to obtain a second set to be processed; Counting the first occurrence frequency of the subject and the second occurrence frequency of the object in each unrelated entity pair in the second to-be-processed set; When the first occurrence frequency of the subject and the second occurrence frequency of the object in the target unrelated entity pair do not exceed the preset threshold, adding the target unrelated entity pair to the first set to be processed, wherein the target unrelated entity pair is any unrelated entity pair in the second set to be processed; After counting the first occurrence frequency of the subject and the second occurrence frequency of the object in each unrelated entity pair, the set of related entity pairs and the first set to be processed are merged to obtain the set of entity pairs to be processed.

[0006] According to an embodiment of the present application, the step of inputting the marked document into the multi-granularity text encoding module of the document relationship extraction model for encoding processing, and obtaining the context embedding vector includes: Using the pre-trained language model of the multi-granularity text encoding module to encode the marked document to obtain a first embedding vector at the word level; Using the phrase detection model of the multi-granularity text encoding module to encode the marked document to obtain a second embedding vector at the phrase level; Using the sentence encoder of the multi-granularity text encoding module to encode the marked document to obtain a third embedding vector at the sentence level; The first embedding vector, the second embedding vector and the third embedding vector are fused by using a fusion module of the multi-granularity text encoding module to obtain the context embedding vector.

[0007] According to an embodiment of the present application, the set of entity pairs to be processed is input into the graph convolutional neural network of the document relationship extraction model for computational processing to obtain a first global embedding representation of the subject and a second global embedding representation of the object in the target entity pair, wherein the target entity pair is any one of the entity pairs in the set of entity pairs to be processed, and the step includes: Constructing an entity graph based on the set of entity pairs to be processed; Based on the entity graph, using the graph convolutional neural network to calculate a multi-layer first embedding representation of a subject in the target entity pair, and using the first embedding representation of the last layer as a first global embedding representation of the subject; Based on the entity graph, the graph convolutional neural network is used to calculate a multi-layer second embedding representation of the object in the target entity pair, and the second embedding representation of the last layer is used as the second global embedding representation of the object.

[0008] According to an embodiment of the present application, the step of inputting the first global embedding representation, the second global embedding representation, and the relationship feature into the hybrid expert system of the document relationship extraction model for score calculation processing, and obtaining the relationship score corresponding to the target entity pair includes: Using the hybrid expert system to perform computational processing on the first global embedding representation and the relationship feature to obtain a first joint feature; Using the hybrid expert system to perform computational processing on the second global embedding representation and the relationship feature to obtain a second joint feature; A relationship score corresponding to the target entity pair is obtained based on the first joint feature and the second joint feature.

[0009] According to an embodiment of the present application, the document-level relationship extraction method based on de-resampled further includes a training step of the document relationship extraction model, and the training step of the document relationship extraction model includes: Obtain a training data set and a true label set, wherein each training data in the training data set has a one-to-one correspondence with one of the true labels in the true label set; Using the preset tags to label the target training data to obtain a training document, wherein the training document includes at least one set of entity pairs; Inputting the training document into the original document relation extraction model, the original document relation extraction model performs de-resample and relation extraction processing on the training document to obtain a prediction result; Calculate a loss function based on the prediction result and the true label corresponding to the target training data; The model parameters of the original document relationship extraction model are adjusted based on the loss function to form the document relationship extraction model.

[0010] A second aspect of the embodiment of the present application provides a document-level relationship extraction device based on de-resample, comprising: A text document acquisition module, used to acquire text documents; A marked document obtaining module, used for marking the text document with a preset mark to obtain a marked document, wherein the marked document includes at least one set of entity pairs; The model processing module is used to input the marked document into the document relationship extraction model, and the document relationship extraction model performs de-resample and relationship extraction processing on the marked document to obtain a relationship extraction result.

[0011] According to a third aspect of an embodiment of the present application, a terminal device is provided, comprising: a processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, and executing the steps of the document-level relationship extraction method based on de-resampling provided in the first aspect of the embodiment of the present application.

[0012] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium is used to store a computer program, wherein the computer program enables a computer to execute the steps of the document-level relationship extraction method based on de-resampling provided in the first aspect of the embodiment of the present application.

[0013] The beneficial effects of the embodiments of the present application include: In the embodiment of the present application, a de-resample method is used to balance the distribution of relationship categories in the document. Specifically, in the embodiment of the present application, a document relationship extraction model with a de-resample function is set up, and the document relationship extraction model is used to perform de-resample and relationship extraction processing on the marked documents that have been marked, thereby obtaining a relationship extraction result. Compared with the prior art, the embodiment of the present application can reduce the impact of the imbalanced distribution of relationship categories on the accuracy of the relationship extraction results, thereby improving the accuracy of the relationship extraction results. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0015] Figure 1 A flowchart of the document-level relationship extraction method based on de-resample in some embodiments of the present application; Figure 2 A training flowchart of the original document relationship extraction model of the present application in some embodiments; Figure 3 A principle block diagram of a document-level relationship extraction device based on de-resampled in some embodiments of the present application; Figure 4 This is a functional block diagram of the terminal device of the present application in some embodiments. DETAILED DESCRIPTION

[0016] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present application, so the present application is not limited by the specific embodiments disclosed below.

[0017] It should be noted that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0018] The terms "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0019] The terms "comprises," "includes," or any other variations thereof are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or elements is not necessarily limited to those steps or elements explicitly listed but may include other steps or elements not explicitly listed or inherent to such process, method, product, or apparatus.

[0020] Unless otherwise defined, all technical and scientific terms used in the specification of this application have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used in the specification of this application includes any and all combinations of one or more related listed items.

[0021] The specific implementation of the present application is further described below in conjunction with the accompanying drawings.

[0022] refer to Figure 1 FIG. 1 is a flowchart of a document-level relationship extraction method based on de-resampled data provided in the first aspect of the embodiment of the present application. Figure 1 In the document-level relationship extraction method based on de-resampled, the document-level relationship extraction method includes: S1. Get a text document.

[0023] The text document may be a word document, and text content is recorded in the text document.

[0024] S2. Marking the text document with a preset tag to obtain a marked document, wherein the marked document includes at least one set of entity pairs.

[0025] Specifically, the preset mark is “*.” The embodiment of the present application uses the preset mark to emphasize the starting position and the ending position of the appearing entity.

[0026] S3. Input the marked document into a document relationship extraction model, and the document relationship extraction model performs de-resample and relationship extraction processing on the marked document to obtain a relationship extraction result.

[0027] Furthermore, the S3 step includes: S31, inputting the marked document into the deduplication module of the document relationship extraction model for deduplication sampling processing to obtain a set of entity pairs to be processed.

[0028] Furthermore, the step S31 includes: S311. Set a first to-be-processed set, and initialize the first to-be-processed set to an empty set.

[0029] The first to-be-processed set can be expressed as .

[0030] S312: Obtain a set of related entity pairs and a set of unrelated entity pairs in the marked document.

[0031] Each entity pair in the set of related entity pairs corresponds to at least one non-empty relationship category. The non-empty relationship category may be "founder relationship" or "partner relationship". Of course, the non-empty relationship category is not limited to the above examples and can be set by those skilled in the art according to actual needs.

[0032] The relationship category of each entity pair in the set of unrelated entity pairs is only “unrelated”.

[0033] The set of related entity pairs can be expressed as The set of unrelated entity pairs can be expressed as .

[0034] S313: Randomly shuffle all entity pairs in the set of unrelated entity pairs to obtain a second set to be processed.

[0035] S314: Count the first occurrence frequency of the subject and the second occurrence frequency of the object in each unrelated entity pair in the second to-be-processed set.

[0036] S315. When the first occurrence frequency of the subject and the second occurrence frequency of the object in the target unrelated entity pair do not exceed the preset threshold, add the target unrelated entity pair to the first set to be processed, wherein the target unrelated entity pair is any unrelated entity pair in the second set to be processed.

[0037] The target unrelated entity pair is composed of two entities, one of which is a subject and the other is an object.

[0038] The preset threshold is a specific value and can be set by those skilled in the art according to actual needs.

[0039] S316: After counting the first occurrence frequency of the subject and the second occurrence frequency of the object in each unrelated entity pair, merge the set of related entity pairs and the first set to be processed to obtain the set of entity pairs to be processed.

[0040] The setting of step S31 can limit the occurrence frequency of each entity in the set of unrelated entity pairs to not exceed the preset threshold, thereby reducing redundant data while maintaining the integrity of the set of related entity pairs.

[0041] S32: Input the marked document into the multi-granularity text encoding module of the document relationship extraction model for encoding processing to obtain a context embedding vector.

[0042] The multi-granularity text encoding module is used to perform encoding at the word level, phrase level and sentence level to capture semantic information at different levels.

[0043] Further, step S32 includes: S321. Use the pre-trained language model of the multi-granularity text encoding module to encode the marked document to obtain a first embedding vector at the word level.

[0044] The pre-trained language model is a BERT (Bidirectional Encoder Representations from Transformers) pre-trained language model. In other embodiments, the pre-trained language model may also be a RoBerta (Robustly Optimized BERT Pretraining Approach) pre-trained language model or a DeBerta (Decoding-enhanced BERT with Disentangled Attention) pre-trained language model, which may be specifically set by a person skilled in the art according to actual needs.

[0045] S322: Use the phrase detection model of the multi-granularity text encoding module to encode the marked document to obtain a second embedding vector at the phrase level.

[0046] The phrase detection model is a SpanBERT model, the full name of which is Improving Pre-training by Representing and Predicting Spans. The SpanBERT model is an extension of BERT.

[0047] S323: Use the sentence encoder of the multi-granularity text encoding module to encode the marked document to obtain a third embedding vector at the sentence level.

[0048] The sentence encoder is a Sentence-BERT (Sentence Bidirectional Encoder Representations from Transformers) model.

[0049] S324. Use the fusion module of the multi-granularity text encoding module to fuse the first embedding vector, the second embedding vector and the third embedding vector to obtain the context embedding vector.

[0050] Furthermore, the calculation formula of step S324 is: ; in, is the context embedding vector, , for dimensional real space, is the length of the labeled document, is the encoding dimension; is the first embedding vector; is the second embedding vector; is the third embedding vector.

[0051] Furthermore, step S32 also includes: S325: Use the pre-trained language model to perform computational processing on the marked document to obtain word-level attention.

[0052] S326: Use the phrase detection model to perform computational processing on the marked document to obtain phrase-level attention.

[0053] S327: Use the sentence encoder to perform computational processing on the marked document to obtain sentence-level attention.

[0054] S328. Use the fusion module to fuse the word-level attention, the phrase-level attention and the sentence-level attention to obtain the context attention.

[0055] Furthermore, the calculation formula of step S328 is: ; in, is the context attention, , for dimensional real space, is the number of attention heads, is the length of the marked document; for the word level attention; for the phrase level attention; for the sentence level attention; is a fusion function, and the fusion function has a merging function.

[0056] S33. Input the set of entity pairs to be processed into the graph convolutional neural network of the document relationship extraction model for computational processing to obtain a first global embedding representation of the subject and a second global embedding representation of the object in the target entity pair, wherein the target entity pair is any entity pair in the set of entity pairs to be processed.

[0057] Further, step S33 includes: S331: Construct an entity graph based on the set of entity pairs to be processed.

[0058] Each entity pair in the set of entity pairs to be processed includes two entities, one of which is a subject and the other is an object.

[0059] The entity graph is expressed as ; is the entity graph; is the set of all nodes of the entity graph, that is, the set of all entities in the set of entity pairs to be processed, , is the first node of the entity graph, the first entity in the set of entity pairs to be processed, is the second entity in the set of entity pairs to be processed, and so on. is the first entities, is the total number of all entities in the set of entity pairs to be processed; are all the edges of the entity graph, entity and Semantic relationship ; is the entity graph Node, that is, the first node in the set of entities to be processed Entities ; is the entity graph Node, that is, the first node in the set of entities to be processed Entities .

[0060] S332. Based on the entity graph, use the graph convolutional neural network to calculate the multi-layer first embedding representation of the subject in the target entity pair, and use the first embedding representation of the last layer as the first global embedding representation of the subject.

[0061] Furthermore, the first embedded representation in the multi-layer The calculation formula for the first embedding representation of the layer is: ; in, Centering the subject for the target entity No. Layer-first embedding representation; is a nonlinear activation function; For Node The neighbor node set of the target entity pair The set of neighbor nodes of For Node The set of neighbor nodes, that is, the entity The set of neighbor nodes of Centering the subject for the target entity No. The learnable weight matrix of the first embedding representation of the layer, , for dimensional real space, is the embedding dimension; Main body No. Layer-first embedding representation; Centering the subject for the target entity No. The bias term of the first embedding representation of the layer, is a normalization coefficient used to balance the influence of neighboring nodes.

[0062] It should be understood that the first embedding representation of the entity to be processed for each entity in the set belongs to ,in, for dimensional real number space; is the embedding dimension. Exemplarily, the target entity is the subject The first embedding of the first layer is expressed as .

[0063] Furthermore, the calculation formula of the first global embedding representation is: ; in, is the first global embedding representation, is the subject in the target entity pair; is the first embedding representation of the last layer; is the last layer in the multi-layer first embedding representation.

[0064] S333. Based on the entity graph, use the graph convolutional neural network to calculate the multi-layer second embedding representation of the object in the target entity pair, and use the second embedding representation of the last layer as the second global embedding representation of the object.

[0065] Furthermore, the multi-layer second embedding representation The calculation formula for the second embedding representation of the layer is: ; in, The object of the target entity No. Layer 2 embedding representation; is a nonlinear activation function; For Node The neighbor node set of the target entity pair The set of neighbor nodes of For Node The set of neighbor nodes, that is, the entity The set of neighbor nodes of The object of the target entity No. The learnable weight matrix of the second embedding representation of the layer, , for dimensional real space, is the embedding dimension; For the object No. Layer 2 embedding representation; The object of the target entity No. The bias term of the second embedding representation of the layer, is a normalization coefficient used to balance the influence of neighboring nodes.

[0066] Furthermore, the calculation formula of the second global embedding representation is: ; in, For the second global embedding representation, is the object in the target entity pair; is the second embedding representation of the last layer; is the last layer in the multi-layer second embedding representation.

[0067] S34: Input the target entity pair and the context embedding vector into the context pooling module of the document relationship extraction model to perform local context pooling processing to obtain relationship features.

[0068] Further, step S34 includes: S341, calculating the first attention weight of the subject in the target entity pair.

[0069] Furthermore, the calculation formula of step S341 is: ; in, is the first attention weight; Centering the subject for the target entity Number of mentions; Centering the subject for the target entity No. The location of the second occurrence The self-attention weight of for dimensional real number space; is the number of attention heads; is the length of the marked document; is the subscript corresponding to the subject in the target entity pair.

[0070] S342. Calculate the second attention weight of the object in the target entity pair.

[0071] Furthermore, the calculation formula of step S342 is: ; in, is the second attention weight; The object of the target entity Number of mentions; The object of the target entity No. The location of the second occurrence The self-attention weight of for dimensional real number space; is the number of attention heads; is the length of the marked document; is the subscript corresponding to the object in the target entity pair.

[0072] S343: Aggregate the first attention weight and the second attention weight by summing and averaging to obtain the importance distribution of the target entity pair.

[0073] Furthermore, the calculation formula of step S343 is: ; in, is the importance distribution of the target entity pair; is the first attention weight; For Hadamard; is the second attention weight; is the transpose of the first attention weight, is the subscript corresponding to the subject in the target entity pair, is the subscript corresponding to the object in the target entity pair.

[0074] S344: Calculate the relationship feature based on the importance distribution and the context embedding vector.

[0075] Furthermore, the calculation formula of step S344 is: ; in, is the relation feature, which is also the weighted average of all words in the marked document; Embedding vector for the context The transpose of is the importance distribution of the target entity pair; is the subscript corresponding to the subject in the target entity pair, is the subscript corresponding to the object in the target entity pair.

[0076] S35: Input the first global embedding representation, the second global embedding representation and the relationship feature into the hybrid expert system of the document relationship extraction model for score calculation processing to obtain a relationship score corresponding to the target entity pair.

[0077] The hybrid expert system MoE (Mixture of Experts) combines expert networks and gating mechanisms to improve the flexibility and performance of the model. The expert network focuses on fine-grained analysis of input features, while the gating mechanism is responsible for dynamically selecting the previous The experts with the highest weights are selected and weighted to generate the final feature representation.

[0078] MoE consists of 16 experts, each of whom The calculation formula is: ; in, It is the layer normalization operation; is the Gaussian error linear unit activation function; For the The learnable weight matrix of experts, , for dimensional real space, is the encoding dimension; is the input feature; For the The learnable bias of experts, , for dimensional real number space.

[0079] The gating mechanism According to the input characteristics Dynamically assign weights, select The most important expert.

[0080] The calculation formula of the gating mechanism is: ; in, is a function for normalizing weights; Before choosing The most weighted expert; is the learnable weight matrix of the gating mechanism, , for dimensional real space, is the encoding dimension; is the input feature; is the learnable bias term of the gating mechanism, , is a 16-dimensional real number space.

[0081] The final output of the hybrid expert system MoE is the previous The calculation formula of the final output of the hybrid expert system MoE is: ; in, is the final output; The gating mechanism is The weights assigned by the experts; For the Experts on input features Output.

[0082] Further, step S35 includes: S351: Use the hybrid expert system to calculate and process the first global embedding representation and the relationship feature to obtain a first joint feature.

[0083] Furthermore, the calculation formula of step S351 is: ; in, is the first joint feature; for the hybrid expert system; is the first global embedding representation; is the characteristic of the relationship.

[0084] S352: Use the hybrid expert system to perform calculation processing on the second global embedding representation and the relationship feature to obtain a second joint feature.

[0085] Furthermore, the calculation formula of step S352 is: ; in, is the second joint feature; for the hybrid expert system; is the second global embedding representation; is the characteristic of the relationship.

[0086] S353: Obtain a relationship score corresponding to the target entity pair based on the first joint feature and the second joint feature.

[0087] Furthermore, the calculation formula of step S353 is: ; in, scoring the relationship corresponding to the target entity pair; is a learnable parameter, , for dimensional real space, is the encoding dimension; is the first joint feature; is a learnable parameter, ; is the second joint feature.

[0088] S36: Obtain the relationship extraction result based on all relationship scores.

[0089] In the embodiment of the present application, all relationship scores may be screened to obtain the relationship extraction result.

[0090] In the embodiment of the present application, a de-resample method is used to balance the distribution of relationship categories in the document. Specifically, in the embodiment of the present application, a document relationship extraction model with a de-resample function is set up, and the document relationship extraction model is used to perform de-resample and relationship extraction processing on the marked documents that have been marked, thereby obtaining a relationship extraction result. Compared with the prior art, the embodiment of the present application can reduce the impact of the imbalanced distribution of relationship categories on the accuracy of the relationship extraction results, thereby improving the accuracy of the relationship extraction results.

[0091] The use of the hybrid expert system can improve the accuracy of target relationship modeling and overcome the information focusing problem that the current document-level relationship extraction is easily disturbed by noise.

[0092] In some implementations, the document-level relationship extraction method based on de-resampled further includes a step of training the document relationship extraction model, and the step of training the document relationship extraction model includes: S4, obtain a training data set and a true label set, each training data in the training data set has a one-to-one correspondence with one of the true labels in the true label set. Figure 2 The "Obtaining training datasets and true label sets" step in .

[0093] Each training data in the training data set is a text document.

[0094] S5. Use the preset labels to label the target training data to obtain a training document, where the training document contains at least one set of entity pairs.

[0095] S6. Input the training document into the original document relationship extraction model, and the original document relationship extraction model performs de-resample and relationship extraction processing on the training document to obtain a prediction result.

[0096] The original document relationship extraction model includes an original deduplication module, an original multi-granularity text encoding module, an original graph convolutional neural network, an original context pooling module and an original hybrid expert system.

[0097] Furthermore, step S6 includes: S61: Input the training document into the original deduplication module of the original document relationship extraction model to perform deduplication sampling processing to obtain a training set of entity pairs to be processed. Figure 2 The "de-resampling" step in .

[0098] S62: Input the training document into the original multi-granularity text encoding module of the original document relation extraction model for encoding processing to obtain a training context embedding vector. Figure 2 The "Multi-granularity text encoding" step in .

[0099] S63, input the training set of entity pairs to be processed into the original graph convolutional neural network of the original document relationship extraction model for computational processing, and obtain a first training global embedding representation of the subject and a second training global embedding representation of the object in the target training entity pair, wherein the target training entity pair is any entity pair in the training set of entity pairs to be processed. Step S63 can refer to Figure 2 The “Entity Embedding with Graph Neural Networks” step in .

[0100] S64: Input the target training entity pair and the training context embedding vector into the original context pooling module of the original document relation extraction model to perform local context pooling processing to obtain training relation features. Figure 2 The "local context pooling" step in .

[0101] S65: Input the first training global embedding representation, the second training global embedding representation and the training relationship features into the original hybrid expert system of the original document relationship extraction model for score calculation processing to obtain a training relationship score corresponding to the target training entity pair. Figure 2 The "Original hybrid expert system computes relationship scores" step in .

[0102] S66: Obtain the prediction result based on all training relationship scores.

[0103] The difference between the original document relationship extraction model and the document relationship extraction model lies in the difference in model parameters.

[0104] S7: Calculate the loss function based on the prediction result and the true label corresponding to the target training data. Figure 2 The "Compute loss function" step in .

[0105] Furthermore, the calculation formula of the loss function is: ; ; in, is the loss function; is the target training data The relationship between entity pairs; is the true label, that is, the label corresponding to the first The true label corresponding to each entity pair; Predict probabilities for relationships; is the target training data Each entity scores the corresponding relationship; is the target training data Each entity scores the corresponding relationship; is the set of all relations in the target training data; is an exponential function. When it is the right relationship, is equal to 1, otherwise is equal to 0.

[0106] S8: Adjust the model parameters of the original document relationship extraction model based on the loss function to form the document relationship extraction model. Figure 2 The "Fix model parameters" step in .

[0107] The document relationship extraction model is a trained model.

[0108] refer to Figure 3 FIG. 1 is a block diagram of a document-level relationship extraction device based on de-resampled data provided by the second aspect of the embodiment of the present application. Figure 3 In the document level relationship extraction device 100 based on de-resampled, the document level relationship extraction device 100 comprises: The text document acquisition module 101 is used to acquire a text document; A marked document obtaining module 102 is used to mark the text document with a preset mark to obtain a marked document, wherein the marked document includes at least one set of entity pairs; The model processing module 103 is used to input the marked document into a document relationship extraction model, and the document relationship extraction model performs de-resample and relationship extraction processing on the marked document to obtain a relationship extraction result.

[0109] A third aspect of the embodiments of the present application provides a terminal device. The principle block diagram of the terminal device can be as follows: Figure 4 As shown. The terminal device includes a processor, a memory, a network interface, a display screen and a temperature sensor connected via a system bus. The processor is used to provide computing and control capabilities. The memory 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 terminal device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a document-level relationship extraction method based on de-resampled is implemented. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the temperature sensor is pre-set inside the terminal device to detect the operating temperature of the internal device.

[0110] Those skilled in the art will understand that Figure 4 The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the terminal device to which the scheme of the present invention is applied. The specific terminal device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0111] In some embodiments, an embodiment of the present application provides a terminal device, the terminal device includes a processor and a memory, the memory is used to store a computer program, the processor is used to call and run the computer program stored in the memory, and execute the steps of the document-level relationship extraction method based on de-resampled provided in the first aspect of the embodiment of the present application. A fourth aspect of the embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium is used to store a computer program, and the computer program enables a computer to execute the steps of the document-level relationship extraction method based on de-resampled provided in the first aspect of the embodiment of the present application.

[0112] 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 by the present invention 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).

[0113] The technical features of the above embodiments can be combined without changing the basic principles of the present application. 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.

[0114] The above 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 patent application. 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 scope of patent protection of the present application shall be subject to the attached claims.

Claims

1. A document-level relationship extraction method based on de-resampled, characterized in that: include: Get the text document; Marking the text document with a preset mark to obtain a marked document, wherein the marked document includes at least one set of entity pairs; The marked document is input into a document relationship extraction model, and the document relationship extraction model performs de-resample and relationship extraction processing on the marked document to obtain a relationship extraction result.

2. The document-level relationship extraction method based on de-resampled according to claim 1, characterized in that: The marked document is input into a document relation extraction model, and the document relation extraction model performs de-resample and relation extraction processing on the marked document. The step of obtaining the relation extraction result includes: Inputting the marked document into the deduplication module of the document relationship extraction model for deduplication sampling processing to obtain a set of entity pairs to be processed; Inputting the marked document into the multi-granularity text encoding module of the document relationship extraction model for encoding processing to obtain a context embedding vector; Inputting the set of entity pairs to be processed into the graph convolutional neural network of the document relationship extraction model for computational processing to obtain a first global embedding representation of the subject and a second global embedding representation of the object in the target entity pair, wherein the target entity pair is any entity pair in the set of entity pairs to be processed; Inputting the target entity pair and the context embedding vector into the context pooling module of the document relationship extraction model to perform local context pooling processing to obtain relationship features; Inputting the first global embedding representation, the second global embedding representation and the relationship feature into the hybrid expert system of the document relationship extraction model for score calculation processing to obtain a relationship score corresponding to the target entity pair; The relationship extraction result is obtained based on all relationship scores.

3. The document-level relationship extraction method based on de-resampled according to claim 2, characterized in that: The step of inputting the marked document into the deduplication module of the document relationship extraction model for deduplication sampling processing to obtain a set of entity pairs to be processed includes: Set a first set to be processed, and initialize the first set to be processed to an empty set; Obtaining a set of related entity pairs and a set of unrelated entity pairs in the marked document; Randomly shuffle all entity pairs in the set of unrelated entity pairs to obtain a second set to be processed; In the second to-be-processed set, counting the first occurrence frequency of the subject and the second occurrence frequency of the object in each unrelated entity pair; When the first occurrence frequency of the subject and the second occurrence frequency of the object in the target unrelated entity pair do not exceed the preset threshold, adding the target unrelated entity pair to the first set to be processed, wherein the target unrelated entity pair is any unrelated entity pair in the second set to be processed; After counting the first occurrence frequency of the subject and the second occurrence frequency of the object in each unrelated entity pair, the set of related entity pairs and the first set to be processed are merged to obtain the set of entity pairs to be processed.

4. The document-level relationship extraction method based on de-resampled according to claim 2, characterized in that: The step of inputting the marked document into the multi-granularity text encoding module of the document relationship extraction model for encoding processing to obtain a context embedding vector comprises: Using the pre-trained language model of the multi-granularity text encoding module to encode the marked document to obtain a first embedding vector at the word level; Using the phrase detection model of the multi-granularity text encoding module to encode the marked document to obtain a second embedding vector at the phrase level; Using the sentence encoder of the multi-granularity text encoding module to encode the marked document to obtain a third embedding vector at the sentence level; The first embedding vector, the second embedding vector and the third embedding vector are fused by using a fusion module of the multi-granularity text encoding module to obtain the context embedding vector.

5. The document-level relationship extraction method based on de-resampled according to claim 2, characterized in that: Inputting the set of entity pairs to be processed into the graph convolutional neural network of the document relationship extraction model for computational processing to obtain a first global embedding representation of the subject and a second global embedding representation of the object in the target entity pair, wherein the target entity pair is any one of the set of entity pairs to be processed, comprises: Constructing an entity graph based on the set of entity pairs to be processed; Based on the entity graph, using the graph convolutional neural network to calculate a multi-layer first embedding representation of a subject in the target entity pair, and using the first embedding representation of the last layer as a first global embedding representation of the subject; Based on the entity graph, the graph convolutional neural network is used to calculate a multi-layer second embedding representation of the object in the target entity pair, and the second embedding representation of the last layer is used as the second global embedding representation of the object.

6. The document-level relationship extraction method based on de-resampled according to claim 2, characterized in that: The step of inputting the first global embedding representation, the second global embedding representation and the relationship feature into the hybrid expert system of the document relationship extraction model for score calculation processing to obtain the relationship score corresponding to the target entity pair includes: Using the hybrid expert system to perform computational processing on the first global embedding representation and the relationship feature to obtain a first joint feature; Using the hybrid expert system to perform computational processing on the second global embedding representation and the relationship feature to obtain a second joint feature; A relationship score corresponding to the target entity pair is obtained based on the first joint feature and the second joint feature.

7. The document-level relationship extraction method based on de-resampled according to claim 1, characterized in that: The document-level relationship extraction method based on de-resampled further includes a step of training the document relationship extraction model, and the step of training the document relationship extraction model includes: Obtain a training data set and a true label set, wherein each training data in the training data set has a one-to-one correspondence with one of the true labels in the true label set; Using the preset tags to label the target training data to obtain a training document, wherein the training document includes at least one set of entity pairs; Inputting the training document into the original document relation extraction model, the original document relation extraction model performs de-resample and relation extraction processing on the training document to obtain a prediction result; Calculate a loss function based on the prediction result and the true label corresponding to the target training data; The model parameters of the original document relationship extraction model are adjusted based on the loss function to form the document relationship extraction model.

8. A document-level relationship extraction device based on de-resampled, characterized in that: include: A text document acquisition module, used to acquire text documents; A marked document obtaining module, used to mark the text document with a preset mark to obtain a marked document, wherein the marked document includes at least one set of entity pairs; The model processing module is used to input the marked document into the document relationship extraction model, and the document relationship extraction model performs de-resample and relationship extraction processing on the marked document to obtain a relationship extraction result.

9. A terminal device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the steps of the document-level relationship extraction method based on de-resampling as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program enables a computer to execute the steps of the document-level relationship extraction method based on de-resampling as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Entity relationship extraction method based on multiple languages and server

    CN107273349A

  • Document level relationship extraction method, device, equipment and storage medium

    CN111597341A

  • Entity relationship identification method and device, equipment and storage medium

    CN114692617A

  • Improved relation extraction method combining entity relation and local information

    CN114791953A

  • Domain knowledge graph construction method based on GlobalPointer joint extraction

    CN118396102A