Document analysis and query method and device based on knowledge graph, equipment and medium
By performing part-of-speech tagging and knowledge element extraction on power grid project documents, and constructing and optimizing a knowledge graph using a power grid domain ontology knowledge base, the problems of insufficient accuracy and usability of knowledge graphs in existing technologies are solved, enabling efficient management and accurate querying of power grid project documents.
Patent Information
- Application Number
- CN202511314120.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-15
- Publication Date
- 2026-01-09
AI Technical Summary
Existing knowledge graph construction methods have limited capabilities in entity disambiguation and relation reasoning, making it difficult to effectively handle the large number of synonyms, abbreviations, and technical terms that appear in documents. This results in redundant nodes and inaccurate relationships in the constructed knowledge graph, reducing its accuracy and usability, and failing to meet the needs of professionals for precise querying and analysis of project documents.
By performing part-of-speech tagging on the received documents to be analyzed, an initial knowledge graph is constructed using an ontology knowledge base in the power grid domain. Nodes are merged and a mapping table is generated. Target query templates are selected based on natural language query statements. Results are queried from the merged knowledge graph and output. Semantic annotation, community discovery algorithms, and tensor decomposition techniques are used to optimize the knowledge graph structure.
It improves the accuracy and comprehensiveness of information analysis, accurately understands users' query intent, meets the needs of professionals for precise query and analysis of project documents, and enhances the efficiency of power grid project document management and user experience.
Smart Images

