Semantic search method based on knowledge graph embedding

By using semantic parsing-guided path search and composite knowledge embedding learning, the limitations of entity understanding and insufficient path reasoning in knowledge graph retrieval are solved, achieving efficient and accurate semantic retrieval and improving the retrieval accuracy and efficiency of complex queries.

CN122489781APending Publication Date: 2026-07-31GUANGDONG POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG POWER GRID CO LTD
Filing Date
2026-06-08
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing semantic retrieval methods based on knowledge graphs suffer from limitations in entity understanding, insufficient multi-hop path reasoning, coarse-grained alignment between queries and structured paths, blind search, and rigid decision-making mechanisms when handling complex queries, resulting in limited retrieval accuracy and efficiency.

Method used

An end-to-end solution is adopted, which uses semantic parsing-guided path search, composite knowledge embedding learning, multi-granularity interactive semantic matching, and adaptive gating fusion. By parsing user queries, generating multi-hop paths, and performing deep semantic alignment and matching, the final output is the retrieval result that best matches the query semantics.

Benefits of technology

It significantly improves the accuracy and efficiency of complex semantic retrieval tasks, can accurately identify query intent, reduce irrelevant path exploration, achieve fine-grained semantic matching and adaptive decision-making, and enhance the robustness and adaptability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122489781A_ABST
    Figure CN122489781A_ABST
Patent Text Reader

Abstract

This invention relates to the field of information technology, specifically to a semantic retrieval method based on knowledge graph embedding. The method includes parsing user input, extracting key entities as starting points for path search, and identifying the type of target entity and related semantic constraints indicated by the query; training and generating vector representations that simultaneously reflect entity semantics and graph structural features; exploring multi-hop paths guided by semantic constraints within the knowledge graph, starting from the initial entity, generating multiple candidate reasoning paths and performing preliminary ranking; performing deep semantic alignment and matching of each candidate reasoning path with the user query, calculating the semantic fit score between the path and the query; fusing the path generation quality score and the semantic fit score, comprehensively ranking all candidate paths, and finally outputting the retrieval result that best matches the query semantics. This invention can effectively improve the accuracy and efficiency of complex semantic retrieval based on knowledge graphs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information technology, and more particularly to a semantic query and understanding method based on knowledge graphs for information retrieval. Specifically, it relates to a semantic retrieval method based on knowledge graph embedding. Background Technology

[0002] With the exponential growth of internet information, users are demanding greater depth and precision in information retrieval. Traditional keyword matching retrieval methods struggle to handle queries like "Which science fiction author's works have been adapted into the most award-winning films?", which require understanding deep semantic intent and multi-step logical connections. Knowledge graphs, with their structured and relational data organization, provide an ideal modeling foundation for semantic retrieval. Currently, semantic retrieval methods based on Knowledge Graph Embedding (KGE) have become a research hotspot.

[0003] However, existing knowledge graph-based semantic retrieval methods still face a series of core challenges that limit their accuracy and efficiency when handling complex queries:

[0004] 1. Limitations of Entity and Intent Understanding: Existing methods mostly rely on named entity recognition modules to directly link entities in the query. However, for queries with complex modifiers, such as "Who was the head of our fastest-growing business unit last year?", entity recognition models struggle to accurately locate the overall concept of "fastest-growing business unit," thus failing to accurately determine the retrieval starting point or core intent in the knowledge graph.

[0005] 2. Limitations of Multi-hop Path Reasoning: Knowledge graph embedding models (such as TransE) primarily learn representations of single-step relationships between entities. For the overall semantics of a multi-hop reasoning path like "Company A → [Owns a subsidiary] → Department B → [Who is in charge] → Person C," it is difficult to form a coherent and compact representation. Simply accumulating or averaging the vectors of relationships along the path cannot effectively capture the complex semantics of the entire path, affecting the accuracy of path ranking.

[0006] 3. Coarse-grained alignment between query and structured path: After obtaining candidate inference paths, existing methods typically assess relevance only by calculating the similarity between the overall query vector and the overall path vector. This macro-level comparison ignores the fine semantic correspondence between specific modifiers in the user query (such as "highest box office" or "youngest") and specific relational fragments in the path (such as the "box office value" of a film or the "date of birth" of a person), leading to inaccurate matching.

