Method and device for extracting entity implicit relations
By inputting the trained sequence labeling model to directly output the entity implicit relationship labeling results, the problem of inaccurate extraction of implicit relationships between entities in the prior art is solved, and a higher accuracy and simple method is achieved.
Patent Information
- Application Number
- CN202010236475.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-03-30
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2040-03-30
AI Technical Summary
The prior art has errors in extracting entities and their relationships, resulting in large cumulative errors in the implicit relationships between entities and inaccurate results.
By obtaining the pending text and inputting it into the trained sequence annotation model, the entity's implicit relationship annotation results are directly output, avoiding relationship reasoning and improving accuracy.
Directly extracting the implicit relationships between entities improves the accuracy of the results, simplifies the method and improves efficiency.
Smart Images

Figure CN113468335B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of knowledge graph technology, and in particular, to a method and device for extracting implicit relationships between entities. Background Art
[0002] With the development of big data and artificial intelligence, knowledge graph, as an important part of artificial intelligence technology, has been widely used in finance, agriculture, e-commerce, medical electronics, transportation and other fields due to its powerful semantic processing, interconnected organization, information retrieval and knowledge reasoning capabilities. In essence, the knowledge graph is a huge semantic network diagram that describes various entities or concepts and their relationships in the real world by using nodes to represent entities or concepts and edges to represent relationships.
[0003] There are often implicit relationships between entities. In the prior art, entities and the relationships between entities are usually extracted first, and then the implicit relationship between the two entities is derived through relationship reasoning. For example, for the text "Zhang San works at Company A", the relationship between the entity "Zhang San" and the entity "Company A" is a working relationship; for the text "Li Si joined Company A in June 2018", the relationship between the entity "Li Si" and the entity "Company A" is a working relationship. Based on this, it is inferred that the implicit relationship between "Zhang San" and "Li Si" is a colleague relationship.
[0004] However, the inventors found that due to certain errors in extracting entities and the relationships between entities, the cumulative error of the implicit relationship between two entities obtained based on this is large, resulting in inaccurate results. Summary of the invention
[0005] The embodiment of the present invention provides a method and device for extracting implicit relationships between entities, which can accurately extract implicit relationships between entities.
[0006] In a first aspect, an embodiment of the present invention provides a method for extracting implicit relations of entities, comprising:
[0007] Obtaining a text to be processed, and inputting the text to be processed into a sequence labeling model;
[0008] Determine the entity implicit relationship of the text to be processed according to the output result of the sequence labeling model;
[0009] The sequence labeling model is obtained by preprocessing a sample set with entity implicit relationship labels to obtain a training sample set, and training a neural network model according to the training sample set.
[0010] As an embodiment of the present invention, the step of obtaining a sample set with entity implicit relationship annotations is further included, as follows:
[0011] Acquire text data, and preprocess the text data to obtain a sample set to be labeled;
[0012] Sending the sample set to be labeled to a labeling terminal, wherein the sample set to be labeled is used to instruct a target person to label entities with implicit relationships in the sample set to be labeled with implicit relationships;
[0013] The implicit relationship annotation result fed back by the annotation terminal is received to obtain a sample set with entity implicit relationship annotations.
[0014] As an embodiment of the present invention, the step of training a neural network model according to the training sample set to obtain a sequence labeling model is further included as follows:
[0015] Encoding the training sample set according to the pre-trained language model to obtain an encoding vector;
[0016] The BiLSTM-CRF neural network model is trained according to the encoding vector to obtain a sequence labeling model.
[0017] As an embodiment of the present invention, the pre-trained language model is BERT language;
[0018] The step of preprocessing the sample set is also included, as follows:
[0019] Add a [CLS] tag to the beginning of each sentence in the sample set, add a [SEP] tag to the end of the sentence, and connect sentence pairs with the [SEP] tag;
[0020] The labeled sentences are processed by word embedding, sentence embedding and position embedding respectively.
[0021] As an embodiment of the present invention, determining the entity implicit relationship of the to-be-processed text according to the output result of the sequence labeling model includes:
[0022] Determine a target entity having the same annotation label according to an output result of the sequence annotation model;
[0023] The implicit relationship between the target entities is determined according to the implicit relationship corresponding to the annotated tags.
[0024] As an embodiment of the present invention, the BiLSTM-CRF neural network model is trained according to the encoding vector to obtain a sequence labeling model, including:
[0025] The BiLSTM-CRF neural network model is trained according to the encoding vector to obtain a target sequence labeling model;
[0026] Get a test sample set;
[0027] Testing the target sequence labeling model according to the test sample set;
[0028] If the accuracy of the output result of the target sequence model is greater than a preset threshold, the target sequence labeling model is determined as a sequence labeling model.
[0029] As an embodiment of the present invention, it also includes:
[0030] Construct a knowledge graph based on the entity implicit relationship extraction results and graph database.
[0031] In a second aspect, an embodiment of the present invention provides an entity implicit relationship extraction device, comprising:
[0032] An input module, used to obtain the text to be processed and input the text to be processed into the sequence labeling model;
[0033] A determination module, used for determining the entity implicit relationship of the text to be processed according to the output result of the sequence labeling model;
[0034] The sequence labeling model is obtained by preprocessing a sample set with entity implicit relationship labels to obtain a training sample set, and training a neural network model according to the training sample set.
[0035] In a third aspect, an embodiment of the present invention provides a device for extracting entity implicit relations, including: at least one processor and a memory;
[0036] The memory stores computer-executable instructions;
[0037] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the method described in the first aspect and various possible implementations of the first aspect.
[0038] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer execution instructions. When a processor executes the computer execution instructions, the method described in the first aspect and various possible implementation methods of the first aspect are implemented.
[0039] The entity implicit relationship extraction method and device provided in this embodiment, the method inputs the text to be processed into a sequence labeling model, the sequence labeling model outputs the entity implicit relationship labeling result of the text to be processed, and the entity implicit relationship of the text to be processed can be determined according to the labeling result, wherein the sequence labeling model is obtained by preprocessing the sample set with entity implicit relationship labeling to obtain a training sample set, and training the neural network model according to the training sample set. The embodiment of the present invention can directly extract the implicit relationship between entities, thereby improving the accuracy of the obtained implicit relationship, and the method is simple and convenient. 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 following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 A schematic diagram of an application scenario of the method for extracting implicit entity relations provided by an embodiment of the present invention;
[0042] Figure 2 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 1 ;
[0043] Figure 3 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 2 ;
[0044] Figure 4 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 3 ;
[0045] Figure 5 A schematic diagram of preprocessing a sample provided by an embodiment of the present invention;
[0046] Figure 6 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 4 ;
[0047] Figure 7 A framework diagram of extracting implicit relationships using the BiLSTM-CRF neural network model provided in an embodiment of the present invention;
[0048] Figure 8 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 5 ;
[0049] Fig. 9 A schematic diagram of the structure of an entity implicit relationship extraction device provided in an embodiment of the present invention Figure 1 ;
[0050] Fig.10 A schematic diagram of the structure of an entity implicit relationship extraction device provided in an embodiment of the present invention Figure 2
[0051] Fig.11 A schematic diagram of the hardware structure of a device for extracting implicit entity relations provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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 part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] In the knowledge graph, there are often implicit relationships between entities. Implicit relationships refer to the relationship between an entity and an entity that is not directly related to it. In the prior art, entities and the relationship between entities are usually extracted first, and then the implicit relationship between the two entities is derived through relationship reasoning. For example, for the text "Zhang San works at Company A", the relationship between the entity "Zhang San" and the entity "Company A" is a working relationship; for the text "Li Si joined Company A in June 2018", the relationship between the entity "Li Si" and the entity "Company A" is a working relationship. Based on this, it is inferred that the implicit relationship between "Zhang San" and "Li Si" is a colleague relationship.
[0054] However, due to certain errors in extracting entities and the relationships between entities, the cumulative error of the implicit relationship between two entities obtained based on this is large, resulting in inaccurate results.
[0055] The present application provides a method for extracting entity implicit relations, which inputs the text to be processed into a trained neural network model and directly outputs the entity implicit relation annotation results. The entity implicit relation can be obtained without relational reasoning, thereby improving the accuracy of the obtained entity implicit relation.
[0056] Figure 1 Schematic diagram of an application scenario of the entity implicit relationship extraction method provided by an embodiment of the present invention. The entity relationship extraction method provided by this application can be applied to Figure 1In the application environment shown, the terminal 101 communicates with the server 103 through the network 102. The terminal 101 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices, and the server 103 can be implemented by an independent server or a server cluster composed of multiple servers.
[0057] For example, the embodiment of the present invention can be used for public security organs to investigate cases. The server 103 stores a large amount of multi-source heterogeneous data, most of which is case information. The terminal 101 sends an implicit relationship extraction request and case information to the server 103. After receiving the implicit relationship extraction request, the server 103 extracts the implicit relationship between entities from the case information and returns the extraction result to the terminal 101.
[0058] Figure 2 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 1 , this method is applied to Figure 1 The terminal in the embodiment can also be applied to a server. The application of this method to a server is used as an example for explanation. Figure 2 As shown, the method of this embodiment includes:
[0059] Step S201, obtain the text to be processed, and input the text to be processed into a sequence labeling model, wherein the sequence labeling model is obtained by preprocessing a sample set with entity implicit relationship labels to obtain a training sample set, and training a neural network model based on the training sample set.
[0060] In an embodiment of the present invention, the text to be processed refers to the text that needs to be annotated with entity implicit relationships. The terminal sends an entity implicit relationship extraction request to the server, and the server generates a corresponding implicit relationship extraction task based on the entity implicit relationship extraction request. The server can also generate an implicit relationship extraction task based on pre-configured information. The implicit relationship extraction task includes attribute information of the text to be processed. The attribute information of the text to be processed includes text name, text path or text link, etc. The server obtains the text to be processed based on the text name or text path, and the server can also crawl the corresponding text to be processed on the network based on the text link, or the terminal can send the text to be processed to the server. The format of the acquired text to be processed includes but is not limited to data in one or more formats of TXT text, word text, and PDF text.
[0061] In the embodiment of the present invention, an implicit relationship refers to a relationship between an entity and an entity that is not directly associated with it. For example, if entity A has a relationship with entity B, and entity B has a relationship with entity C, then entity A has an implicit relationship with entity C. For another example, for the text "Zhang San works at Company A", the entity "Zhang San" and the entity "Company A" are in a working relationship, and for the text "Li Si works at Company A", the entity "Li Si" and the entity "Company A" are also in a working relationship, then the implicit relationship between "Zhang San" and "Li Si" is a colleague relationship.
[0062] The sequence labeling model can label entities with implicit relationships in the processed text. The sequence labeling model is obtained by the following steps: obtaining a sample set with entity implicit relationship labels, preprocessing the sample set to obtain a training sample set, and training the neural network model according to the training sample set to obtain the sequence labeling model. Among them, the terminal sends the sample set with entity implicit relationship labels to the server; or the terminal sends the sample name or sample path of the sample set with entity implicit relationship labels to the server, and the server obtains the corresponding sample set from the database according to the sample name or sample path. The server converts the sample set into the data format required by the neural network model to obtain the training sample set.
[0063] The server preprocesses the text to be processed, converts the format of the text to be processed into the data format required by the sequence labeling model, and inputs the preprocessed text to be processed into the sequence labeling model, and the sequence labeling model outputs the entity implicit relationship labeling result.
[0064] Step S202, determining the entity implicit relationship of the text to be processed according to the output result of the sequence labeling model.
[0065] In the embodiment of the present invention, the output result of the sequence labeling model is the entity implicit relationship labeling result of the text to be processed, and the entity implicit relationship of the text to be processed can be determined according to the labeling result.
[0066] The embodiment of the present invention inputs the text to be processed into a sequence labeling model, and the sequence labeling model outputs the entity implicit relationship labeling results of the text to be processed. The entity implicit relationship of the text to be processed can be determined according to the labeling results. The embodiment of the present invention can directly extract the implicit relationship between entities, thereby improving the accuracy of the obtained implicit relationship, and this method is simple and convenient.
[0067] Figure 3 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 2 , in the above Figure 2 Based on the embodiment shown, the embodiment of the present invention further includes the step of obtaining a sample set with entity implicit relationship annotations, such as Figure 3 As shown, the method of the embodiment of the present invention includes:
[0068] Step S301: obtain text data and preprocess the text data to obtain a sample set to be labeled.
[0069] In an embodiment of the present invention, the terminal sends the text name, text path or text link of the text data to the server. The server can obtain the corresponding text data in the database according to the text name or text path. The server can also crawl the corresponding text data on the network according to the text link. The format of the obtained text data includes but is not limited to one or more formats of TXT text, word text, and PDF text.
[0070] The server preprocesses the text data by first removing irrelevant words, sentences, and punctuation marks, converting traditional Chinese characters into simplified Chinese characters, and then segmenting the text data according to sentences to obtain a sample set to be labeled.
[0071] Step S302: sending the sample set to be annotated to the annotation terminal, where the sample set to be annotated is used to instruct the target person to perform implicit relationship annotation on entities with implicit relationships in the sample set to be annotated.
[0072] Step S303: receiving the implicit relationship annotation result fed back by the terminal, and obtaining a sample set with entity implicit relationship annotations.
[0073] In an embodiment of the present invention, the server sends the sample set to be annotated to the annotation terminal, and the target personnel manually annotate the entities with implicit relationships in the sample set to be annotated through the annotation terminal. After the annotation is completed, the annotation terminal feeds back the sample set with the entity implicit relationship annotation to the server.
[0074] Implicit relationships can be manually annotated using the BIO annotation method, where B represents the beginning of an entity or relationship, I represents the non-beginning part of an entity or relationship, and O represents the part that is not an entity or relationship. The annotation terminal can be a visual data annotation terminal rebuilt in the form of a web page, or it can use an existing data annotation platform in the market. The annotation terminal can annotate text in TXT, word, PDF and other formats.
[0075] Below, we take the original text data as an example of the case information data of the public security agency to illustrate the BIO implicit relationship annotation. The text information of the case is as follows:
[0076] Zhang San, male, 25 years old, checked into Hotel A on April 15, 2019. He used to work at Company B, in the R&D department for two years.
[0077] Li Si, female, 32 years old, joined Company B in March 2016 and has been working in the R&D department ever since.
[0078] Zhang Li, female, 34 years old, joined Company C in April 2017 and has been working in the testing department ever since.
[0079] Perform BIO annotation on the implicit relationship of the above entities. From the above case text information, it can be clearly seen that Zhang San and Company B have a working relationship, and Li Si and Company B also have a working relationship, and then Zhang San and Li Si are colleagues. Taking the human entity annotation of named entity recognition as an example, in the prior art, all the names in the above text information are usually labeled, for example, Zhang B-person San I-person, O male O... Li B-person Si I-person, O female O... Zhang B-person Li I-person, O female O...
[0080] The embodiment of the present invention labels the implicit relationship between entities, and the new data labeling format is: Zhang B-colleague three I-colleague, O male O... Li B-colleague four I-colleague, O female O... Zhang O Li O, O female O... The new data labeling format indicates that Zhang San and Li Si are colleagues, and Zhang Li is not a colleague with Zhang San and Li Si.
[0081] In the embodiment of the present invention, text data is sent to a labeling terminal, and the target personnel manually label the implicit relationships of entities. Since the target personnel are very clear about the relationships between entities, whether explicit or implicit, the accuracy of labeling is improved.
[0082] Figure 4 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 3 , in the above Figure 2 Based on the embodiment shown, the embodiment of the present invention also includes the step of training the neural network model according to the training sample set to obtain a sequence labeling model, such as Figure 4 As shown, the method of the embodiment of the present invention includes:
[0083] Step S401, encoding the training sample set according to the pre-trained language model to obtain an encoding vector.
[0084] Step S402: Train the BiLSTM-CRF neural network model according to the encoding vector to obtain a sequence labeling model.
[0085] In an embodiment of the present invention, the pre-trained language model encodes each character in the training sample set to generate an encoding vector. The encoding vector contains context information. Specifically, the pre-trained language model can be a BERT (Bidirectional Encoder Representations from Transformers) language model. The server uses the first layer of Transformer of the BERT language model to encode each character of the marked text, and transfers the character encoding vector of the first layer to the second layer of Transformer, which continues to encode until the last layer of Transformer completes the encoding to obtain the final encoding vector of the character, also called the character encoding vector. During the encoding process, the BERT language model can encode characters using the model parameters of each layer of Transformer, making full use of the model parameters of each layer of Transformer of the BERT language model, which can effectively improve the performance of entity implicit relationship extraction, and can learn relevant features at the sentence level.
[0086] In the embodiment of the present invention, before the BERT language model encodes the sample set, it is necessary to pre-process the sample set to obtain a training sample set. Specifically, Figure 5 As shown in the figure, first, add the [CLS] tag to the beginning of each sentence in the sample set, add the [SEP] tag to the end of the sentence, and use the [SEP] tag to connect the sentence pairs to convert the sample set into the format required by the BERT model. Then, perform token embeddings processing, segment embeddings processing, and position embeddings processing on the labeled sentences to obtain the training sample set.
[0087] The training sample set is trained using the BERT language model to obtain the encoding vector, which is then input into the BiLSTM-CRF neural network model to learn its features and obtain a sequence labeling model.
[0088] The present invention implements the method of enhancing the semantic information of characters through a pre-trained language model, obtaining a coding vector through the pre-trained language model, and inputting the coding vector into a BiLSTM-CRF neural network model for training, requiring a small computer memory and having a short model training cycle.
[0089] Figure 6 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 4 , in the above Figure 2 Based on the embodiment shown, the embodiment of the present invention describes in detail a possible implementation of step S202, such as Figure 6 As shown, the method of the embodiment of the present invention includes:
[0090] Step S601, determining target entities with the same annotation label according to the output result of the sequence annotation model.
[0091] Step S602: determining the implicit relationship between target entities according to the implicit relationship corresponding to the annotated tags.
[0092] In the embodiment of the present invention, entities with the same annotated label have an implicit relationship corresponding to the label.
[0093] For example, Figure 7 The framework diagram of the BiLSTM-CRF neural network model for extracting implicit relationships provided by the embodiment of the present invention is as follows: Figure 7 As shown, the text to be processed contains 5 words w0w1w2w3w4w5. The BiLSTM-CRF model is used to extract entity implicit relationships of the text to be processed. According to the extraction results, it can be determined that the labels of [w0, w1] and [w3, w4] are both "college". Therefore, it can be determined that the implicit relationship between [w0, w1] and [w3, w4] is the implicit relationship corresponding to the label "college". For example, the label "college" corresponds to a colleague relationship, and the implicit relationship between [w0, w1] and [w3, w4] is a colleague relationship.
[0094] Figure 8 Implementation process of the entity implicit relationship extraction method provided by the embodiment of the present invention Figure 5 , in the above Figure 4 Based on the embodiment shown, the implementation method of step S402 is described in detail in the embodiment of the present invention. Figure 8 As shown, the method of the embodiment of the present invention includes:
[0095] Step S801, training the BiLSTM-CRF neural network model according to the encoding vector to obtain a target sequence labeling model.
[0096] Step S802: Acquire a test sample set.
[0097] Step S803: testing the target sequence labeling model according to the test sample set.
[0098] Step S804: If the accuracy of the output result of the target sequence model is greater than a preset threshold, the target sequence labeling model is determined as the sequence labeling model.
[0099] In an embodiment of the present invention, the terminal sends attribute information of the test sample set to the server, and the attribute information of the test sample set includes the test sample set name, the test sample set path or the test sample set link, etc. The server can obtain the corresponding test sample set in the database according to the test sample set identifier. The server can also crawl the corresponding test sample set on the network according to the text link.
[0100] After the server obtains the test sample set, the server inputs the test sample set into the target sequence labeling model for testing, and sends the output results of the target sequence labeling model and the test sample set to the terminal. The target personnel determines the accuracy of the entity implicit relationship extracted by the target sequence labeling model based on the output results of the target sequence labeling model and the test sample set. Only when the accuracy is greater than the preset threshold, the target sequence labeling model is used as the sequence labeling model.
[0101] The embodiment of the present invention improves the accuracy of extracting implicit relationships of entities by testing the target sequence labeling model.
[0102] As an embodiment of the present invention, in the above Figure 2 Based on the embodiment, the method of the embodiment of the present invention may further include: constructing a knowledge graph based on the entity implicit relationship extraction results and the graph database.
[0103] In an embodiment of the present invention, the existing knowledge graph only includes entities and explicit relationships between entities. The embodiment of the present invention completes the knowledge graph and adds implicit relationships between entities into the knowledge graph, so that the knowledge graph can more comprehensively reflect entities and the relationships between entities.
[0104] Fig. 9 A schematic diagram of the structure of an entity implicit relationship extraction device provided in an embodiment of the present invention Figure 1 .like Fig. 9 As shown, the entity implicit relationship extraction device 900 includes: an input module 901 and a determination module 902.
[0105] The input module 901 is used to obtain the text to be processed and input the text to be processed into the sequence labeling model. The sequence labeling model is obtained by preprocessing the sample set with entity implicit relationship annotations to obtain a training sample set, and training the neural network model according to the training sample set.
[0106] The determination module 902 is used to determine the entity implicit relationship of the text to be processed according to the output result of the sequence labeling model.
[0107] Fig.10 A schematic diagram of the structure of an entity implicit relationship extraction device provided in an embodiment of the present invention Figure 2 .like Fig.10As shown, the entity implicit relationship extraction device 900 further includes: a model training module 903 and a construction module 904. The model training module 903 includes an acquisition submodule 9031, a preprocessing submodule 9032, a training submodule 9033 and a testing submodule 9034.
[0108] As an embodiment of the present invention, the acquisition submodule 9031 is used to acquire text data and preprocess the text data to obtain a sample set to be labeled; the sample set to be labeled is sent to the labeling terminal, and the sample set to be labeled is used to instruct the target personnel to perform implicit relationship labeling on entities with implicit relationships in the sample set to be labeled; the implicit relationship labeling results fed back by the labeling terminal are received to obtain a sample set with entity implicit relationship labeling.
[0109] As an embodiment of the present invention, the training submodule 9033 is used to encode the training sample set according to the pre-trained language model to obtain the encoding vector; and train the BiLSTM-CRF neural network model according to the encoding vector to obtain the sequence labeling model.
[0110] As an embodiment of the present invention, the pre-trained language model is BERT language. The pre-processing submodule 9032 is used to add a [CLS] tag to the beginning of each sentence in the sample set, add a [SEP] tag to the end of the sentence, and connect sentence pairs with the [SEP] tag; perform word embedding processing, sentence embedding processing, and position embedding processing on the sentences after adding the tags.
[0111] As an embodiment of the present invention, the determination module 902 is specifically configured to determine target entities having the same labeled labels according to the output results of the sequence labeling model; and determine the implicit relationship between the target entities according to the implicit relationship corresponding to the labeled labels.
[0112] As an embodiment of the present invention, the training submodule 9033 is used to train the neural network model according to the training sample set to obtain the target sequence labeling model. The testing submodule 9034 is used to obtain the test sample set; test the target sequence labeling model according to the test sample set; if the accuracy of the output result of the target sequence model is greater than the preset threshold, the target sequence labeling model is determined as the sequence labeling model.
[0113] As an embodiment of the present invention, the construction module 904 is used to construct a knowledge graph based on the entity implicit relationship extraction results and the graph database.
[0114] The entity implicit relationship extraction device provided in the embodiment of the present invention can be used to execute the above-mentioned method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be repeated here.
[0115] Fig.11Schematic diagram of the hardware structure of the entity implicit relationship extraction device provided by the embodiment of the present invention. Fig.11 As shown, the entity implicit relationship extraction device 1100 provided in this embodiment includes: at least one processor 1101 and a memory 1102. The entity implicit relationship extraction device 1100 also includes a communication component 1103. The processor 1101, the memory 1102 and the communication component 1103 are connected via a bus 1104.
[0116] In the specific implementation process, at least one processor 1101 executes the computer execution instructions stored in the memory 1102, so that at least one processor 1101 executes the entity implicit relationship extraction method as executed by the entity implicit relationship extraction device 1100.
[0117] The specific implementation process of the processor 1101 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0118] In the above Fig.11 In the illustrated embodiment, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0119] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk storage.
[0120] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0121] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the entity implicit relationship extraction method performed by the entity implicit relationship extraction device as above is implemented.
[0122] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, an entity implicit relationship extraction method such as that performed by an entity implicit relationship extraction device is implemented.
[0123] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0124] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0125] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0126] 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 implicit relations of entities, characterized in that: include: Acquire a text to be processed, convert the format of the text to be processed into a data format required by a sequence labeling model, and input the text to be processed after the format conversion into the sequence labeling model; Determine a target entity having the same annotation label according to an output result of the sequence annotation model; Determining the implicit relationship between the target entities according to the implicit relationship corresponding to the annotated tags; The sequence labeling model is obtained by preprocessing a sample set with entity implicit relationship labels to obtain a training sample set, and training a neural network model according to the training sample set; The step of obtaining a sample set with entity implicit relationship annotations is also included, as follows: Acquire text data, and preprocess the text data to obtain a sample set to be labeled; Sending the sample set to be labeled to a labeling terminal, wherein the sample set to be labeled is used to instruct a target person to label entities with implicit relationships in the sample set to be labeled with implicit relationships; The implicit relationship annotation result fed back by the annotation terminal is received to obtain a sample set with entity implicit relationship annotations.
2. The method according to claim 1, characterized in that The step of training the neural network model according to the training sample set to obtain a sequence labeling model is as follows: Encoding the training sample set according to the pre-trained language model to obtain an encoding vector; According to the encoding vector The neural network model is trained to obtain a sequence labeling model.
3. The method according to claim 2, characterized in that The pre-trained language model is BERT language; The step of preprocessing the sample set is also included, as follows: Add a [CLS] tag to the beginning of each sentence in the sample set, add a [SEP] tag to the end of the sentence, and connect sentence pairs with the [SEP] tag; The labeled sentences are processed by word embedding, sentence embedding and position embedding respectively.
4. The method according to claim 2, characterized in that: The BiLSTM-CRF neural network model is trained according to the encoding vector to obtain a sequence labeling model, including: The BiLSTM-CRF neural network model is trained according to the encoding vector to obtain a target sequence labeling model; Get a test sample set; Testing the target sequence labeling model according to the test sample set; If the accuracy of the output result of the target sequence labeling model is greater than a preset threshold, the target sequence labeling model is determined as the sequence labeling model.
5. The method according to any one of claims 1 to 4, characterized in that: Also includes: Construct a knowledge graph based on the entity implicit relationship extraction results and graph database.
6. A device for extracting implicit relations of entities, characterized in that: include: An input module, used to obtain a text to be processed, convert the format of the text to be processed into a data format required by a sequence labeling model, and input the converted text to be processed into the sequence labeling model; A determination module, used for determining the entity implicit relationship of the text to be processed according to the output result of the sequence labeling model; The sequence labeling model is obtained by preprocessing a sample set with entity implicit relationship labels to obtain a training sample set, and training a neural network model according to the training sample set; The determination module is specifically used to determine the target entity with the same annotation label according to the output result of the sequence annotation model; Determining the implicit relationship between the target entities according to the implicit relationship corresponding to the annotated tags; The entity implicit relationship extraction device also includes: a model training module; The model training module includes an acquisition submodule; The acquisition submodule is used to acquire text data and preprocess the text data to obtain a sample set to be labeled; send the sample set to be labeled to a labeling terminal, and the sample set to be labeled is used to instruct a target person to perform implicit relationship labeling on entities with implicit relationships in the sample set to be labeled; receive the implicit relationship labeling results fed back by the labeling terminal, and obtain a sample set with entity implicit relationship labels.
7. An entity implicit relationship extraction device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the entity implicit relationship extraction method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the processor executes the computer-executable instructions, the entity implicit relationship extraction method as described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Relation extraction and knowledge graph construction method based on deep learning model
CN110598000A
Relationship extraction method and device and storage medium
CN110852107A