A semantic retrieval method and device based on a knowledge graph
By constructing a knowledge graph in the information service domain, eliminating entity ambiguity and completing relationships, and extracting target entities and related relationships from search statements, the problems of weak semantic understanding and low relevance of results in traditional search methods are solved, achieving efficient semantic search results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINESE PEOPLES LIBERATION ARMY UNIT 61618
- Filing Date
- 2026-02-05
- Publication Date
- 2026-06-05
AI Technical Summary
Traditional keyword-based retrieval methods cannot understand the deep semantics of user search statements and ignore the semantic relationships between entities, resulting in low relevance and a lot of redundant information in the search results. Existing knowledge graph-based retrieval methods are inefficient and have poor accuracy in relational reasoning, making it difficult to meet the retrieval needs in complex scenarios.
By acquiring information service data, a knowledge graph for the information service domain is constructed, including an entity layer, a relation layer, and an attribute layer. Entity identification, relation extraction, and attribute annotation are performed to eliminate ambiguity of entities with the same name, perform knowledge completion, extract target entities and related relationships from search statements, and calculate semantic similarity in combination with the knowledge graph to generate semantic search results.
It achieves deep semantic parsing of search statements, improves the relevance and accuracy of search results, avoids irrelevant and redundant results caused by literal matching, and provides accurate semantic search support.
Smart Images