[0007] 4. Blindness and Inefficiency of Search: When exploring multi-hop paths in a massive knowledge graph, classic graph search algorithms such as breadth-first search and depth-first search are prone to search space explosion or insufficient exploration due to a lack of goal orientation. Although heuristic search (such as A*) has improved this to some extent, in the knowledge graph domain, there is a lack of a high-quality heuristic function that can interact with query semantics in real time, resulting in a large number of candidate paths with low quality but few effective paths.

[0008] 5. Rigid decision-making mechanism: When ranking the final answer based on multi-source evidence (such as the structural reliability score and semantic matching score of the path), most systems use simple weighted summation or fixed rules. This "one-size-fits-all" strategy cannot dynamically adjust the weight of different evidence according to query type and path characteristics, limiting the system's adaptability to different scenarios.

[0009] To overcome the above challenges, this invention proposes an end-to-end solution that integrates semantic parsing-guided path search, composite knowledge embedding learning, multi-granularity interactive semantic matching, and adaptive gating fusion, aiming to significantly improve the performance of complex semantic retrieval tasks. Summary of the Invention

[0010] To overcome the shortcomings of existing technologies, this invention provides a semantic retrieval method based on knowledge graph embedding.

[0011] According to one aspect of the present invention, a semantic retrieval method based on knowledge graph embedding is provided, comprising: S1: parsing the natural language query input by the user, extracting key entities as the starting point for path search, and identifying the target entity type and related semantic constraints pointed to by the query; S2: training and generating a vector representation containing both entity semantics and graph structure features based on entity and relation data in the knowledge graph; S3: exploring multi-hop paths guided by semantic constraints in the knowledge graph, starting from the initial entity, generating multiple candidate reasoning paths and performing preliminary ranking; S4: performing deep semantic alignment and matching of each candidate reasoning path with the user query, and calculating the semantic fit score between the path and the query; S5: fusing the generation quality score and semantic fit score of the path, performing comprehensive ranking of all candidate paths, and finally outputting the retrieval result that best matches the query semantics.

[0012] In some optional implementations of some embodiments, S1 includes: encoding the natural language query input by the user using a pre-trained language model, identifying and extracting the hit entities using a sequence labeling model; associating and matching the extracted entities with nodes in the knowledge graph to determine the starting entity set for path search; and identifying the target entity type and the restrictions on entity attributes implicit in the query using a semantic parsing model.

[0013] In some optional implementations of some embodiments, S2 includes: learning basic vector representations of entities and relations based on a geometric transformation model; aggregating multi-hop neighborhood information of each entity using a graph neural network to generate an enhanced vector representation containing graph structural features; and fusing the basic vector representation and the enhanced vector representation to obtain a final embedded representation that combines semantic and structural information.

[0014] In some optional implementations of certain embodiments, the semantically constrained multi-hop path exploration in the knowledge graph in S3 includes: calculating the semantic similarity between the relationship to be expanded and the user query when expanding each node in the path search; retaining only relationships with semantic similarity higher than a preset threshold as candidate expansion directions to reduce the generation of irrelevant paths.

[0015] In some optional implementations of some embodiments, the preliminary sorting in S3 includes: comprehensively considering factors such as the confidence score of the path in the search process, the frequency of the path being selected by the exploration algorithm, and the preliminary semantic matching degree between the path and the user query to perform a preliminary sorting of the candidate paths.

[0016] In some optional implementations of certain embodiments, the step S4 of performing deep semantic alignment and matching between each candidate inference path and the user query includes: converting the user query and the candidate inference path into structured semantic representation sequences respectively; calculating the association strength between each semantic unit in the query and each segment in the path through a cross-attention mechanism; weighting the path segments based on the association strength to generate a path-enhanced representation that integrates query semantics; and fusing the path-enhanced representation with the global semantics of the query through multi-dimensional feature fusion to finally obtain a semantic fit score between the path and the query.

