An entity relation extraction method and device based on ontology knowledge enhancement

By constructing an ontology knowledge base and dynamically building prompt templates, the problem of insufficient ontology knowledge mining in existing technologies is solved, achieving efficient and accurate entity relationship extraction and reducing computational and human resource costs.

CN116757205BActive Publication Date: 2025-12-23ZHEJIANG UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310059359.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-16
Publication Date
2025-12-23
Estimated Expiration
2043-01-16

AI Technical Summary

Technical Problem

Existing entity relation extraction methods rely on downstream fine-tuning of pre-trained language models, lack in-depth mining of ontology knowledge, and manually constructing ontology relation hint templates is costly and inefficient.

Method used

An ontology knowledge base is constructed, relevant ontology knowledge is obtained through text similarity retrieval, ontology knowledge prompt templates are dynamically constructed, and entity relations are extracted by injecting the text to be extracted, using generative or classification methods.

Benefits of technology

It improves the accuracy of entity relationship extraction, reduces computational costs and manpower consumption, and enhances the relevance of extraction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116757205B_ABST
    Figure CN116757205B_ABST
Patent Text Reader

Abstract

The application discloses an entity relation extraction method and device based on ontology knowledge enhancement, comprising the following steps: obtaining text corpus and ontology information of a sample, and constructing an ontology knowledge base; for a text to be extracted, searching for ontology knowledge related to the text to be extracted in the ontology knowledge base through a search method, and constructing an ontology knowledge prompt template based on the ontology knowledge; injecting the ontology knowledge prompt template into the text to be extracted to realize ontology knowledge enhancement, and performing entity relation extraction on the text to be extracted after the ontology knowledge enhancement to obtain an extraction result. Through the method, the ontology knowledge can be searched and enhanced for different entity relation extractions in a plug-in manner, so that the accuracy of the entity relation extraction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of entity relation extraction based on natural language processing, and particularly relates to an entity relation extraction method and device based on ontology knowledge retrieval enhancement. BACKGROUND

[0002] The information extraction task is an important task in many natural language processing tasks, and the entity relation extraction task is an important subtask of the information extraction task. The entity relation extraction task refers to extracting a head entity, a tail entity and a relation between the entities from a given text.

[0003] Most existing entity relation extraction methods are based on pre-training language models, and are implemented through fine-tuning training of downstream tasks. This is a common paradigm for completing many tasks in natural language processing in recent years. However, this paradigm also has several problems when completing entity relation extraction:

[0004] Problem 1: For the entity relation extraction task, the extraction result is closely related to the ontology of the task, that is, the relation type to be extracted needs to be defined in advance, and the final extraction can be completed. The common research in the industry or academia is focused on how to improve the model method to better complete the entity relation extraction task, and lacks deep mining of ontology knowledge.

[0005] Problem 2: Although some methods of other information extraction use ontology knowledge, they are all through natural language processing prompt learning technology, and artificially construct prompt templates of ontology relation types to limit the generation output. For example, the documents DEGREE: A Data-Efficient Generation-Based Event Extraction Model and Document-Level Event Argument Extraction by Conditional Generation all construct artificial prompt templates according to different event types. Artificially constructing prompt templates requires a large amount of manpower, and each sample needs to traverse and splice all kinds of relation templates, which doubles the overall operation cost. In addition, the brute-force traversal and splicing of prompt templates cannot efficiently mine the enhancement of ontology knowledge on the entity relation extraction task. SUMMARY

[0006] In view of the above, the purpose of the present application is to provide an entity relation extraction method and device based on ontology knowledge enhancement, which can dynamically and effectively utilize ontology knowledge to realize entity relation extraction on the basis of constructing an ontology knowledge base, and improve the accuracy of entity relation extraction.

[0007] To achieve the above-mentioned purposes, the embodiment provides an entity relation extraction method based on ontology knowledge enhancement, comprising the following steps:

[0008] Obtaining text corpus and ontology information of samples, and constructing an ontology knowledge base;

[0009] For the text to be extracted, the ontology knowledge related to the text to be extracted is retrieved in the ontology knowledge base by retrieval, and an ontology knowledge prompt template is constructed based on the ontology knowledge.

