Document analysis method based on dynamic knowledge graph and RAG model
By constructing a document analysis method based on dynamic knowledge graphs and RAG models, and updating the knowledge graphs in real time and combining them with large language models, the problem of insufficient capture of semantic associations and dynamic relationships in document analysis is solved, enabling reasoning and structured answer generation through multi-level semantic networks.
Patent Information
- Application Number
- CN202511099961.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-07
- Publication Date
- 2025-11-14
AI Technical Summary
Existing technologies suffer from insufficient semantic association capabilities, difficulty in capturing dynamic relationships, and poor interpretability in document analysis, especially when dealing with complex queries and multi-hop reasoning.
By constructing a document analysis method based on dynamic knowledge graphs and RAG models, the knowledge graph is updated in real time. Graph embedding models are used to map entities and relationships as low-dimensional vectors, and a large language model is combined to generate structured answers, thus realizing reasoning in a multi-level semantic network.
It significantly improves the semantic understanding and reasoning capabilities of document analysis, and can automatically connect scattered document fragments to generate structured and interpretable answers, solving the problem that existing models are insufficient in capturing deep semantics and dynamic relationships.
Smart Images

Figure CN120952003A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a document analysis method based on dynamic knowledge graphs and RAG models. Background Technology
[0002] With the rapid development of artificial intelligence technology, the field of Natural Language Processing (NLP) has made significant progress in document analysis tasks. Traditional document analysis methods mainly rely on keyword matching or static knowledge bases. While these methods can handle simple query tasks, they often perform poorly when faced with complex problems requiring deep semantic understanding. For example, keyword matching methods are easily affected by synonyms, polysemous words, and contextual information, leading to inaccurate search results. While static knowledge bases provide some structured information, their coverage is limited and they struggle to adapt to different domains or dynamically changing document content. These limitations prevent them from fully capturing the semantic connections and dynamic relationships within documents when processing complex queries, severely restricting the accuracy and practicality of document analysis.
[0003] Existing Retrieval Augmented Generation (RAG) models, by combining the retrieval and generation stages, have improved document analysis capabilities to some extent. RAG models can retrieve relevant text fragments from large-scale documents and synthesize the final answer using a generative model. However, these models still have significant limitations: their semantic association capabilities are limited, especially when dealing with multi-hop reasoning or dynamically updated knowledge. For example, when a question requires connecting information from multiple text fragments for reasoning, RAG models often struggle to establish semantic associations across fragments. Furthermore, while static knowledge graphs can provide structured relationships between entities, their long update cycles and poor flexibility prevent them from reflecting dynamically changing entities and relationships within documents in a timely manner, potentially leading to generated answers containing outdated or incorrect information.
[0004] The main challenges currently faced by the technology can be summarized in three aspects: First, insufficient semantic association ability. Traditional RAG models mainly rely on the surface information of text fragments during retrieval, making it difficult to capture the complex relationship network between entities in a document. Second, difficulty in capturing dynamic relationships. Static knowledge graphs lack a real-time update mechanism, making it difficult to respond promptly to new entity or relationship changes. Finally, poor interpretability. Answers generated by existing methods often lack structured support, making it difficult for users to understand the reasoning process and basis behind the answers.
[0005] Therefore, developing a document analysis method that combines the advantages of dynamic knowledge graphs and RAG models has become an important problem that urgently needs to be solved. Summary of the Invention
[0006] To overcome the aforementioned shortcomings of existing technologies, embodiments of the present invention provide a document analysis method based on a RAG model and dynamic knowledge graph. This method, through deep fusion retrieval enhancement generation technology and dynamic knowledge graph technology, achieves intelligent analysis and processing of document content, significantly improving the quality and interpretability of answers to complex questions, and solving the problem of insufficient model capture of deep semantics and dynamic relationships in existing technologies.
[0007] To achieve the above objectives, the present invention provides the following technical solution: A document analysis method based on dynamic knowledge graphs and RAG models is characterized by the following steps: jointly extracting entity relations from input documents to generate structured triples and constructing a dynamically updatable knowledge graph; based on the knowledge graph, using a graph embedding model to map entities and relations into low-dimensional vectors to construct a local vector knowledge base with topological structure; receiving user questions in real time, encoding them into query vectors, and performing approximate nearest neighbor search based on the vector knowledge base to match relevant knowledge graph fragments; combining the retrieved knowledge graph fragments with a large language model, and generating structured answers by injecting path constraints into the knowledge graph.
[0008] In a preferred embodiment, the construction of a dynamically updatable knowledge graph specifically involves: obtaining initial structural triples through joint extraction of entity relationships as the basic data of the knowledge graph; and using an incremental update strategy based on the basic data to dynamically expand and optimize the knowledge graph, thereby forming a dynamically updatable knowledge graph.
[0009] In a preferred embodiment, the step of using a graph embedding model to map entities and relations into low-dimensional vectors and constructing a local vector knowledge base with a topological structure specifically involves: based on a knowledge graph, using a structure-aware graph embedding algorithm, incorporating entities and relations in the knowledge graph into a joint optimization objective to obtain the original feature vectors and embedding matrices of the entities; and adjusting the weights of the original feature vectors and embedding matrices by balancing hyperparameters to construct a local vector knowledge base with a topological structure.
[0010] In a preferred embodiment, the real-time reception of user questions, encoding them into query vectors, and performing approximate nearest neighbor search based on a vector knowledge base to match relevant graph fragments specifically involves: receiving user questions in real-time and encoding them into query vectors; constructing a multimodal index to generate a fused index vector based on multimodal features in the local vector knowledge base using an adaptive weighting mechanism; performing an approximate nearest neighbor search in the vector knowledge base based on the fused index vector to obtain an initial set of relevant entities; and obtaining relevant graph fragments based on the query vectors and the initial set of relevant entities using a subgraph diffusion algorithm.
[0011] In a preferred embodiment, the step of combining the retrieved knowledge graph fragments with a large language model and generating a structured answer by injecting path constraints into the knowledge graph specifically involves: generating a structured prompt template based on the relevant knowledge graph fragments and the path constraints of the knowledge graph; obtaining the final template weight through the interaction between the structured prompt template and the large language model; and generating a structured answer that conforms to the path constraints of the dynamic knowledge graph based on the final template weight.
[0012] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: A document analysis method based on the RAG model and dynamic knowledge graph significantly enhances the semantic understanding and reasoning capabilities of the RAG model through deep integration with the dynamic knowledge graph. Specifically, the knowledge graph constructed by the system not only includes explicit relationships between entities but also learns implicit semantic associations through graph neural networks, forming a multi-layered semantic network. When dealing with complex problems requiring multi-hop reasoning, the system can perform progressive reasoning along the association paths of the knowledge graph, automatically connecting relevant information scattered across different document fragments. This solves the problem of insufficient capture of deep semantics and dynamic relationships in existing technologies. Attached Figure Description
[0013] Figure 1 This is a schematic diagram of a document analysis method based on a RAG model and dynamic knowledge graph, provided as an embodiment of the present invention. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0015] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0016] Example 1, Figure 1 This invention presents a document analysis method based on dynamic knowledge graphs and RAG models, comprising the following steps: S1, perform joint entity relation extraction on the input document, generate structural triples, and construct a dynamically updatable knowledge graph; S2, based on knowledge graphs, uses a graph embedding model to map entities and relations into low-dimensional vectors, and builds a local vector knowledge base with topological structure. S3 receives user questions in real time, encodes them into query vectors, and performs an approximate nearest neighbor search based on the vector knowledge base to match relevant graph fragments; S4 combines the retrieved graph fragments with a large language model, and generates structured answers by injecting path constraints from the knowledge graph.
[0017] This embodiment significantly enhances the semantic understanding and reasoning capabilities of the RAG model through deep integration of a dynamic knowledge graph. Specifically, the knowledge graph constructed by the system not only includes explicit relationships between entities but also learns implicit semantic associations through graph neural networks, forming a multi-layered semantic network. When dealing with complex problems requiring multi-hop reasoning, the system can perform progressive reasoning along the association paths of the knowledge graph, automatically connecting relevant information scattered across different document fragments. This effectively solves the problems of weak multi-hop reasoning capabilities and lagging updates to static knowledge graphs in existing technologies.
[0018] S1 extracts entity relations from the input document, generates structural triples, and constructs a dynamically updatable knowledge graph.
[0019] In this embodiment, the construction of a dynamically updatable knowledge graph specifically includes: Initial structural triples are obtained through joint extraction of entity relationships, serving as the basic data for the knowledge graph. Based on the basic data, an incremental update strategy is adopted to realize the dynamic expansion and optimization of the knowledge graph, forming a dynamically updatable knowledge graph.
[0020] Joint entity relation extraction is performed on the input document to generate structural triples, thereby constructing a dynamically updatable knowledge graph. The specific process is as follows: First, an entity relationship joint extraction algorithm (such as a BERT-based joint extraction model) is used to identify and extract entities (such as names of people, names of organizations, professional terms, etc.) and relationships between entities (such as "belongs to", "related", "causal", etc.) from the input document, and obtain initial structure triples (head entity, relationship, tail entity) as the basic data of the knowledge graph.
[0021] Based on this foundational data, an incremental update strategy is adopted: continuously monitor new input documents or version updates of existing documents. When a new triple is generated, its reliability is first determined by calculating the relation confidence (combining indicators such as entity similarity and semantic similarity). Then, the reliable new triple is integrated into the existing knowledge graph. At the same time, old relations that may conflict due to the introduction of new data are verified and corrected, so as to realize the dynamic expansion and optimization of the knowledge graph and form a knowledge graph that can be continuously updated with information changes.
[0022] S2, based on knowledge graphs, uses a graph embedding model to map entities and relations into low-dimensional vectors, constructing a local vector knowledge base with topological structure.
[0023] In this embodiment, the step of using a graph embedding model to map entities and relations to low-dimensional vectors and constructing a local vector knowledge base with a topological structure specifically involves: Based on the knowledge graph, a structure-aware graph embedding algorithm is used to incorporate the entities and relations in the knowledge graph into a joint optimization objective to obtain the original feature vectors and embedding matrices of the entities. By balancing the hyperparameters to adjust the weights of the original feature vectors and the embedding matrix, a local vector knowledge base with a topological structure is constructed.
[0024] Based on the generated knowledge graph, a graph embedding model is used to map entities and relations into low-dimensional vectors, constructing a local vector knowledge base with topological structure. Specific implementation details are as follows: Based on knowledge graphs, a structure-aware graph embedding algorithm is selected. The embedding vectors of head entities, relations, and tail entities in the knowledge graph are used as joint optimization targets. During the optimization process, the original feature vectors of entities (obtained after transformation of entity text descriptions, attributes, and other features by multilayer perceptron MLP), the global embedding matrix of all entities (reflecting the global association between entities), and the normalized Laplacian matrix of the graph (characterizing the graph topology) are simultaneously included in the optimization scope.
[0025] By adjusting the balancing hyperparameters (such as using a validation set to determine the weight ratio of the original features, embedding matrix, and topology in the optimization objective), the mapped low-dimensional vectors can accurately reproduce the semantics of entities and relationships while retaining the topological connection information of the knowledge graph. Ultimately, a local vector knowledge base with topological structure is constructed, providing structured vector data support for subsequent retrieval.
[0026] S3 receives user questions in real time, encodes them into query vectors, and performs an approximate nearest neighbor search based on the vector knowledge base to match relevant graph fragments.
[0027] In this embodiment, the real-time reception of user questions, encoding them into query vectors, and performing an approximate nearest neighbor search based on a vector knowledge base to match relevant graph fragments specifically involves: Receive user questions in real time and encode them into query vectors; For multimodal features in the local vector knowledge base, a multimodal index is constructed through an adaptive weighting mechanism to generate a fused index vector; Based on the fused index vector, an approximate nearest neighbor search is performed in the vector knowledge base to obtain an initial set of related entities; Based on the query vector and the initial set of relevant entities, relevant graph fragments are obtained through a subgraph diffusion algorithm.
[0028] For the multimodal features that may be contained in the local vector knowledge base, such as text and structure, an adaptive weighting mechanism is adopted to construct a multimodal index: for the feature vectors of different modalities (such as text semantic modality and topological structure modality), a learnable transformation matrix and bias term are designed, and the dynamic importance weight of each modality to the current query is calculated through an attention mechanism (for example, when the question focuses on semantics, the weight of text modality is increased). Then, the multimodal features are dynamically fused according to the weights to generate a fused index vector.
[0029] Based on the fused index vector, the approximate nearest neighbor search algorithm (such as the HNSW algorithm) is used to quickly retrieve the initial set of relevant entities (i.e. entities that are associated with the query semantics and structure) in the vector knowledge base.
[0030] To uncover more comprehensive related information, a subgraph diffusion algorithm is initiated based on the query vector and the initial entity set: starting with the initial entity, the diffusion is initiated by combining the entity's neighborhood relationship and degree (reflecting the entity's importance) in the knowledge graph with the relevance function of the relationship and the query (the matching degree is calculated using the entity and relationship embedding vectors), setting a decay coefficient to control the diffusion range, and iteratively executing entity activation and diffusion until convergence, ultimately obtaining a graph fragment highly related to the user's question, covering entities, relationships, and related paths.
[0031] S4 combines the retrieved graph fragments with a large language model, and generates structured answers by injecting path constraints from the knowledge graph.
[0032] In this embodiment, the step of combining the retrieved knowledge graph fragments with a large language model and generating structured answers by injecting path constraints into the knowledge graph specifically involves: Structured prompt templates are generated based on path constraints from relevant graph fragments and knowledge graphs; The final template weights are obtained through the interaction between the structured prompt template and the large language model. A structured answer that conforms to the path constraints of the dynamic knowledge graph is generated based on the final template weights.
[0033] Combining knowledge graph fragments with a large language model and injecting knowledge graph path constraints to generate structured answers involves the following steps: Extract relevant graph fragments and sort out the path information composed of entities and relationships within them, which serves as path constraints for the knowledge graph.
[0034] Based on these path constraints and candidate template sets (predefined structured templates for different question-and-answer scenarios), the semantics of the retrieved paragraphs are comprehensively considered (the semantic matching degree between the paragraphs and templates is calculated using a similarity algorithm) and the importance weight of relationships in the knowledge subgraph (such as higher weight for core technology relationships). Through the filtering and optimization of indicator functions, a structured prompt template adapted to the current question is generated.
[0035] The structured prompt template is input into the large language model. Based on the template constraints, the model combines its own knowledge and graph fragment information to generate and structure the text, output the final template weight (reflecting the contribution of each template element to the answer), and generate an answer that conforms to the path logic of the knowledge graph and has a clear structure (such as listing patent technologies in points and explaining the relationship with products and institutions), thus completing the closed loop of document analysis and intelligent question answering.
[0036] In this embodiment, the incremental update strategy is specifically formulated as follows:
[0037] in: To update the reliability of the relationship, It is the Sigmoid activation function. Represents entity similarity based on embedding vectors. The semantic similarity of the relational context is represented. Representing entities and The set of all paths between them Calculation path Reliability score, , , The weight parameters are adaptive and dynamically adjusted through gradient descent.
[0038] In this embodiment, the structure-aware graph embedding algorithm is specifically formulated as follows:
[0039] in: The total loss of the structure-aware graph embedding algorithm, These represent the embedding vectors of the head entity, relation, and tail entity, respectively. This refers to the set of triples in a knowledge graph. For entities The original feature vector, It is a feature converter for a multilayer perceptron. For the embedding matrix of all entities, The normalized Laplace matrix of the graph. , To balance the hyperparameters.
[0040] In this embodiment, the specific formula for generating the fused index vector by constructing a multimodal index through an adaptive weighting mechanism is as follows:
[0041] in: This is the index vector after multimodal fusion. Indicates the total number of modes. For the first Feature vectors of each modality and For the first The learnable transformation matrix and bias terms for each modality. For the first The dynamic importance weights of each modality are calculated using an attention mechanism:
[0042] in , and For learnable parameters, This is the sigmoid function.
[0043] In this embodiment, the subgraph diffusion algorithm is specifically formulated as follows:
[0044] in: Representing entities In the Activation probability in round diffusion This represents the probability distribution of the initial search results. Representing entities The set of neighboring entities, Representing entities The degree, The attenuation coefficient is... For relationship With query The correlation function; The formula is:
[0045] The diffusion process is executed iteratively until... convergence.
[0046] In this embodiment, the specific formula for generating the structured prompt template is as follows:
[0047] in: For the candidate template set, Indicates the first One search segment, This is the paragraph weighting coefficient. For query Related knowledge subgraphs, To represent relations Importance weights For indicator functions, Calculate the semantic similarity between the paragraph and the template.
[0048] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0049] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, in the form of a computer program product.
[0050] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0051] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0052] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0053] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A document analysis method based on dynamic knowledge graphs and RAG models, characterized in that, Includes the following steps: Entity relations are jointly extracted from the input document to generate structural triples and construct a dynamically updatable knowledge graph. Based on knowledge graphs, a graph embedding model is used to map entities and relations into low-dimensional vectors, thereby constructing a local vector knowledge base with topological structure. It receives user questions in real time, encodes them into query vectors, and performs an approximate nearest neighbor search based on a vector knowledge base to match relevant graph fragments; The retrieved knowledge graph fragments are combined with a large language model, and structured answers are generated by injecting path constraints into the knowledge graph.
2. The document analysis method based on dynamic knowledge graph and RAG model according to claim 1, characterized in that, The construction of a dynamically updatable knowledge graph specifically involves: Initial structural triples are obtained through joint extraction of entity relationships, serving as the basic data for the knowledge graph. Based on the basic data, an incremental update strategy is adopted to realize the dynamic expansion and optimization of the knowledge graph, forming a dynamically updatable knowledge graph.
3. The document analysis method based on dynamic knowledge graph and RAG model according to claim 2, characterized in that, The method employs a graph embedding model to map entities and relations into low-dimensional vectors, constructing a local vector knowledge base with a topological structure, specifically as follows: Based on the knowledge graph, a structure-aware graph embedding algorithm is used to incorporate the entities and relations in the knowledge graph into a joint optimization objective to obtain the original feature vectors and embedding matrices of the entities. By balancing the hyperparameters to adjust the weights of the original feature vectors and the embedding matrix, a local vector knowledge base with a topological structure is constructed.
4. The document analysis method based on dynamic knowledge graph and RAG model according to claim 3, characterized in that, The real-time reception of user questions is encoded into query vectors, and an approximate nearest neighbor search is performed based on a vector knowledge base to match relevant graph fragments, specifically as follows: Receive user questions in real time and encode them into query vectors; For multimodal features in the local vector knowledge base, a multimodal index is constructed through an adaptive weighting mechanism to generate a fused index vector; Based on the fused index vector, an approximate nearest neighbor search is performed in the vector knowledge base to obtain an initial set of related entities; Based on the query vector and the initial set of relevant entities, relevant graph fragments are obtained through a subgraph diffusion algorithm.
5. The document analysis method based on dynamic knowledge graph and RAG model according to claim 4, characterized in that, The process of combining the retrieved knowledge graph fragments with a large language model and generating structured answers by injecting path constraints into the knowledge graph specifically involves: Structured prompt templates are generated based on path constraints from relevant graph fragments and knowledge graphs; The final template weights are obtained through the interaction between the structured prompt template and the large language model. A structured answer that conforms to the path constraints of the dynamic knowledge graph is generated based on the final template weights.
6. The document analysis method based on dynamic knowledge graph and RAG model according to claim 5, characterized in that, The incremental update strategy is specifically formulated as follows: in: To update the reliability of the relationship, It is the Sigmoid activation function. Represents entity similarity based on embedding vectors. The semantic similarity of the relational context is represented. Representing entities and The set of all paths between them Calculation path Reliability score, , , The weight parameters are adaptive and dynamically adjusted through gradient descent.
7. The document analysis method based on dynamic knowledge graph and RAG model according to claim 6, characterized in that, The structure-aware graph embedding algorithm is specifically formulated as follows: in: The total loss of the structure-aware graph embedding algorithm, These represent the embedding vectors of the head entity, relation, and tail entity, respectively. This refers to the set of triples in a knowledge graph. For entities The original feature vector, It is a feature converter for a multilayer perceptron. For the embedding matrix of all entities, The normalized Laplace matrix of the spectrum, , To balance the hyperparameters.
8. The document analysis method based on dynamic knowledge graph and RAG model according to claim 7, characterized in that, The process of constructing a multimodal index and generating a fused index vector using an adaptive weighting mechanism is specifically formulated as follows: in: This is the index vector after multimodal fusion. Indicates the total number of modes. For the first Feature vectors of each modality and For the first The learnable transformation matrix and bias terms for each modality. For the first The dynamic importance weights of each modality are calculated using an attention mechanism: in , and For learnable parameters, This is the sigmoid function.
9. The document analysis method based on dynamic knowledge graph and RAG model according to claim 8, characterized in that, The specific formula for the subgraph diffusion algorithm is as follows: in: Representing entities In the Activation probability in round diffusion This represents the probability distribution of the initial search results. Representing entities The set of neighboring entities, Representing entities The degree, The attenuation coefficient is... For relationship With query The correlation function; The formula is: The diffusion process is executed iteratively until... convergence.
10. The document analysis method based on dynamic knowledge graph and RAG model according to claim 9, characterized in that, The specific formula for generating the structured prompt template is as follows: in: For user queries The generated optimal structured prompt template, For the candidate template set, Indicates the first One search segment, This is the paragraph weighting coefficient. For query Related knowledge subgraphs, To represent relations Importance weights For indicator functions, Calculate the semantic similarity between the paragraph and the template.
Citation Information
Cited By
Intelligent archive management method based on large language model
CN121455906A
Enhanced generation method based on topology perception graph coding and self-adaptive sub-graph retrieval
CN121562834A
Large-scale semantic retrieval optimization method based on deep learning
CN121765032A
Data processing method for enterprise digital intelligence quality management
CN121836471A
Computing device (embodiments) and method for determining event by layout of documents
RU2867851C1