[0017] In some optional implementations of certain embodiments, the generation quality score and semantic fit score of the fusion path in S5 include: generating a dynamic weight coefficient for each candidate path based on semantic content; dynamically weighting and summing the generation quality score and semantic fit score of the path based on the generated dynamic weight coefficient to obtain the comprehensive score of the path; wherein the value of the dynamic weight coefficient is between 0 and 1, and is used to dynamically balance the contribution of the two scores in the final ranking.

[0018] In some optional implementations of certain embodiments, when the final output in S5 matches the retrieval result that best matches the query semantics, the answer aggregation process is also included: merging multiple candidate paths pointing to the same target entity; using the highest comprehensive score among all merged paths as the final score of the target entity; and sorting all target entities from high to low according to the final score to form the final retrieval result list.

[0019] According to a second aspect of the present invention, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the semantic retrieval method based on knowledge graph embedding.

[0020] According to a third aspect of the present invention, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the semantic retrieval method based on knowledge graph embedding.

[0021] Compared with the prior art, the present invention has the following significant advantages:

[0022] (1) Precise intent decomposition: By combining entity recognition and deep intent parsing, the system can accurately identify the starting point, target type and complex constraints in the query, providing a precise starting point and constraint direction for subsequent path search.

[0023] (2) Enhanced reasoning ability: By integrating complex spatial relation modeling and graph attention network into a composite embedding model, the representation of entities and relations contains both precise single-step relation logic and neighborhood structure information on multi-hop paths. This provides a high-quality embedding foundation for semantic similarity calculation and semantic alignment.

[0024] (3) Targeted and efficient path exploration: In real time, query semantics are introduced as a filtering condition in path search, so that the search process is guided by intent from the beginning, significantly reducing the unnecessary exploration of irrelevant branch paths, thereby generating higher quality candidate paths in a shorter time.

[0025] (4) Fine-grained, interaction-based semantic matching: fine-grained alignment of query and path is achieved through cross-attention mechanism, which can find the exact correspondence between specific concepts in the query and each step in the path, thereby achieving more accurate matching scores, which is better than existing methods that only make macro-global comparisons.

[0026] (5) Adaptive decision fusion: The introduced gating mechanism enables the system to automatically determine whether to rely more on the structural confidence obtained during the search or the subsequent semantic matching degree based on the semantic features of each path itself. For queries with stable structures and common paths, the search score dominates; for creative queries that rely on complex descriptions, the semantic matching degree weight may increase, thus enhancing the robustness and adaptability of the system. Attached Figure Description

[0027] Figure 1 This is the overall flowchart of the present invention.

[0028] Figure 2 This is a schematic diagram of an electronic device. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0030] Example 1

[0031] Reference Appendix Figure 1 This application provides a semantic retrieval method based on knowledge graph embedding. This method achieves accurate and efficient deep semantic retrieval on the knowledge graph, and mainly includes the following process: (1) In the query understanding stage, by combining a pre-trained model with a task-specific model, not only are entities identified, but the types and constraints in the query are also parsed, providing more accurate guidance information for subsequent steps; (2) In the knowledge representation stage, through the composite training of the RotatE model and GAT, more robust embedding vectors are obtained. These vectors can not only depict the precise semantics of single-step relationships, but also contain the contextual information of entities in the entire graph; (3) In the path search stage, semantic constraints are used to expand each step. Filtering is performed, upgrading the traditional knowledge graph search from simply pursuing the shortest path or random walk to a goal-oriented, task-driven guided heuristic search, which greatly improves search efficiency and the relevance of results; (4) In the semantic matching stage, a multi-granularity cross-attention mechanism is adopted to realize the modeling of asymmetric, fine-grained semantic association between query intent and structured path, making the matching score more accurate; (5) In the result fusion stage, a gating mechanism is used to dynamically adjust the weights of different evidence sources (structural reliability and semantic fit), which enhances the robustness of the system and its adaptability to different types of queries. Through the close collaboration of the above 5 steps, a closed loop is formed from "intent parsing" to "reasoning generation" to "accurate evaluation", which significantly improves the ability to handle complex semantic queries. The specific implementation steps of this method are as follows.

[0032] S1: Parse the natural language query input by the user, extract key entities as the starting point for path search, and identify the type of target entity and related semantic constraints pointed to by the query.