[0010] The ontology knowledge prompt template is injected into the text to be extracted to realize ontology knowledge enhancement, and entity relation extraction is performed on the ontology knowledge enhanced text to be extracted to obtain an extraction result.

[0011] Preferably, the obtaining of the text corpus and the ontology information of the samples, and the construction of the ontology knowledge base, comprises:

[0012] In the ontology knowledge base, the text corpus and the corresponding ontology information of each sample are stored in the form of key-value pairs, wherein the key corresponds to the text corpus of each sample, and the value corresponds to the ontology information of each sample, and the ontology information includes entities and / or relations.

[0013] Preferably, the retrieving of the ontology knowledge related to the text to be extracted in the ontology knowledge base by retrieval comprises:

[0014] The retrieval is performed by text similarity, similarity calculation is performed between the text to be extracted and the text corpus of each sample in the ontology knowledge base, and the ontology knowledge corresponding to the top K text corpora with high similarity is selected for the construction of the ontology knowledge prompt template.

[0015] Preferably, the construction of the ontology knowledge prompt template based on the ontology knowledge comprises: constructing the ontology knowledge prompt template by using the prompt technology in natural language processing.

[0016] The injection of the ontology knowledge prompt template into the text to be extracted to realize ontology knowledge enhancement comprises: splicing the ontology knowledge prompt template with the text to be extracted to realize ontology knowledge enhancement.

[0017] Preferably, the entity relation extraction on the ontology knowledge enhanced text to be extracted to obtain an extraction result comprises:

[0018] An entity relation extraction is performed by using a generative method, and the text knowledge enhanced text to be extracted is taken as an input of the generative method to perform entity relation extraction to obtain an extraction result.

[0019] Preferably, the entity relation extraction on the ontology knowledge enhanced text to be extracted to obtain an extraction result comprises:

[0020] The entity relation extraction is performed by using a classification method, and the text knowledge enhanced text to be extracted is coded, in the coding process, the ontology knowledge prompt template is masked by using a masking method, and the coding vector of the masked text to be extracted is used as the input of the classification method to perform entity relation extraction to obtain an extraction result.

[0021] To achieve the above-mentioned purposes, the embodiment further provides an entity relation extraction device based on ontology knowledge enhancement, comprising an ontology knowledge base construction module, a prompt template construction module, an extraction module,

[0022] The ontology knowledge base construction module is used for acquiring text corpus and ontology information of samples, and constructing an ontology knowledge base;

[0023] The prompt template construction module is used for acquiring ontology knowledge related to the text to be extracted in the ontology knowledge base by searching, and constructing an ontology knowledge prompt template based on the ontology knowledge;

[0024] The extraction module is used for injecting the ontology knowledge prompt template into the text to be extracted to realize ontology knowledge enhancement, and performing entity relation extraction on the ontology knowledge enhanced text to be extracted to obtain an extraction result.

[0025] To achieve the above-mentioned purposes, the embodiment further provides a computing device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor realizes the above-mentioned entity relation extraction method based on ontology knowledge enhancement when executing the computer program.

[0026] To achieve the above-mentioned purposes, the embodiment further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the above-mentioned entity relation extraction method based on ontology knowledge enhancement.

[0027] Compared with the prior art, the present application has at least the following beneficial effects:

[0028] The ontology knowledge base for text knowledge retrieval is constructed based on the dataset of the entity relation extraction task, and based on the ontology knowledge base, the related ontology knowledge is dynamically searched for each text to be extracted by searching, and the prompt template is constructed, so that each text to be extracted can be injected with the most relevant ontology knowledge for ontology knowledge enhancement, and then the entity relation extraction is performed based on the text to be extracted with the injected ontology knowledge, so as to improve the accuracy of the extraction result. BRIEF DESCRIPTION OF DRAWINGS

[0029] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description only constitute some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

[0030] Figure 1 is a flow chart of the entity relation extraction method based on ontology knowledge enhancement provided by the embodiment;

[0031] Figure 2 is an example flow chart of the entity relation extraction method based on ontology knowledge enhancement provided by the embodiment;

