Intelligent retrieval method and system based on knowledge graph index and large model optimization
Patent Information
- Application Number
- CN202511901977.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-10-27
- Estimated Expiration
- 2045-12-17
AI Technical Summary
传统生成式模型(如GPT等)主要依赖模型自身参数中存储的知识进行内容生成,这种模式存在几个关键缺陷:首先,模型的知识完全来源于训练数据,存在严重的知识固化问题,训练截止日期后的新知识无法被模型获取和使用,导致生成内容经常出现事实性错误或过时信息
利用大型语言模型对数据集进行深度分析,精准识别其中的三元组,从而基于三元组构建结构化的知识图谱,同时对知识图谱中的实体节点、实体节点之间的关系、实体节点在输入数据中对应的实体描述文本以及实体节点之间的关系在输入数据中对应的关系描述文本进行向量化,并将向量化结果存储至向量数据库,实现双轨查询。在此基础上,引入了多级语义关联机制,通过计算基于“拓扑最短路径”与“向量余弦相似度”的混合相似度评分,当置信度超过阈值时动态在非直连节点间建立“语义强相关”边,显著丰富知识图谱的语义连接,为后续的逻辑推理提供更丰富的语义基础。
Smart Images

Figure CN121743470B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing, and more specifically, relates to an intelligent retrieval method and system based on knowledge graph indexing and large model optimization. Background Technology
[0002] Against the backdrop of the rapid development of artificial intelligence technology, Retrieval Augmented Generation (RAG) technology has emerged as a crucial bridge connecting large-scale knowledge bases and generative AI. This technology's rise stems from the knowledge lag and illusion problems inherent in traditional large language models, particularly evident in applications requiring precise professional knowledge. Traditional generative models (such as GPT) primarily rely on knowledge stored in the model's own parameters for content generation. This approach suffers from several key drawbacks: First, the model's knowledge is entirely derived from training data, leading to severe knowledge stagnation. New knowledge acquired after the training deadline cannot be acquired or used by the model, resulting in frequent factual errors or outdated information in the generated content. Second, the model's parameter capacity is limited, making it difficult to accurately memorize massive amounts of detailed knowledge. This is especially problematic in scenarios requiring precise data in specialized fields (such as logistics route planning and medical diagnosis), often producing seemingly reasonable but actually erroneous "illusionary" answers. RAG effectively addresses the limitations of generative models in terms of factual accuracy by organically combining external knowledge retrieval with text generation capabilities. Its core idea is to dynamically retrieve relevant information as contextual basis during the generation process, significantly improving the credibility and professionalism of the generated content. Despite the immense potential of RAG technology, it still faces numerous technical challenges in practical applications. In the retrieval stage, the semantic gap limits the accuracy of matching query intent with document relevance, particularly the lexical mismatch when dealing with specialized terminology, which can reduce recall by 15-20%. The conflict between real-time requirements and computational costs is becoming increasingly acute. At the model level, the collaborative optimization of retrieval and generation modules suffers from conflicting objective functions; the retrieval engine prioritizes recall while the generator focuses on fluency, an inherent contradiction that makes end-to-end training convergence difficult. Furthermore, the problem of broken reasoning chains in complex queries is prevalent. In logistics route planning scenarios requiring multi-hop reasoning, the accuracy of a single retrieval decreases exponentially with the number of hops. These challenges are driving academia and industry to explore next-generation RAG architectures, including innovative directions such as reinforcement learning-based joint training of retrieval and generation, incremental index update algorithms, and knowledge integrity verification mechanisms.
[0003] Current RAG (Retrieval and Generation) technical solutions mainly revolve around the collaborative optimization of retrieval and generation, resulting in several typical paradigms in architectural design. Based on the differences in retrieval timing, existing solutions can be divided into three categories: retrieval-pre-processing, iterative retrieval, and generation-guided. Retrieval-pre-processing adopts a classic two-stage process, first retrieving relevant documents from the knowledge base through dense retrieval (such as DPR, ANCE) or sparse retrieval (such as BM25, SPLADE), and then inputting them into a large language model to generate answers. This approach is simple to implement but suffers from the problem of inconsistency between retrieval and generation goals. Iterative retrieval optimizes retrieval results through multiple rounds of interaction, with typical examples such as FLARE and IRCot. They dynamically trigger new retrieval requests during the generation process, gradually improving contextual information. Although the results are better, the computational cost is higher. Generation-guided approaches allow the language model to actively guide the retrieval process. For example, Self-RAG uses special tags to predict when a retrieval is needed, achieving finer control but significantly increasing training complexity. In terms of knowledge fusion, existing technologies mainly explore three paths: direct concatenation simply appends the retrieval results to the input, which is computationally efficient but results in coarse information integration; attention injection uses cross-attention mechanisms (such as REPLUG and RETRO) to deeply interact with the retrieval document and the generation process, achieving better results but requiring high GPU memory; and knowledge distillation first compresses and summarizes the retrieval results (such as DSI) before inputting them into the generation model, balancing performance and efficiency. For optimization in specialized domains, the industry has also developed hybrid retrieval schemes, combining semantic vectors, keyword matching, and metadata filtering (such as time and region) to improve recall accuracy, as well as structured knowledge retrieval based on graph databases, transforming knowledge graph relationship paths into generated prompt words. Regarding training strategies, in addition to standard supervised fine-tuning, contrastive learning (such as COGENT) optimizes the retrieval machine through positive and negative examples, reinforcement learning (such as RAR) optimizes the overall effect of retrieval generation end-to-end, and adapter fine-tuning (such as kNN-LM) keeps the base model frozen and only trains lightweight modules. These technical solutions each have their own focus, collectively driving the continuous progress of RAG systems in terms of knowledge coverage, factual accuracy, and reasoning ability.
[0004] Existing RAG technology still has significant shortcomings in terms of query relevance and response speed in general domains. Regarding semantic relevance, traditional retrieval models have limited ability to capture professional terminology and domain-specific expressions. When processing professional content such as medical and legal documents, the false negative rate for key documents generally exceeds 30%, while returning a large number of semantically relevant but practically irrelevant interference results. In terms of query processing mechanisms, existing systems lack sufficient understanding of queries containing professional abbreviations (such as "EGFR" and "CRP" in medicine) or compound concepts (such as "targeted therapy for non-small cell lung cancer"), leading to a decrease in exact match rate of over 40%. Regarding response speed, GPU-based dense retrieval often exceeds 800ms latency when dealing with a document database of hundreds of millions, while traditional inverted indexes can control latency within 300ms, but at the cost of over 25% in recall. System scalability also has bottlenecks; when the document scale exceeds tens of millions, query latency increases exponentially, with P99 latency reaching over 2 seconds. Furthermore, the existing RAG lacks effective query expansion and rewriting mechanisms, and its tolerance for queries with ambiguous descriptions or incomplete information (such as mistakenly writing "cardiac machine therapy" instead of "myocardial infarction treatment plan") is poor, with the accuracy of such queries fluctuating by as much as 50%. These technical deficiencies severely restrict the practical application of the RAG system in some professional service scenarios. Summary of the Invention
[0005] In view of the above-mentioned defects or improvement needs of the existing technology, the present invention provides an intelligent retrieval method and system based on knowledge graph indexing and large model optimization.
[0006] To achieve the above objectives, according to a first aspect of the present invention, an intelligent retrieval method based on knowledge graph indexing and large model optimization is provided, comprising: S1, using a large language model to extract entities and relationships between entities from the input data, and constructing a structured knowledge graph based on the entities and relationships between entities in the input data; S2, the entity nodes, relationships between entity nodes, entity description text corresponding to entity nodes in the input data, and relationship description text corresponding to relationships between entity nodes in the input data in the knowledge graph are vectorized, and the vectorized entity nodes, relationships between entity nodes, entity description text, and relationship description text are stored in the vector database. S3, link the vector of the entity node to the corresponding node in the knowledge graph; calculate the cosine similarity between any two entity nodes based on their vectors; calculate the mixed similarity between any two entity nodes based on their cosine similarity and the shortest path distance between them; add a strongly related semantic edge to two non-directly connected entity nodes whose mixed similarity is higher than a preset threshold. S4. Based on the query text input by the user, retrieve the knowledge graph and the vector database to obtain the retrieval results, and use the generative model to generate query return results in natural language form based on the retrieval results.
[0007] Based on the aforementioned intelligent retrieval method using knowledge graph indexing and large model optimization, the mixed similarity between any two entity nodes is... It is calculated based on the following formula:
[0008] in, The shortest path distance between any two entity nodes is the topological distance. Let be the cosine similarity between any two entity nodes. and This is the adjustment coefficient.
[0009] According to the above-mentioned intelligent retrieval method based on knowledge graph indexing and large model optimization, the step of retrieving the knowledge graph and the vector database based on the user-input query text to obtain retrieval results specifically includes: Based on a large language model, the query entities in the query text and the implicit intent descriptions of the query entities are identified; After vectorizing the query entity and the implicit intent description between query entities, the vector database is retrieved to locate the K candidate nodes in the knowledge graph that are most similar to the query entity and the high-confidence relationship that matches the implicit intent description. Based on the candidate nodes and the high-confidence relationship, the knowledge graph is subjected to diffusion propagation search to obtain N nodes most similar to the query entity, and the retrieval result is determined based on the N nodes most similar to the query entity; where N>K.
[0010] Based on the aforementioned intelligent retrieval method using knowledge graph indexing and large model optimization, a diffusion propagation search is performed on the knowledge graph based on the candidate nodes and the high-confidence relationship to obtain the N nodes most similar to the query entity, specifically including: Based on the pairwise transition probabilities between each entity node in the knowledge graph, a transition matrix is constructed. The transition probability between two entity nodes is the normalized semantic relevance score of the edge between the two entity nodes, and the normalized semantic relevance score of the outgoing edge corresponding to the high confidence relationship among the outgoing edges of the candidate node is higher than that of other outgoing edges. Construct a personalized vector with the same dimension as the number of entity nodes in the knowledge graph. ; wherein, the personalized vector The position corresponding to the candidate node is assigned a non-zero value, while the other positions are 0; The damping factor of each entity node is calculated based on the following formula:
[0011] in, Let i be the damping factor of entity node i. Let i be the degree of entity node i. It is a natural constant; Based on the transition matrix The personalized vector and a matrix composed of the damping factors of each entity node. The PageRank algorithm is executed iteratively until convergence, and the PageRank score of each entity node is obtained. Based on the PageRank score of each entity node, the N nodes with the highest PageRank scores are selected.
[0012] Based on the aforementioned intelligent retrieval method using knowledge graph indexing and large model optimization, the retrieval results are determined based on the N nodes most similar to the query entity, specifically including: Obtain the entity description texts corresponding to the N nodes most similar to the queried entity as candidate texts; Relationships are extracted from each candidate text to obtain the relationship between two entities in the corresponding candidate text. The relationship between two entities in the corresponding candidate text is then compared with the relationship represented by the path between the corresponding nodes of the two entities extracted from the knowledge graph. If the relationship between two entities in any candidate text is inconsistent with the relationship represented by the path between the corresponding nodes of the two entities extracted from the knowledge graph, then the candidate text is filtered or its confidence level is reduced to obtain the retrieval results composed of each candidate text.
[0013] Based on the aforementioned intelligent retrieval method using knowledge graph indexing and large model optimization, a generative model is used to generate query results in natural language form based on the retrieval results, specifically including: A global relevance score is performed on the candidate texts in the search results to obtain a global relevance score for each candidate text. The candidate texts are sorted to obtain a text sequence; the candidate texts with the highest and second highest global relevance scores are located at the beginning and end of the text sequence, respectively, and the remaining candidate texts are arranged in descending order of global relevance scores. Based on the entity type of the query entity, a preset inference template is selected, and the N nodes most similar to the query entity and the high confidence relationship are filled into the inference template to form a structured prompt word containing explicit inference steps; The structured prompts and the text sequence are input into the generation model to obtain the query return results generated by the generation model for the query text.
[0014] Based on the aforementioned intelligent retrieval method using knowledge graph indexing and large model optimization, the generated model was fine-tuned in the following manner: Obtain the query return results generated by the generative model for the sample query text; Based on the reward model, the entities contained in the query results corresponding to the sample query text are mapped back to the knowledge graph. The subgraph structure corresponding to the entity is extracted, and a structural consistency embedding vector between the subgraph structure corresponding to the entity and the query results corresponding to the sample query text is generated. Based on the structural consistency embedding vector, the degree of fit between the query results corresponding to the sample query text and the knowledge graph is output. The model loss is calculated based on the degree of fit, and the generated model is fine-tuned based on the model loss.
[0015] Based on the aforementioned intelligent retrieval method using knowledge graph indexing and large model optimization, the model loss is calculated using the following loss function:
[0016] in, The parameters representing the generated model, This represents the output of the generative model. This is the sample query text. To and Semantically relevant or logically correct positive candidate texts To and Negative candidate texts that are semantically irrelevant or logically flawed It is the Sigmoid activation function. This represents the expected value on the training dataset D. The higher the degree of consistency, the smaller the penalty for factual deviation. This is the balance coefficient.
[0017] According to a second aspect of the present invention, an intelligent retrieval system based on knowledge graph indexing and large model optimization is provided for performing the method described in the first aspect.
[0018] According to a third aspect of the present invention, an electronic device is provided, comprising: a computer-readable storage medium and a processor; The computer-readable storage medium is used to store executable instructions; The processor is configured to read executable instructions stored in the computer-readable storage medium and execute the method as described in the first aspect.
[0019] In summary, compared with the prior art, the above-described technical solutions conceived by this invention can achieve the following beneficial effects: This study leverages a large-scale language model to perform deep analysis on a dataset, accurately identifying triples and constructing a structured knowledge graph based on these triples. Simultaneously, it vectorizes entity nodes, relationships between entity nodes, entity description text corresponding to entity nodes in the input data, and relationship description text corresponding to relationships between entity nodes in the input data, storing the vectorized results in a vector database for dual-track querying. Building upon this foundation, a multi-level semantic association mechanism is introduced. By calculating a hybrid similarity score based on "topological shortest path" and "vector cosine similarity," semantically strong edges are dynamically established between non-directly connected nodes when the confidence level exceeds a threshold. This significantly enriches the semantic connections of the knowledge graph, providing a richer semantic foundation for subsequent logical reasoning.
[0020] Furthermore, a deep integration of vector databases and knowledge graphs forms an efficient retrieval architecture. During the retrieval phase, a large-scale language model is used to identify the core query entities and their implicit intent descriptions in the user's query text. Subsequently, based on these two types of information, the vector database is searched, quickly locating potential knowledge sources and significantly narrowing the search scope. Building upon this, a semantic-topologically coupled adaptive random walk algorithm is used to achieve diffusion propagation search within the knowledge graph. Logical reasoning is then performed using the knowledge graph, ensuring the accuracy and logical consistency of the retrieval results.
[0021] Furthermore, the retrieved multi-source candidate texts are relevance-scored, and a "bidirectional peak focusing" strategy is employed to reorganize the context layout according to the principle of "high at the beginning and end, low in the middle" to alleviate the attention loss phenomenon in long texts. Additionally, a reward model with a graph adaptation layer is constructed to calculate the structural consistency embedding vector between the generated content of the generative model and the graph facts. Finally, a multi-objective loss function including ranking loss and fact deviation penalty is defined, and the generative model parameters are updated using a proximal policy optimization algorithm. High negative feedback suppresses generation paths that conflict with graph facts, causing the parameter distribution of the generative model to gradually converge towards the high-reward region. This allows it to spontaneously avoid fact-incorrect generation paths in subsequent reasoning, gradually "learning" to generate high-quality answers that conform to the knowledge graph logic. Attached Figure Description
[0022] Figure 1 This is a flowchart illustrating the intelligent retrieval method based on knowledge graph indexing and large model optimization provided in an embodiment of the present invention. Figure 2 A schematic diagram of a user query process provided in an embodiment of the present invention; Figure 3 A schematic diagram illustrating the knowledge graph node propagation process provided in an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the fine-tuning of the generative model provided in an embodiment of the present invention. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.
[0024] This invention provides an intelligent retrieval method based on knowledge graph indexing and large model optimization, such as... Figure 1 As shown, it includes: S1, using a large language model to extract entities and relationships between entities from the input data, and constructing a structured knowledge graph based on the entities and relationships between entities in the input data; S2, the entity nodes, relationships between entity nodes, entity description text corresponding to entity nodes in the input data, and relationship description text corresponding to relationships between entity nodes in the input data in the knowledge graph are vectorized, and the vectorized entity nodes, relationships between entity nodes, entity description text, and relationship description text are stored in the vector database. S3, link the vector of the entity node to the corresponding node in the knowledge graph; calculate the cosine similarity between any two entity nodes based on their vectors; calculate the mixed similarity between any two entity nodes based on their cosine similarity and the shortest path distance between them; add a strongly related semantic edge to two non-directly connected entity nodes whose mixed similarity is higher than a preset threshold. S4. Based on the query text input by the user, retrieve the knowledge graph and the vector database to obtain the retrieval results, and use the generative model to generate query return results in natural language form based on the retrieval results.
[0025] This invention relies on the general domain knowledge of a large-scale language model as its foundation, and achieves a comprehensive improvement in semantic understanding and index query speed through multi-stage collaborative optimization of vector databases and knowledge graphs. First, a large-scale language model is used to extract entity-relationship triples from structured and unstructured input data, constructing a basic graph architecture with the Neo4j graph database as the storage carrier. Simultaneously, BERT semantic vectors, TransE structural vectors, and multi-hop neighbor features aggregated by the Graph Attention Network (GAT) are integrated to construct the FAISS vector database, achieving dual-track storage of "graph structure + vector embedding". Specifically, the input data covers two categories: structured data (such as existing business databases and Excel reports) and unstructured text data (such as industry documents, PDF reports, and log files). Entities and relations are extracted from the preprocessed input data (e.g., noise filtering), and these entities and relations are stored as nodes and edges using the storage capacity of the graph database. Neo4j's Cypher language can be used to create nodes and relations, constructing a structured knowledge graph.
[0026] To filter more relevant entities and select a more suitable query starting point (i.e., the set of nodes that serve as the initial active state in the graph traversal algorithm, usually directly mapped from the keywords in the user's query), thus narrowing the query scope, this embodiment of the invention also simultaneously constructs a vector database. Here, the BERT embedding model can be used to convert text data into vectors, and the TransE algorithm is employed to optimize the relationship mapping between entities, ensuring that the geometric constraint "head entity + relation ≈ tail entity" holds. Simultaneously, to better capture long-distance semantic dependencies, a graph attention network is further introduced to weighted aggregate multi-hop relationship paths during entity vectorization. The specific process includes: for each entity node in the knowledge graph, calculating its attention coefficient with neighboring nodes and their connections, which is obtained by concatenating the head entity vector, relation vector, and tail entity vector (which can be provided by the BERT and TransE algorithms) through a linear transformation layer; normalizing the attention coefficient using the Softmax function to obtain the importance weights of different neighboring nodes to the current node; and, based on the calculated importance weights, weighted summing of entity vectors on multi-hop paths to obtain the new entity vector for the current node, thereby generating an enhanced node representation containing long-range semantic dependencies. Furthermore, embodiments of the present invention also vectorize the entity description text (i.e., sentences or paragraphs containing entities) corresponding to entity nodes in the input data, as well as the relationship description text (i.e., sentences or paragraphs containing relationships between entities) corresponding to the relationships between entity nodes in the input data, to support multi-granularity retrieval. These vectors are then stored in the FAISS vector database.
[0027] To enhance the semantic density and potential reasoning ability of the knowledge graph, this invention introduces a multi-level semantic association mechanism. By calculating a hybrid similarity score based on "topological shortest path" and "vector cosine similarity," a "semantically strong correlation" edge is automatically established between non-directly connected nodes when the confidence level exceeds a threshold. Specifically, the vectors of entity nodes can be linked to corresponding nodes in the knowledge graph. Based on the vectors of any two entity nodes in the knowledge graph, the cosine similarity between the two entity nodes is calculated. Subsequently, based on the cosine similarity of any two entity nodes and the topological shortest path distance between them (i.e., the distance corresponding to the shortest path between the two entity nodes in the knowledge graph), the hybrid similarity between the two entity nodes is calculated. In some embodiments, the hybrid similarity between any two entity nodes can be calculated based on the following formula. :
[0028] in, The shortest path distance between these two entity nodes is the topological path distance. Let the cosine similarity between these two entity nodes be . and This is the adjustment coefficient.
[0029] For two non-directly connected entity nodes with a mixed similarity higher than a preset threshold (e.g., 0.85), a strongly related semantic edge is added to these two non-directly connected entity nodes. This strongly related semantic edge can represent that the two connected entity nodes are "synonymous". In some embodiments, the weight of the edge between the two entity nodes can be set to the mixed similarity between the two entity nodes. This process can establish a "semantically strong correlation" between non-directly connected node pairs, which not only enriches the semantic structure of the knowledge graph, but also provides a more accurate semantic foundation for subsequent retrieval.
[0030] After receiving the query text entered by the user, such as Figure 2 The data flow in the upper half shows that the knowledge graph and vector database can be searched based on the query text to obtain search results related to the query text. Then, the generative model can be used to generate query results in natural language form based on the search results for the query text. Figure 2 The data flow in the lower half represents a dual-track query framework between the vector database and the knowledge graph. In some embodiments, when performing dual-track queries on the vector database and the knowledge graph, the vector database can be queried first based on the vectorized results of the query text to obtain related vectors and locate the text fragments (including entity description text and relation description text) corresponding to the related vectors. Then, the knowledge graph can be traversed based on these text fragments to find more related entities from the knowledge graph.
[0031] Specifically, a large-scale language model can be used to identify the core query entities and their implicit intent descriptions within the query text. These implicit intent descriptions express the relationships involved in the query entities within the user's intent, resolving ambiguity issues in single-entity retrieval. For example, the implicit intent description corresponding to the core query entity "apple" in the query text indicates that the entity relates to a technology company. This helps filter out the relationship path "fruit" connecting the entity node "apple," thus preventing propagation along the ambiguous "fruit" path during graph traversal and ensuring that subsequent graph traversal follows a semantic path consistent with the user's query intent. After vectorizing the query entities and their implicit intent descriptions, a vector database is retrieved. Based on the mapping relationship between the vector database and the knowledge graph, the K most similar candidate nodes to the query entities and the high-confidence relationships connecting these candidate nodes that match the implicit intent descriptions can be located in the knowledge graph. Subsequently, based on the candidate nodes and high-confidence relationships, a propagation search is performed on the knowledge graph to obtain the N most similar nodes to the query entities (where N>K). The retrieval results are then determined based on these N most similar nodes.
[0032] In some embodiments, to overcome the problems of the traditional PageRank algorithm ignoring node semantic content and having poor adaptability to sparse graphs, this invention proposes a "semantic-topology coupled adaptive random walk algorithm" to achieve knowledge graph diffusion and propagation search. The node propagation process of the knowledge graph is as follows: Figure 3 As shown. Specifically, unlike the traditional PageRank algorithm which constructs a transition matrix solely based on connection relationships, this embodiment of the invention constructs a transition matrix based on the semantic weights of edges. Specifically, the transition matrix is constructed based on the pairwise transition probabilities between each entity node in the knowledge graph. The unique aspect lies in the fact that the transition probability between two entity nodes is the normalized semantic relevance score of the edge between them. Here, the normalized semantic relevance score of an edge represents the semantic relevance between the two entity nodes connected by that edge. For example, the normalized semantic relevance score of an edge can be determined based on the edge weights set above. Furthermore, to guide the diffusion propagation process along a semantic path that aligns with the user's query intent, the outgoing edges of candidate nodes corresponding to high-confidence relationships can be weighted, making their normalized semantic relevance scores higher than other outgoing edges of the candidate nodes. Then, a personalized vector with the same dimension as the number of entity nodes in the knowledge graph is constructed. Among them, personalized vectors The positions corresponding to candidate nodes are assigned non-zero values (these non-zero values can be the similarity between the candidate node's vector and the query entity's vector during vector retrieval), while the remaining positions are 0, further ensuring that the traversal process always revolves around the user's query intent. To prevent super nodes (Hub Nodes, such as common high-frequency words) from absorbing too much weight, a damping factor based on node degree is also introduced:
[0033] in, Let i be the damping factor of entity node i. Let i be the degree of entity node i. It is a natural constant.
[0034] Based on the above transition matrix Personalized vectors and a matrix composed of the damping factors of each entity node. The PageRank algorithm is iterated until convergence (i.e., the difference between the ranking vectors calculated in two iterations is less than a threshold), yielding the PageRank score for each entity node. Based on these scores, the N nodes with the highest PageRank scores are selected. Here, the following calculations are performed in one iteration: .
[0035] in, This is the damping coefficient (usually set to 0.85). For the first The ranking vector for the next iteration contains the PageRank score of each entity node calculated in the current iteration.
[0036] In other embodiments, the knowledge graph can be used to perform further semantic reasoning and logical consistency checks on the N nodes obtained from the above diffusion propagation to ensure the quality of the retrieval results. Specifically, the entity description texts corresponding to the N nodes most similar to the query entity are obtained as candidate texts. Subsequently, relationship extraction is performed on each candidate text to obtain the relationship between two entities in the corresponding candidate text, and the relationship between the two entities in the corresponding candidate text is compared with the relationship represented by the path between the corresponding nodes of the two entities extracted from the knowledge graph to achieve fact comparison. If there is a conflict, that is, the relationship between two entities in any candidate text is inconsistent with the relationship represented by the path between the corresponding nodes of the two entities extracted from the knowledge graph, for example, the candidate text indicates that entity A and entity B have a causal relationship, but the knowledge graph path shows A->C->B and C indicates negation (such as "suppress"), then the candidate text is filtered or the confidence of the candidate text is reduced to obtain the retrieval results composed of each candidate text.
[0037] After obtaining the search results, a generative model can be used to generate query results in natural language based on these results. To address the attention loss and logical discontinuity issues that traditional generative models encounter when dealing with multi-source search fragments, this invention uses a knowledge graph as a benchmark for fact verification, achieving the transformation from "precise retrieval" to "high-quality generation" through the following methods: Document re-ranking and thought chain construction are performed using bidirectional peak focusing. To maximize the use of the retrieval results obtained in the preceding steps, a global relevance score is calculated for all candidate texts, resulting in a global relevance score for each candidate text. The greater the relevance between a candidate text and the query text, the higher its global relevance score. In some embodiments, the global relevance score of a candidate text can be calculated based on a weighted fusion strategy. Specifically, firstly, the cosine similarity between the corresponding vector of the candidate text and the corresponding vector of the query text, and the PageRank score of the corresponding node of the candidate text obtained during the graph diffusion propagation stage, are both Min-Max normalized, mapping them to the [0,1] interval to eliminate dimensional differences. Then, the normalized cosine similarity and PageRank score are weighted and fused to obtain the global relevance score of the candidate text. The weights corresponding to the normalized cosine similarity and PageRank score are learnable parameters (initial values set to 0.6 and 0.4), thus balancing semantic matching and graph topological importance. Then, the candidate texts are reorganized using a bidirectional peak focusing strategy to obtain a text sequence. Specifically, the candidate texts with the highest and second-highest global relevance scores are located at the beginning and end of the text sequence, respectively, while the remaining candidate texts are arranged in the middle in descending order of global relevance scores. This "high at the beginning and end, low in the middle" layout strategy ensures that the most critical evidence information is always within the optimal attention window of the large language model. Based on this, an entity-driven chain of thought (CoT) construction procedure is further executed: a pre-set inference template (such as a "symptom-cause-treatment" template) corresponding to the core query entity type is selected, and the N nodes most similar to the query entity and high-confidence relationships are filled into the inference template slots, forming structured prompts containing explicit inference steps.
[0038] By inputting the aforementioned structured prompts and text sequences into the generative model, it can be guided to perform step-by-step logical reasoning based on the rearranged candidate text, generating query results for the query text. In this process, the retrieved high-confidence relationships serve as explicit logical constraints, addressing the semantic fragmentation problem caused by fragmented information. Specifically, these high-confidence relationships, acting as "semantic bridges," are embedded in the structured prompts, explicitly informing the generative model of the implicit causal or parallel logic between candidate texts. The generative model can then calibrate its internal attention mechanism, shifting the generation logic from simple probabilistic co-occurrence to structured facts determined by the graph. For example, it can force the correction of potential semantic contradictions based on explicit "inhibition" relationships, thereby ensuring the logical rigor and factual accuracy of the final generated content in complex reasoning scenarios.
[0039] To ensure that the generated content maintains semantic fluency while strictly adhering to factual logic, the generation model can be fine-tuned. Specifically, the query return results generated by the generation model for the sample query text are obtained. The entire process of generating the query return results is as described in the above embodiments and will not be repeated here. In addition, this embodiment of the invention also constructs a reward model including a graph adaptation layer. This graph adaptation layer is a graph neural network module whose input interface is connected to the knowledge graph. The graph adaptation layer receives entities contained in the query return results corresponding to the sample query text, maps them back to the original knowledge graph to extract the corresponding subgraph structure (including entity nodes that can be reached by making several hops from the entity node) of the corresponding entity, and generates a structural consistency embedding vector between the subgraph structure corresponding to the entity and the query return results corresponding to the sample query text through graph computation. This structural consistency embedding vector is used to quantify the degree of consistency between the query return results corresponding to the sample query text and the knowledge graph. If the query return results corresponding to the sample query text forcibly establish erroneous relationships that do not exist in the graph, the degree of consistency calculated based on the structural consistency embedding vector will significantly reduce the final reward score. In some embodiments, the structural consistency embedding vector can be constructed by combining a graph attention network with global pooling operations. The specific steps include: First, using the entity node vectors in the subgraph structure corresponding to the entity as the initial feature input to the graph attention network; then, calculating the feature aggregation weights between nodes using the multi-head attention mechanism of the graph attention network, updating the node representations through two layers of message passing, and capturing high-order neighbor features; finally, using a readout function to aggregate all updated node features in the subgraph, mapping the variable-length graph structure data into a fixed-dimensional graph-level vector, i.e., the structural consistency embedding vector. Then, using similarity measurement structures such as fully connected layers and the softmax function, the structural consistency embedding vector and the vector of the sample query text are calculated to obtain the corresponding degree of similarity. The model loss can be calculated based on the degree of similarity, with lower similarity resulting in higher model loss. Based on this model loss, a near-end strategy optimization algorithm is used to fine-tune the generated model, such as... Figure 4 As shown.
[0040] In some embodiments, to balance language fluency and factual accuracy, this invention defines a multi-objective loss function that includes ranking loss and factual consistency loss: .
[0041] in, The parameters representing the generated model, This represents the output of the generative model. This is the sample query text. To and Semantically relevant or logically correct positive candidate texts To and Negative candidate texts that are semantically irrelevant or logically flawed It is the Sigmoid activation function. This represents the expected value on the training dataset D. The higher the degree of consistency, the smaller the penalty for factual deviation. This is the balance coefficient.
[0042] During training, when the content generated by the generative model logically conflicts with the knowledge graph, the fact deviation penalty term generates high negative feedback, forcing the model parameters to update in the direction of "following the facts of the knowledge graph." Simultaneously, a dynamic KL divergence constraint is introduced to prevent the model output from deviating excessively from the initial language distribution. Through continuous iteration, the parameter distribution of the generative model gradually converges towards the high-reward region, thus enabling it to spontaneously avoid fact-incorrect generation paths in subsequent inferences and gradually "learn" to generate high-quality answers that conform to the logic of the knowledge graph.
[0043] In summary, the method provided by this invention significantly overcomes the bottlenecks of traditional solutions in semantic understanding depth and factual accuracy through collaborative innovation in three dimensions: index construction, retrieval strategy, and generation optimization. First, at the knowledge representation and index construction level, this invention changes the traditional static discrete storage model and proposes a dynamic graph construction mechanism based on hybrid similarity. By calculating a hybrid score that integrates the topological shortest path and vector cosine similarity, it dynamically establishes semantically strongly related edges between non-directly connected nodes, effectively solving the sparsity problem of traditional graphs and endowing the index structure with self-evolving semantic reasoning capabilities. Second, at the retrieval accuracy and breadth level, unlike traditional methods that simply rely on vector nearest neighbor search, the semantic-topological coupling adaptive random walk algorithm proposed in this invention achieves precise targeting of query intent during the retrieval process by constructing a transition matrix and personalized vectors based on edge-normalized semantic relevance scores. In particular, the introduction of node damping factors effectively suppresses noise diffusion from common high-frequency nodes, significantly improving the logical relevance of retrieval results while ensuring recall. Finally, regarding the generation quality and factual controllability, the embodiments of this invention not only ensure the focus of attention and the explicitness of logic for key evidence through a bidirectional peak-focused reordering strategy and an entity-driven thought chain mechanism, but also design a reward model that includes a graph adaptation layer. By calculating the structural consistency embedding vector between the generated content and the knowledge graph subgraph, and using a multi-objective loss function that includes a fact deviation penalty term for policy updates, the generated results maintain linguistic fluency while possessing higher factual accuracy and logical rigor, thereby achieving significant improvements in the depth, accuracy, and efficiency of knowledge processing.
[0044] This invention provides an intelligent retrieval system based on knowledge graph indexing and large model optimization, for performing the methods described in any of the above embodiments.
[0045] This invention provides an electronic device, including: a computer-readable storage medium and a processor; The computer-readable storage medium is used to store executable instructions; The processor is configured to read executable instructions stored in the computer-readable storage medium and execute the method as described in any of the above embodiments.
[0046] This invention provides a computer-readable storage medium storing computer instructions that cause a processor to perform the method described in any of the above embodiments.
[0047] This invention provides a computer program product, including a computer program or instructions, which, when executed by a processor, implement the method described in any of the above embodiments.
[0048] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An intelligent retrieval method based on knowledge graph indexing and large model optimization, characterized in that, include: S1, using a large language model to extract entities and relationships between entities from the input data, and constructing a structured knowledge graph based on the entities and relationships between entities in the input data; S2, the entity nodes, relationships between entity nodes, entity description text corresponding to entity nodes in the input data, and relationship description text corresponding to relationships between entity nodes in the input data in the knowledge graph are vectorized, and the vectorized entity nodes, relationships between entity nodes, entity description text, and relationship description text are stored in the vector database. S3, link the vector of the entity node to the corresponding node in the knowledge graph, and calculate the cosine similarity between any two entity nodes based on the vectors of any two entity nodes in the knowledge graph. Based on the cosine similarity of any two entity nodes and the topological shortest path distance between the two entity nodes, calculate the mixed similarity of the two entity nodes; for two non-directly connected entity nodes whose mixed similarity is higher than a preset threshold, add a strongly related semantic edge to the two non-directly connected entity nodes. S4. Based on the query text input by the user, retrieve the knowledge graph and the vector database to obtain the retrieval results, and use the generative model to generate query return results in natural language form based on the retrieval results; Specifically, the step of retrieving the knowledge graph and the vector database based on user-input query text to obtain retrieval results includes: Based on a large language model, the query entities in the query text and the implicit intent descriptions of the query entities are identified; After vectorizing the query entity and the implicit intent description between query entities, the vector database is retrieved to locate the K candidate nodes in the knowledge graph that are most similar to the query entity and the high-confidence relationship that matches the implicit intent description. Based on the candidate nodes and the high-confidence relationship, a diffusion propagation search is performed on the knowledge graph to obtain N nodes most similar to the query entity, and the retrieval result is determined based on the N nodes most similar to the query entity; where N>K; Generative models are used to generate query results in natural language form based on the retrieval results, specifically including: A global relevance score is performed on the candidate texts in the search results to obtain a global relevance score for each candidate text. The candidate texts are sorted to obtain a text sequence; the candidate texts with the highest and second highest global relevance scores are located at the beginning and end of the text sequence, respectively, and the remaining candidate texts are arranged in descending order of global relevance scores. Based on the entity type of the query entity, a preset inference template is selected, and the N nodes most similar to the query entity and the high confidence relationship are filled into the inference template to form a structured prompt word containing explicit inference steps; The structured prompts and the text sequence are input into the generation model to obtain the query return results generated by the generation model for the query text; The generative model was fine-tuned based on the following method: Obtain the query return results generated by the generative model for the sample query text; Based on the reward model, the entities contained in the query results corresponding to the sample query text are mapped back to the knowledge graph. The subgraph structure corresponding to the entity is extracted, and a structural consistency embedding vector between the subgraph structure corresponding to the entity and the query results corresponding to the sample query text is generated. Based on the structural consistency embedding vector, the degree of fit between the query results corresponding to the sample query text and the knowledge graph is output. The model loss is calculated based on the degree of fit, and the generated model is fine-tuned based on the model loss.
2. The intelligent retrieval method based on knowledge graph indexing and large model optimization as described in claim 1, characterized in that, Mixed similarity between any two entity nodes It is calculated based on the following formula: in, The shortest path distance between any two entity nodes is the topological distance. Let be the cosine similarity between any two entity nodes. and This is the adjustment coefficient.
3. The intelligent retrieval method based on knowledge graph indexing and large model optimization as described in claim 1, characterized in that, Based on the candidate nodes and the high-confidence relationship, a diffusion propagation search is performed on the knowledge graph to obtain the N nodes most similar to the query entity, specifically including: Based on the pairwise transition probabilities between each entity node in the knowledge graph, a transition matrix is constructed. The transition probability between two entity nodes is the normalized semantic relevance score of the edge between the two entity nodes, and the normalized semantic relevance score of the outgoing edge corresponding to the high confidence relationship among the outgoing edges of the candidate node is higher than that of other outgoing edges. Construct a personalized vector with the same dimension as the number of entity nodes in the knowledge graph. ; wherein, the personalized vector The position corresponding to the candidate node is assigned a non-zero value, while the other positions are 0; The damping factor of each entity node is calculated based on the following formula: in, Let i be the damping factor of entity node i. Let i be the degree of entity node i. It is a natural constant; Based on the transition matrix The personalized vector and a matrix composed of the damping factors of each entity node. The PageRank algorithm is executed iteratively until convergence, and the PageRank score of each entity node is obtained. Based on the PageRank score of each entity node, the N nodes with the highest PageRank scores are selected.
4. The intelligent retrieval method based on knowledge graph indexing and large model optimization as described in claim 3, characterized in that, The search results are determined based on the N nodes most similar to the query entity, specifically including: Obtain the entity description texts corresponding to the N nodes most similar to the queried entity as candidate texts; Relationships are extracted from each candidate text to obtain the relationship between two entities in the corresponding candidate text. The relationship between two entities in the corresponding candidate text is then compared with the relationship represented by the path between the corresponding nodes of the two entities extracted from the knowledge graph. If the relationship between two entities in any candidate text is inconsistent with the relationship represented by the path between the corresponding nodes of the two entities extracted from the knowledge graph, then the candidate text is filtered or its confidence level is reduced to obtain the retrieval results composed of each candidate text.
5. The intelligent retrieval method based on knowledge graph indexing and large model optimization as described in claim 1, characterized in that, The model loss is calculated based on the following loss function: in, The parameters representing the generated model, This represents the output of the generative model. This is the sample query text. To and Semantically relevant or logically correct positive candidate texts To and Negative candidate texts that are semantically irrelevant or logically flawed It is the Sigmoid activation function. This represents the expected value on the training dataset D. The higher the degree of consistency, the smaller the penalty for factual deviation. This is the balance coefficient.
6. An intelligent retrieval system based on knowledge graph indexing and large model optimization, characterized in that, The intelligent retrieval system is used to perform the method as described in any one of claims 1-5.
7. An electronic device, characterized in that, include: Computer-readable storage media and processors; The computer-readable storage medium is used to store executable instructions; The processor is configured to read executable instructions stored in the computer-readable storage medium and execute the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Data graph, information graph and knowledge graph architecture-based UML model consistency detection method
CN108363563A
Intelligent learning guide method for Chinese international education
CN109062939A