[0033] In one embodiment of this application, S1 includes: encoding the user query using a pre-trained language model (such as BERT), identifying and extracting named entities from it using a sequence labeling model (such as CRF); linking and matching the extracted entities with nodes in the knowledge graph to determine the starting entity set for path search; further, identifying the target entity type and the restrictions on entity attributes implicit in the query using a semantic parsing model (such as sequence-to-sequence architecture).

[0034] In one embodiment of this application, if a user inputs a natural language query text, such as "Which suspense film released after 2020 had the highest box office?", query parsing and intent structuring are performed through S1, specifically including: 1. Basic entity extraction: A BERT-CRF model fine-tuned with domain-specific data is used to perform named entity recognition on the query. Specifically, the BERT model encodes the query into word-level context vectors, and the CRF layer is responsible for predicting a "BIO" tag sequence for each word, completing the precise delineation of the boundaries of named entities in the text. For example, entities or conceptual phrases such as "suspense," "movie," and "highest box office" may be identified in this query, but the core objective of this step is to identify named entities that can be directly associated with knowledge graph nodes and have clear referents. In this example, the model may not directly identify "highest box office" as an entity, but it will identify "suspense" and "movie." The initially identified explicit entities, such as "suspense," may be associated with "type tag" nodes in the knowledge graph. 2. Target and Constraint Parsing: To address the complex modification problem, this invention introduces an independent semantic parsing model (which can be based on a pre-trained encoder-decoder, such as T5). The model takes the original query as input and outputs a structured query representation. This structured representation includes at least the following key parts: (1) Starting entity set: provided by the entity recognition module or supplemented by the parsing model (e.g., mapping "after 2020" to a time constraint). (2) Target entity type: the parsing model infers the type of answer the user is seeking, such as the target type being "movie" in this example. (3) Core relation chain: the model deconstructs the expected relation pattern implicit in the query, such as "release time later than AND type is [suspense] AND attribute [box office] takes the maximum value". (4) Constraints: specific constraints on the starting entity (if any, specific type restrictions may be required) and the target entity, such as the release time being "after 2020", the tag containing "suspense", and the aggregation attribute being "highest box office". This parsing step transforms vague and implicit intents into a structured query template, providing clear direction and filtering conditions for subsequent path searches. 3. Output: The final output is a structured query representation object containing the starting point (or starting constraint), the target path pattern (relationship chain and target entity type), and various constraints.

[0035] S2: Based on entity and relation data in the knowledge graph, train and generate vector representations that simultaneously reflect entity semantics and graph structure features.

[0036] In one embodiment of this application, S2 includes: employing a composite embedding learning framework. First, basic vector representations of entities and relations are learned based on geometric transformation models such as complex space rotation (e.g., RotatE). Second, a graph neural network (e.g., a graph attention network GAT) is used to aggregate multi-hop neighborhood information for each entity, generating an enhanced vector representation containing global graph structural features. Finally, the two representations are effectively fused to obtain entity and relation vectors that can simultaneously encode semantic and structural information.

[0037] In one embodiment of this application, the following example is used: If a user inputs: "Which suspense film released after 2020 had the highest box office?" A composite embedded knowledge graph representation is constructed using S2. To achieve high-quality multi-hop reasoning, a knowledge representation that can simultaneously capture fine-grained relational semantics and global graph structure is needed. This step uses a composite embedding framework instead of a single embedding model, specifically including: (1) Basic semantic embedding (relation modeling layer): RotatE is selected as the underlying relational model. (2) Structural enhancement embedding (neighborhood aggregation layer): Simultaneously, a graph attention network (GAT) is constructed. The RotatE representation of the entity (its real and imaginary parts are concatenated) is used as the initial node feature. Through one or more layers of graph attention aggregation, each entity aggregates its directly connected neighborhood information, and the different contributions of its different neighbors and relationships are judged by attention weights. Higher-level GATs propagate to second-order or even higher-order neighbors, thereby capturing structural patterns within a certain path. (3) Representation Fusion: For an entity, the RotatE representation (e.g., dimension 512) is concatenated with the structural representation of the final output of GAT (e.g., dimension 256) to obtain a high-dimensional fusion vector. This vector is then passed through a multilayer perceptron and projected onto a unified low-dimensional space to form the final entity embedding. Relation embedding is based on the RotatE vector, but can also be fused as needed. This process is trained end-to-end using a unified loss function. At the same time, the joint loss also needs to be considered. The overall loss is composed of the original objective function of RotatE (encouraging high scores for positive samples and low scores for negative samples) and a structural consistency loss about the GAT representation. For example, entity category information in the knowledge graph can be used as an auxiliary supervision signal for the GAT output. (4) Path Encoder Pre-training: In order to better perform complex pattern matching across knowledge units (relation sequences), a path encoder, such as a bidirectional GRU network, can be pre-trained. It takes the embedding vector sequence of relations at each step of the path as input and outputs a single vector representing the semantics of the entire path. The encoder can be trained by sampling a large number of reliable paths from the knowledge graph and pre-training it with the task of predicting the "head and tail entities" of the path, so that it learns the semantics contained in the combination of relation sequences.