[0032] Figure 3 is a structural schematic diagram of the entity relation extraction device based on ontology knowledge enhancement provided by the embodiment. DETAILED DESCRIPTION

[0033] In order to make the objects, technical solutions and advantages of the present application more clear, the following will further describe the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, and do not limit the protection scope of the present application.

[0034] Figure 1 is a flow chart of the entity relation extraction method based on ontology knowledge enhancement provided by the embodiment; Figure 2 is an example flow chart of the entity relation extraction method based on ontology knowledge enhancement provided by the embodiment; as Figure 1 and Figure 2 The entity relation extraction method based on ontology knowledge enhancement provided by the embodiment includes the following steps:

[0035] Step 1, obtaining the text corpus and ontology information of the sample, and constructing an ontology knowledge base.

[0036] In the embodiment, the text corpus of the sample comes from the data set of the entity relation extraction task, and the text corpus refers to the text content in the data set. The text information refers to the entity type, relation type and other contents contained in the label. The ontology knowledge base constructed based on the text corpus and the ontology information is a knowledge base stored in the form of key-value pair, as shown in Figure 2 The key corresponds to the text corpus of each sample, and the value corresponds to the ontology information of each sample.

[0037] Step 2, for the text to be extracted, the ontology knowledge related to the text to be extracted is obtained by searching in the ontology knowledge base, and the ontology knowledge prompt template is constructed based on the ontology knowledge.

[0038] In the embodiment, for each sample to be extracted, retrieval is performed by text similarity, specifically by using the open-source retrieval tool Elasticsearch to calculate the similarity between the sample to be extracted and the text corpus in the ontology knowledge base, and the ontology knowledge corresponding to the top K text corpus with high similarity is screened as the most relevant ontology knowledge of the sample to be extracted.

[0039] For example, in Figure 2 It can be seen that, for the sample to be extracted (input text) "Paul Allen, a co-founder of Microsoft, paid the bills for aircraft designer Burt Rutan to develop Space Ship One.", the top k samples with the highest similarity are obtained in the ontology knowledge base by similarity retrieval, Figure 2 In the example, the sample with the highest similarity is taken as an example, that is, the text corpus sentence "... to space through his company, Virgin Galactic..." is retrieved.

[0040] After obtaining the top k samples with the highest similarity, the ontology information corresponding to each sample is obtained, that is, the relationship type and entity type of the sample, and the like. For example, the text corpus sentence "... to space through his company, Virgin Galactic..." corresponds to the relationship type "Company", and the types of the head and tail entities corresponding to the relationship type are "Person" and "Organization".

[0041] After retrieving the relevant ontology knowledge, the ontology knowledge retrieved is constructed into an ontology knowledge prompt template by using the prompting technology in natural language processing. For example, the ontology knowledge retrieved above is constructed into the template Person Company Organization "... to space through his company, Virgin Galactic...".

[0042] Step 3: Injecting the ontology knowledge prompt template into the text to be extracted to realize ontology knowledge enhancement, and performing entity relationship extraction on the ontology knowledge enhanced text to be extracted to obtain an extraction result.

[0043] In the embodiment, the ontology knowledge prompt template is spliced with the text to be extracted to inject the ontology knowledge prompt template into the text to be extracted to realize ontology knowledge enhancement. Then, entity relation extraction is performed on the text to be extracted after ontology knowledge enhancement to obtain an extraction result. The entity relation extraction can be performed in a generative manner and a classification manner.

[0044] For entity relation extraction in the generative manner, the text to be extracted after knowledge enhancement is input into a generative method, for example, a method based on a pre-trained language model, such as a Bart model. The pre-trained language model is used for entity relation extraction to obtain an extraction result.

[0045] For entity relation extraction in the classification manner, the text to be extracted after knowledge enhancement is encoded. In the encoding process, the ontology knowledge prompt template is masked by a mask method. The encoded vector of the text to be extracted after masking is input into a classification method. Specifically, after the text content "INPUTPrompt" obtained by splicing the extraction text INPUT and the prompt template Prompt is input into the encoder of the classification method, the Prompt is masked. Therefore, only the token in the INPUT is classified in the subsequent classification to perform entity relation extraction and obtain an extraction result.