Figure CN121301518A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, device, and medium for document analysis and query based on knowledge graphs. Background Technology
[0002] With the continuous expansion of power grid construction, the number of power grid project documents has exploded. These documents contain a wealth of important information related to power grid design, construction, and operation and maintenance. Traditional power grid project document management mainly relies on manual retrieval and analysis, which is inefficient and makes it difficult to fully extract the knowledge value from the documents. To improve the management and utilization efficiency of power grid project documents, intelligent analysis methods based on knowledge graphs have emerged. As a semantic network structure, knowledge graphs can represent domain knowledge in the form of entity-relationship-entity, providing a new technical path for the intelligent management and analysis of power grid project documents. By constructing a power grid domain knowledge graph, information scattered across different documents can be semantically linked to form a knowledge network, thereby supporting more intelligent information retrieval, knowledge discovery, and decision support.
[0003] Existing knowledge graph construction methods have limited capabilities in entity disambiguation and relation reasoning, making it difficult to effectively handle the large number of synonyms, abbreviations, and technical terms appearing in documents. This results in a large number of redundant nodes and inaccurate relationships in the constructed knowledge graph, reducing its accuracy and usability. Furthermore, the lack of effective semantic understanding and matching mechanisms makes it difficult to accurately understand the user's query intent, leading to inaccurate or incomplete search results that fail to meet the needs of professionals for precise querying and analysis of project documents. Summary of the Invention
[0004] This invention provides a knowledge graph-based document analysis and query method that can effectively improve the accuracy and comprehensiveness of information analysis, accurately understand the user's query intent, and meet the needs of professionals for precise query and analysis of project documents.
[0005] In a first aspect, embodiments of the present invention provide a document analysis and query method based on a knowledge graph, comprising:
[0006] The received document to be analyzed is tagged with part-of-speech tags to obtain the tagging results;
[0007] Based on a pre-defined ontology knowledge base for the power grid domain, knowledge element information is extracted from the part-of-speech tagging results, and an initial knowledge graph is constructed based on the knowledge element information.
[0008] The nodes in the initial knowledge graph are merged to obtain a fused knowledge graph;
[0009] A mapping table is constructed based on the fused knowledge graph, and a candidate query template set is generated based on the mapping table;
[0010] Receive a natural language query statement input by the user, select a target query template from the candidate query template set based on the natural language query statement, and generate the target query statement;
[0011] Use the target query statement to query from the fused knowledge graph and output the query results.
[0012] Furthermore, the step of extracting knowledge element information from the part-of-speech tagging results based on the preset power grid domain ontology knowledge base, and constructing an initial knowledge graph based on the knowledge element information, includes:
[0013] The part-of-speech tagging results are matched with the power grid domain ontology knowledge base to extract knowledge element information;
[0014] Semantic annotation is performed on the knowledge element information to obtain knowledge elements with semantic tags, and a knowledge element interaction graph is constructed based on the knowledge elements with semantic tags.
[0015] For knowledge element pairs connected by edges in the knowledge element interaction graph, calculate the cosine similarity and generate an association matrix;
[0016] Based on the correlation matrix and the semantic tags, feature encoding is performed on the knowledge elements, each knowledge element is represented as a multi-dimensional feature vector, and the semantic similarity of the multi-dimensional feature vectors of each knowledge element pair is calculated.
[0017] Using the semantic tags as constraints, a minimum spanning tree is constructed based on the semantic similarity, and the minimum spanning tree is optimized to obtain several knowledge element clusters;
[0018] An initial knowledge graph is constructed based on the aforementioned knowledge element clusters.
[0019] Furthermore, merging the nodes in the initial knowledge graph to obtain a fused knowledge graph includes:
[0020] Based on the power grid domain ontology knowledge base, all entity nodes in the initial knowledge graph are transformed into semantic vectors to obtain the node semantic feature space;
[0021] A third-order semantic feature tensor is constructed based on the node semantic feature space. Tensor decomposition technique is used to extract the structural feature vector and context feature vector of the entity node. The structural feature vector and the context feature vector are concatenated to obtain the fused feature vector of the entity node.
[0022] Calculate the similarity of the fused feature vectors of any two entity nodes and construct a similarity association graph of all entity nodes;
[0023] The similarity association graph is divided into multiple communities using a community discovery algorithm, and entity nodes in the communities with semantic similarity higher than a preset semantic similarity threshold are merged.
[0024] Based on the relationship types and attribute information of the merged entity nodes, a fused knowledge graph is obtained.
[0025] Furthermore, the step of extracting the structural feature vector and context feature vector of the entity node using tensor decomposition technology, and concatenating the structural feature vector and the context feature vector to obtain the fused feature vector of the entity node, includes:
[0026] Tensor decomposition technology is used to perform spatiotemporal decomposition on the third-order semantic feature tensor to obtain a heterogeneous feature matrix including temporal pattern features and spatial pattern features. Spatiotemporal correlation degree is calculated based on the heterogeneous feature matrix.
[0027] Select the feature combination with the highest spatiotemporal correlation as the structural feature;
[0028] A node attention matrix is constructed using the third-order semantic feature tensor. The node attention matrix is then weighted according to the spatiotemporal correlation. Based on the adjusted attention weights, the contextual semantic representation of the entity is calculated, and the contextual semantic representation with the largest attention weight is selected as the contextual feature.
[0029] A fused feature vector is generated based on the structural features and the context features.
[0030] Furthermore, the step of constructing a mapping table based on the fused knowledge graph and generating a candidate query template set based on the mapping table includes:
[0031] The entity type, relationship type, and attribute information of all entity nodes are extracted from the fused knowledge graph. A first mapping matrix and a second mapping matrix are constructed, and a mapping table is constructed based on the first mapping matrix and the second mapping matrix. The first mapping matrix is used to record the correspondence between the entity type and the relationship type, and the second mapping matrix is used to record the correspondence between the entity type and the attribute information.
[0032] The mapping table is traversed using a depth-first traversal algorithm to generate a node access sequence, and the node access sequence is grouped according to the mapping level;
[0033] Calculate the mutual information of nodes within a group and the mutual information of nodes between groups, and construct a heterogeneous node co-occurrence matrix based on the mutual information of nodes within a group and the mutual information of nodes between groups.
[0034] Singular value decomposition is performed on the heterogeneous node co-occurrence matrix to obtain the node feature matrix. Based on the node feature matrix, the inter-layer node attention distribution is calculated to generate an inter-layer node association weight table.
[0035] Based on the inter-layer node association weight table, a query path is selected from the mapping table to generate a query path set, and a candidate query template set is generated based on the query path set.
[0036] Furthermore, the step of selecting a target query template from the candidate query template set based on the natural language query statement and generating a target query statement includes:
[0037] Extract the query keyword sequence from the natural language query statement and map the keyword sequence into a query semantic vector;
[0038] Extract the template keyword sequence of each candidate query template in the candidate query template set, and map the template keyword sequence into a template semantic vector;
[0039] Based on the query semantic vector and the template semantic vector, the target query template is determined from the candidate query template set;
[0040] Entity words and relation words are identified from the natural language query statement, an entity-relation correspondence graph is constructed, the entity-relation correspondence graph is bidirectionally mapped to the slots in the target query template, a set of slot filling rules is generated, and the consistency of the set of slot filling rules is verified to obtain the target slot filling rules.
[0041] The target query template is instantiated based on the target slot filling rules to generate an intermediate query expression. The intermediate query expression is then normalized to generate the target query statement.
[0042] Furthermore, determining the target query template from the candidate query template set based on the query semantic vector and the template semantic vector includes:
[0043] The query semantic vector and the template semantic vector are mapped to the same semantic space to extract a multi-level semantic association matrix, including a local semantic association matrix and a global semantic association matrix.
[0044] The interaction influence degree is calculated based on the multi-level semantic association matrix to generate an interaction weight matrix. The interaction influence degree includes the first influence degree of the query semantic vector on the template semantic vector and the second influence degree of the template semantic vector on the query semantic vector.
[0045] The multi-level semantic association matrix and the interaction weight matrix are merged to obtain a joint representation matrix. The main feature vectors are extracted by eigenvalue decomposition to obtain a multi-dimensional similarity feature set.
[0046] The features in the multidimensional similarity feature set are iteratively optimized and weighted based on a dynamic programming strategy to generate a comprehensive matching score. The candidate query template with the highest comprehensive matching score is then determined as the target query template.
[0047] Secondly, embodiments of the present invention provide a document analysis and query device based on a knowledge graph, comprising:
[0048] The document preprocessing module is used to perform part-of-speech tagging on the received documents to be analyzed, and obtain the part-of-speech tagging results;
[0049] The knowledge graph construction module is used to extract knowledge element information from the part-of-speech tagging results based on a preset power grid domain ontology knowledge base, and to construct an initial knowledge graph based on the knowledge element information;
[0050] The knowledge graph fusion module is used to merge the nodes in the initial knowledge graph to obtain a fused knowledge graph;
[0051] The query template generation module is used to construct a mapping table based on the fused knowledge graph and generate a set of candidate query templates based on the mapping table.
[0052] The query statement generation module is used to receive a natural language query statement input by the user, select a target query template from the candidate query template set based on the natural language query statement, and generate a target query statement.
[0053] The query result output module is used to query the fused knowledge graph using the target query statement and output the query results.
[0054] Thirdly, embodiments of the present invention provide an electronic device, comprising:
[0055] Memory, used to store computer programs;
[0056] A processor for executing the computer program;
[0057] Wherein, when the processor executes the computer program, it implements the document analysis and query method based on knowledge graph as described in any of the first aspects above.
[0058] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, which, when executed, implements the knowledge graph-based document analysis and query method described in any of the first aspects above.
[0059] Compared with existing technologies, the document analysis and query method based on knowledge graph provided by this invention has the following advantages: Part-of-speech tagging is performed on the received document to be analyzed to obtain the tagging results; based on a preset power grid domain ontology knowledge base, knowledge element information is extracted from the tagging results, and an initial knowledge graph is constructed based on the knowledge element information; nodes in the initial knowledge graph are merged to obtain a fused knowledge graph; a mapping table is constructed according to the fused knowledge graph, and a candidate query template set is generated based on the mapping table; a natural language query statement is received from the user, a target query template is selected from the candidate query template set based on the natural language query statement, and a target query statement is generated; the target query statement is used to query from the fused knowledge graph, and the query results are output; this invention can effectively mine key information in documents, improve the accuracy and comprehensiveness of information analysis, accurately understand the user's query intent, and meet the needs of professionals for precise querying and analysis of project documents. Attached Figure Description
[0060] To more clearly illustrate the technical features of the embodiments of the present invention, the drawings used in the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0061] Figure 1 This is a flowchart illustrating the document analysis and query method based on knowledge graphs provided in an embodiment of the present invention.
[0062] Figure 2 This is a schematic diagram illustrating the effect of the document analysis and query method based on knowledge graphs provided in an embodiment of the present invention;
[0063] Figure 3 This is a schematic diagram of the structure of the knowledge graph-based document analysis and query device provided in an embodiment of the present invention;
[0064] Figure 4 This is a flowchart illustrating an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0065] 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.
[0066] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0067] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.
[0068] Firstly, this invention provides a document analysis and query method based on knowledge graphs, see [link to relevant documentation]. Figure 1 This is a flowchart illustrating one embodiment of a knowledge graph-based document analysis and query method.
[0069] like Figure 1 As shown, the method includes the following steps:
[0070] S1: Perform part-of-speech tagging on the received document to be analyzed to obtain the part-of-speech tagging results;
[0071] S2: Based on the preset power grid domain ontology knowledge base, extract knowledge element information from the part-of-speech tagging results, and construct an initial knowledge graph based on the knowledge element information;
[0072] S3: Merge the nodes in the initial knowledge graph to obtain a fused knowledge graph;
[0073] S4: Construct a mapping table based on the fused knowledge graph, and generate a candidate query template set based on the mapping table;
[0074] S5: Receive the natural language query statement input by the user, select the target query template from the candidate query template set based on the natural language query statement, and generate the target query statement;
[0075] S6: Use the target query statement to query from the fused knowledge graph and output the query results.
[0076] In specific implementation, the document to be analyzed is first received. In this embodiment of the invention, the document to be analyzed can be a power grid project document. The received power grid project document is cleaned, redundant formatting is removed, typos are corrected, and it is segmented into sentences and words. Based on the power grid domain-specific vocabulary library, the document is tagged with parts of speech to obtain the part-of-speech tagging results. Based on the part-of-speech tagging results, key information is extracted from the perspective of the power grid domain and an initial knowledge graph is constructed. The nodes in the initial knowledge graph are merged to obtain a fused knowledge graph.
[0077] To achieve efficient integration between user natural language queries and knowledge graphs, a mapping table is constructed based on the fused knowledge graph, and candidate query templates are generated. The user's input natural language query statement is segmented, part-of-speech tagging is performed, and intent recognition is performed to extract key elements. Based on the extracted key elements, the most matching target template is determined from each candidate template. The key elements in the user's natural language query statement are filled into the variables of the target template and converted into a target query statement supported by the knowledge graph. The fused knowledge graph is retrieved using the target query statement, and the query results are output.
[0078] In summary, this invention effectively mines and organizes key information in power grid project documents by performing part-of-speech tagging and knowledge element extraction, and constructing a knowledge graph based on a power grid domain ontology knowledge base. This improves the accuracy and comprehensiveness of information extraction. The invention also utilizes entity node similarity calculation and relationship determination mechanisms to construct a fused knowledge graph, reducing redundant information and optimizing the knowledge representation structure, making the knowledge graph more accurate and compact. This lays a solid foundation for subsequent intelligent analysis. Furthermore, the invention constructs mapping tables and query templates based on the fused knowledge graph, accurately converting users' natural language queries into knowledge graph query statements, achieving intelligent human-computer interaction, and improving the efficiency and user experience of power grid project document analysis.
[0079] In one optional implementation, the step of extracting knowledge element information from the part-of-speech tagging results based on a preset power grid domain ontology knowledge base, and constructing an initial knowledge graph based on the knowledge element information, includes:
[0080] The part-of-speech tagging results are matched with the power grid domain ontology knowledge base to extract knowledge element information;
[0081] Semantic annotation is performed on the knowledge element information to obtain knowledge elements with semantic tags, and a knowledge element interaction graph is constructed based on the knowledge elements with semantic tags.
[0082] For knowledge element pairs connected by edges in the knowledge element interaction graph, calculate the cosine similarity and generate an association matrix;
[0083] Based on the correlation matrix and the semantic tags, feature encoding is performed on the knowledge elements, each knowledge element is represented as a multi-dimensional feature vector, and the semantic similarity of the multi-dimensional feature vectors of each knowledge element pair is calculated.
[0084] Using the semantic tags as constraints, a minimum spanning tree is constructed based on the semantic similarity, and the minimum spanning tree is optimized to obtain several knowledge element clusters;
[0085] An initial knowledge graph is constructed based on the aforementioned knowledge element clusters.
[0086] Specifically, when performing pattern matching between the power grid ontology knowledge base and the part-of-speech tagging results, the concept templates in the power grid ontology knowledge base are first read, such as core concepts and attribute relationships like "substation," "transmission line," and "cable channel." These templates are then matched with the part-of-speech tagging text. For example, in the tagging text "110kV double-circuit overhead line project," "110kV" is identified as the voltage level attribute, "double-circuit" as the circuit characteristic, "overhead line" as the equipment type, and "project" as the project type, thus extracting complete knowledge element information. Pattern matching uses a combination of rule-based matching methods and statistical learning to ensure matching accuracy and coverage. By using predefined regular expressions, the patterns of power grid-specific terminology are identified. For candidate knowledge elements obtained from rule matching, their frequency of occurrence in the text set to be processed is statistically analyzed, and high-confidence matching results are selected.
[0087] After extracting the knowledge element information, semantic annotation is performed, mapping each knowledge element to a predefined semantic category, including but not limited to labels such as "equipment entity", "technical parameter", "engineering activity", "fault type", and "maintenance operation". For example, "transformer" is labeled as "equipment entity", "95%" is labeled as "operation indicator", and "installation" is labeled as "engineering activity". The semantic annotation process adopts a combination of rule-based and deep learning methods. The annotation task is completed by a semantic rule base built by experts in the power grid field and a pre-trained semantic classification model. In a specific case, from the text "the main transformer temperature rises to 85℃", "main transformer" is labeled as "equipment entity", "temperature rise" is labeled as "state change", and "85℃" is labeled as "technical parameter".
[0088] A knowledge element interaction graph is constructed based on knowledge element information with semantic labels. Each knowledge element with a semantic label is treated as a node in the graph. Connections between nodes are established according to the semantic relationships between knowledge elements. To quantify the association strength of knowledge elements, a pre-trained power grid domain word vector model is used to convert knowledge elements into word vectors. For knowledge element pairs with edge connections in the interaction graph, the cosine similarity of their word vectors is calculated. For example, the cosine similarity of the word vectors of "distribution transformer" and "power transformer" is 0.92, indicating that they are highly semantically related. Finally, an association degree matrix is generated, which records the degree of semantic association between all knowledge element pairs, laying the foundation for subsequent knowledge graph construction.
[0089] Based on the correlation matrix and semantic tags, feature encoding is performed on knowledge elements, representing each knowledge element as a multi-dimensional feature vector. The feature vector contains the following components: the word vector representation of the knowledge element, the one-hot encoding of the semantic tag, and the correlation vector with other elements. For example, for the knowledge element "circuit breaker," its feature vector includes its 300-dimensional vector representation in the word space, the encoding of the semantic tag "equipment entity," and a vector composed of correlation values with all other knowledge elements. For each pair of knowledge elements, weighted cosine distance is used as the similarity calculation method to calculate the semantic similarity of its feature vectors.
[0090] When constructing a minimum spanning tree based on semantic similarity, a complete graph is first established. The weight of each edge in the graph is the reciprocal of the semantic similarity between the feature vectors corresponding to the knowledge elements. An improved Kruskal algorithm is used to construct the minimum spanning tree. During the algorithm execution, semantic labels are used as constraints, prioritizing the connection of nodes with the same semantic labels, and optimizing the minimum spanning tree. The initial minimum spanning tree may contain connections between nodes with weak semantic association. In specific implementation, edges with semantic similarity lower than a preset first similarity threshold can be pruned, and connections can be added between unconnected nodes with semantic similarity higher than a second similarity threshold, forming multiple connected subgraphs. Each connected subgraph is a knowledge element cluster. For each knowledge element cluster, redundant elements are merged. Knowledge elements with semantic similarity higher than a preset merging threshold and identical semantic labels, such as "cable trench" and "cable trough," are identified and merged into a unified knowledge representation to avoid redundant nodes in the graph and ensure optimal association between elements within the cluster.
[0091] According to predefined mapping rules, the merged knowledge element information and its semantic tags are mapped to the knowledge graph. For example, elements labeled as "equipment entities" are mapped to entity nodes, and elements labeled as "engineering activities" are mapped to event nodes. The relationships between elements are determined based on their co-occurrence in the document and the results of semantic analysis, such as subject-action relationships, part-whole relationships, etc. In this way, an initial knowledge graph that can reflect the core knowledge content of power grid project documents is constructed.
[0092] This invention extracts knowledge elements from an ontology knowledge base in the power grid domain, constructs an interaction graph, and utilizes semantic tags and semantic similarity for fusion optimization. This helps to uncover implicit conceptual relationships and knowledge structures in documents, improves the expressive accuracy and coverage of the knowledge graph, and finally achieves highly semantically related knowledge aggregation through feature encoding and minimum spanning tree optimization. This transforms unstructured document data into a structured semantic network, providing a high-quality, interpretable knowledge foundation for subsequent applications such as knowledge query, intelligent recommendation, and decision support.
[0093] In one optional implementation, merging the nodes in the initial knowledge graph to obtain a fused knowledge graph includes:
[0094] Based on the power grid domain ontology knowledge base, all entity nodes in the initial knowledge graph are transformed into semantic vectors to obtain the node semantic feature space;
[0095] A third-order semantic feature tensor is constructed based on the node semantic feature space. Tensor decomposition technique is used to extract the structural feature vector and context feature vector of the entity node. The structural feature vector and the context feature vector are concatenated to obtain the fused feature vector of the entity node.
[0096] Calculate the similarity of the fused feature vectors of any two entity nodes and construct a similarity association graph of all entity nodes;
[0097] The similarity association graph is divided into multiple communities using a community discovery algorithm, and entity nodes in the communities with semantic similarity higher than a preset semantic similarity threshold are merged.
[0098] Based on the relationship types and attribute information of the merged entity nodes, a fused knowledge graph is obtained.
[0099] Specifically, based on the ontology knowledge base of the power grid domain, each entity node in the initial graph is transformed into a semantic vector, which is then mapped to a fixed-dimensional vector space through a word vector model to provide numerical basis for subsequent similarity analysis. For example, entity nodes such as "110kV transformer" and "220kV transformer" are represented as 300-dimensional feature vectors, recording their position information in the semantic space. The semantic vectors of all entity nodes are placed in the same high-dimensional space, namely the node semantic feature space.
[0100] Relying solely on semantic vectors cannot fully reflect the associative characteristics of entity nodes in a knowledge graph. Therefore, a third-order semantic feature tensor is constructed based on the node semantic feature space. This third-order semantic feature tensor contains information in three dimensions: node-node-relationship, used to capture complex semantic associations between entity nodes. First, initial semantic features of nodes are extracted using a pre-trained word embedding model. A multi-scale sampling strategy is adopted, setting different sampling window sizes, such as 3×3, 5×5, and 7×7, each covering a different range in the node feature space, thereby capturing semantic information at different scales. For a semantic feature space containing 10,000 nodes, each with a 128-dimensional feature vector, a third-order semantic feature tensor is constructed based on the node semantic feature space. By sampling windows at different scales, three feature matrices can be obtained, with dimensions of 10000×64, 10000×32, and 10000×16, respectively, forming a multi-scale feature matrix set. Expanding the multi-scale feature matrix in the time dimension, the temporal change information of node semantic features is obtained, and a third-order semantic feature tensor is constructed. For example, node semantic data for 30 consecutive days is collected with a week as the cycle, and the multi-scale feature matrices of each day are arranged in chronological order to form a third-order semantic feature tensor. The three dimensions of this tensor correspond to the number of nodes, the feature dimension, and the time step, respectively. For the above example, a third-order semantic feature tensor of 10000×112×30 can be obtained, where 112 is the sum of the three different scale feature dimensions.
[0101] Tensor decomposition is used to extract structural feature vectors and context feature vectors of entity nodes. Structural features reflect the node's position and connection pattern in the graph, while context features reflect the node's semantic environment. Taking "distribution transformer" as an example, its structural features include information about nodes directly connected to it, such as "distribution network" and "power equipment," while context features include broader semantic associations, such as the degree of association with concepts like "power transmission" and "voltage transformation." The structural feature vector and context feature vector are concatenated. Assuming that both structural and context features are 150-dimensional vectors, the concatenation results in a 300-dimensional fused feature vector. The fused feature vector contains both structural and semantic information, which can more comprehensively represent the characteristics of the node.
[0102] The cosine similarity method is used to calculate the similarity of the fused feature vectors of any two entity nodes (the value ranges from 0 to 1, and the closer the value is to 1, the stronger the semantic association). If there are N entity nodes in the initial knowledge graph, an N×N similarity matrix M is constructed. The matrix element M(i,j) represents the semantic similarity between the i-th entity and the j-th entity. A similarity association graph is constructed based on the similarity matrix to intuitively present the association strength between entities. The nodes in the graph represent all entity nodes in the initial knowledge graph, and the weight of the edge represents the semantic similarity between the two nodes.
[0103] A community discovery algorithm is used to cluster highly correlated entity nodes in the similarity association graph into multiple communities. Each community corresponds to a group of semantically highly similar entity nodes. For example, the algorithm may identify a community containing nodes such as "distribution transformer", "power transformer", and "oil-immersed transformer". These nodes are highly correlated semantically. To avoid semantically unrelated entities being incorrectly clustered (e.g., classifying "substation" and "transformer" into the same community), the communities need to be verified using the power grid domain ontology knowledge base. This involves checking whether all entity nodes within the community have the same conceptual hierarchy in the ontology, i.e., whether they belong to the same subclass or parent class. For example, it checks whether "oil-immersed transformer" and "dry-type transformer" are both sub-concepts of "transformer" to ensure that the nodes within the community have a reasonable conceptual relationship. For entity nodes in the verified communities with a semantic similarity higher than a preset semantic similarity threshold (e.g., 0.75), a merging operation is performed to eliminate redundancy. For example, "distribution transformer" and "power transformer" are identified as the same entity and merged.
[0104] The system extracts relationship types and attribute information between merged entity nodes from the power grid ontology knowledge base. Relationship types include "part-whole," "type-subclass," and "equipment-function," while attribute information includes equipment parameters, operating status, and maintenance records. For example, for the merged "transformer" entity, the system obtains its "installed at" relationship with "substation," as well as the transformer's "rated voltage" and "capacity" attributes. These relationship types and attribute information are then added to the merged entity nodes to form a complete fused knowledge graph. The final fused knowledge graph contains deduplicated and merged entity nodes, along with rich relationships and attribute information between them. For instance, the fused knowledge graph clearly shows that a "220kV transformer" is a type of "transformer," it is "installed at" a "substation," and it has attributes such as "rated voltage 220kV" and "capacity 500MVA." It also has an "equipment" relationship with a "cooling system." This fused knowledge graph provides a structured knowledge foundation for knowledge management and intelligent applications in the power grid field.
[0105] This invention integrates semantic, structural, and contextual features to construct a more expressive fusion feature vector, enabling more accurate semantic similarity calculation between entity nodes. It introduces community discovery and ontology-level verification mechanisms to effectively identify and merge redundant nodes representing the same or highly related concepts, avoiding information fragmentation. Furthermore, based on relational types and attribute information obtained from the power grid domain ontology, it enhances semantic connections between nodes and enriches the semantic relationship expression in the graph. This results in the construction of a semantically coherent, structurally optimized fusion knowledge graph that conforms to the power grid professional semantic system, providing solid support for intelligent retrieval, semantic reasoning, and auxiliary decision-making in power grid business scenarios.
[0106] In one optional implementation, the step of extracting the structural feature vector and context feature vector of the entity node using tensor decomposition technology, and concatenating the structural feature vector and the context feature vector to obtain the fused feature vector of the entity node, includes:
[0107] Tensor decomposition technology is used to perform spatiotemporal decomposition on the third-order semantic feature tensor to obtain a heterogeneous feature matrix including temporal pattern features and spatial pattern features. Spatiotemporal correlation degree is calculated based on the heterogeneous feature matrix.
[0108] Select the feature combination with the highest spatiotemporal correlation as the structural feature;
[0109] A node attention matrix is constructed using the third-order semantic feature tensor. The node attention matrix is then weighted according to the spatiotemporal correlation. Based on the adjusted attention weights, the contextual semantic representation of the entity is calculated, and the contextual semantic representation with the largest attention weight is selected as the contextual feature.
[0110] A fused feature vector is generated based on the structural features and the context features.
[0111] Specifically, the third-order tensor contains spatial and temporal features. Tensor decomposition is used to decompose it spatiotemporally into the product of the core tensor and three factor matrices. The three factor matrices correspond to the node dimension, feature dimension, and time dimension, respectively. The factor matrix of the feature dimension is extracted as the spatial pattern feature with a dimension of 112×20, and the factor matrix of the time dimension is extracted as the temporal pattern feature with a dimension of 30×15. By controlling the dimension of the factor matrices, the complexity of the features can be reduced while retaining the main pattern information. The temporal pattern feature and the spatial pattern feature are multiplied by matrix to obtain the combined feature matrix. Then, the original node features are horizontally concatenated with the flattened result of the combined feature matrix to obtain the heterogeneous feature matrix.
[0112] For each entity in the heterogeneous feature matrix, cosine similarity is used to calculate the similarity between its features and the features of other nodes. The top K nodes with the highest similarity are selected to form its associated node set. For example, K can be set to 20. The feature similarity change rate between the node and each node in the associated node set at different time steps is calculated. The associated nodes with a change rate greater than a preset change rate threshold (e.g., 0.3) are regarded as strong spatiotemporal associated nodes. Based on the feature combination of strong spatiotemporal associated nodes, the frequently occurring feature patterns are extracted as structural features with a dimension of 128.
[0113] A node attention matrix is constructed based on the third-order semantic feature tensor. Specifically, for each node, an attention score is calculated based on its feature similarity with other nodes. The higher the similarity, the larger the attention score. The attention scores are normalized to obtain attention weights, and a 10000×10000 node attention matrix is constructed. The attention matrix is adjusted according to the previously calculated spatiotemporal correlation to enhance the weights between nodes with strong spatiotemporal correlation. The adjustment coefficient can be set to 1.5 times. When calculating the contextual semantic representation of each node, its attention weight is weighted and summed with the feature vector of the corresponding node. The weighted average of the contextual semantic representations corresponding to the top 10 maximum attention weights is selected as the final contextual feature with a dimension of 128.
[0114] The structural features and contextual features are concatenated, that is, two 128-dimensional feature vectors are directly concatenated to obtain a 256-dimensional vector. To reduce feature redundancy, an important feature is selected from them by ranking based on importance. The relevance score of each feature to the target task is calculated, and the top few features with the highest scores are selected to form the final fused feature vector.
[0115] This invention, through constructing a third-order semantic feature tensor and performing spatiotemporal decomposition, can extract potential patterns of nodes under temporal evolution and spatial distribution, mine implicit semantic evolution relationships between entities, and introduce attention mechanisms and spatiotemporal correlation calculations. This allows for dynamic focusing on contextual information that contributes more to semantics, improving the accuracy and discriminativeness of semantic modeling. Finally, through feature selection, a fused feature vector is generated, achieving efficient compression and semantic enhancement of entity node representations. This enables in-depth mining of multi-dimensional feature information of entity nodes at multiple scales, temporal sequences, and contextual semantic levels, achieving accurate modeling of the semantic expression of entity nodes in the power grid knowledge graph. This provides a high-quality input foundation for subsequent node clustering, graph fusion, and intelligent analysis.
[0116] In one optional implementation, the step of constructing a mapping table based on the fused knowledge graph and generating a candidate query template set based on the mapping table includes:
[0117] The entity type, relationship type, and attribute information of all entity nodes are extracted from the fused knowledge graph. A first mapping matrix and a second mapping matrix are constructed, and a mapping table is constructed based on the first mapping matrix and the second mapping matrix. The first mapping matrix is used to record the correspondence between the entity type and the relationship type, and the second mapping matrix is used to record the correspondence between the entity type and the attribute information.
[0118] The mapping table is traversed using a depth-first traversal algorithm to generate a node access sequence, and the node access sequence is grouped according to the mapping level;
[0119] Calculate the mutual information of nodes within a group and the mutual information of nodes between groups, and construct a heterogeneous node co-occurrence matrix based on the mutual information of nodes within a group and the mutual information of nodes between groups.
[0120] Singular value decomposition is performed on the heterogeneous node co-occurrence matrix to obtain the node feature matrix. Based on the node feature matrix, the inter-layer node attention distribution is calculated to generate an inter-layer node association weight table.
[0121] Based on the inter-layer node association weight table, a query path is selected from the mapping table to generate a query path set, and a candidate query template set is generated based on the query path set.
[0122] Specifically, the entity type, relationship type, and attribute information of all entity nodes are extracted from the fused knowledge graph to construct a first mapping matrix and a second mapping matrix. Taking a power grid project document as an example, the fused knowledge graph contains entity types such as "substation", "transmission line", and "power equipment", relationship types such as "connection", "located", and "power supply", and attribute information such as "voltage level", "capacity", and "activation time". The first mapping matrix records the correspondence between entity types and relationship types, such as "substation-connection-transmission line" and "power equipment-located-substation". The second mapping matrix records the correspondence between entity types and attribute information, such as "substation-voltage level-500kV" and "transmission line-length-50 km". A complete mapping table is constructed through these two matrices. The mapping table structure includes entity type nodes, relationship type nodes, attribute nodes, and attribute value nodes, as well as the connection relationships between them.
[0123] A depth-first traversal is performed on the mapping table, starting from the root node and traversing the entire mapping table according to the depth-first strategy. The order of the nodes visited is recorded. For example, starting from the entity type node "substation", the related relationship node "connection" is visited, then the entity type node "transmission line" related to "connection" is visited, then the attribute node "length" of "transmission line" is visited, and so on, to generate a node visit sequence that reflects the association order of elements.
[0124] The node access sequence is grouped according to the mapping hierarchy. Nodes at the same level are grouped together. For example, entity type nodes are at the first level, relation type nodes are at the second level, attribute nodes are at the third level, and attribute value nodes are at the fourth level. Intra-group mutual information and inter-group mutual information are calculated to quantify the association strength between nodes at the same level and across levels. When calculating intra-group node mutual information, the co-occurrence frequency and association degree between nodes within the same group are analyzed. For example, the co-occurrence frequency of the entity type nodes "substation" and "power equipment" in the document is analyzed. When calculating inter-group node mutual information, the association degree between nodes in different groups is analyzed. For example, the association strength between the entity type node "substation" and the attribute node "voltage level" is analyzed. Based on the intra-group node mutual information and inter-group node mutual information, a heterogeneous node co-occurrence matrix is constructed. The matrix dimension is the set of all heterogeneous nodes, and the element value is the mutual information value of the corresponding node pair. This matrix represents the co-occurrence relationship and association strength between different types of nodes.
[0125] Singular value decomposition is performed on the heterogeneous node co-occurrence matrix to retain core association features, resulting in a low-dimensional node feature matrix. Each row of the node feature matrix represents a feature vector of a node, and the dimension of the vector reflects the richness of the features. Based on the node feature matrix, attention weights between nodes at different levels are calculated to quantify the degree of attention of a node at one level to a node at another level. The higher the weight value, the closer the association. An inter-level node association weight table is then generated.
[0126] The mapping table is used to extract paths based on the inter-layer node association weight table. Paths with high association weights are selected based on the association weights between nodes. For example, starting from the "substation" entity type node, passing through the "located in" relation type node, reaching the "region" entity type node, and then to the "name" attribute node, a query path is formed. Each path represents a possible query pattern. The total weight of the path is calculated based on the association weights between nodes in the path, and paths with higher weights are selected first. This method generates a set of query paths. Query statement templates are constructed using the node combination information in the query path set. The nodes in the path are converted into the syntax structure of the query language. For example, the path "substation-voltage level-500kV" can be converted into the template "query substations with a voltage level of 500kV". For the complex path "substation-connection-transmission line-length-50 km", it can be converted into the template "query substations connected to a transmission line with a length of 50 km". The query statement templates are sorted based on the path weight information in the query path set, with templates with higher weights ranked first, generating a set of candidate query templates.
[0127] This invention, through the construction of a mapping table, facilitates the comprehensive integration of semantic elements in the knowledge graph. By combining node access sequences and mutual information analysis to construct a heterogeneous co-occurrence matrix, it can reveal potential dependencies between different semantic levels. By utilizing singular value decomposition and attention mechanisms to generate inter-layer node association weights, it achieves accurate extraction and effective compression of query paths. Finally, the candidate query templates constructed through weight ranking can cover semantically rich and structurally sound query paths. This enables the automatic extraction of structured semantic information from the fused knowledge graph and the construction of high-quality query templates, significantly improving intelligent query capabilities for power grid business scenarios and providing accurate and efficient support for intelligent question answering, semantic search, and automated data interaction.
[0128] In one optional implementation, the step of selecting a target query template from the candidate query template set based on the natural language query statement and generating a target query statement includes:
[0129] Extract the query keyword sequence from the natural language query statement and map the keyword sequence into a query semantic vector;
[0130] Extract the template keyword sequence of each candidate query template in the candidate query template set, and map the template keyword sequence into a template semantic vector;
[0131] Based on the query semantic vector and the template semantic vector, the target query template is determined from the candidate query template set;
[0132] Entity words and relation words are identified from the natural language query statement, an entity-relation correspondence graph is constructed, the entity-relation correspondence graph is bidirectionally mapped to the slots in the target query template, a set of slot filling rules is generated, and the consistency of the set of slot filling rules is verified to obtain the target slot filling rules.
[0133] The target query template is instantiated based on the target slot filling rules to generate an intermediate query expression. The intermediate query expression is then normalized to generate the target query statement.
[0134] Specifically, user-input natural language queries are typically unstructured text. They are first preprocessed, including word segmentation and stop word removal. For example, if a user inputs "query the distribution locations of substations with a voltage level of 500kV," the preprocessed keyword sequence is extracted as "query-voltage level-500kV-substation-distribution location." To quantify the semantic meaning of the keyword sequence, a pre-trained word embedding model is used to convert the keyword sequence into a vector representation. Each keyword is mapped to a vector in a high-dimensional space. For power grid-related terms such as "voltage level" and "substation," a domain-adaptive fine-tuned word embedding model is used to obtain a more accurate semantic representation. A weighted average of each word vector in the keyword sequence is then performed to obtain the query semantic vector of the entire query statement. The weights can be determined based on factors such as part-of-speech, word frequency, and the word's position in the sentence. Technical terms and specialized jargon are typically assigned higher weights.
[0135] Semantic decomposition is performed on each candidate query template in the candidate query template set. The structure and semantic composition of the template are parsed, and the template keyword sequence is extracted. For example, the candidate query template "query {attribute} of {substation} with {voltage level} as {value}" can be extracted into the template keyword sequence "query-voltage level-value-substation-attribute". The template keyword sequence is mapped to the template semantic vector. The method is similar to that used to construct the query semantic vector. The template keyword sequence is converted into a vector representation and a weighted average is performed to obtain the template semantic vector. For the slot parts in the template, such as "{voltage level}" and "{value}", special slot vectors are used to distinguish between fixed text and variable parameters.
[0136] This algorithm calculates multiple similarity metrics between the query semantic vector and the template semantic vector, including cosine similarity, Euclidean distance, and dot product. Considering the structural similarity of keyword sequences, the longest common subsequence algorithm is used to calculate the structural matching degree between the query keyword sequence and the template keyword sequence. Semantic similarity is also considered, performing a one-to-one semantic matching between query keywords and template keywords. Combining these features, a multi-dimensional similarity feature set is constructed. A comprehensive matching score is calculated based on this feature set, and weights are assigned to each feature dimension. The final matching score is obtained by weighted summation. For queries in the power grid field, the accuracy of matching specialized terminology is more important, and the corresponding feature dimensions have higher weights. The comprehensive matching score of all candidate query templates is calculated, and the template with the highest score is selected as the target query template. For example, for the query "distribution locations of substations with a voltage level of 500kV", the target query template might be "{attributes} of {substations} with {voltage level} as {value}".
[0137] Furthermore, entity words and relation words are identified from natural language queries to construct an entity-relationship mapping graph. Specifically, named entity recognition technology is used to identify power grid-specific entities, such as "substation" and "transmission line," and dependency parsing is used to identify relation words between entities, such as "connection" and "power supply." An entity-relationship mapping graph is constructed based on the identified entity words and relation words. This graph represents the structural association between entities and relations in the query statement. For example, for the query "distribution location of substations with a voltage level of 500kV," the constructed entity-relationship mapping graph includes the entity "substation," the attributes "voltage level" and "distribution location," and the relationship between the entity and the attributes.
[0138] The entity-relationship mapping diagram is bidirectionally mapped to the slots in the target query template to determine the correspondence between entity terms, relation terms and template slots. For example, "substation" is mapped to the "{substation}" slot in the template, "500kV" is mapped to the "{value}" slot, and "distribution location" is mapped to the "{attribute}" slot. Through this mapping relationship, a set of slot filling rules is generated to specify the specific content that should be filled in each slot.
[0139] The set of slot filling rules is subjected to consistency verification to check whether there are any conflicts between the rules and whether the content of the slot filling conforms to the type and format required by the template. For example, it is checked whether the "{voltage level}" slot is indeed filled with voltage level-related content and whether the "{value}" slot is filled with a valid value. The target slot filling rules are obtained through verification to ensure the consistency and rationality of the rules.
[0140] The target query template is instantiated based on the target slot filling rules, replacing the slots with specific entity words, relational words, or attribute values. For example, the target query template "Query {attribute} of {substation} with {voltage level} as {value}" is instantiated as "Query the distribution location of substations with voltage level of 500kV", generating an intermediate query expression such as "FIND(substation).WHERE(voltage level = 500kV).SELECT(distribution location)". The intermediate query expression is then normalized and converted into the syntax structure of a specific knowledge graph query language, such as SPARQL or Cypher. For example, it is converted into "MATCH(s: substation)WHERE s.voltage level = '500kV'RETURN s.distribution location". In this way, the user's natural language query is converted into an executable target query statement, realizing intelligent analysis of power grid project documents.
[0141] This invention, through constructing query semantic vectors and template semantic vectors and performing multi-dimensional semantic similarity matching, can accurately identify user intent and select the optimal query template. Combined with entity-relationship correspondence graphs and slot mapping mechanisms, it achieves precise alignment of natural language information to structured query slots. Consistency verification of slot filling rules ensures the semantic integrity and execution effectiveness of the generated query expression. The final standardized query statement can be directly used for knowledge graph retrieval, effectively supporting the extraction of power grid business data and knowledge acquisition under complex semantics.
[0142] In one optional implementation, determining the target query template from the candidate query template set based on the query semantic vector and the template semantic vector includes:
[0143] The query semantic vector and the template semantic vector are mapped to the same semantic space to extract a multi-level semantic association matrix, including a local semantic association matrix and a global semantic association matrix.
[0144] The interaction influence degree is calculated based on the multi-level semantic association matrix to generate an interaction weight matrix. The interaction influence degree includes the first influence degree of the query semantic vector on the template semantic vector and the second influence degree of the template semantic vector on the query semantic vector.
[0145] The multi-level semantic association matrix and the interaction weight matrix are merged to obtain a joint representation matrix. The main feature vectors are extracted by eigenvalue decomposition to obtain a multi-dimensional similarity feature set.
[0146] The features in the multidimensional similarity feature set are iteratively optimized and weighted based on a dynamic programming strategy to generate a comprehensive matching score. The candidate query template with the highest comprehensive matching score is then determined as the target query template.
[0147] Specifically, query semantic vectors and template semantic vectors are mapped to the same semantic space, establishing a three-layer semantic association structure at the word, phrase, and sentence levels. Taking a query in the power grid domain as an example, when a user inputs "query the capacity and operating time of the main transformer of substation A," the corresponding query semantic vector contains semantic information of keywords such as "substation," "main transformer," "capacity," and "operating time." The template semantic vector of a candidate template, "query the {attribute 1} and {attribute 2} of {equipment} of {substation}," contains semantic information of the corresponding slot. At the word level, the semantic vector of each... The semantic similarity between each word and each word in the template is analyzed, such as the matching degree between "substation" and "{substation}", and "main transformer" and "{equipment}". At the phrase level, the phrases in the query semantic vector are matched with the structure in the template, such as the matching degree between "main transformer of substation A" and "{equipment} of {substation}". At the sentence level, the semantic consistency between the complete query semantic vector and the complete template is compared. Through this hierarchical analysis, the local semantic association strength and the global semantic association strength are extracted to generate a multi-level semantic association matrix. This matrix contains semantic association information between the query and the template at different levels.
[0148] The semantic matching between queries and templates is a two-way process. Based on a multi-level semantic association matrix, the degree of interaction influence is calculated. For each element in the query semantic vector, the degree of influence on each element in the template semantic vector is calculated to form the first degree of influence of the query semantic vector on the template semantic vector. For example, "main transformer" in the query has a high degree of influence on the "{equipment}" slot in the template, but a small degree of influence on the "{substation}" slot. Similarly, the degree of influence of each element in the template semantic vector on each element in the query semantic vector is calculated to form the second degree of influence of the template semantic vector on the query semantic vector. In the power grid field, the slots with professional terms in the template, such as "{voltage level}" and "{capacity}", have a high degree of influence on the relevant terms in the query.
[0149] By weighted aggregation of these bidirectional influences, an interaction weight matrix is generated. For example, for the query "Query the capacity and operating time of the main transformer of substation A" and the template "Query the {attribute 1} and {attribute 2} of {equipment} of {substation}", the interaction weight matrix shows that the influence weight of "main transformer" on the slot of "{equipment}" is 0.92, and the influence weight of "capacity" on the slot of "{attribute 1}" is 0.88.
[0150] By merging the multi-level semantic association matrix with the interaction weight matrix, a joint representation matrix is obtained. The main feature vectors are extracted through eigenvalue decomposition. In the power grid field, semantic features related to equipment type, attribute features, and relationship type may be extracted. For example, the "equipment-attribute" relationship feature can be extracted from "the capacity of the main transformer of substation A" to represent the semantic association pattern between equipment and its attributes. In this way, local semantic features (such as word-level and phrase-level matching features) and global semantic features (such as overall structural consistency features) are extracted to obtain a multi-dimensional similarity feature set. In practical cases, the multi-dimensional similarity feature set may include multiple dimensions such as semantic matching degree, structural similarity, and technical term matching accuracy.
[0151] Based on a dynamic programming strategy, the features in the multidimensional similarity feature set are iteratively optimized and weighted. First, an initial weight is assigned to each feature. In the power grid document analysis scenario, the matching accuracy of professional terms usually has a higher initial weight. Through iterative optimization, the feature weights are continuously adjusted to make the matching results more consistent with the query characteristics of the power grid field. The dynamic programming algorithm is used to find the optimal weight combination. This algorithm decomposes the feature weight optimization problem into sub-problems and gradually constructs the optimal solution by solving the sub-problems. In each iteration, the matching effect under the current weight combination is evaluated, and the weights are adjusted according to the evaluation results. For example, if it is found that term matching has a greater impact on the overall matching result, the weight of the corresponding feature is increased; if structural matching has a greater impact, the weight of structural features is increased. Through multiple rounds of iteration, the optimal weight combination is finally determined and used to calculate the comprehensive matching score. All candidate query templates are sorted according to the comprehensive matching score, and the template with the highest score is selected as the target query template.
[0152] For example, a user inputs "query the overload status and maintenance records of 35kV lines within power grid area B". After processing, a query semantic vector is obtained, containing key information such as "power grid area", "35kV", "line", "overload status", and "maintenance records". After constructing a hierarchical semantic association graph, the association strength with multiple candidate templates is calculated. For example, candidate template 1 "query the {status} and {record type} of {voltage level} {equipment} within {area}", and candidate template 2 "query the {attribute 1} and {attribute 2} of {voltage level} {equipment} in {area}", etc. At the word level, the matching degree between "35kV" and "{voltage level}" is 0.95, and the matching degree between "line" and "{equipment}" is 0.93. At the phrase level, "power grid area" and "35kV line" are matched. The matching degree between "within network area B" and "within {area}" is 0.89. After calculating the bidirectional interaction weights, it was found that the influence weight of "overload status" in the query on "{status}" in the template is 0.91, and the influence weight of "{record type}" in the template on "maintenance record" in the query is 0.88. Through adaptive feature decomposition, key features such as "area-device" relationship features (weight 0.25), "device-status" relationship features (weight 0.30), and professional terminology matching features (weight 0.35) were extracted. After dynamic programming optimization, the comprehensive matching score of candidate template 1 is 0.92, and the score of candidate template 2 is 0.78. Therefore, candidate template 1 is determined as the target query template for subsequent target query statement generation.
[0153] For example, see Figure 2 The figure shows the implementation effect of an embodiment of the present invention. It illustrates the comparison of semantic matching accuracy of three different methods at the word level, phrase level, and sentence level. This embodiment adopts the hierarchical semantic association graph method, which achieves a matching accuracy of 90.2% at the word level, 94.5% at the phrase level, and as high as 96.8% at the sentence level, showing a clear increasing trend. It can provide more accurate matching results as the semantic level increases. In contrast, the traditional method (Word2Vec algorithm based on word vector similarity) has an accuracy of 84.7% at the word level, 82.1% at the phrase level (showing a decrease), and 87.3% at the sentence level, with unstable and generally low matching accuracy. Although the improved method (BERT model based on attention mechanism) achieved good performance of 88.3%, 91.2% and 93.4% at the three levels, it was still lower than that of this embodiment. In particular, at the phrase level and the whole sentence level, this embodiment outperformed the traditional method by 12.4 and 9.5 percentage points, respectively, and outperformed the improved method by 3.3 and 3.4 percentage points, respectively. This fully demonstrates the superiority of hierarchical semantic association graphs in handling complex query template matching tasks.
[0154] This invention improves the multi-granularity perception of user query intent and template semantic structure by constructing a hierarchical semantic association graph and extracting local and global semantic relationships. Bidirectional interactive modeling further enhances the bidirectional constraint capability of semantic alignment, effectively capturing the semantic response relationship between the query and the template. Combined with adaptive feature decomposition and dynamic programming weighted optimization, it can extract the most discriminative matching elements from multi-dimensional similarity features, improving matching accuracy and robustness. It can achieve deep semantic matching and high-precision template selection between natural language query statements and candidate query templates, thereby ensuring that the final selected query template is highly consistent with the user intent, providing a reliable basis for the accurate generation of subsequent knowledge graph query statements.
[0155] Secondly, embodiments of the present invention provide a document analysis and query device based on a knowledge graph, see [link to related document description]. Figure 3 The diagram shown is a structural schematic of a knowledge graph-based document analysis and query device provided in an embodiment of the present invention.
[0156] like Figure 3 As shown, the device includes:
[0157] Document preprocessing module 21 is used to perform part-of-speech tagging on the received document to be analyzed and obtain the part-of-speech tagging results;
[0158] The knowledge graph construction module 22 is used to extract knowledge element information from the part-of-speech tagging results based on a preset power grid domain ontology knowledge base, and to construct an initial knowledge graph based on the knowledge element information;
[0159] The knowledge graph fusion module 23 is used to merge the nodes in the initial knowledge graph to obtain a fused knowledge graph;
[0160] The query template generation module 24 is used to construct a mapping table based on the fused knowledge graph and generate a set of candidate query templates based on the mapping table.
[0161] The query statement generation module 25 is used to receive a natural language query statement input by the user, select a target query template from the candidate query template set based on the natural language query statement, and generate a target query statement.
[0162] The query result output module 26 is used to query the fused knowledge graph using the target query statement and output the query results.
[0163] In one optional implementation, the step of extracting knowledge element information from the part-of-speech tagging results based on a preset power grid domain ontology knowledge base, and constructing an initial knowledge graph based on the knowledge element information, includes:
[0164] The part-of-speech tagging results are matched with the power grid domain ontology knowledge base to extract knowledge element information;
[0165] Semantic annotation is performed on the knowledge element information to obtain knowledge elements with semantic tags, and a knowledge element interaction graph is constructed based on the knowledge elements with semantic tags.
[0166] For knowledge element pairs connected by edges in the knowledge element interaction graph, calculate the cosine similarity and generate an association matrix;
[0167] Based on the correlation matrix and the semantic tags, feature encoding is performed on the knowledge elements, each knowledge element is represented as a multi-dimensional feature vector, and the semantic similarity of the multi-dimensional feature vectors of each knowledge element pair is calculated.
[0168] Using the semantic tags as constraints, a minimum spanning tree is constructed based on the semantic similarity, and the minimum spanning tree is optimized to obtain several knowledge element clusters;
[0169] An initial knowledge graph is constructed based on the aforementioned knowledge element clusters.
[0170] In one optional implementation, merging the nodes in the initial knowledge graph to obtain a fused knowledge graph includes:
[0171] Based on the power grid domain ontology knowledge base, all entity nodes in the initial knowledge graph are transformed into semantic vectors to obtain the node semantic feature space;
[0172] A third-order semantic feature tensor is constructed based on the node semantic feature space. Tensor decomposition technique is used to extract the structural feature vector and context feature vector of the entity node. The structural feature vector and the context feature vector are concatenated to obtain the fused feature vector of the entity node.
[0173] Calculate the similarity of the fused feature vectors of any two entity nodes and construct a similarity association graph of all entity nodes;
[0174] The similarity association graph is divided into multiple communities using a community discovery algorithm, and entity nodes in the communities with semantic similarity higher than a preset semantic similarity threshold are merged.
[0175] Based on the relationship types and attribute information of the merged entity nodes, a fused knowledge graph is obtained.
[0176] In one optional implementation, the step of extracting the structural feature vector and context feature vector of the entity node using tensor decomposition technology, and concatenating the structural feature vector and the context feature vector to obtain the fused feature vector of the entity node, includes:
[0177] Tensor decomposition technology is used to perform spatiotemporal decomposition on the third-order semantic feature tensor to obtain a heterogeneous feature matrix including temporal pattern features and spatial pattern features. Spatiotemporal correlation degree is calculated based on the heterogeneous feature matrix.
[0178] Select the feature combination with the highest spatiotemporal correlation as the structural feature;
[0179] A node attention matrix is constructed using the third-order semantic feature tensor. The node attention matrix is then weighted according to the spatiotemporal correlation. Based on the adjusted attention weights, the contextual semantic representation of the entity is calculated, and the contextual semantic representation with the largest attention weight is selected as the contextual feature.
[0180] A fused feature vector is generated based on the structural features and the context features.
[0181] In one optional implementation, the step of constructing a mapping table based on the fused knowledge graph and generating a candidate query template set based on the mapping table includes:
[0182] The entity type, relationship type, and attribute information of all entity nodes are extracted from the fused knowledge graph. A first mapping matrix and a second mapping matrix are constructed, and a mapping table is constructed based on the first mapping matrix and the second mapping matrix. The first mapping matrix is used to record the correspondence between the entity type and the relationship type, and the second mapping matrix is used to record the correspondence between the entity type and the attribute information.
[0183] The mapping table is traversed using a depth-first traversal algorithm to generate a node access sequence, and the node access sequence is grouped according to the mapping level;
[0184] Calculate the mutual information of nodes within a group and the mutual information of nodes between groups, and construct a heterogeneous node co-occurrence matrix based on the mutual information of nodes within a group and the mutual information of nodes between groups.
[0185] Singular value decomposition is performed on the heterogeneous node co-occurrence matrix to obtain the node feature matrix. Based on the node feature matrix, the inter-layer node attention distribution is calculated to generate an inter-layer node association weight table.
[0186] Based on the inter-layer node association weight table, a query path is selected from the mapping table to generate a query path set, and a candidate query template set is generated based on the query path set.
[0187] In one optional implementation, the step of selecting a target query template from the candidate query template set based on the natural language query statement and generating a target query statement includes:
[0188] Extract the query keyword sequence from the natural language query statement and map the keyword sequence into a query semantic vector;
[0189] Extract the template keyword sequence of each candidate query template in the candidate query template set, and map the template keyword sequence into a template semantic vector;
[0190] Based on the query semantic vector and the template semantic vector, the target query template is determined from the candidate query template set;
[0191] Entity words and relation words are identified from the natural language query statement, an entity-relation correspondence graph is constructed, the entity-relation correspondence graph is bidirectionally mapped to the slots in the target query template, a set of slot filling rules is generated, and the consistency of the set of slot filling rules is verified to obtain the target slot filling rules.
[0192] The target query template is instantiated based on the target slot filling rules to generate an intermediate query expression. The intermediate query expression is then normalized to generate the target query statement.
[0193] In one optional implementation, determining the target query template from the candidate query template set based on the query semantic vector and the template semantic vector includes:
[0194] The query semantic vector and the template semantic vector are mapped to the same semantic space to extract a multi-level semantic association matrix, including a local semantic association matrix and a global semantic association matrix.
[0195] The interaction influence degree is calculated based on the multi-level semantic association matrix to generate an interaction weight matrix. The interaction influence degree includes the first influence degree of the query semantic vector on the template semantic vector and the second influence degree of the template semantic vector on the query semantic vector.
[0196] The multi-level semantic association matrix and the interaction weight matrix are merged to obtain a joint representation matrix. The main feature vectors are extracted by eigenvalue decomposition to obtain a multi-dimensional similarity feature set.
[0197] The features in the multidimensional similarity feature set are iteratively optimized and weighted based on a dynamic programming strategy to generate a comprehensive matching score. The candidate query template with the highest comprehensive matching score is then determined as the target query template.
[0198] Thirdly, embodiments of the present invention provide an electronic device, see [link to previous document]. Figure 4 The diagram shown is a structural schematic of an electronic device provided by the present invention.
[0199] like Figure 4As shown, the device includes:
[0200] Memory 31 is used to store computer programs;
[0201] Processor 32 is used to execute the computer program;
[0202] When the processor 32 executes the computer program, it implements the knowledge graph-based document analysis and query method as described in any of the above embodiments.
[0203] For example, the computer program may be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 32 to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.
[0204] The processor 32 may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0205] The memory 31 can be used to store the computer programs and / or modules. The processor 32 implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory 31 and calling the data stored in the memory 31. The memory 31 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 51 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital card (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0206] It should be noted that the aforementioned electronic devices include, but are not limited to, processors and memory, as will be understood by those skilled in the art. Figure 4 The structural diagram is merely an example of the electronic device described above and does not constitute a limitation on the electronic device. It may include more components than shown in the diagram, or combine certain components, or use different components.
[0207] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing a computer program, which, when executed, implements the knowledge graph-based document analysis and query method described in any of the above embodiments.
[0208] It should be understood that the present invention can implement all or part of the processes in the above-described knowledge graph-based document analysis and query method, or it can be accomplished by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the above-described knowledge graph-based document analysis and query method. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content contained in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0209] The above description is merely a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. It should be noted that, for those skilled in the art, several equivalent obvious modifications and / or equivalent substitutions can be made without departing from the technical principles of the present invention, and these obvious modifications and / or equivalent substitutions should also be considered within the scope of protection of the present invention.
Claims
1. A document analysis and query method based on knowledge graphs, characterized in that, include: The received document to be analyzed is tagged with part-of-speech tags to obtain the tagging results; Based on a pre-defined ontology knowledge base for the power grid domain, knowledge element information is extracted from the part-of-speech tagging results, and an initial knowledge graph is constructed based on the knowledge element information. The nodes in the initial knowledge graph are merged to obtain a fused knowledge graph; A mapping table is constructed based on the fused knowledge graph, and a candidate query template set is generated based on the mapping table; Receive a natural language query statement input by the user, select a target query template from the candidate query template set based on the natural language query statement, and generate the target query statement; Use the target query statement to query from the fused knowledge graph and output the query results.
2. The document analysis and query method based on knowledge graphs as described in claim 1, characterized in that, The pre-defined power grid domain ontology knowledge base extracts knowledge element information from the part-of-speech tagging results and constructs an initial knowledge graph based on the knowledge element information, including: The part-of-speech tagging results are matched with the power grid domain ontology knowledge base to extract knowledge element information; Semantic annotation is performed on the knowledge element information to obtain knowledge elements with semantic tags, and a knowledge element interaction graph is constructed based on the knowledge elements with semantic tags. For knowledge element pairs connected by edges in the knowledge element interaction graph, calculate the cosine similarity and generate an association matrix; Based on the correlation matrix and the semantic tags, feature encoding is performed on the knowledge elements, each knowledge element is represented as a multi-dimensional feature vector, and the semantic similarity of the multi-dimensional feature vectors of each knowledge element pair is calculated. Using the semantic tags as constraints, a minimum spanning tree is constructed based on the semantic similarity, and the minimum spanning tree is optimized to obtain several knowledge element clusters; An initial knowledge graph is constructed based on the aforementioned knowledge element clusters.
3. The document analysis and query method based on knowledge graphs as described in claim 1, characterized in that, The process of merging nodes in the initial knowledge graph to obtain a fused knowledge graph includes: Based on the power grid domain ontology knowledge base, all entity nodes in the initial knowledge graph are transformed into semantic vectors to obtain the node semantic feature space; A third-order semantic feature tensor is constructed based on the node semantic feature space. Tensor decomposition technique is used to extract the structural feature vector and context feature vector of the entity node. The structural feature vector and the context feature vector are concatenated to obtain the fused feature vector of the entity node. Calculate the similarity of the fused feature vectors of any two entity nodes and construct a similarity association graph of all entity nodes; The similarity association graph is divided into multiple communities using a community discovery algorithm, and entity nodes in the communities with semantic similarity higher than a preset semantic similarity threshold are merged. Based on the relationship types and attribute information of the merged entity nodes, a fused knowledge graph is obtained.
4. The document analysis and query method based on knowledge graphs as described in claim 3, characterized in that, The step of extracting structural feature vectors and context feature vectors of entity nodes using tensor decomposition technology, and concatenating the structural feature vectors and context feature vectors to obtain the fused feature vector of the entity node, includes: Tensor decomposition technology is used to perform spatiotemporal decomposition on the third-order semantic feature tensor to obtain a heterogeneous feature matrix including temporal pattern features and spatial pattern features. Spatiotemporal correlation degree is calculated based on the heterogeneous feature matrix. Select the feature combination with the highest spatiotemporal correlation as the structural feature; A node attention matrix is constructed using the third-order semantic feature tensor. The node attention matrix is then weighted according to the spatiotemporal correlation. Based on the adjusted attention weights, the contextual semantic representation of the entity is calculated, and the contextual semantic representation with the largest attention weight is selected as the contextual feature. A fused feature vector is generated based on the structural features and the context features.
5. The document analysis and query method based on knowledge graphs as described in claim 1, characterized in that, The step of constructing a mapping table based on the fused knowledge graph and generating a candidate query template set based on the mapping table includes: The entity type, relationship type, and attribute information of all entity nodes are extracted from the fused knowledge graph. A first mapping matrix and a second mapping matrix are constructed, and a mapping table is constructed based on the first mapping matrix and the second mapping matrix. The first mapping matrix is used to record the correspondence between the entity type and the relationship type, and the second mapping matrix is used to record the correspondence between the entity type and the attribute information. The mapping table is traversed using a depth-first traversal algorithm to generate a node access sequence, and the node access sequence is grouped according to the mapping level; Calculate the mutual information of nodes within a group and the mutual information of nodes between groups, and construct a heterogeneous node co-occurrence matrix based on the mutual information of nodes within a group and the mutual information of nodes between groups. Singular value decomposition is performed on the heterogeneous node co-occurrence matrix to obtain the node feature matrix. Based on the node feature matrix, the inter-layer node attention distribution is calculated to generate an inter-layer node association weight table. Based on the inter-layer node association weight table, a query path is selected from the mapping table to generate a query path set, and a candidate query template set is generated based on the query path set.
6. The document analysis and query method based on knowledge graphs as described in claim 1, characterized in that, The step of selecting a target query template from the candidate query template set based on the natural language query statement and generating a target query statement includes: Extract the query keyword sequence from the natural language query statement and map the keyword sequence into a query semantic vector; Extract the template keyword sequence of each candidate query template in the candidate query template set, and map the template keyword sequence into a template semantic vector; Based on the query semantic vector and the template semantic vector, the target query template is determined from the candidate query template set; Entity words and relation words are identified from the natural language query statement, an entity-relation correspondence graph is constructed, the entity-relation correspondence graph is bidirectionally mapped to the slots in the target query template, a set of slot filling rules is generated, and the consistency of the set of slot filling rules is verified to obtain the target slot filling rules. The target query template is instantiated based on the target slot filling rules to generate an intermediate query expression. The intermediate query expression is then normalized to generate the target query statement.
7. The document analysis and query method based on knowledge graphs as described in claim 6, characterized in that, The step of determining the target query template from the candidate query template set based on the query semantic vector and the template semantic vector includes: The query semantic vector and the template semantic vector are mapped to the same semantic space to extract a multi-level semantic association matrix, including a local semantic association matrix and a global semantic association matrix. The interaction influence degree is calculated based on the multi-level semantic association matrix to generate an interaction weight matrix. The interaction influence degree includes the first influence degree of the query semantic vector on the template semantic vector and the second influence degree of the template semantic vector on the query semantic vector. The multi-level semantic association matrix and the interaction weight matrix are merged to obtain a joint representation matrix. The main feature vectors are extracted by eigenvalue decomposition to obtain a multi-dimensional similarity feature set. The features in the multidimensional similarity feature set are iteratively optimized and weighted based on a dynamic programming strategy to generate a comprehensive matching score. The candidate query template with the highest comprehensive matching score is then determined as the target query template.
8. A document analysis and query device based on knowledge graphs, characterized in that, include: The document preprocessing module is used to perform part-of-speech tagging on the received documents to be analyzed, and obtain the part-of-speech tagging results; The knowledge graph construction module is used to extract knowledge element information from the part-of-speech tagging results based on a preset power grid domain ontology knowledge base, and to construct an initial knowledge graph based on the knowledge element information; The knowledge graph fusion module is used to merge the nodes in the initial knowledge graph to obtain a fused knowledge graph; The query template generation module is used to construct a mapping table based on the fused knowledge graph and generate a set of candidate query templates based on the mapping table. The user query input module is used to receive natural language query statements input by users, select target query templates from the candidate query template set based on the natural language query statements, and generate target query statements. The user query output module is used to query the fused knowledge graph using the target query statement and output the query results.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program; The processor executes the computer program to implement the knowledge graph-based document analysis and query method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed, implements the knowledge graph-based document analysis and query method as described in any one of claims 1 to 7.
Citation Information
Cited By
Standard text semantic analysis and key clause extraction method and system
CN121615656A
Database query statement intelligent conversion and analysis method based on natural language
CN121681575A
Enterprise document access permission determination method and system
CN121997307A
A method and system for determining access rights to enterprise documents
CN121997307B
Knowledge recommendation method, system and equipment based on scene perception and dynamic permission
CN122196166A