[0038] S3: Starting from the initial entity, explore multi-hop paths guided by semantic constraints in the knowledge graph, generate multiple candidate reasoning paths and perform preliminary sorting.

[0039] In one embodiment of this application, the path exploration in S3 employs a semantic constraint-guided strategy. Specifically, at each node expansion step, the similarity (e.g., cosine similarity) between the relation to be expanded and the semantic vector parsed from the user query is calculated. Only relation edges with a similarity higher than a preset threshold are selected as subsequent expansion directions, thereby effectively pruning irrelevant branches and focusing on path regions strongly related to the query semantics.

[0040] In one embodiment of this application, given the starting entity set determined in S1, the structured intent, and the embedded vector representation learned in S2, the core task of this step is to efficiently and with high quality find the reasoning path connecting the starting point and the possible answer that conforms to the target type and constraints in the structured intent. This step is responsible for implementing query intent-driven heuristic path search. Multi-hop path search and sorting guided by semantic constraints are performed through S3, specifically including: 1. Initialization and semantic pruning: (1) Construct the root node of the search tree, corresponding to the set of all elements in the starting entity set; (2) Obtain the vector representing the core constraints / semantics from the structured query structured intent; (3) Define an expansion filtering rule: When exploring each node (corresponding to an entity) in the search tree, consider all the adjacency relationships of the current entity. For each adjacency relationship, calculate its cosine similarity with the query semantic vector and set a threshold. Only the relationship edge with a calculated cosine similarity greater than the set threshold is considered to be relevant to the current query and is added to the candidate list for this node expansion. This early pruning greatly reduces the branching factor of the search. 2. Heuristic-guided search (e.g., HC-MCTS): A feasible search scheme is a variant of Monte Carlo Tree Search (MCTS). Define the state: (1) Current path (the sequence of paths from the root node to the current entity). (2) Action: Select an edge that satisfies the above semantic filtering conditions for expansion. (3) Simulation (Rollout): Starting from a certain state, quickly simulate based on certain rules (e.g., select the edge with the highest cosine similarity with a certain probability), generate the complete path, and return the score. (4) Evaluation function: Evaluate the reward of the path after the simulation ends. The reward comprehensively considers: a. Global matching degree between the path and the query: Compare the representation vector of the entire path (which may be the mean of the relation vector or obtained through the path encoder of S2) with the vector of the core constraints / semantics. b. Path length penalty: Give a negative reward for excessively long paths. c. End point type conformity: If the type of the entity at the end of the path is consistent with the type of the target entity in the structured intent, a positive reward can be obtained. Furthermore, when selecting nodes for expansion, an upper confidence interval is used to balance exploration (actions with fewer visits) and exploitation (actions with high historical average rewards). This invention introduces heuristic information into the UCT formula, resulting in the following improved formula: In the formula: Let W represent the upper confidence threshold, W represent the cumulative reward, N represent the number of visits, and C represent the exploration coefficient. This represents the total number of visits to the parent node. H represents the number of visits to the current child node, and H represents the heuristic weight. This represents the semantic relevance score of the current edge. Semantic constraint score. 3. Path Collection and Preliminary Ranking: Through the above search strategy (running multiple iterations), the system will generate a large number of candidate paths. We collect these paths and calculate the confidence score accumulated during the generation process for each path, which can be obtained by combining the final access frequency in MCTS with the normalized average reward. Paths are sorted in descending order according to their confidence score or a comprehensive score combining their similarity to the query, and the top-ranked paths (e.g., top 10) are selected as candidate paths to proceed to the next step.