Figure CN122152887A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of semantic retrieval technology, and in particular to a semantic retrieval method and apparatus based on knowledge graphs. Background Technology
[0002] With the development of information technology, data is growing explosively, and users have increasingly higher demands for the accuracy and intelligence of information retrieval. Traditional retrieval methods are mostly based on keyword matching, determining the relevance of search results by statistically analyzing the frequency of keyword occurrences in documents. However, this method has obvious limitations: on the one hand, it cannot understand the deep semantics of user search queries, easily leading to word mismatch problems. For example, if a user searches for "Apple's operating system," a traditional keyword search might return a large amount of content about the fruit "apple." On the other hand, it ignores the semantic relationships between entities, failing to uncover implicit search intent, resulting in low relevance and excessive redundant information in the search results.
[0003] Knowledge graphs, as a structured semantic knowledge base, can clearly describe the relationships between entities, relations, and attributes, providing a technological foundation for semantic retrieval. Currently, most knowledge graph-based retrieval methods remain at the level of simple entity matching, lacking deep semantic analysis of search queries, and suffer from low efficiency and accuracy in relational reasoning, making it difficult to meet the retrieval needs of complex scenarios. Therefore, how to achieve accurate semantic retrieval based on knowledge graphs has become an urgent technical problem to be solved. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a semantic retrieval method and device based on knowledge graphs, which solves the problems of weak semantic understanding ability and low relevance of retrieval results in traditional keyword retrieval.
[0005] To address the aforementioned technical problems, a first aspect of this invention discloses a semantic retrieval method based on a knowledge graph, the method comprising: S1, Obtain information service data; the information service data includes structured data, semi-structured data, and unstructured data; S2, Process the information service data to obtain an information service domain knowledge graph; the information service domain knowledge graph includes an entity layer, a relation layer, and an attribute layer; S3, process the user-input search query and the information service domain knowledge graph to obtain semantic search results.
[0006] As an optional implementation, in the first aspect of the present invention, processing the information service data information to obtain an information service domain knowledge graph includes: S21, perform entity recognition on the information service data information to obtain entity information; S22, perform relation extraction on the entity information to obtain entity relation information; S23, perform attribute annotation on the entity and the entity relationship information to obtain entity triples; S24, process the entity triples to obtain an information service domain knowledge graph.
[0007] As an optional implementation, in the first aspect of the present invention, processing the entity triples to obtain an information service domain knowledge graph includes: S241, Perform same-name entity disambiguation processing on the entity triplet to obtain the first entity triplet; S242, perform conflict detection on the first entity triplet to obtain the second entity triplet; S243, perform knowledge completion on the second entity triple to obtain the information service domain knowledge graph.
[0008] As an optional implementation, in the first aspect of the present invention, the step of performing same-name entity disambiguation processing on the entity triples to obtain a first entity triple includes: S2411, Process the entities with the same name to be disambiguated in the entity triples to obtain a candidate entity set. Where d is the number of candidate entities, Let i be the i-th candidate entity, i = 1, 2, ..., d; S2412, Process the candidate entity set to obtain the feature vector of the candidate entity; the feature vector of the candidate entity includes attribute features, context relationship features and domain association features; S2413, Calculate the similarity of the feature vectors of the candidate entities to obtain the candidate entity similarity value; Among them, candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are Candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are , For entity attribute feature weights, Weights for the contextual relationship features of entities. For entity domain related feature weights, For entities and entity The similarity value of candidate entities; S2414, The similarity values of the candidate entities are processed to obtain the first entity triplet.
[0009] As an optional implementation, in the first aspect of the present invention, the step of performing knowledge completion on the second entity triple to obtain an information service domain knowledge graph includes: S2431, Map the second entity triple to obtain a low-dimensional semantic space representation; S2432, Process the low-dimensional semantic space representation to obtain matching information; The matching information expression is: Where is the dot product symbol, q To query the triple embedding vector, To match information, The preset balance coefficient, For entities The domain weights are either predefined or learned from domain data; S2433, Process the matching information to obtain normalized matching information; in To normalize the matching information, is a preset learnable parameter, and margin is a hyperparameter used to introduce a penalty term for negative samples in the denominator to enhance the ability to distinguish negative samples. S2434, The normalized matching information is processed to obtain a knowledge graph of the information service domain.
[0010] As an optional implementation, in the first aspect of the present invention, the processing of the user-input search query and the information service domain knowledge graph to obtain semantic search results includes: S31, preprocess the search statement entered by the user to obtain the preprocessed search statement; S32, perform semantic parsing on the preprocessed retrieval statement to obtain the target entity in the statement, the relationship between entities in the statement, and the attribute constraint information in the statement; S33, perform matching processing on the target entity in the statement and the information service domain knowledge graph to obtain the matching entity; S34, Process the relationship between the matching entity and the entity in the statement, and the attribute constraint information in the statement to obtain a set of candidate search paths; S35, perform semantic similarity calculation on the candidate retrieval path set and the retrieval statement input by the user to obtain a semantic similarity value; S36, Sort the semantic similarity values and output the candidate retrieval path corresponding to the maximum semantic similarity value as the semantic retrieval result.
[0011] As an optional implementation, in the first aspect of the present invention, processing the relationship between the matching entity and the entity in the statement, and the attribute constraint information in the statement, to obtain a candidate retrieval path set includes: S341, the matching entity is the starting node, and according to the relationship between entities in the statement, a breadth-first traversal is performed in the knowledge graph of the information service domain to obtain first-order directly related entities and first-order directly related entity relationships. S342, Process the first-order directly related entities and the first-order directly related entity relationships to obtain second-order directly related entities and second-order directly related entity relationships; S343, process the first-order directly related entities and the second-order directly related entities to obtain a set of candidate retrieval paths.
[0012] A second aspect of this invention discloses a semantic retrieval device based on a knowledge graph, the device comprising: The data acquisition module is used to acquire information service data; the information service data includes structured data, semi-structured data, and unstructured data. The knowledge graph construction module is used to process the information service data to obtain an information service domain knowledge graph; the information service domain knowledge graph includes an entity layer, a relation layer, and an attribute layer; The semantic retrieval module processes the user-input search query and the knowledge graph of the information service domain to obtain semantic retrieval results.
[0013] As an optional implementation, in the second aspect of the present invention, the processing of the information service data information to obtain an information service domain knowledge graph includes: S21, perform entity recognition on the information service data information to obtain entity information; S22, perform relation extraction on the entity information to obtain entity relation information; S23, perform attribute annotation on the entity and the entity relationship information to obtain entity triples; S24, process the entity triples to obtain an information service domain knowledge graph.
[0014] As an optional implementation, in the second aspect of the present invention, processing the entity triples to obtain an information service domain knowledge graph includes: S241, Perform same-name entity disambiguation processing on the entity triplet to obtain the first entity triplet; S242, perform conflict detection on the first entity triplet to obtain the second entity triplet; S243, perform knowledge completion on the second entity triple to obtain the information service domain knowledge graph.
[0015] As an optional implementation, in a second aspect of the present invention, the step of performing same-name entity disambiguation on the entity triples to obtain a first entity triple includes: S2411, Process the entities with the same name to be disambiguated in the entity triples to obtain a candidate entity set. Where d is the number of candidate entities, Let i be the i-th candidate entity, i = 1, 2, ..., d; S2412, Process the candidate entity set to obtain the feature vector of the candidate entity; the feature vector of the candidate entity includes attribute features, context relationship features and domain association features; S2413, Calculate the similarity of the feature vectors of the candidate entities to obtain the candidate entity similarity value; Among them, candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are Candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are , For entity attribute feature weights, Weights for the contextual relationship features of entities. For entity domain related feature weights, For entities and entity The similarity value of candidate entities; As an optional implementation, in the second aspect of the present invention, the step of performing knowledge completion on the second entity triple to obtain an information service domain knowledge graph includes: S2431, Map the second entity triple to obtain a low-dimensional semantic space representation; S2432, Process the low-dimensional semantic space representation to obtain matching information; The matching information expression is: Where is the dot product symbol, q To query the triple embedding vector, To match information, The preset balance coefficient, For entities The domain weights are either predefined or learned from domain data; S2433, Process the matching information to obtain normalized matching information; in To normalize the matching information, is a preset learnable parameter, and margin is a hyperparameter used to introduce a penalty term for negative samples in the denominator to enhance the ability to distinguish negative samples. S2434, The normalized matching information is processed to obtain a knowledge graph of the information service domain.
[0016] As an optional implementation, in the second aspect of the present invention, the processing of the user-input search query and the information service domain knowledge graph to obtain semantic search results includes: S31, preprocess the search statement entered by the user to obtain the preprocessed search statement; S32, perform semantic parsing on the preprocessed retrieval statement to obtain the target entity in the statement, the relationship between entities in the statement, and the attribute constraint information in the statement; S33, perform matching processing on the target entity in the statement and the information service domain knowledge graph to obtain the matching entity; S34, Process the relationship between the matching entity and the entity in the statement, and the attribute constraint information in the statement to obtain a set of candidate search paths; S35, perform semantic similarity calculation on the candidate retrieval path set and the retrieval statement input by the user to obtain a semantic similarity value; S36, Sort the semantic similarity values and output the candidate retrieval path corresponding to the maximum semantic similarity value as the semantic retrieval result.
[0017] As an optional implementation, in the second aspect of the present invention, the processing of the relationship between the matching entity and the entity in the statement, and the attribute constraint information in the statement, to obtain a candidate retrieval path set includes: S341, the matching entity is the starting node, and according to the relationship between entities in the statement, a breadth-first traversal is performed in the knowledge graph of the information service domain to obtain first-order directly related entities and first-order directly related entity relationships. S342, Process the first-order directly related entities and the first-order directly related entity relationships to obtain second-order directly related entities and second-order directly related entity relationships; S343, process the first-order directly related entities and the second-order directly related entities to obtain a set of candidate retrieval paths.
[0018] A third aspect of the present invention discloses another semantic retrieval device based on a knowledge graph, the device comprising: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute some or all of the steps in the knowledge graph-based semantic retrieval method disclosed in the first aspect of the present invention.
[0019] The fourth aspect of the present invention discloses a computer-storable medium storing computer instructions, which, when invoked, are used to execute some or all of the steps in the knowledge graph-based semantic retrieval method disclosed in the first aspect of the present invention.
[0020] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: This invention discloses a semantic retrieval method based on knowledge graphs. By processing information service data, a knowledge graph of the information service domain is obtained. Entity ambiguity is eliminated, and missing entities and relationships are supplemented. The generated domain knowledge graph possesses advantages in completeness and accuracy, providing reliable data support for precise semantic retrieval. By extracting target entities, relationships, and attribute constraints from the search query and combining them with the information service domain knowledge graph, the method overcomes the limitations of traditional keyword retrieval that relies solely on word matching, effectively avoiding the problem of irrelevant and redundant results caused by literal matching. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart illustrating a semantic retrieval method based on a knowledge graph disclosed in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a semantic retrieval device based on a knowledge graph disclosed in an embodiment of the present invention; Figure 3 This is a schematic diagram of another semantic retrieval device based on knowledge graphs disclosed in an embodiment of the present invention. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0024] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.
[0025] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0026] In all embodiments of the present invention, the variables involved in all computational expressions or mathematical functions are dimensionless before calculation. The values of the independent variables in all computational expressions or mathematical functions in these embodiments conform to the reasonable requirements of the input range of the computational expression or mathematical function, ensuring that the computational expression or mathematical function can be calculated smoothly without violating physical laws or mathematical rules.
[0027] This invention discloses a semantic retrieval method and apparatus based on a knowledge graph. The method includes acquiring information service data, which includes structured data, semi-structured data, and unstructured data; processing the information service data to obtain an information service domain knowledge graph, which includes an entity layer, a relation layer, and an attribute layer; and processing a user-input search query and the information service domain knowledge graph to obtain semantic retrieval results. This invention, by processing information service data to obtain an information service domain knowledge graph, extracts target entities, relationships, and attribute constraints from the search query. Combined with the information service domain knowledge graph, it overcomes the limitations of traditional keyword retrieval that relies solely on word matching, effectively avoiding the problem of irrelevant and redundant results caused by literal matching. Detailed explanations follow.
[0028] Example 1 Please see Figure 1 , Figure 1 This is a flowchart illustrating a semantic retrieval method based on a knowledge graph, as disclosed in an embodiment of the present invention. Figure 1 The described knowledge graph-based semantic retrieval method is applied in the field of semantic retrieval technology, and the embodiments of this invention are not limited thereto. Figure 1 As shown, this knowledge graph-based semantic retrieval method can include the following operations: S1, Obtain information service data; the information service data includes structured data, semi-structured data, and unstructured data; S2, process the information service data to obtain an information service domain knowledge graph; the information service domain knowledge graph includes an entity layer, a relation layer, and an attribute layer; S3, process the user-input search query and the information service domain knowledge graph to obtain semantic search results.
[0029] Optionally, processing the information service data to obtain an information service domain knowledge graph includes: S21, perform entity recognition on the information service data information to obtain entity information; S22, perform relation extraction on the entity information to obtain entity relation information; S23, perform attribute annotation on the entity and the entity relationship information to obtain entity triples; S24, process the entity triples to obtain an information service domain knowledge graph.
[0030] Optionally, processing the entity triples to obtain an information service domain knowledge graph includes: S241, Perform same-name entity disambiguation processing on the entity triplet to obtain the first entity triplet; S242, perform conflict detection on the first entity triplet to obtain the second entity triplet; Includes: relational logic conflict detection, removing mutually exclusive relation types between the same entity pairs; Attribute value conflict detection removes multiple mutually exclusive values of the same attribute from the same entity, or removes mutually exclusive attribute values from related entities. Domain rule conflict detection: If the entity-relation combination of a triple violates the predefined core rules of the domain, it will be removed. S243, perform knowledge completion on the second entity triple to obtain the information service domain knowledge graph.
[0031] Optionally, the step of performing same-name disambiguation on the entity triples to obtain the first entity triples includes: S2411, Process the entities with the same name to be disambiguated in the entity triples to obtain a candidate entity set. Where d is the number of candidate entities, Let i be the i-th candidate entity, i = 1, 2, ..., d; S2412, Process the candidate entity set to obtain the feature vector of the candidate entity; the feature vector of the candidate entity includes attribute features, context relationship features and domain association features; Attribute features include extracting entity-specific attribute information, such as entity type, domain, spatial location, temporal characteristics, core attribute parameters, etc. Extract the associated entities and relationships of an entity, construct a local context subgraph of the entity, and use the topological features of the subgraph (such as the number of associated entities, relationship type, and entity degree centrality) as context association features; Domain-specific association features: Extract domain-specific association attributes and convert them into binary / numerical features. S2413, Calculate the similarity of the feature vectors of the candidate entities to obtain the candidate entity similarity value; Among them, candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are Candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are , For entity attribute feature weights, Weights for the contextual relationship features of entities. For entity domain related feature weights, For entities and entity The similarity value of candidate entities; S2414, The similarity values of the candidate entities are processed to obtain the first entity triplet.
[0032] Entities with a similarity value higher than a preset threshold are grouped into the same entity, while entities with a similarity value lower than a preset threshold are marked as different entities and assigned a unique entity identifier, thus obtaining the first entity triplet.
[0033] Optionally, the step of performing knowledge completion on the second entity triple to obtain an information service domain knowledge graph includes: S2431, Map the second entity triple to obtain a low-dimensional semantic space representation; The second entity triple is processed to obtain neighbor information (based on the structural information of the knowledge graph, its multi-hop neighbor entities and relationships are extracted to construct a local subgraph). The neighbor information is processed to obtain a low-dimensional semantic space representation, including structural semantic embedding representation and text semantic embedding representation. S2432, Process the low-dimensional semantic space representation to obtain matching information; 1) Calculate the semantic similarity score of the text: This is the weight matrix of the neural network (Adaptive Cross-Modal Feedforward Network ACM-MLP). d Let be the dimension of the matrix. r For neighbor information, Embed vectors for predefined task relationships. For the information of the i-th neighbor, This refers to the bias information of the hybrid neural network. Score the semantic similarity of the text; Calculate the semantic attention weights of the text; For the first Text semantic attention weights of each neighbor node For the first Pre-defined task relationship embedding vectors: Text semantic entity embedding is performed to obtain text semantic embedding result e1; Let be the embedding vector of the adjacent entities of the i-th query head node; 2) Calculate the text structure similarity score; Given a node and its neighbor node set Then its population coefficient for: in, l This represents the actual number of edges that exist between a node and its neighboring nodes. d The number of neighboring nodes. Population coefficient. The value ranges from [0,1], and a higher value indicates that the neighbors of the node are more closely connected; Assign a score based on the similarity of the text structure. For query header entities, weight matrix Bias terms are used to learn the relationships between different dimensions. Used to adjust the model's output. Attention weights of the text structure of each neighboring node for: Text structure entity embedding is performed to obtain text structure embedding result e2; The semantic embedding result e1 and the structural embedding result e2 are fused to obtain the entity embedding result; Swish is the activation function of the adaptive cross-modal feedforward network ACM-MLP. For entity embedding results, , W4 , and The weight matrices are preset and independent. , ≠ , ).
[0034] The entity embedding results are processed using a Transformer encoder to obtain triple information. ; , For the tail entity embedding result, For relational embedding, This represents the concatenation operation; the calculation methods for tail entity embedding and relation embedding, and The calculation method is the same, and this embodiment does not impose any restrictions.
[0035] The triplet information is processed to obtain the query triplet embedding vector. q ; in This indicates a dynamic routing feedforward network. This indicates domain-aware multi-head attention.
[0036] Query triple embedding vector q The process is performed to obtain matching information; The matching information expression is: Where is the dot product symbol, q To query the triple embedding vector, To match information, The preset balance coefficient, For entities The domain weights are either predefined or learned from domain data; S2433, Process the matching information to obtain normalized matching information; in To normalize the matching information, is a preset learnable parameter, and margin is a hyperparameter used to introduce a penalty term for negative samples in the denominator to enhance the ability to distinguish negative samples. S2434, The normalized matching information is processed to obtain a knowledge graph of the information service domain.
[0037] Weighted embedding information; calculation of prediction scores : Select all possible tail entities from a pre-defined entity library to construct candidate triples. Based on the prediction scores, calculate the embedding score of each candidate triple relative to the reference prototype. , Candidate triples are represented by a threshold, and candidate triples with scores higher than the threshold are selected. The output is sorted: candidates are arranged in descending order of score, and the Top-N are selected as completion suggestions. The selected links are used to generate new triples, thereby completing the knowledge graph and obtaining a knowledge graph for the information service domain.
[0038] In the implementation of the above method, in each round of training, the negative sample q− with the highest predicted score of the current model is selected from the candidate set as a hard negative example, forcing the model to continuously learn subtle semantic differences. In the initial stage, easy negative examples (similarity < 0.4) are used for stable training, and then gradually transition to hard negative examples (similarity > 0.6) to alleviate the problem of early training oscillation in the model.
[0039] An improved interval ranking loss is adopted: in The interval hyperparameter controls the minimum difference between positive and negative sample scores. It is a dynamic interval hyperparameter, which is dynamically generated by the similarity between negative and positive samples. The higher the similarity, the larger the interval.
[0040] Optionally, the process of processing the user-input search query and the information service domain knowledge graph to obtain semantic search results includes: S31, preprocess the search statement entered by the user to obtain the preprocessed search statement; S32, perform semantic parsing on the preprocessed retrieval statement to obtain the target entity in the statement, the relationship between entities in the statement, and the attribute constraint information in the statement; S33, perform matching processing on the target entity in the statement and the information service domain knowledge graph to obtain the matching entity; S34, Process the relationship between the matching entity and the entity in the statement, and the attribute constraint information in the statement to obtain a set of candidate search paths; S35, perform semantic similarity calculation on the candidate retrieval path set and the retrieval statement input by the user to obtain a semantic similarity value; S36, Sort the semantic similarity values and output the candidate retrieval path corresponding to the maximum semantic similarity value as the semantic retrieval result.
[0041] Optionally, the step of processing the relationship between the matched entities and the entities in the statement, as well as the attribute constraint information in the statement, to obtain a candidate retrieval path set includes: S341, taking the matching entity as the starting node, and according to the entity association relationship in the statement, perform a breadth-first traversal in the information service domain knowledge graph to obtain first-order directly related entities and first-order directly related entity relationships. In a knowledge graph, a first-order directly related entity refers to all entities connected to the target entity through a direct relationship. A first-order directly related entity relationship refers to the type of direct relationship between the target entity and its first-order directly related entities.
[0042] Specifically, based on the relationships between entities in the statement, relationship filtering rules are constructed to retain only relationship types that match the search intent. The breadth-first search (BFS) algorithm is adopted, with a traversal depth of 1. Starting from the matching entity, all direct adjacent nodes in the knowledge graph that satisfy the relation filtering rules are traversed. The first-order directly related entities obtained by traversal are initially filtered in combination with the attribute constraint information in the statement: entities that do not satisfy the attribute constraints are eliminated; and a first-order path set is generated.
[0043] S342, Process the first-order directly related entities and the first-order directly related entity relationships to obtain second-order directly related entities and second-order directly related entity relationships; In a knowledge graph, a second-order directly associated entity refers to an entity that is indirectly connected to the target entity through a two-hop path of the target entity, a first-order associated entity, and a second-order associated entity. It is a first-order associated entity of a first-order associated entity (excluding the target entity itself). Second-order direct association entity relations refer to the combination of relations on the two-hop paths connecting the target entity and the second-order associated entity, as well as the direct relations between the second-order associated entity and the first-order associated entity.
[0044] Starting with the first-order directly related entities filtered in step S341, the breadth-first traversal is performed again using the relationship filtering rules of step S341, with a traversal depth of 1, to obtain the direct adjacent nodes of the first-order entities. The adjacent nodes obtained by traversal are deduplicated and excluded: nodes that are duplicates of the matching entities are removed, and redundant nodes that have appeared in the first-order path are removed. Combined with the attribute constraint information in the statement, the adjacent nodes are filtered a second time to obtain the second-order directly related entities that satisfy the constraints.
[0045] S343, Process the first-order directly related entities and the second-order directly related entities to obtain a candidate retrieval path set, including: Based on a domain core rule base using a knowledge graph in the information service domain, this study verifies the logical validity of first-order path set P1 and second-order path set P2, eliminating invalid paths that violate domain rules. It also verifies the consistency between the attributes of all entities in the path and the attribute constraints of the stated query, retaining paths that fully satisfy the constraints and marking partially satisfied paths as low-priority paths. Redundant paths with the same structure but different entity representations are merged, and paths with the same combination of path relationships are sorted by entity attribute similarity. Path priority rules are established: first-order paths have higher priority than second-order paths; paths satisfying all attribute constraints have higher priority than partially satisfied paths; paths that completely match the relevance of the search query have higher priority than partially matched paths. Finally, the hierarchical first-order and second-order paths are integrated to generate a final set of candidate search paths, which are then sorted by priority.
[0046] As can be seen, this invention discloses a semantic retrieval method based on a knowledge graph. By processing information service data, a knowledge graph of the information service domain is obtained, and entity ambiguity is eliminated, missing entities and relationships are supplemented. The generated domain knowledge graph has advantages in completeness and accuracy, providing reliable data support for precise semantic retrieval. By extracting target entities, relationships, and attribute constraints from the search query and combining them with the information service domain knowledge graph, the method overcomes the limitations of traditional keyword retrieval that relies solely on word matching, effectively avoiding the problem of irrelevant and redundant results caused by literal matching.
[0047] Example 2 Please see Figure 2 , Figure 2 This is a schematic flowchart of a semantic retrieval device based on a knowledge graph, as disclosed in an embodiment of the present invention. Figure 2 The described knowledge graph-based semantic retrieval device is applied in the field of semantic retrieval technology, and the embodiments of this invention are not limited thereto. Figure 2 As shown, the knowledge graph-based semantic retrieval device may include the following operations: S301, Data acquisition module, used to acquire information service data; the information service data includes structured data, semi-structured data, and unstructured data; S302, Knowledge Graph Construction Module, used to process the information service data information to obtain an information service domain knowledge graph; the information service domain knowledge graph includes an entity layer, a relation layer, and an attribute layer; S303, Semantic retrieval module, processes the user-input retrieval statement and the information service domain knowledge graph to obtain semantic retrieval results.
[0048] Example 3 Please see Figure 3 , Figure 3This is a schematic flowchart of another semantic retrieval device based on a knowledge graph disclosed in an embodiment of the present invention. Figure 3 The described knowledge graph-based semantic retrieval device is applied in the field of semantic retrieval technology, and the embodiments of this invention are not limited thereto. Figure 3 As shown, the knowledge graph-based semantic retrieval device may include the following operations: Memory 401 storing executable program code; Processor 402 coupled to memory 401; The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the knowledge graph-based semantic retrieval method described in Embodiment 1.
[0049] Example 4 This invention discloses a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program enables a computer to perform the steps in the knowledge graph-based semantic retrieval method described in Embodiment 1.
[0050] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0051] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0052] Finally, it should be noted that the semantic retrieval method and apparatus based on knowledge graph disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A semantic retrieval method based on knowledge graphs, characterized in that, The method includes: S1, Obtain information service data; the information service data includes structured data, semi-structured data, and unstructured data; S2, Process the information service data to obtain an information service domain knowledge graph; the information service domain knowledge graph includes an entity layer, a relation layer, and an attribute layer; S3, process the user-input search query and the information service domain knowledge graph to obtain semantic search results.
2. The semantic retrieval method based on knowledge graphs according to claim 1, characterized in that, The process of processing the information service data to obtain an information service domain knowledge graph includes: S21, perform entity recognition on the information service data information to obtain entity information; S22, perform relation extraction on the entity information to obtain entity relation information; S23, perform attribute annotation on the entity and the entity relationship information to obtain entity triples; S24, process the entity triples to obtain an information service domain knowledge graph.
3. The semantic retrieval method based on knowledge graphs according to claim 2, characterized in that, The process of processing the entity triples to obtain an information service domain knowledge graph includes: S241, Perform same-name entity disambiguation processing on the entity triplet to obtain the first entity triplet; S242, perform conflict detection on the first entity triplet to obtain the second entity triplet; S243, perform knowledge completion on the second entity triple to obtain the information service domain knowledge graph.
4. The semantic retrieval method based on knowledge graphs according to claim 3, characterized in that, The step of performing same-name disambiguation on the entity triples to obtain the first entity triples includes: S2411, Process the entities with the same name to be disambiguated in the entity triples to obtain a candidate entity set. Where d is the number of candidate entities, Let i be the i-th candidate entity, i = 1, 2, ..., d; S2412, Process the candidate entity set to obtain the feature vector of the candidate entity; the feature vector of the candidate entity includes attribute features, context relationship features and domain association features; S2413, Calculate the similarity of the feature vectors of the candidate entities to obtain the candidate entity similarity value; The expression for the candidate entity similarity value is: Among them, candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are Candidate entities The attribute characteristics are Contextual relationship features are Domain-related characteristics are , For entity attribute feature weights, Weights for the contextual relationship features of entities. For entity domain related feature weights, For entities and entity The similarity value of candidate entities; S2414, The similarity values of the candidate entities are processed to obtain the first entity triplet.
5. The semantic retrieval method based on knowledge graphs according to claim 3, characterized in that, The step of performing knowledge completion on the second entity triple to obtain an information service domain knowledge graph includes: S2431, Map the second entity triple to obtain a low-dimensional semantic space representation; S2432, Process the low-dimensional semantic space representation to obtain matching information; The matching information expression is: Where is the dot product symbol, q To query the triple embedding vector, To match information, The preset balance coefficient, For entities The domain weights are either predefined or learned from domain data; S2433, Process the matching information to obtain normalized matching information; in To normalize the matching information, is a preset learnable parameter, and margin is a hyperparameter used to introduce a penalty term for negative samples in the denominator to enhance the ability to distinguish negative samples. S2434, The normalized matching information is processed to obtain a knowledge graph of the information service domain.
6. The semantic retrieval method based on knowledge graphs according to claim 1, characterized in that, The process of processing the user-input search query and the information service domain knowledge graph to obtain semantic search results includes: S31, preprocess the search statement entered by the user to obtain the preprocessed search statement; S32, perform semantic parsing on the preprocessed retrieval statement to obtain the target entity in the statement, the relationship between entities in the statement, and the attribute constraint information in the statement; S33, perform matching processing on the target entity in the statement and the information service domain knowledge graph to obtain the matching entity; S34, Process the relationship between the matching entity and the entity in the statement, and the attribute constraint information in the statement to obtain a set of candidate search paths; S35, perform semantic similarity calculation on the candidate retrieval path set and the retrieval statement input by the user to obtain a semantic similarity value; S36, Sort the semantic similarity values and output the candidate retrieval path corresponding to the maximum semantic similarity value as the semantic retrieval result.
7. The semantic retrieval method based on knowledge graphs according to claim 6, characterized in that, The process of processing the relationships between the matched entities and the entities in the statement, as well as the attribute constraint information in the statement, to obtain a set of candidate search paths includes: S341, the matching entity is the starting node, and according to the relationship between entities in the statement, a breadth-first traversal is performed in the knowledge graph of the information service domain to obtain first-order directly related entities and first-order directly related entity relationships. S342, Process the first-order directly related entities and the first-order directly related entity relationships to obtain second-order directly related entities and second-order directly related entity relationships; S343, process the first-order directly related entities and the second-order directly related entities to obtain a set of candidate retrieval paths.
8. A semantic retrieval device based on a knowledge graph, characterized in that, The device includes: The data acquisition module is used to acquire information service data; the information service data includes structured data, semi-structured data, and unstructured data. The knowledge graph construction module is used to process the information service data to obtain an information service domain knowledge graph; the information service domain knowledge graph includes an entity layer, a relation layer, and an attribute layer; The semantic retrieval module processes the user-input search query and the knowledge graph of the information service domain to obtain semantic retrieval results.
9. A semantic retrieval device based on a knowledge graph, characterized in that, The device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the semantic retrieval method based on knowledge graph as described in any one of claims 1-7.
10. A computer-storable medium, characterized in that, The computer storage medium stores computer instructions, which, when invoked, are used to execute the knowledge graph-based semantic retrieval method as described in any one of claims 1-7.