[0046] For example, as shown in FIG. 7, the text to be extracted after ontology knowledge enhancement is input into an entity relation extraction method based on the Bart model. The final extraction result is: head entity: "Paul Allen", tail entity: "Microsoft", and relation: "Company". Figure 2

[0047] The entity relation extraction method based on ontology knowledge enhancement provided in the above embodiment constructs an ontology knowledge base for ontology knowledge retrieval for completing entity relation extraction. A prompt template is dynamically constructed for each sentence to be constructed by a retrieval method, so that each sentence can be injected with the most relevant ontology knowledge. This method can be plugged into different entity relation extraction to perform ontology knowledge retrieval enhancement. The text after ontology knowledge enhancement is used for entity relation extraction, which can improve the accuracy of entity relation extraction. Moreover, the prompt template does not need to be manually constructed, which saves labor costs. The constructed prompt template only needs the most relevant k ontology knowledge, rather than all types of ontology knowledge, which reduces the computational overhead and cost of entity relation extraction.

[0048] Based on the same inventive concept, the embodiment further provides an entity relation extraction device based on ontology knowledge enhancement, as shown in FIG. 8. Figure 3 ​As shown, the entity relationship extraction device based on ontology knowledge enhancement includes a ontology knowledge base construction module, a prompt template construction module, and an extraction module. The ontology knowledge base construction module is configured to obtain text corpus and ontology information of a sample, and construct a ontology knowledge base. The prompt template construction module is configured to, for a text to be extracted, retrieve ontology knowledge related to the text to be extracted from the ontology knowledge base by a retrieval manner, and construct an ontology knowledge prompt template based on the ontology knowledge. The extraction module is configured to inject the ontology knowledge prompt template into the text to be extracted to implement ontology knowledge enhancement, and perform entity relationship extraction on the text to be extracted with the ontology knowledge enhancement to obtain an extraction result.

[0049] It should be noted that the entity relationship extraction device based on ontology knowledge enhancement provided in the above embodiments is illustrated by division of the above functional modules, and the above functions can be completed by different functional modules according to needs, that is, the internal structure of a terminal or a server is divided into different functional modules to complete all or part of the above described functions. In addition, the entity relationship extraction device based on ontology knowledge enhancement provided in the above embodiments and the entity relationship extraction method based on ontology knowledge enhancement belong to the same concept, and the specific implementation process is detailed in the entity relationship extraction method based on ontology knowledge enhancement, which will not be described here.

[0050] The embodiment further provides a computing device including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the above entity relationship extraction method based on ontology knowledge enhancement when executing the computer program, including the following steps:

[0051] Step 1, obtaining text corpus and ontology information of a sample, and constructing a ontology knowledge base;

[0052] Step 2, for a text to be extracted, retrieving ontology knowledge related to the text to be extracted from the ontology knowledge base by a retrieval manner, and constructing an ontology knowledge prompt template based on the ontology knowledge;

[0053] Step 3, injecting the ontology knowledge prompt template into the text to be extracted to implement ontology knowledge enhancement, and performing entity relationship extraction on the text to be extracted with the ontology knowledge enhancement to obtain an extraction result.

[0054] The memory can be a volatile memory close to the terminal, such as RAM, and can also be a non-volatile memory, such as ROM, FLASH, floppy disk, mechanical hard disk, etc., and can also be a remote storage cloud. The processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA), that is, the steps of the entity relationship extraction method can be implemented by these processors.

[0055] The embodiment further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the above-mentioned entity relation extraction method based on ontology knowledge enhancement, and comprises the following steps:

[0056] Step 1, obtaining text corpus and ontology information of a sample, and constructing an ontology knowledge base;

[0057] Step 2, for the text to be extracted, obtaining the ontology knowledge related to the text to be extracted in the ontology knowledge base by searching, and constructing an ontology knowledge prompt template based on the ontology knowledge;

[0058] Step 3, injecting the ontology knowledge prompt template into the text to be extracted to realize ontology knowledge enhancement, and performing entity relation extraction on the ontology knowledge enhanced text to be extracted to obtain an extraction result.

[0059] The computer readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.