[0041] S4: Perform deep semantic alignment and matching of each candidate inference path with the user query, and calculate the semantic fit score between the path and the query.

[0042] In one embodiment of this application, S4 includes a refined semantic matching network. This network first converts the user query and candidate inference paths into structured semantic representation sequences, respectively. Then, through a cross-attention mechanism, it deeply computes the association strength matrix between each semantic unit (word / phrase) in the query and each semantic segment (relation / entity pair) in the path. Based on this association matrix, an enhanced path representation incorporating query semantics is generated, and then multi-dimensional feature fusion (such as concatenation, dot product, difference) is performed with the global semantics of the query. Finally, a multilayer perceptron computes a fine-grained semantic fit score between the path and the query.

[0043] In one embodiment of this application, for each candidate path, it is necessary to perform a more refined semantic comparison with the original natural language query (rather than just structured vectors). Deep semantic matching and fit calculation are performed through this step. A multi-granularity cross-attention matching network (MG-CAMN) is adopted, the core of which is to perform fine-grained, non-global semantic interaction analysis on the query and the path. The specific implementation steps include: 1. Dual sequence encoding: (1) Query encoding: The original query is encoded into a vector representation of a word sequence and a vector representation of the overall query using a model such as BERT. (2) Path sequence encoding: For candidate paths, the path is modeled as a sequence composed of several "step-entity units". Each unit is obtained by fusing the relation embedding of the step, the entity embedding of the node before the step and the entity embedding of the node after the step, so that the entire path constitutes a feature sequence. 2. Cross-attention calculation: Cross-attention calculation (Attention) is performed on the query sequence (as Query) and the path step sequence (as Key and Value) to generate a query-enhanced path representation. 3. Aggregation and Matching Score Calculation: (1) Segment-level matching: For each element in the query-enhanced path representation, interact with the overall query vector (e.g., concatenate and then add a small MLP_{seg}) to generate a unit-level matching vector. (2) Path-level aggregation: Aggregate all unit-level matching vectors into a fixed-dimensional path-level feature vector through a sequence model (e.g., LSTM, GRU). This aggregation may give higher weights to path segments that are more important to the final answer (e.g., segments that reflect constraints). (3) Final scoring: Input the fixed-dimensional path-level feature vector into a final classifier (e.g., a fully connected layer FCFC followed by a Sigmoid), and output a scalar between 0 and 1, representing the semantic fit score between this path and the original query. Then normalize, and use Softmax to obtain the normalized score for the scalars of the batch K paths (used for subsequent integration stages).

[0044] S5: The quality score and semantic fit score of the merged path generation are combined and ranked to finally output the retrieval result that best matches the query semantics.

[0045] In one embodiment of this application, S5 employs a gated adaptive fusion mechanism. For each candidate path, a weight coefficient (gating value) between 0 and 1 is dynamically generated based on the semantic representation of its path content. This gating value determines the weight of the "semantic fit score" and the "generation quality score" in the final score. Subsequently, the two scores are weighted and summed using the dynamic weight coefficient to obtain the comprehensive score for each path. Finally, multiple paths pointing to the same target entity are aggregated (e.g., taking the maximum value of their respective comprehensive scores), and different target entities are sorted in descending order of the aggregated scores, outputting the final retrieval result list.

[0046] In one embodiment of this application, each path at this point has two scores: 1) a generation quality score from the search phase (derived from the number of visits, rewards, etc. during the search process); and 2) a semantic fit score from S4. Simple linear combinations cannot capture the semantic characteristics of a path. Therefore, a gating mechanism is introduced in this step.

