Method, apparatus, and electronic device for detecting entity relationships in a knowledge graph
By constructing inverted indexes and semantic analysis to calculate entity similarity, the problem of low accuracy of entity relationship detection in the knowledge graph is solved, and efficient and convenient entity relationship detection is achieved.
Patent Information
- Application Number
- CN202110512898.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-11
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-05-11
AI Technical Summary
The prior art has low accuracy in entity relationship detection in the knowledge graph and poor detection effect.
By obtaining the entity pairs in the knowledge graph to be detected, building an inverted index list, and semantic analysis of the entity information, calculating the similarity between the entity pairs, and determining the entity pairs with the correct link relationship.
It improves the accuracy of entity relationship detection in the knowledge graph, reduces the calculation amount and manual labeling cost, and improves detection efficiency and convenience.
Smart Images

Figure CN113761104B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, and electronic device for detecting entity relationships in a knowledge graph. Background Art
[0002] A knowledge graph describes the concepts, entities, and relationships between their keys in the objective world in a structured manner, providing a better ability to organize, manage, and understand the vast amount of information on the Internet. Error detection is one of the main research contents of knowledge graph applications, and has broad application prospects in fields such as robots, intelligent question answering, and information retrieval. Therefore, it is of great significance to conduct research on it. However, the existing solutions for error detection of knowledge graphs have a low accuracy rate and poor detection effect during the detection process. Summary of the Invention
[0003] Embodiments of this application provide a method, apparatus, electronic device, and storage medium for detecting entity relationships in a knowledge graph, which can effectively improve the accuracy of entity relationship detection in the knowledge graph.
[0004] Embodiments of this application provide a method for detecting entity relationships in a knowledge graph, including:
[0005] Obtaining at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a link relationship on a target attribute;
[0006] Inverting the entity information of the first entity in all entity pairs to obtain an inverted index list;
[0007] Performing semantic analysis on the entity information of each second entity respectively to obtain query information corresponding to each second entity;
[0008] Based on the inverted index list and the query information, calculating a first similarity between the first entity and the second entity in each entity pair;
[0009] Determining the entity pairs whose first similarity meets a first preset condition as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected.
[0010] Correspondingly, embodiments of this application further provide a device for detecting entity relationships in a knowledge graph, including:
[0011] An obtaining unit, configured to obtain at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a link relationship on a target attribute;
[0012] An inverting unit, configured to invert the entity information of the first entity in all entity pairs to obtain an inverted index list;
[0013] An analysis unit for semantically analyzing the entity information of each second entity respectively to obtain query information corresponding to each second entity;
[0014] A calculation unit for calculating a first similarity between the first entity and the second entity in each entity pair based on the inverted index list and the query information;
[0015] A determination unit for determining an entity pair whose first similarity meets a first preset condition as an entity pair with a correct link relationship in the target attribute in the to-be-detected knowledge graph.
[0016] Optionally, in some embodiments, the apparatus for detecting entity relationships in the knowledge graph may further include a candidate unit as follows:
[0017] Specifically, the candidate unit may determine the first entity in the entity pair with a correct link relationship as the target first entity, and determine other first entities linked to the same second entity as the target first entity as candidate first entities; semantically analyze the entity information of the target first entity to obtain target query information corresponding to the target first entity; calculate a second similarity between the target first entity and the candidate first entities based on the target query information and the entity information of the candidate first entities; if the second similarity meets a second preset condition, then determine the candidate first entities and the second entity linked to the target first entity as entity pairs with a correct link relationship in the target attribute in the to-be-detected knowledge graph.
[0018] Optionally, in some embodiments, the apparatus for detecting entity relationships in the knowledge graph may further include a verification unit as follows:
[0019] Specifically, when all candidate first entities are calculated, the verification unit may add all entity pairs with a correct link relationship in the target attribute in the to-be-detected knowledge graph to an entity pair set; if an entity pair with a link relationship in the target attribute is not in the entity pair set, then determine the entity pair not in the entity pair set as an entity pair with an incorrect link relationship in the target attribute in the to-be-detected knowledge graph.
[0020] Optionally, in some embodiments, the inversion unit may specifically be used to segment the entity information of the first entity in all entity pairs to obtain a first word set; remove duplicates from the first word set to obtain a deduplicated first word set; establish a mapping relationship between the entity information of each first entity and each word in the deduplicated first word set, and generate an inverted index list based on the mapping relationship.
[0021] Optionally, in some embodiments, the analysis unit may include a word segmentation subunit, an extraction subunit, and a screening subunit as follows:
[0022] The word segmentation subunit can be used to segment the entity information of each second entity respectively to obtain a second word set corresponding to each second entity;
[0023] The extraction subunit can be used to extract keywords from each of the second word sets respectively to obtain a keyword set corresponding to each second entity;
[0024] The screening subunit can be used to screen a preset number of target keywords from each keyword set and determine the screened target keywords as the query information corresponding to the corresponding second entity.
[0025] Optionally, in some embodiments, the extraction subunit can specifically be used to calculate the word frequency of each word and the inverse document frequency of each word in each of the second word sets respectively; based on the word frequency and inverse document frequency of each word in each of the second word sets, determine a keyword set corresponding to each second entity.
[0026] Optionally, in some embodiments, the analysis unit can specifically be used to segment the entity information of each second entity respectively to obtain a second word set corresponding to each second entity; remove the stop words in each of the second word sets respectively to obtain a non-stop word set corresponding to each second entity; select a preset number of non-stop words in sequence from the non-stop word set corresponding to each second entity and determine them as the query information corresponding to the corresponding second entity.
[0027] Optionally, in some embodiments, the calculation unit may include a parsing subunit, a first calculation subunit and a second calculation subunit, as follows:
[0028] The parsing subunit can be used to determine a pair of entities to be processed from the obtained entity pairs; perform morpheme parsing on the query information of the second entity in the pair of entities to be processed to obtain a morpheme set of the second entity in the pair of entities to be processed;
[0029] The first calculation subunit can be used to calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the pair of entities to be processed respectively based on the entity information of the first entity in all entity pairs;
[0030] The second calculation subunit can be used to perform weighted summation on the calculated correlations based on the inverted index list to obtain a first similarity between the first entity and the second entity in the pair of entities to be processed.
[0031] Optionally, in some embodiments, the first calculation subunit may specifically be configured to calculate the average length of the entity information of the first entity in all entity pairs based on the entity information of the first entity in all entity pairs, and determine the target length of the entity information of the first entity in the entity pair to be processed; calculate the occurrence frequency of each morpheme in the morpheme set in the entity information of the first entity in the entity pair to be processed, to obtain the occurrence frequency of each morpheme; and calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed respectively based on the average length, the target length, and the occurrence frequency of each morpheme.
[0032] Optionally, in some embodiments, the second calculation subunit may specifically be configured to determine the number of occurrences of each morpheme in the morpheme set in the entity information of the first entity in all entity pairs based on the inverted index list; determine the weight of each morpheme based on the number of occurrences of each morpheme; and perform a weighted summation on the calculated correlation using the weight of each morpheme, to obtain the first similarity between the first entity and the second entity in the entity pair to be processed.
[0033] In addition, an embodiment of the present application further provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in any of the methods for detecting entity relationships in the knowledge graph provided by the embodiments of the present application.
[0034] In addition, an embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the steps in any of the methods for detecting entity relationships in the knowledge graph provided by the embodiments of the present application are implemented.
[0035] According to one aspect of the present application, there is provided a computer program product or a computer program. The computer product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in various alternative implementations of the above-mentioned aspect of detecting entity relationships in the knowledge graph.
[0036] In this embodiment, at least one entity pair in the knowledge graph to be detected can be obtained. Each entity pair includes a first entity and a second entity that have a linking relationship on the target attribute. Then, the entity information of the first entities in all entity pairs is inverted to obtain an inverted index list. Next, semantic analysis is performed on the entity information of each second entity to obtain query information corresponding to each second entity. Then, based on the inverted index list and the query information, the first similarity between the first entity and the second entity in each entity pair is calculated. Then, the entity pairs whose first similarity meets the first preset condition are determined as the entity pairs with correct linking relationships on the target attribute in the knowledge graph to be detected. This solution can effectively improve the accuracy of entity relationship detection in the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] To more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0038] Figure 1a is a schematic diagram of the scenario of the method for detecting entity relationships in the knowledge graph provided by the embodiment of the present application;
[0039] Figure 1b is the first flowchart of the method for detecting entity relationships in the knowledge graph provided by the embodiment of the present application;
[0040] Figure 2a is the second flowchart of the method for detecting entity relationships in the knowledge graph provided by the embodiment of the present application;
[0041] Figure 2b is the third flowchart of the method for detecting entity relationships in the knowledge graph provided by the embodiment of the present application;
[0042] Figure 2c is a schematic diagram of constructing an inverted index and queries provided by the embodiment of the present application;
[0043] Figure 3 is a schematic diagram of the structure of the device for detecting entity relationships in the knowledge graph provided by the embodiment of the present application;
[0044] Figure 4 is a schematic diagram of the structure of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0046] The principle of the present application is illustrated by way of implementation in a suitable computing environment. In the following description, specific embodiments of the present application will be described with reference to steps and symbols executed by one or more computers, unless otherwise stated. Therefore, these steps and operations will be referred to as being executed by a computer several times. The computer execution referred to herein includes the operation of a computer processing unit that represents an electronic signal of data in a structured form. This operation transforms the data or maintains it in a position in the computer's memory system, which can be reconfigured or otherwise changed in a manner well known to those skilled in the art. The data structure maintained by the data is a physical location in the memory, which has specific characteristics defined by the data format. However, the principle of the present application is described in the above text, which does not represent a limitation. Those skilled in the art will understand that the following various steps and operations can also be implemented in hardware.
[0047] The term "unit" used herein can be regarded as a software object executed on the computing system. Different components, units, engines, and services herein can be regarded as implementation objects on the computing system. The apparatus and method herein can be implemented in software, and of course, can also be implemented in hardware, all within the scope of protection of the present application.
[0048] The terms "first", "second", "third", etc. in the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units. Instead, some embodiments also include steps or units not listed, or some embodiments also include other steps or units inherent to these processes, methods, products, or devices.
[0049] Referring to "embodiment" herein means that a specific feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears at various positions in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0050] Embodiments of the present application provide a method, apparatus, electronic device, and storage medium for detecting entity relationships in a knowledge graph. Among them, the apparatus for detecting entity relationships in the knowledge graph can be integrated in an electronic device, which can be a server or a terminal device, etc.
[0051] The method for detecting entity relationships in the knowledge graph provided by the embodiments of the present application relates to the field of natural language processing in the field of artificial intelligence, and can perform natural language processing through the entity information of the first entity and the entity information of the second entity, so as to realize the detection of entity relationships in the knowledge graph.
[0052] Among them, Artificial Intelligence (AI) is to use a digital computer or a machine controlled by a digital computer to simulate, extend, and expand human intelligence, and to perceive the environment, acquire knowledge, and use knowledge to obtain the best results in terms of theory, method, technology, and application system. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence is also to study the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning, and decision-making. Artificial intelligence technology is an interdisciplinary subject, involving a wide range of fields, including both hardware-level technologies and software-level technologies. Among them, artificial intelligence software technology mainly includes directions such as computer vision technology, machine learning / deep learning.
[0053] Among them, Natural Language Processing (NLP) is an important direction in the field of computer science and the field of artificial intelligence. It studies various theories and methods that can realize effective communication between humans and computers in natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, the research in this field will involve natural language, that is, the language that people use in daily life, so it has a close connection with the research of linguistics. Natural language processing technology usually includes technologies such as text processing, semantic understanding, machine translation, robot question answering, and knowledge graphs.
[0054] For example, as Figure 1aAs shown, first, the electronic device of the detection device for entity relationships in the knowledge graph can obtain at least one entity pair in the knowledge graph to be detected. Each entity pair includes a first entity and a second entity that have a link relationship on the target attribute. Then, invert the entity information of the first entity in all entity pairs to obtain an inverted index list. Next, perform semantic analysis on the entity information of each second entity to obtain the query information corresponding to each second entity. Then, based on the inverted index list and the query information, calculate the first similarity between the first entity and the second entity in each entity pair. Then, determine the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected. Since this solution constructs an inverted index using the entity information of the first entity, constructs a query using the entity information of the second entity, and calculates the first similarity between the first entity and the second entity in each entity pair through the constructed inverted index and query to detect the link relationships of entity pairs in the knowledge graph to be detected, it effectively improves the accuracy of entity relationship detection in the knowledge graph. Since this solution mainly relies on the entity information of entities for matching and can complete the detection without too many edge relationships, it effectively improves the detection efficiency and enhances the convenience of detection. And this solution does not require manual construction of features or use of neural networks for representation learning, reducing the computational amount and manual annotation cost, and can quickly and effectively detect incorrect edges.
[0055] The following will be described in detail respectively. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments.
[0056] This embodiment will be described from the perspective of the detection device for entity relationships in the knowledge graph. The detection device for entity relationships in the knowledge graph can be specifically integrated in an electronic device, which can be a server or a terminal device, etc. Among them, the terminal can include devices such as mobile phones, tablets, laptops, and personal computers (PCs).
[0057] A method for detecting entity relationships in a knowledge graph includes: obtaining at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a link relationship on the target attribute; then, inverting the entity information of the first entity in all entity pairs to obtain an inverted index list; next, performing semantic analysis on the entity information of each second entity to obtain the query information corresponding to each second entity; then, based on the inverted index list and the query information, calculating the first similarity between the first entity and the second entity in each entity pair; then, determining the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected.
[0058] As Figure 1b shown, the specific process of the method for detecting entity relationships in the knowledge graph can be as follows:
[0059] 101. Obtain at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a link relationship on the target attribute.
[0060] Among them, the knowledge graph is a structured semantic knowledge base used to describe concepts in the physical world and their interrelationships in symbolic form. Its basic unit of composition is the [entity-attribute-attribute value] triple. An entity refers to a distinguishable and independently existing thing, which can be a person, a place, an organization, a plant, a commodity, etc., such as "Liu Wu", "Beijing", etc. The edges emitted by these entities represent information related to this entity, which can be text or other entities. For example, in the graph, "Work 1" and "Author A" are both entities, and there is an edge (i.e., a link relationship, also known as a link edge relationship) between the two entities, and the name of the edge is "author".
[0061] Among them, an entity pair can refer to a pair composed of a first entity and a second entity that have a link relationship on the target attribute. Among them, an attribute can refer to an internal characteristic of a thing. The first entity can refer to an entity in the link relationship of the target attribute, and the second entity can refer to another entity in the link relationship of the target attribute. For example, the first entity can be the head entity, and the second entity can be the tail entity, or the second entity can be the head entity, and the first entity can be the tail entity. The head and tail entities can be determined based on the link relationship of the target attribute. For example, for [Work 1 - Author - Author A], Work 1 is the head entity, Author A is the tail entity, and the attribute is author; for another example, for [Author A - Work - Work 1], Author A is the head entity, Work 1 is the tail entity, and the attribute is work, and so on.
[0062] However, in the constructed knowledge graph, there may be incorrect edge relationships. For example, the author of "XX Guide" is Zhang X San, but if Zhang X San is linked to the entity [Zhang X San (XX Founder)], it is an incorrect link. As the data source for multiple services, the knowledge graph has extremely high requirements for data accuracy, and the incorrect data in the graph will affect the subsequent reasoning and the training module of the graph representation. For example, the author of "XX Guide" is Zhang X San, but if Zhang X San is linked to the entity [Zhang X San (XX Founder)], during the reasoning process, "XX Guide" will be regarded as the work of [Zhang X San (XX Founder)]. This will amplify the existing errors for cumulative errors. Therefore, it is necessary to detect the entity relationships in the knowledge graph to ensure the accuracy of the link relationships in the knowledge graph.
[0063] For example, the link relationships in the knowledge graph can be partitioned according to attributes to obtain the first entity and the second entity of the link relationships under the same attribute, as well as the entity information of the first entity and the entity information of the second entity. For example, the head entity and the tail entity of the link edge relationship under the same attribute can be obtained, as well as the entity information of the head entity and the entity information of the tail entity. Among them, the entity information can refer to the information about the entity, including but not limited to the entity profile, entity attribute information, etc.
[0064] After obtaining multiple entity pairs of the target attribute in the knowledge graph to be detected, an inverted index can be constructed for the entity information of the first entity, and then the entity information of the second entity can be used as a retrieval query (query). Alternatively, an inverted index can be constructed for the entity information of the second entity, and then the entity information of the first entity can be used to construct a retrieval query. There is no limitation here. The following takes constructing an inverted index for the entity information of the first entity and then constructing a query for the entity information of the second entity as an example for illustration.
[0065] 102. Invert the entity information of the first entity in all entity pairs to obtain an inverted index list.
[0066] Among them, the inverted index, also often referred to as the reverse index, placement file or reverse file, is an indexing method used to store the mapping of the storage location of a certain word in a document or a group of documents under full-text search. It is the most commonly used data structure in document retrieval systems. Through the inverted index, a list of documents containing this word can be quickly obtained according to the word. The inverted index mainly consists of two parts: "word dictionary" and "inverted file".
[0067] Among them, there are many ways to construct the inverted index list. For example, the document can be analyzed into word terms (words), then the words are de-duplicated using hash, and then an inverted index list is generated for the words. For example, specifically, the entity information of the first entity in all entity pairs can be tokenized to obtain a first word set; the first word set is de-duplicated to obtain a de-duplicated first word set; a mapping relationship is established between the entity information of each first entity and each word in the de-duplicated first word set, and an inverted index list is generated based on the mapping relationship.
[0068] For example, the entity information of each first entity in the obtained entity pairs can be used as a document to be retrieved to construct an inverted index. First, a word segmentation system is used to automatically segment the document into a sequence of words, and each document is converted into a data stream composed of a sequence of words. For the convenience of subsequent processing of the system, it is necessary to assign a unique word number to each different word, and at the same time record which documents contain this word. After such processing, the simplest inverted index list can be obtained. For example, the inverted index list can include three columns. The first column can record the word number (Identity document, ID) of each word, the second column is the corresponding word, and the third column is the inverted list corresponding to each word. For example, there are 5 documents to be retrieved, and the word "project". The word number in the first column is 1, the word in the second column is "project", and the inverted list in the third column is {1, 2, 3, 4, 5}, indicating that each document in the document set contains this word.
[0069] Optionally, in addition to constructing a basic inverted index, an inverted index with word frequency information can also be constructed. For example, in the inverted list corresponding to a word, not only the document number is recorded, but also the word frequency information (term frequency, TF), that is, the number of times this word appears in a certain document. Since the word frequency information is an important calculation factor for calculating the similarity between the query and the document during the sorting of search results, it is recorded in the inverted list to facilitate the score calculation during subsequent sorting.
[0070] To construct the rationality of the inversion, for example, the entity attribute information can be used to construct the text of the entity information in the way of triple splicing. For example, [Work 1 - Author - Author A] is spliced into "Work 1 Author Author A" to obtain the constructed triple text, which is used as a supplement to the entity profile and spliced behind the profile to jointly form the entity information of the entity with the entity profile. For example, specifically, the entity description information and entity attribute information of the first entity can be obtained; the entity attribute information is spliced to obtain the spliced attribute information; the spliced attribute information is added to the entity description information to obtain the entity information of the first entity.
[0071] 103. Semantic analysis is performed on the entity information of each second entity respectively to obtain the query information corresponding to each second entity.
[0072] Among them, there are many ways to construct query information (i.e., construct a query). For example, specifically, the entity information of each second entity can be tokenized respectively to obtain a second word set corresponding to each second entity; keyword extraction can be performed on each second word set respectively to obtain a keyword set corresponding to each second entity; a preset number of target keywords are screened out from each keyword set, and the screened-out target keywords are determined as the query information corresponding to the corresponding second entity. Among them, the corresponding second entity refers to the second entity corresponding to the keyword set to which the screened-out target keyword belongs.
[0073] Among them, there are many ways to set the preset number. For example, it can be flexibly set according to the needs of actual applications, or it can be preset and stored in an electronic device. In addition, the preset number can be built into the electronic device, or it can be stored in a memory and sent to the electronic device, etc. For example, the preset number can be set to 50.
[0074] Among them, there are many ways to perform keyword extraction on each second word set. For example, for the step of "performing keyword extraction on each second word set respectively to obtain a keyword set corresponding to each second entity", specifically, the word frequency of each word in each second word set and the inverse document frequency of each word can be calculated respectively; based on the word frequency and inverse document frequency of each word in each second word set, a keyword set corresponding to each second entity is determined. Among them, the inverse document frequency (IDF) is also called the anti-document frequency and is the reciprocal of the document frequency, which is mainly used in the concept of TF-IDF (term frequency–inverse document frequency).
[0075] For example, to construct query information for each second entity, the following steps can be executed: determine the second entity to be processed from the obtained second entities; tokenize the entity information of the second entity to be processed to obtain a second word set corresponding to the second entity to be processed; perform keyword extraction on the second word set to obtain a keyword set corresponding to the second entity to be processed; screen out a preset number of target keywords from the keyword set, and determine the screened-out target keywords as the query information corresponding to the second entity to be processed. Among them, the second entity to be processed can be one or more, that is, query information can be constructed for each second entity in sequence, or query information can be constructed for multiple second entities simultaneously.
[0076] Among them, there are many ways to extract keywords from the second word set. For example, for the step "extracting keywords from the second word set to obtain the keyword set corresponding to the second entity to be processed", specifically, the word frequency of each word in the second word set and the inverse document frequency of each word can be calculated; based on the word frequency and the inverse document frequency, the keyword set corresponding to the second entity to be processed is determined. For example, the term frequency–inverse document frequency (TF-IDF) method can be used for keyword extraction. TF-IDF is a statistical method used to evaluate the importance of a word for a document set or a single document in a corpus. The importance of a word increases in direct proportion to the number of times it appears in the document, but at the same time decreases in inverse proportion to the frequency of its appearance in the corpus. TF (term frequency) can refer to the frequency of a term (keyword) in the text, such as the number of times the word appears in the text. The specific calculation formula can be as follows:
[0077]
[0078] where n i,j is the number of times the word appears in document d j and the denominator is the total number of times all words appear in document d j . That is
[0079]
[0080] IDF (inverse document frequency) can refer to the inverse document frequency of a certain word, which can be obtained by dividing the total number of documents by the number of documents containing the word and then taking the logarithm of the resulting quotient. If the number of documents containing the term t is smaller, the IDF is larger, indicating that the term has good category discrimination ability. The specific calculation formula can be as follows:
[0081]
[0082] where |D| is the total number of documents in the corpus. |{j:t i ∈d j}| represents the number of documents containing the word t i (i.e., the number of documents where n i,j ≠0). If the word is not in the corpus, it will cause the denominator to be zero. Therefore, generally, 1 + |{j:t i ∈d j}| is used, that is:
[0083]
[0084] Then TF-IDF is actually: TF * IDF, which refers to the high term frequency in a specific document and the low document frequency of the term in the entire document collection, and can produce a high-weight TF-IDF. Therefore, TF-IDF tends to filter out common terms and retain important terms. That is:
[0085] TF-IDF = TF * IDF
[0086] For another example, the way to construct query information can specifically be: perform word segmentation on the entity information of each second entity to obtain a second word set corresponding to each second entity; remove the stop words in each second word set to obtain a non-stop word set corresponding to each second entity; select a preset number of non-stop words in sequence from the non-stop word set corresponding to each second entity, and determine them as the query information corresponding to the respective second entity.
[0087] For example, constructing query information for each second entity can perform the following steps: determine the second entity to be processed from the obtained second entities; perform word segmentation on the entity information of the second entity to be processed to obtain a second word set corresponding to the second entity to be processed; remove the stop words in the second word set to obtain a non-stop word set corresponding to the second entity to be processed; select a preset number of non-stop words in sequence from the non-stop word set corresponding to the second entity to be processed, and determine them as the query information corresponding to the second entity to be processed.
[0088] Among them, stop words refer to in information retrieval, to save storage space and improve search efficiency, certain words or terms will be automatically filtered out before or after processing natural language data (or text), and these words or terms are called Stop Words (stop words). These stop words are all manually input and not automatically generated, and a stop word list will be formed after generation. However, there is no clear stop word list that can be applied to all tools. Even some tools explicitly avoid using stop words to support phrase search.
[0089] 104. Based on the inverted index list and the query information, calculate the first similarity between the first entity and the second entity in each entity pair.
[0090] For example, for each entity pair, the following operations can be performed: determine the entity pair to be processed from the obtained entity pairs; perform morpheme analysis on the query information of the second entity in the entity pair to be processed to obtain the morpheme set of the second entity in the entity pair to be processed; calculate the relevance between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed respectively based on the entity information of the first entity in all entity pairs; perform weighted summation on the calculated relevance based on the inverted index list to obtain the first similarity between the first entity and the second entity in the entity pair to be processed. Among them, the entity pair to be processed can be one or multiple, that is, the calculation can be performed on each entity pair in sequence, or multiple entity pairs can be calculated simultaneously, and so on.
[0091] Among them, a morpheme refers to the smallest phonetic-semantic combination in a language. That is to say, a language unit must meet three conditions at the same time - "the smallest, having a sound, and having a meaning" to be called a morpheme, especially "the smallest" and "having a meaning". Monosyllabic language units can be directly judged using the definition of morphemes. For disyllabic and polysyllabic language units, the substitution method can be used, that is, using known morphemes to substitute the language units whose morpheme status needs to be determined. Whether a morpheme can form words or not can be combined with other morphemes to form words. A morpheme is not an independent language unit, and its main function is to be used as the material for forming words. Saying that it is a phonetic-semantic combination and a meaningful language unit is to distinguish it from syllables. Some syllables have only sounds and no meanings and cannot be regarded as morphemes, such as "li" and "hun". Saying that it is the smallest meaningful language unit and does not belong to an independent language unit is to distinguish it from words.
[0092] For example, perform morpheme analysis on the Query to generate the morpheme qi; then, for the entity information of each first entity (i.e., each document to be retrieved) D, calculate the relevance score between each morpheme qi and D, and finally, perform weighted summation on the relevance scores of qi with respect to D to obtain the relevance score between the Query and D. The specific calculation formula can be as follows:
[0093]
[0094] Among them, Q represents the Query, qi represents a morpheme after Q is parsed (for Chinese, the word segmentation of the Query can be regarded as morpheme analysis, and each word is regarded as a morpheme qi); d represents a document to be retrieved; Wi represents the weight of the morpheme qi; R(qi, d) represents the relevance score between the morpheme qi and the document to be retrieved d.
[0095] Among them, there are many ways to calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed. For example, specifically, based on the entity information of the first entity in all entity pairs, the average length of the entity information of the first entity in all entity pairs can be calculated, and the target length of the entity information of the first entity in the entity pair to be processed can be determined; calculate the occurrence frequency of each morpheme in the morpheme set in the entity information of the first entity in the entity pair to be processed, and obtain the occurrence frequency of each morpheme; based on the average length, target length, and the occurrence frequency of each morpheme, calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed respectively.
[0096] For example, the specific calculation formula for the correlation score R(qi, d) between the morpheme qi and the document d to be retrieved can be as follows:
[0097]
[0098] Among them, k1, k2, and b are adjustment factors, usually set according to experience. For example, k1 = 2 and b = 0.75 can be set; fi is the occurrence frequency of qi in d, and qfi is the occurrence frequency of qi in the Query. dl is the length of the document d, and avgdl is the average length of all documents to be retrieved. Since in most cases, qi will only appear once in the Query, that is, qfi = 1, therefore, the formula can be simplified to:
[0099]
[0100] From the definition of K, it can be seen that the role of the parameter b is to adjust the magnitude of the influence of the length of the document to be retrieved on the correlation. The larger b is, the greater the influence of the length of the document to be retrieved on the correlation score, and vice versa. And the longer the relative length of the document to be retrieved, the larger the value of K, and the smaller the correlation score will be. Therefore, it can be understood that when the document to be retrieved is longer, the chance of containing qi is greater. Therefore, in the case of the same fi, the correlation between the long document and qi should be weaker than the correlation between the short document and qi.
[0101] Among them, there are also many ways to perform weighted summation on the calculated correlation to obtain the first similarity between the first entity and the second entity in the entity pair to be processed. For example, specifically, based on the inverted index list, determine the number of occurrences of each morpheme in the morpheme set in the entity information of the first entity in all entity pairs; based on the number of occurrences of each morpheme, determine the weight of each morpheme; use the weight of each morpheme to perform weighted summation on the calculated correlation to obtain the first similarity between the first entity and the second entity in the entity pair to be processed. For example, there are various methods for determining the weight of the correlation between a word and a document to be retrieved. A relatively common one is IDF, and the specific calculation formula can be as follows:
[0102]
[0103] Among them, N is the total number of documents to be retrieved in the index, and n(qi) is the number of documents to be retrieved that contain qi.
[0104] It can be seen from the definition of IDF that for a given set of documents to be retrieved, the more documents to be retrieved that contain qi, the lower the weight of qi. That is to say, when many documents to be retrieved contain qi, the discrimination of qi is not high. Therefore, the importance of using qi to judge the correlation is relatively low.
[0105] In summary, based on the inverted index list and the query information, calculate the first similarity between the first entity and the second entity in each entity pair. The specific calculation method can be as follows:
[0106]
[0107] Among them, other text matching methods can also be used to calculate the first similarity between the first entity and the second entity in each entity pair, such as TF-IDF + VSM, etc.
[0108] 105. Determine the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct link relationships in the target attribute in the knowledge graph to be detected.
[0109] Among them, there are many ways to set the first preset condition. For example, it can be flexibly set according to the actual application requirements, or it can be preset and stored in the electronic device. In addition, the first preset condition can be built into the electronic device, or it can be saved in the memory and sent to the electronic device, etc. For example, the first preset condition can be set to that the first similarity is greater than or equal to a certain preset threshold, such as 80. The setting method of the preset threshold can also be flexibly set according to the actual application requirements.
[0110] After calculating the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected, other entity pairs with link relationships on the target attribute in the knowledge graph to be detected can be determined as entity pairs with incorrect link relationships. For example, specifically, entity pairs whose first similarity does not meet the first preset condition can be determined as entity pairs with incorrect link relationships on the target attribute in the knowledge graph to be detected.
[0111] Optionally, in order to improve the recall rate of link relationships on the target attribute in the knowledge graph to be detected, entities on one side of the entity pair with correct link relationships can be matched with entities on the same side, thereby expanding the matching rate and reducing the error rate. For example, the first entity with correct link relationships can be matched with other first entities linked to the same second entity, or the second entity with correct link relationships can be matched with other second entities linked to the same first entity. The specific situation can be set according to the actual situation and is not limited here.
[0112] For example, the first entity in the entity pair with correct link relationships can be used as the target first entity; calculate the second similarity between the target first entity and the candidate first entity, where the candidate first entity is other first entities linked to the same second entity as the target first entity; determine the candidate first entity whose second similarity meets the second preset condition, and the second entity linked to the target first entity as the entity pair with correct link relationships on the target attribute in the knowledge graph to be detected. For example, specifically, the first entity in the entity pair with correct link relationships can be determined as the target first entity, and other first entities linked to the same second entity as the target first entity can be determined as candidate first entities; perform semantic analysis on the entity information of the target first entity to obtain the target query information corresponding to the target first entity; based on the target query information and the entity information of the candidate first entity, calculate the second similarity between the target first entity and the candidate first entity; if the second similarity meets the second preset condition, then determine the candidate first entity and the second entity linked to the target first entity as the entity pair with correct link relationships on the target attribute in the knowledge graph to be detected.
[0113] Among them, there are many ways to set the second preset condition. For example, it can be flexibly set according to the requirements of actual applications, or it can be preset and stored in an electronic device. In addition, the second preset condition can be built into the electronic device, or it can be stored in a memory and sent to the electronic device, etc. For example, the second preset condition can be set to the second similarity being greater than or equal to a certain preset threshold, such as 80. The setting method of the preset threshold can also be flexibly set according to the requirements of actual applications. Among them, the first preset condition and the second preset condition can be set to be the same, or the first preset condition and the second preset condition can be set to be different, which is not limited here.
[0114] For example, after calculating the second similarity between the target first entity and the candidate first entity, entity pairs for which the second similarity does not meet the second preset condition can be determined as entity pairs with incorrect linking relationships. For instance, after "if the second similarity meets the second preset condition, the candidate first entity and the second entity linked to the target first entity are determined as entity pairs with correct linking relationships in the target attribute of the knowledge graph to be detected", it can further include: if the second similarity does not meet the second preset condition, the candidate first entity and the second entity linked to the target first entity are determined as entity pairs with incorrect linking relationships in the target attribute of the knowledge graph to be detected.
[0115] For example, after calculating the second similarity between the target first entity and the candidate first entity, and the second similarity between the target first entity and the candidate first entity, entity pairs other than the entity pairs with correct linking relationships in the target attribute in the knowledge graph to be detected can be determined as entity pairs with incorrect linking relationships. For instance, after "if the second similarity meets the second preset condition, the candidate first entity and the second entity linked to the target first entity are determined as entity pairs with correct linking relationships in the target attribute of the knowledge graph to be detected", it can further include: when all candidate first entities have been calculated, all entity pairs with correct linking relationships in the target attribute in the knowledge graph to be detected are added to the entity pair set; if entity pairs with linking relationships in the target attribute are not in the entity pair set, then the entity pairs not in the entity pair set are determined as entity pairs with incorrect linking relationships in the target attribute of the knowledge graph to be detected.
[0116] As can be seen from the above, in this embodiment, at least one entity pair in the knowledge graph to be detected can be obtained, and each entity pair includes a first entity and a second entity that have a link relationship on the target attribute. Then, the entity information of the first entity in all entity pairs is inverted to obtain an inverted index list. Next, semantic analysis is performed on the entity information of each second entity to obtain query information corresponding to each second entity. Then, based on the inverted index list and the query information, the first similarity between the first entity and the second entity in each entity pair is calculated. Then, the entity pairs whose first similarity meets the first preset condition are determined as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected. Since this solution constructs an inverted index by using the entity information of the first entity, constructs a query by using the entity information of the second entity, and calculates the first similarity between the first entity and the second entity in each entity pair through the constructed inverted index and query, so as to detect the link relationship of entity pairs in the knowledge graph to be detected, effectively improving the accuracy of entity relationship detection in the knowledge graph. Since this solution mainly relies on the entity information of entities for matching and can complete the detection without too many edge relationships, it effectively improves the detection efficiency and enhances the convenience of detection. And this solution does not require manual construction of features or use of neural networks for representation learning, reducing the computational amount and manual annotation cost, and can quickly and effectively detect incorrect edges.
[0117] According to the method described in the previous embodiment, the following will give a further detailed example.
[0118] In this embodiment, an example will be given with the detection device for entity relationships in the knowledge graph specifically integrated in an electronic device, the first entity being specifically the head entity, and the second entity being specifically the tail entity.
[0119] As Figure 2a and Figure 2b shown, a method for detecting entity relationships in a knowledge graph may specifically include the following steps:
[0120] 201. The electronic device obtains at least one entity pair in the knowledge graph to be detected, and each entity pair includes a head entity and a tail entity that have a link relationship on the target attribute.
[0121] Among them, an entity pair can refer to a pair composed of a head entity and a tail entity that have a linking relationship on a target attribute. Among them, an attribute can refer to an internal feature of a thing. The head entity can refer to an entity in the linking relationship of the target attribute, and the tail entity can refer to another entity in the linking relationship of the target attribute. For example, the head and tail entities can be determined based on the linking relationship of the target attribute. For example, for [Work 1 - Author - Author A], Work 1 is the head entity, Author A is the tail entity, and the attribute is author; another example is that for [Author A - Work - Work 1], Author A is the head entity, Work 1 is the tail entity, and the attribute is work, and so on.
[0122] For example, an electronic device can divide the linking relationships in the knowledge graph according to attributes, and obtain the head entity, head entity information, tail entity, and tail entity information of the linking relationships under the same attribute. For example, it can obtain the head entity and tail entity of the linking edge relationship under the same attribute, as well as the entity information of the head entity and the entity information of the tail entity. Among them, entity information can refer to information about the entity, including but not limited to entity introductions, entity attribute information, and so on.
[0123] For example, if the target attribute is author, then the entity pairs obtained for the linking edge relationship of the author attribute in the knowledge graph to be detected can be as follows: Entity pair 1, Work 1 - Author - Author A; Entity pair 2, Work 2 - Author - Author A; Entity pair 3, Work 3 - Author - Author A; Entity pair 4, Work 4 - Author - Author B; Entity pair 5, Work 5 - Author - Author B.
[0124] After obtaining multiple entity pairs of the target attribute in the knowledge graph to be detected, an inverted index can be constructed for the head entity information, and then the tail entity information can be used as a retrieval query (query). Or an inverted index can be constructed for the tail entity information, and then the head entity information can be used to construct a retrieval query. There is no restriction here. The following takes constructing an inverted index for the head entity information and then constructing a query for the tail entity information as an example for explanation.
[0125] 202. The electronic device performs an inverted index on the head entity information of all entity pairs to obtain an inverted index list.
[0126] For example, the electronic device can perform word segmentation on the entity information, use the head entity information as the document to be retrieved to construct an inverted index, and use the tail entity information as the retrieval query. Different from general inverted index construction, since the entity name is an indivisible concept, the entity word is not segmented during word segmentation. To improve the convenience of word segmentation, both the head and tail entities can be added to the word segmentation dictionary to retain the information of the entity itself with the highest probability.
[0127] For example, to build an inverted index list, the electronic device can specifically tokenize the head entity information of the head entity in all entity pairs to obtain a first set of words; remove duplicates from the first set of words to obtain a deduplicated first set of words; establish a mapping relationship between the head entity information of each head entity and each word in the deduplicated first set of words, and generate an inverted index list based on the mapping relationship. For example, the electronic device can invert the head entity information of Works 1, 2, 3, 4, and 5 to obtain an inverted index list, as shown in Figure 2c . The detailed method of construction can be referred to the above embodiments. Figure 2c as shown.
[0128] To build the rationality of inversion, for example, the electronic device can construct the text of the head entity information by splicing the head entity attribute information in the form of triples. For example, [Work 1 - Author - Author A] after splicing is "Work 1 Author Author A", obtaining the constructed triple text, which is used as a supplement to the head entity profile and spliced behind the profile to jointly form the entity information of the entity with the entity profile. For example, the electronic device can specifically obtain the entity description information and entity attribute information of the head entity; splice the entity attribute information to obtain the spliced attribute information; add the spliced attribute information to the entity description information to obtain the head entity information of the head entity.
[0129] 203. The electronic device performs semantic analysis on the tail entity information of each tail entity respectively to obtain the query information corresponding to each tail entity.
[0130] Since the lengths of each entity information are inconsistent, when used for retrieval, the morpheme length of the query has a great impact on the subsequent calculation of similarity. Therefore, the entity information needs to be trimmed to a certain length (if it cannot reach, it will be according to the actual length) as the query information (query), and then the similarity score between the query and the document is calculated according to each word (morpheme) in the query. Among them, there are many trimming methods. For example, there are the following two methods: One is direct fixed-length trimming. For example, take the first 50 non-stop words as the query; the other is to construct the query by taking information keywords. For example, use TFIDF to extract document keywords and obtain a fixed number, such as the top 50 keywords as the query, mainly to obtain the more important words in the entity information as the morphemes of the query.
[0131] For example, to construct query information (i.e., construct a query), the electronic device can specifically perform word segmentation on the tail entity information of each tail entity to obtain a second word set corresponding to each tail entity; perform keyword extraction on each of the second word sets to obtain a keyword set corresponding to each tail entity; screen a preset number of target keywords from each keyword set, and determine the screened target keywords as the query information corresponding to the corresponding tail entity. Here, the corresponding tail entity refers to the tail entity corresponding to the keyword set to which the screened target keyword belongs. For example, the electronic device can perform word segmentation on the tail entity information of author A to obtain a second word set corresponding to author A; perform keyword extraction on the second word set of author A to obtain a keyword set corresponding to author A; screen a preset number of target keywords from the keyword set of author A, and determine the screened target keywords as the query information corresponding to author A. The construction methods of other tail entities (such as author B) are similar. Among them, the query information can be constructed for each tail entity in sequence, or the query information can be constructed for multiple tail entities simultaneously.
[0132] Among them, there are many ways to set the preset number. For example, it can be flexibly set according to the needs of actual applications, or it can be preset and stored in the electronic device in advance. In addition, the preset number can be built into the electronic device, or it can be stored in the memory and sent to the electronic device, etc. For example, the preset number can be set to 50.
[0133] For example, when performing keyword extraction on each of the second word sets, the electronic device can specifically calculate the word frequency of each word and the inverse document frequency of each word in each of the second word sets; based on the word frequency and inverse document frequency of each word in each of the second word sets, determine the keyword set corresponding to each tail entity. For example, the electronic device can calculate the word frequency of each word and the inverse document frequency of each word in the second word set of author A; based on the word frequency and inverse document frequency of each word in the second word set of author A, determine the corresponding keyword set of author A. The construction methods of other tail entities (such as author B) are similar. The keyword extraction methods of other tail entities (such as author B) are similar. Among them, keyword extraction can be performed on each tail entity in sequence, or keyword extraction can be performed on multiple tail entities simultaneously.
[0134] For example, the term frequency-inverse document frequency (TF-IDF) method can be used to perform keyword extraction on the word set of the tail entity information A of author A. TF can refer to the frequency of a word (or character) appearing in the tail entity information A, such as the number of times a word (or character) appears in the tail entity information A. The specific calculation formula can be as follows:
[0135]
[0136] where n i,j is the frequency of the word in the tail entity information Adj The number of occurrences in it, and the denominator is the tail entity information Ad j The total number of occurrences of all words in it. That is
[0137]
[0138] IDF (inverse document frequency) can refer to the inverse document frequency of a certain word, which can be obtained by dividing the total number of documents (the number of all tail entity information) by the number of tail entity information containing the word, and then taking the logarithm of the obtained quotient. If the fewer the tail entity information containing the term t, the larger the IDF, it indicates that the term has good category discrimination ability. The specific calculation formula can be as follows:
[0139]
[0140] Among them, |D| is the total number of tail entity information in the corpus. |{j:t i ∈d j}| represents the number of tail entity information containing the word t i (that is, the number of files with n i,j ≠0). If the word is not in the corpus, it will cause the denominator to be zero. Therefore, generally, 1 + |{j:t i ∈d j}| is used, that is:
[0141]
[0142] Then TF-IDF is actually: TF * IDF, which refers to the high word frequency in a specific file and the low file frequency of the word in the entire file set, and can produce a high-weight TF-IDF. Therefore, TF-IDF tends to filter out common words and retain important words. That is:
[0143] TF-IDF = TF * IDF
[0144] For another example, to construct query information, the electronic device can specifically perform word segmentation on the tail entity information of each tail entity to obtain a second word set corresponding to each tail entity; remove the stop words in each second word set to obtain a non-stop word set corresponding to each tail entity; select a preset number of non-stop words in sequence from the non-stop word set corresponding to each tail entity, and determine them as the query information corresponding to the corresponding tail entity. For example, the electronic device can perform word segmentation on the tail entity information of author A to obtain a second word set corresponding to author A; remove the stop words in the second word set of author A to obtain a non-stop word set corresponding to author A; select a preset number of non-stop words in sequence from the non-stop word set corresponding to author A, and determine them as the query information corresponding to author A. The construction methods of other tail entities (such as author B) are similar. Among them, the query information can be constructed for each tail entity in sequence, or the query information can be constructed for multiple tail entities at the same time.
[0145] 204. The electronic device calculates a first similarity between the head entity and the tail entity in each entity pair based on the inverted index list and the query information.
[0146] For example, for each entity pair, the following operations can be performed: The electronic device determines a to-be-processed entity pair from the obtained entity pairs; performs morpheme parsing on the query information of the tail entity in the to-be-processed entity pair to obtain a morpheme set of the tail entity in the to-be-processed entity pair; calculates the relevance between each morpheme in the morpheme set and the head entity information of the head entity in the to-be-processed entity pair respectively based on the head entity information of the head entities in all entity pairs; performs weighted summation on the calculated relevance based on the inverted index list to obtain the first similarity between the head entity and the tail entity in the to-be-processed entity pair. Among them, the to-be-processed entity pair can be one pair or multiple pairs, that is, the calculation can be performed on each entity pair in sequence, or the calculation can be performed on multiple entity pairs at the same time, and so on.
[0147] For example, for entity pair 1: Work 1 - Author - Author A, the following operations can be performed: The electronic device determines the entity pair to be processed (such as entity pair 1) from the obtained entity pairs; performs morpheme parsing on the query information of Author A in entity pair 1 to obtain the morpheme set of entity pair 1; based on the head entity information of Work 1, Work 2, Work 3, Work 4, and Work 5, calculates the correlation between each morpheme in the morpheme set of Author A and the head entity information of Work 1; based on the inverted index list, performs weighted summation on the calculated correlations to obtain the first similarity between Work 1 and Author A in entity pair 1. The calculation methods for other entity pairs (such as entity pair 2, entity pair 3, entity pair 4, and entity pair 5) are similar. Among them, each entity pair can be calculated sequentially, or multiple entity pairs can be calculated simultaneously. Since in this embodiment, step 203 has performed word segmentation and fixed-length processing on the query information of Author A, the selected target keywords corresponding to Author A can be used as the morphemes in the morpheme set of Author A.
[0148] For example, for entity pair 1: perform morpheme parsing on the Query (such as the query information of Author A) to generate morpheme qi; then, for the head entity information D of each head entity (such as the head entity information of Work 1), calculate the correlation score between each morpheme qi and D, and finally, perform weighted summation on the correlation scores of qi with respect to D to obtain the correlation score between the Query and D. The specific calculation formula can be as follows:
[0149]
[0150] Among them, Q represents the Query, qi represents a morpheme after Q is parsed (for Chinese, the word segmentation of the Query can be used as morpheme analysis, and each word is regarded as morpheme qi); d represents a document to be retrieved (such as the head entity information of Work 1); Wi represents the weight of morpheme qi; R(qi, d) represents the correlation score between morpheme qi and the document to be retrieved (such as the head entity information of Work 1) d.
[0151] For example, to calculate the correlation between each morpheme in the morpheme set and the head entity information of the head entity in the entity pair to be processed, specifically, based on the head entity information of the head entities in all entity pairs, calculate the average length of the head entity information of the head entities in all entity pairs, and determine the target length of the head entity information of the head entity in the entity pair to be processed; calculate the occurrence frequency of each morpheme in the morpheme set in the head entity information of the head entity in the entity pair to be processed to obtain the occurrence frequency of each morpheme; based on the average length, target length, and the occurrence frequency of each morpheme, calculate the correlation between each morpheme in the morpheme set and the head entity information of the head entity in the entity pair to be processed.
[0152] For example, for entity pair 1: Based on the head entity information of Works 1, 2, 3, 4, and 5, calculate the average length of the head entity information of Works 1, 2, 3, 4, and 5, and determine the target length of the head entity information of Work 1; calculate the occurrence frequency of each morpheme in the morpheme set of Author A in the head entity information of Work 1 to obtain the occurrence frequency of each morpheme; based on the average length, target length, and the occurrence frequency of each morpheme, calculate the correlation between each morpheme in the morpheme set of Author A and the head entity information of Work 1 respectively.
[0153] For example, the specific calculation formula for the correlation score R(qi, d) between the morpheme qi and the document to be retrieved (such as the head entity information of Work 1) d can be as follows:
[0154]
[0155] Among them, k1, k2, and b are adjustment factors, usually set according to experience. For example, k1 = 2 and b = 0.75 can be set; fi is the occurrence frequency of qi in d, qfi is the occurrence frequency of qi in the Query. dl is the length of the document (such as the head entity information of Work 1) d, and avgdl is the average length of all documents to be retrieved (the head entity information of Works 1, 2, 3, 4, and 5). Since in most cases, qi will only appear once in the Query, that is, qfi = 1, the formula can be simplified as:
[0156]
[0157] For example, for the step of "based on the inverted index list, perform weighted summation on the calculated correlation to obtain the first similarity between the head entity and the tail entity in the entity pair to be processed", the electronic device can specifically determine the number of occurrences of each morpheme in the morpheme set in the head entity information of the head entities in all entity pairs based on the inverted index list; determine the weight of each morpheme based on the number of occurrences of each morpheme; use the weight of each morpheme to perform weighted summation on the calculated correlation to obtain the first similarity between the head entity and the tail entity in the entity pair to be processed.
[0158] For example, based on the inverted index list, the number of occurrences of each morpheme in the morpheme set of Author A in the head entity information of the head entities in all entity pairs can be determined; the weight of each morpheme can be determined based on the number of occurrences of each morpheme; use the weight of each morpheme to perform weighted summation on the calculated correlation to obtain the first similarity between Work 1 and Author A.
[0159] For example, there are various methods for determining the weight of the correlation between a word and a document to be retrieved. The more commonly used one is IDF, and the specific calculation formula can be as follows:
[0160]
[0161] Among them, N is the total number of documents to be retrieved in the index (for example, the number of head entity information of Works 1, 2, 3, 4, and 5, that is, the total number of documents to be retrieved is 5), and n(qi) is the number of documents to be retrieved that contain qi (for example, the number of documents to be retrieved that contain qi is 2).
[0162] It can be seen from the definition of IDF that for a given set of documents to be retrieved, the more documents to be retrieved that contain qi, the lower the weight of qi. That is to say, when many documents to be retrieved contain qi, the discrimination of qi is not high. Therefore, the importance of using qi to judge relevance is relatively low.
[0163] In summary, based on the inverted index list and the query information, the first similarity between the head entity and the tail entity in each entity pair can be calculated. The specific calculation method can be as follows:
[0164]
[0165] 205. The electronic device determines the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct link relationships in the target attribute in the knowledge graph to be detected.
[0166] Among them, there are many ways to set the first preset condition. For example, it can be flexibly set according to the needs of actual applications, or it can be preset and stored in the electronic device. In addition, the first preset condition can be built into the electronic device, or it can be stored in the memory and sent to the electronic device, etc. For example, the first preset condition can be set to the first similarity being greater than or equal to 80.
[0167] For example, it is calculated that the first similarity between Work 1 and Author A in Entity Pair 1 is greater than 80, the first similarity between Work 2 and Author A in Entity Pair 2 is less than 80, the first similarity between Work 3 and Author A in Entity Pair 3 is less than 80, the first similarity between Work 4 and Author B in Entity Pair 4 is greater than 80, and the first similarity between Work 5 and Author B in Entity Pair 5 is greater than 80. Then, Entity Pair 1, Entity Pair 4, and Entity Pair 5 are the entity pairs with correct link relationships in the author attribute in the knowledge graph to be detected.
[0168] 206. The electronic device calculates the second similarity between the target head entity and the candidate head entity.
[0169] Among them, the head entity in the entity pair with the correct link relationship can be used as the target head entity, and the other head entities linked to the same tail entity as the target head entity can be used as candidate head entities.
[0170] To improve the recall rate of the link relationships on the target attribute in the knowledge graph to be detected, the entity on one side of the entity pair with correct link relationships can be matched with the entities on the same side (for example, match Work 1 with Work 2 and Work 3 respectively), thereby expanding the matching rate and reducing the error rate. For example, the bootstrapping method can be used to match the head entities with the same attribute, reducing the over-recall of incorrect edges.
[0171] Among them, in statistics, the Bootstrap Method (Bootstrapping or self-sampling method) is a uniform sampling with replacement from a given training set. That is to say, whenever a sample is selected, it is equally likely to be selected again and added to the training set again.
[0172] For example, the head entity in the entity pair with correct link relationships can be used as the target head entity (such as Work 1); calculate the second similarity between the target head entity and the candidate head entities, where the candidate head entities are other head entities that are linked to the same tail entity as the target head entity (for example, if Work 2, Work 3, and Work 1 are linked to Author A, then Work 2 and Work 3 are used as candidate head entities).
[0173] Among them, there are many ways to set the second preset condition. For example, it can be flexibly set according to the needs of actual applications, or it can be preset and stored in the electronic device. In addition, the second preset condition can be built into the electronic device, or it can be stored in the memory and sent to the electronic device, and so on. For example, the second preset condition can be set to the second similarity being greater than or equal to 80.
[0174] 207. The electronic device determines the candidate head entities whose second similarity meets the second preset condition, and the tail entities linked to the target head entity as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected.
[0175] For example, the electronic device can determine the candidate head entities whose second similarity meets the second preset condition, and the tail entities linked to the target head entity as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected. For example, if the second similarity between Work 2 and Work 1 meets the second preset condition, then the entity pair 2 of Work 2 and Author A is determined as the entity pair with correct link relationships on the author attribute in the knowledge graph to be detected.
[0176] For example, the electronic device can specifically determine the head entity in the entity pair with the correct link relationship as the target head entity, and determine the other head entities linked to the same tail entity as the candidate head entities as the candidate head entities; perform semantic analysis on the head entity information of the target head entity (such as the head entity information of Work 1) to obtain the target query information corresponding to the target head entity; calculate the second similarity between the target head entity and the candidate head entities based on the target query information and the head entity information of the candidate head entities; if the second similarity meets the second preset condition, then determine the candidate head entity and the tail entity linked to the target head entity as the entity pair with the correct link relationship in the target attribute in the to-be-detected knowledge graph.
[0177] 208. The electronic device determines the entity pairs whose first similarity does not meet the first preset condition and whose second similarity does not meet the second preset condition as the entity pairs with incorrect link relationships in the target attribute in the to-be-detected knowledge graph.
[0178] For example, after calculating the second similarity between the target head entity and the candidate head entities, the electronic device can determine the entity pairs whose second similarity does not meet the second preset condition as the entity pairs with incorrect link relationships. For example, if the second similarity does not meet the second preset condition, the electronic device determines the candidate head entity and the tail entity linked to the target head entity as the entity pairs with incorrect link relationships in the target attribute in the to-be-detected knowledge graph. For example, if the second similarity between Work 3 and Work 1 does not meet the second preset condition, then determine the entity pair 2 corresponding to Work 2 and Author A as the entity pair with incorrect link relationships in the author attribute in the to-be-detected knowledge graph.
[0179] For example, when all candidate head entities are calculated, the electronic device adds all the entity pairs with correct link relationships in the target attribute in the to-be-detected knowledge graph to the entity pair set; if the entity pairs with link relationships in the target attribute are not in the entity pair set, then determine the entity pairs not in the entity pair set as the entity pairs with incorrect link relationships in the target attribute in the to-be-detected knowledge graph. For example, entity pair 1, entity pair 2, entity pair 4, and entity pair 5 can be added to the entity pair set. If the entity pair with a link relationship in the author attribute (such as entity pair 3) is not in the entity pair set, then determine entity pair 3 as the entity pair with incorrect link relationships in the target attribute in the to-be-detected knowledge graph.
[0180] For example, in steps 206 and 207 under the iteration of bootstrapping, if there are no new retrievals for the work, it indicates that the entire retrieval has converged, and the retrieval is terminated. All relevant works obtained by the author are matched with the works with known links of the author. If the works with known links are not among the obtained relevant works, it is determined as an incorrect link edge relationship.
[0181] Among them, the setting of the first condition and the second condition can be set according to the performance on the validation set. The validation set can be data with known answers. For example, when evaluating the data quality, some data can be labeled. For example, 100 pairs of head and tail entities for the author edge relationship are sampled to determine whether they are correct. These 100 pairs of data can be used as the validation set to verify the results, and the preset thresholds in the first condition and the second condition can be adjusted according to the verification results, and so on.
[0182] This solution mainly performs similarity matching on the existing link edge relationships in the knowledge graph to detect whether there are link errors. This solution can quickly and effectively obtain possible incorrect edges and reduce the situation of detection errors, that is, judging a correct link edge as incorrect.
[0183] For example, as shown in the following table, Table 1 shows the metrics on the test data before adding the bootstrapping retrieval, and Table 2 shows the metrics on the test data after adding the bootstrapping retrieval. Among them, precision is the accuracy rate, recall is the recall rate, f1-score is the combination of the two (i.e., the accuracy rate and the recall rate), and support is the number of samples. It can be seen from Table 1 and Table 2 that after adding the bootstrapping retrieval, the accuracy rate of the correct edges remains unchanged, but the recall rate doubles. The recall of the incorrect edges slightly decreases, but the accuracy rate increases by 30%. That is to say, adding the bootstrapping retrieval can greatly reduce the situation of detection errors while ensuring the detection quality.
[0184] Table 1. Metrics chart without bootstrapping retrieval
[0185] precision recall f1-score support Wrong edge 0 0.53 0.96 0.69 83 Correct edge 1 0.94 0.40 0.56 117 avg / total 0.77 0.64 0.61 200
[0186] Table 2. Metrics chart with bootstrapping retrieval added
[0187] precision recall f1-score support Wrong edge 0 0.77 0.93 0.84 83 Correct edge 1 0.94 0.80 0.87 117 avg / total 0.87 0.85 0.86 200
[0188] Among them, the F1-score is an index used in statistics to measure the accuracy of a binary classification model. It takes into account both the precision and recall of the classification model. The F1-score can be regarded as a harmonic mean of the model's precision and recall, with a maximum value of 1 and a minimum value of 0.
[0189] As can be seen from the above, in this embodiment, at least one entity pair in the knowledge graph to be detected can be obtained, and each entity pair includes a first entity and a second entity that have a link relationship on the target attribute; then, the entity information of the first entity in all entity pairs is inverted to obtain an inverted index list; then, semantic analysis is performed on the entity information of each second entity to obtain query information corresponding to each second entity; then, based on the inverted index list and the query information, the first similarity between the first entity and the second entity in each entity pair is calculated; then, the entity pairs whose first similarity meets the first preset condition are determined as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected. Since this solution constructs an inverted index using the entity information of the first entity, constructs a query using the entity information of the second entity, and calculates the first similarity between the first entity and the second entity in each entity pair through the constructed inverted index and query to detect the link relationships of the entity pairs in the knowledge graph to be detected, it effectively improves the accuracy of entity relationship detection in the knowledge graph. Since this solution mainly relies on the entity information of entities for matching and can complete the detection without too many edge relationships, it effectively improves the detection efficiency and enhances the convenience of detection. And this solution does not require manual construction of features or use of neural networks for representation learning, reducing the computational amount and manual annotation cost, and can quickly and effectively detect incorrect edges. This solution also uses the Bootstrapping method, which not only relies on head and tail entity matching but also adds head entity matching between the same attributes to expand the matching amount to assist in incorrect edge detection and reduce the over-recall of incorrect edges.
[0190] To better implement the above method, correspondingly, an embodiment of the present application also provides a device for detecting entity relationships in a knowledge graph. The device for detecting entity relationships in the knowledge graph can be specifically integrated in an electronic device, and the electronic device can be a server or a terminal device, etc.
[0191] For example, as Figure 3 shown, the device for detecting entity relationships in the knowledge graph can include an acquisition unit 301, an inversion unit 302, an analysis unit 303, a calculation unit 304, and a determination unit 305, as follows:
[0192] The acquisition unit 301 is configured to acquire at least one entity pair in the knowledge graph to be detected, and each entity pair includes a first entity and a second entity that have a link relationship on the target attribute;
[0193] An inverted index unit 302 is configured to invert the entity information of the first entity in all entity pairs to obtain an inverted index list;
[0194] An analysis unit 303 is configured to perform semantic analysis on the entity information of each second entity respectively to obtain query information corresponding to each second entity;
[0195] A calculation unit 304 is configured to calculate a first similarity between the first entity and the second entity in each entity pair based on the inverted index list and the query information;
[0196] A determination unit 305 is configured to determine the entity pairs whose first similarity meets a first preset condition as the entity pairs with correct linking relationships on the target attribute in the to-be-detected knowledge graph.
[0197] Optionally, in some embodiments, the detection device for entity relationships in the knowledge graph may further include a candidate unit as follows:
[0198] The candidate unit may specifically determine the first entity in the entity pairs with correct linking relationships as the target first entity, and determine the other first entities linked to the same second entity as the target first entity as candidate first entities; perform semantic analysis on the entity information of the target first entity to obtain target query information corresponding to the target first entity; calculate a second similarity between the target first entity and the candidate first entities based on the target query information and the entity information of the candidate first entities; if the second similarity meets a second preset condition, then determine the candidate first entities and the second entity linked to the target first entity as the entity pairs with correct linking relationships on the target attribute in the to-be-detected knowledge graph.
[0199] Optionally, in some embodiments, the detection device for entity relationships in the knowledge graph may further include a verification unit as follows:
[0200] The verification unit may specifically add all the entity pairs with correct linking relationships on the target attribute in the to-be-detected knowledge graph to an entity pair set when the calculation of all candidate first entities is completed; if the entity pairs with linking relationships on the target attribute are not in the entity pair set, then determine the entity pairs not in the entity pair set as the entity pairs with incorrect linking relationships on the target attribute in the to-be-detected knowledge graph.
[0201] Optionally, in some embodiments, the inverted index unit 302 may specifically be configured to perform word segmentation on the entity information of the first entity in all entity pairs to obtain a first word set; remove duplicates from the first word set to obtain a deduplicated first word set; establish a mapping relationship between the entity information of each first entity and each word in the deduplicated first word set, and generate an inverted index list based on the mapping relationship.
[0202] Optionally, in some embodiments, the analysis unit 303 may include a word segmentation subunit, an extraction subunit, and a screening subunit, as follows:
[0203] The word segmentation subunit may be configured to perform word segmentation on the entity information of each second entity to obtain a second word set corresponding to each second entity;
[0204] The extraction subunit may be configured to perform keyword extraction on each of the second word sets to obtain a keyword set corresponding to each second entity;
[0205] The screening subunit may be configured to screen a preset number of target keywords from each keyword set, and determine the screened target keywords as the query information corresponding to the respective second entity.
[0206] Optionally, in some embodiments, the extraction subunit may specifically be configured to calculate the word frequency of each word and the inverse document frequency of each word in each of the second word sets; determine a keyword set corresponding to each second entity based on the word frequency and inverse document frequency of each word in each of the second word sets.
[0207] Optionally, in some embodiments, the analysis unit 303 may specifically be configured to perform word segmentation on the entity information of each second entity to obtain a second word set corresponding to each second entity; remove stop words from each of the second word sets to obtain a non-stop word set corresponding to each second entity; sequentially select a preset number of non-stop words from the non-stop word set corresponding to each second entity, and determine them as the query information corresponding to the respective second entity.
[0208] Optionally, in some embodiments, the calculation unit 304 may include a parsing subunit, a first calculation subunit, and a second calculation subunit, as follows:
[0209] The parsing subunit may be configured to determine a to-be-processed entity pair from the obtained entity pairs; perform morpheme parsing on the query information of the second entity in the to-be-processed entity pair to obtain a morpheme set of the second entity in the to-be-processed entity pair;
[0210] The first calculation subunit can be used to calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed, respectively, based on the entity information of the first entity in all entity pairs;
[0211] The second calculation subunit can be used to perform a weighted sum on the calculated correlation based on the inverted index list to obtain a first similarity between the first entity and the second entity in the entity pair to be processed.
[0212] Optionally, in some embodiments, the first calculation subunit can specifically be used to calculate the average length of the entity information of the first entity in all entity pairs based on the entity information of the first entity in all entity pairs, and determine the target length of the entity information of the first entity in the entity pair to be processed; calculate the occurrence frequency of each morpheme in the entity information of the first entity in the entity pair to be processed to obtain the occurrence frequency of each morpheme; calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed, respectively, based on the average length, the target length, and the occurrence frequency of each morpheme.
[0213] Optionally, in some embodiments, the second calculation subunit can specifically be used to determine the number of occurrences of each morpheme in the entity information of the first entity in all entity pairs based on the inverted index list; determine the weight of each morpheme based on the number of occurrences of each morpheme; perform a weighted sum on the calculated correlation using the weight of each morpheme to obtain a first similarity between the first entity and the second entity in the entity pair to be processed.
[0214] In specific implementation, the above-mentioned each unit can be implemented as an independent entity, or can be combined arbitrarily to be implemented as the same or several entities. For the specific implementation of the above-mentioned each unit, reference can be made to the method embodiments above, which will not be elaborated here.
[0215] As can be seen from the above, in this embodiment, the acquisition unit 301 can acquire at least one entity pair in the knowledge graph to be detected, and each entity pair includes a first entity and a second entity that have a link relationship on the target attribute; then, the inverted index unit 302 inverts the entity information of the first entity in all entity pairs to obtain an inverted index list; then, the analysis unit 303 semantically analyzes the entity information of each second entity to obtain the query information corresponding to each second entity; then, the calculation unit 304 calculates the first similarity between the first entity and the second entity in each entity pair based on the inverted index list and the query information; then, the determination unit 305 determines the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected. Since this solution constructs an inverted index using the entity information of the first entity, constructs a query using the entity information of the second entity, and calculates the first similarity between the first entity and the second entity in each entity pair through the constructed inverted index and query to detect the link relationship of the entity pairs in the knowledge graph to be detected, it effectively improves the accuracy of entity relationship detection in the knowledge graph. Since this solution mainly relies on the entity information of entities for matching and can complete the detection without too many edge relationships, it effectively improves the detection efficiency and enhances the convenience of detection. And this solution does not require manual construction of features or use of neural networks for representation learning, reducing the computational amount and manual annotation cost, and can quickly and effectively detect incorrect edges.
[0216] In addition, an embodiment of the present application also provides an electronic device, as Figure 4 shown, which shows a schematic structural diagram of the electronic device involved in the embodiment of the present application. Specifically:
[0217] The electronic device may include a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, an input unit 404 and other components. Those skilled in the art can understand that Figure 4 the structure of the electronic device shown in does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Among them:
[0218] The processor 401 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 402, and by calling the data stored in the memory 402, it executes various functions of the electronic device and processes data, thereby performing an overall detection of the electronic device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 401 either.
[0219] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 mainly includes a program storage area and a data storage area. Among them, the program storage area can store the operating system, application programs required for at least one function (such as the sound playback function, image playback function, etc.); the data storage area can store the data created according to the use of the electronic device. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0220] The electronic device also includes a power supply 403 for powering each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 403 may also include any components such as one or more DC or AC power supplies, a recharge system, a power failure detection circuit, a power converter or inverter, and a power status indicator.
[0221] The electronic device may further include an input unit 404, which can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.
[0222] Although not shown, the electronic device may also include a display unit, etc., which will not be elaborated here. Specifically, in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402 to realize various functions as follows:
[0223] Obtain at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a link relationship on the target attribute; then, invert the entity information of the first entity in all entity pairs to obtain an inverted index list; then, perform semantic analysis on the entity information of each second entity respectively to obtain query information corresponding to each second entity; then, based on the inverted index list and the query information, calculate a first similarity between the first entity and the second entity in each entity pair; then, determine the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected.
[0224] For the specific implementation of each of the above operations, reference may be made to the previous embodiments and will not be elaborated here.
[0225] As can be seen from the above, this embodiment can obtain at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a link relationship on the target attribute; then, invert the entity information of the first entity in all entity pairs to obtain an inverted index list; then, perform semantic analysis on the entity information of each second entity respectively to obtain query information corresponding to each second entity; then, based on the inverted index list and the query information, calculate a first similarity between the first entity and the second entity in each entity pair; then, determine the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected. Since this solution constructs an inversion using the entity information of the first entity, constructs a query using the entity information of the second entity, and calculates the first similarity between the first entity and the second entity in each entity pair through the constructed inversion and query to detect the link relationship of the entity pairs in the knowledge graph to be detected, it effectively improves the accuracy of entity relationship detection in the knowledge graph. Since this solution mainly relies on the entity information of entities for matching and can complete the detection without too many edge relationships, it effectively improves the detection efficiency and enhances the convenience of detection. And this solution does not require manual construction of features or the use of neural networks for representation learning, reducing the computational amount and manual annotation cost, and can quickly and effectively perform wrong edge detection.
[0226] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions or by controlling related hardware through instructions. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0227] Accordingly, an embodiment of the present application further provides a storage medium storing a plurality of instructions that can be loaded by a processor to execute the steps in any of the methods for detecting entity relationships in a knowledge graph provided by the embodiments of the present application. For example, the instructions may perform the following steps:
[0228] Obtain at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a link relationship on a target attribute; then, invert the entity information of the first entity in all entity pairs to obtain an inverted index list; then, perform semantic analysis on the entity information of each second entity respectively to obtain query information corresponding to each second entity; then, based on the inverted index list and the query information, calculate a first similarity between the first entity and the second entity in each entity pair; then, determine the entity pairs whose first similarity meets a first preset condition as the entity pairs with correct link relationships on the target attribute in the knowledge graph to be detected.
[0229] For the specific implementation of each of the above operations, reference may be made to the previous embodiments and will not be elaborated herein.
[0230] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.
[0231] Since the instructions stored in the storage medium can execute the steps in any of the methods for detecting entity relationships in a knowledge graph provided by the embodiments of the present application, the beneficial effects that can be achieved by any of the methods for detecting entity relationships in a knowledge graph provided by the embodiments of the present application can be realized. For details, reference may be made to the previous embodiments and will not be elaborated herein.
[0232] The above has introduced in detail a method, device, electronic device, and storage medium for detecting entity relationships in a knowledge graph provided by the embodiments of the present application. Specific examples are used herein to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for detecting entity relationships in a knowledge graph, characterized in that, Including: Obtain at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity that have a linking relationship on the target attribute; Invert the entity information of the first entity in all entity pairs to obtain an inverted index list; Perform semantic analysis on the entity information of each second entity respectively to obtain query information corresponding to each second entity; Based on the inverted index list and the query information, calculate a first similarity between the first entity and the second entity in each entity pair; Determine the entity pairs whose first similarity meets the first preset condition as the entity pairs with correct linking relationships on the target attribute in the knowledge graph to be detected; Determine the first entity in the entity pairs with correct linking relationships as the target first entity, and determine the other first entities linked to the same second entity as the target first entity as candidate first entities; Perform semantic analysis on the entity information of the target first entity to obtain target query information corresponding to the target first entity; Based on the target query information and the entity information of the candidate first entities, calculate a second similarity between the target first entity and the candidate first entities; If the second similarity meets the second preset condition, then determine the candidate first entity and the second entity linked to the target first entity as the entity pairs with correct linking relationships on the target attribute in the knowledge graph to be detected.
2. The method according to claim 1, wherein After the step of "if the second similarity meets the second preset condition, then determine the candidate first entity and the second entity linked to the target first entity as the entity pairs with correct linking relationships on the target attribute in the knowledge graph to be detected", it further includes: When all candidate first entities are calculated, add all the entity pairs with correct linking relationships on the target attribute in the knowledge graph to be detected to the entity pair set; If the entity pairs with linking relationships on the target attribute are not in the entity pair set, then determine the entity pairs not in the entity pair set as the entity pairs with incorrect linking relationships on the target attribute in the knowledge graph to be detected.
3. The method according to claim 1, characterized in that, The step of "invert the entity information of the first entity in all entity pairs to obtain an inverted index list" includes: Segment the entity information of the first entity in all entity pairs to obtain a first word set; Remove duplicates from the first word set to obtain a deduplicated first word set; 4. The method according to claim 1, wherein Establish a mapping relationship between the entity information of each first entity and each word in the deduplicated first word set, and generate an inverted index list based on the mapping relationship. The step of "perform semantic analysis on the entity information of each second entity respectively to obtain query information corresponding to each second entity" includes: Segment the entity information of each second entity respectively to obtain a second word set corresponding to each second entity; Extract keywords from each of the second word sets respectively to obtain a keyword set corresponding to each second entity; 5. The method according to claim 4, characterized in that Select a preset number of target keywords from each keyword set, and determine the selected target keywords as the query information corresponding to the corresponding second entity. The step of "extract keywords from each of the second word sets respectively to obtain a keyword set corresponding to each second entity" includes: Calculate the word frequency of each word in each second word set and the inverse document frequency of each word respectively; Based on the word frequency and inverse document frequency of each word in each second word set, determine the keyword set corresponding to each second entity.
6. The method according to any one of claims 1 to 5, characterized in that, The semantic analysis is respectively performed on the entity information of each second entity to obtain the query information corresponding to each second entity, including: The entity information of each second entity is respectively segmented to obtain the second word set corresponding to each second entity; The stop words in each second word set are respectively removed to obtain the non-stop word set corresponding to each second entity; A preset number of non-stop words are sequentially selected from the non-stop word set corresponding to each second entity and determined as the query information corresponding to the corresponding second entity.
7. The method according to any one of claims 1 to 5, characterized in that Based on the inverted index list and the query information, calculate the first similarity between the first entity and the second entity in each entity pair, including: Determine the entity pair to be processed from the obtained entity pairs; Perform morpheme analysis on the query information of the second entity in the entity pair to be processed to obtain the morpheme set of the second entity in the entity pair to be processed; Based on the entity information of the first entity in all entity pairs, calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed respectively; Based on the inverted index list, perform weighted summation on the calculated correlations to obtain the first similarity between the first entity and the second entity in the entity pair to be processed.
8. The method according to claim 7, wherein Based on the entity information of the first entity in all entity pairs, calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed respectively, including: Based on the entity information of the first entity in all entity pairs, calculate the average length of the entity information of the first entity in all entity pairs, and determine the target length of the entity information of the first entity in the entity pair to be processed; Calculate the occurrence frequency of each morpheme in the entity information of the first entity in the entity pair to be processed to obtain the occurrence frequency of each morpheme; Based on the average length, target length, and the occurrence frequency of each morpheme, calculate the correlation between each morpheme in the morpheme set and the entity information of the first entity in the entity pair to be processed respectively.
9. The method according to claim 7, wherein Based on the inverted index list, perform weighted summation on the calculated correlations to obtain the first similarity between the first entity and the second entity in the entity pair to be processed, including: Based on the inverted index list, determine the occurrence times of each morpheme in the entity information of the first entity in all entity pairs; Based on the occurrence times of each morpheme, determine the weight of each morpheme; Use the weight of each morpheme to perform weighted summation on the calculated correlations to obtain the first similarity between the first entity and the second entity in the entity pair to be processed.
10. A detection device for entity relationships in a knowledge graph, characterized in that, Including: An acquisition unit, configured to acquire at least one entity pair in the knowledge graph to be detected, where each entity pair includes a first entity and a second entity having a link relationship on a target attribute; An inverted unit, configured to invert the entity information of the first entity in all entity pairs to obtain an inverted index list; An analysis unit for semantically analyzing the entity information of each second entity respectively to obtain query information corresponding to each second entity; A calculation unit for calculating a first similarity between a first entity and a second entity in each entity pair based on the inverted index list and the query information; A determination unit for determining an entity pair whose first similarity meets a first preset condition as an entity pair with a correct link relationship on a target attribute in the knowledge graph to be detected; A candidate unit for determining the first entity in the entity pair with a correct link relationship as a target first entity, and determining other first entities linked to the same second entity as the target first entity as candidate first entities; semantically analyzing the entity information of the target first entity to obtain target query information corresponding to the target first entity; Calculating a second similarity between the target first entity and the candidate first entity based on the target query information and the entity information of the candidate first entity; If the second similarity meets a second preset condition, then determining the candidate first entity and the second entity linked to the target first entity as entity pairs with a correct link relationship on the target attribute in the knowledge graph to be detected.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method for detecting entity relationships in the knowledge graph according to any one of claims 1 to 9.
12. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein, When the processor executes the program, the steps of the method according to any one of claims 1 to 9 are implemented.
13. A computer program product, characterized in that, A computer product includes computer instructions, the computer instructions are stored in a computer-readable storage medium, a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Exception identification method and device for file association relationship and computer equipment
CN111914101A
Method and device for determining target information based on knowledge graph
CN112487787A