[0060] The above detailed description of the specific embodiments has described the technical solutions and beneficial effects of the present application, and it should be understood that the above description is only the most preferred embodiment of the present application, and is not used to limit the present application, and any modification, supplement and equivalent replacement, etc. within the principle range of the present application should be included in the protection range of the present application.

Claims

1. An entity relation extraction method based on ontology knowledge enhancement, characterized in that, The method comprises the following steps: Obtaining text corpus and ontology information of samples, and constructing an ontology knowledge base, comprising: storing the text corpus and corresponding ontology information of each sample in the ontology knowledge base in the form of key-value pairs, wherein the key corresponds to the text corpus of each sample, and the value corresponds to the ontology information of each sample, and the ontology information comprises entities and / or relationships; For the text to be extracted, ontology knowledge related to the text to be extracted is retrieved from the ontology knowledge base by retrieval, and an ontology knowledge prompt template is constructed based on the ontology knowledge; The ontology knowledge prompt template is injected into the text to be extracted to realize ontology knowledge enhancement, and entity relationship extraction is performed on the ontology knowledge enhanced text to be extracted to obtain an extraction result.

2. The ontology knowledge base enhanced entity relation extraction method according to claim 1, characterized in that, The ontology knowledge related to the text to be extracted is retrieved from the ontology knowledge base by retrieval, comprising: Retrieval is performed by text similarity, similarity calculation is performed on the text to be extracted and the text corpus of each sample in the ontology knowledge base, and the ontology knowledge corresponding to the top K text corpora with high similarity is selected for construction of the ontology knowledge prompt template. 3.The ontology knowledge base enhanced entity relation extraction method according to claim 1, characterized in that, The ontology knowledge prompt template is constructed based on the ontology knowledge, comprising: the retrieved ontology knowledge is used to construct the ontology knowledge prompt template by using a prompt technology in natural language processing; The ontology knowledge prompt template is injected into the text to be extracted to realize ontology knowledge enhancement, comprising: the ontology knowledge prompt template and the text to be extracted are spliced to realize ontology knowledge enhancement. 4.The ontology knowledge base enhanced entity relation extraction method according to claim 1, characterized in that, The ontology knowledge enhanced text to be extracted is subjected to entity relationship extraction to obtain an extraction result, comprising: A generative method is used for entity relationship extraction, and the text knowledge enhanced text to be extracted is used as input of the generative method to perform entity relationship extraction to obtain an extraction result. 5.The ontology knowledge base enhanced entity relation extraction method according to claim 1, characterized in that, The ontology knowledge enhanced text to be extracted is subjected to entity relationship extraction to obtain an extraction result, comprising: A classification method is used for entity relationship extraction, and the text knowledge enhanced text to be extracted is encoded, and in the encoding process, the ontology knowledge prompt template is masked by a masking method, and the encoded vector of the masked text to be extracted is used as input of the classification method to perform entity relationship extraction to obtain an extraction result.

6. An entity relation extraction device based on ontology knowledge enhancement, characterized in that, The method comprises an ontology knowledge base construction module, a prompt template construction module, and an extraction module, The ontology knowledge base construction module is used to obtain text corpus and ontology information of samples, and construct an ontology knowledge base, comprising: storing the text corpus and corresponding ontology information of each sample in the ontology knowledge base in the form of key-value pairs, wherein the key corresponds to the text corpus of each sample, and the value corresponds to the ontology information of each sample, and the ontology information comprises entities and / or relationships; The prompt template construction module is used to retrieve ontology knowledge related to the text to be extracted from the ontology knowledge base by retrieval for the text to be extracted, and construct an ontology knowledge prompt template based on the ontology knowledge; The extraction module is used to inject the ontology knowledge prompt template into the text to be extracted to realize ontology knowledge enhancement, and perform entity relationship extraction on the ontology knowledge enhanced text to be extracted to obtain an extraction result.

7. A computing device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, The computer program is executed by the processor to implement the entity relation extraction method based on ontology knowledge enhancement in any one of claims 1-5.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the entity relation extraction method based on ontology knowledge enhancement in any one of claims 1-5.

Citation Information

Patent Citations

  • Method for constructing and storing knowledge graph in network space security field

    CN111428054A