[0047] In one embodiment of this application, gated adaptive fusion and final answer output are performed via S5, including: 1. Gating value calculation: For each path, a path vector is obtained using its semantic features (e.g., from path sequence encoding via mean pooling or path encoder), and input into a gated network GateNet (e.g., a single fully connected layer + sigmoid activation function) to calculate a weight, as follows: In the formula: σ represents the weights; σ represents the Sigmoid activation function, with an output range of (0,1); Represents the weight matrix; Represents the path vector; This represents the bias term. This weight (i.e., the gating value) can adjust the weights of the two scoring sources based on the nature of the path itself. For example, if a path has a very rare structure, the generated quality score may be low, but the path semantics highly match the query description. In this case, it is desirable to have a higher weight, allowing the semantic fit score to dominate. 2. Final Path Score: The two scores are dynamically fused using the gating value, with the following formula: In the formula: This indicates the final fusion score; This represents the semantic fit score; This indicates the generation of a quality score. 3. Answer Aggregation: Several different paths may lead to the same candidate answer entity. Multiple paths pointing to the same target entity are aggregated (e.g., the maximum of their combined scores). 4. Sorting and Return: Finally, the results are sorted in descending order based on the final score of each candidate answer entity, and a sorted list is returned. The output can be the top-ranked entities, or it can include explanatory paths.

[0048] This invention constructs a complete closed-loop system, from initial query understanding to refined reasoning and decision-making, through the aforementioned steps. First, through deep analysis of the query, the starting and ending constraints of the retrieval are accurately located. Second, by combining relational embedding based on complex rotation with structural aggregation based on graph neural networks, a composite knowledge representation capable of supporting multi-step relational reasoning is provided. Third, the real-time guidance of path generation using query semantics significantly improves search efficiency and directionality. Fourth, by introducing a cross-attention mechanism, fine-grained, asymmetric semantic correspondence between queries and paths is modeled. Finally, a gating fusion mechanism enables the system to intelligently balance the structural confidence and semantic fit of paths, enhancing the system's robustness and adaptability. Experimental results demonstrate that this invention significantly improves accuracy and recall compared to baseline methods when dealing with complex semantic queries requiring multi-hop reasoning.

[0049] Example 2

[0050] Based on Embodiment 1 described above, this embodiment also provides an electronic device, please refer to the appendix. Figure 2 , Figure 2 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.

[0051] like Figure 2 As shown, an electronic device may include a processing unit (such as a central processing unit, graphics processing unit, etc.) that can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) or a program loaded from a storage device into random access memory (RAM). The RAM also stores various programs and data required for the operation of the electronic device. The processing unit, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also connected to the bus.

[0052] Typically, the following devices can be connected to an I / O interface: input devices such as touchscreens, touchpads, keyboards, mice, and cameras; output devices such as liquid crystal displays (LCDs) and speakers; storage devices such as magnetic tapes and hard drives; and communication devices. Communication devices allow electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 2 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively. Figure 2 Each box shown can represent a device or multiple devices as needed.

[0053] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined above in the methods of some embodiments of this disclosure.

[0054] Example 3

[0055] Based on Embodiment 1 above, this embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the above method.

[0056] It should be noted that, in some embodiments of this disclosure, the computer-readable medium described above may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In some embodiments of this disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In some embodiments of this disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), or any suitable combination thereof.

[0057] In this embodiment, the client and server can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol), and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.

[0058] The aforementioned computer-readable medium may be included in the aforementioned device or may exist independently without being assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: parse the natural language query input by the user, extract key entities as starting points for path search, and identify the target entity type and related semantic constraints pointed to by the query; based on entity and relation data in the knowledge graph, train and generate vector representations containing both entity semantics and graph structural features; starting from the initial entity, conduct multi-hop path exploration in the knowledge graph guided by semantic constraints, generate multiple candidate reasoning paths and perform preliminary ranking; perform deep semantic alignment and matching of each candidate reasoning path with the user query, and calculate the semantic fit score between the path and the query; fuse the path generation quality score and the semantic fit score, comprehensively rank all candidate paths, and finally output the retrieval result that best matches the query semantics.

[0059] Computer program code for performing operations of some embodiments of this disclosure can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0060] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0061] The functions described above in this document can be performed at least in part by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), etc.

[0062] Obviously, those skilled in the art will understand that the various steps of the present invention described above can be performed in ways different from those described herein, and the simulation methods and experimental equipment include, but are not limited to, the above description. The steps of the present invention described above can be performed in a different order in certain circumstances, and the steps shown or described above can be performed separately. Therefore, the present invention is not limited to any particular combination of hardware and software.

[0063] The above description, in conjunction with specific embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such deductions or substitutions should be considered within the scope of protection of the present invention.

Claims

1. A semantic search method based on knowledge graph embedding, characterized in that, include: S1: Parse the natural language query input by the user, extract key entities as the starting point for path search, and identify the type of target entity and related semantic constraints pointed to by the query; S2: Based on entity and relation data in the knowledge graph, train and generate vector representations that simultaneously reflect entity semantics and graph structure features; S3: Starting from the initial entity, explore multi-hop paths guided by semantic constraints in the knowledge graph, generate multiple candidate reasoning paths and perform preliminary sorting; S4: Perform deep semantic alignment and matching of each candidate reasoning path with the user query, and calculate the semantic fit score between the path and the query; S5: The quality score and semantic fit score of the merged path generation are combined and ranked to finally output the retrieval result that best matches the query semantics.

2. The semantic retrieval method based on knowledge graph embedding according to claim 1, characterized in that, S1 includes: A pre-trained language model is used to encode the natural language query input by the user, and a sequence labeling model is used to identify and extract the hit entities; The extracted entities are associated and matched with nodes in the knowledge graph to determine the starting set of entities for path search; The semantic parsing model identifies the target entity type implicit in the query and the restrictions on entity attributes.

3. The semantic retrieval method based on knowledge graph embedding according to claim 1, characterized in that, S2 includes: Learning the basic vector representations of entities and relationships based on geometric transformation models; A graph neural network is used to aggregate the multi-hop neighborhood information of each entity to generate an enhanced vector representation containing graph structure features; By fusing the basic vector representation with the enhanced vector representation, a final embedded representation that combines semantic and structural information is obtained.

4. The semantic retrieval method based on knowledge graph embedding according to claim 1, characterized in that, The semantically constrained multi-hop path exploration in the knowledge graph in S3 includes: At each step of the path search, when expanding a node, the semantic similarity between the relationship to be expanded and the user query is calculated. Only relationships with semantic similarity higher than a preset threshold are retained as candidate expansion directions to reduce the generation of irrelevant paths.

5. The semantic retrieval method based on knowledge graph embedding according to claim 1, characterized in that, The preliminary sorting in S3 includes: The candidate paths are initially ranked by comprehensively considering factors such as the confidence score of the path during the search process, the frequency of the path being selected by the exploration algorithm, and the initial semantic matching degree between the path and the user query.

6. The semantic retrieval method based on knowledge graph embedding according to claim 1, characterized in that, The step S4, which involves performing deep semantic alignment and matching of each candidate inference path with the user query, includes: The user query and candidate inference path are respectively converted into a sequence of structured semantic representations; The cross-attention mechanism is used to calculate the association strength between each semantic unit in the query and each segment in the path; Path segments are weighted based on association strength to generate a path-enhanced representation that integrates query semantics; The path augmentation representation is fused with the global semantics of the query through multi-dimensional feature fusion, and finally the semantic fit score between the path and the query is obtained.

7. The semantic retrieval method based on knowledge graph embedding according to claim 1, characterized in that, The generation quality score and semantic fit score of the fusion path in S5 include: For each candidate path, a dynamic weight coefficient is generated based on the semantic content; Based on the generated dynamic weight coefficients, the path generation quality score and semantic fit score are dynamically weighted and summed to obtain the path's comprehensive score. The dynamic weight coefficient ranges from 0 to 1 and is used to dynamically balance the contributions of the two scores in the final ranking.

8. The semantic retrieval method based on knowledge graph embedding according to claim 1, characterized in that, When the final output in S5 matches the retrieval result that best matches the query semantics, it also includes an answer aggregation process: Multiple candidate paths pointing to the same target entity will be merged; The highest overall score among all merged paths is taken as the final score for the target entity. Sort all target entities from highest to lowest according to their final scores to form the final search results list.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the semantic retrieval method based on knowledge graph embedding as described in any one of claims 1 to 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the semantic retrieval method based on knowledge graph embedding as described in any one of claims 1 to 8.