Enterprise data intelligent question answering method based on semantic knowledge graph and incremental update
By employing semantic knowledge graphs and incremental updates, we have addressed the technical barriers, response cycles, and knowledge silos in enterprise data queries. This has enabled low-cost, high-efficiency intelligent question answering for enterprise data, improving query accuracy and response speed, and meeting enterprise-level data management needs.
Patent Information
- Application Number
- CN202611226501.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-13
- Publication Date
- 2026-11-06
AI Technical Summary
Existing enterprise data query models suffer from high technical barriers, lengthy response cycles, lack of consistency in definitions, untraceable results, and knowledge silos. Traditional NL2SQL technology has poor generalization ability, deep learning models cannot adapt to changes in enterprise business, knowledge graph construction is costly and updates are lagging, and single retrieval paradigms have insufficient recall.
We employ a semantic knowledge graph-based incremental update approach. Through a dual-path retrieval mechanism that integrates multi-source heterogeneous enterprise document parsing, semantic knowledge graph construction, adaptive incremental updates, and graph structure and vector semantic fusion, we achieve low-cost construction and real-time updates of the knowledge graph. Combined with multi-level reasoning and data lineage tracing, we generate accurate SQL queries.
It significantly reduces the cost of knowledge graph construction, enhances complex multi-hop reasoning capabilities, accelerates knowledge update response speed, improves SQL generation accuracy, and achieves enterprise-level standards in data interpretability and compliance. The system performance is comprehensively superior to similar solutions.
Smart Images

Figure CN123050632A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence, natural language processing, and enterprise data governance, and in particular to an intelligent question-answering method for enterprise data based on semantic knowledge graphs and incremental updates. Background Technology
[0002] In the current wave of digital transformation sweeping the globe, data has become the most core strategic asset for enterprises. Currently, structured, semi-structured, and unstructured documents within enterprises continue to accumulate at a rapid pace, forming a highly complex heterogeneous data ecosystem among business systems, data warehouses, indicator platforms, knowledge documents, and historical SQL case repositories. However, in stark contrast to the continuous expansion of data scale, the efficiency of releasing enterprise data value remains low: many business personnel lack SQL (Structured Query Language) writing skills, and data acquisition still relies on IT teams for "human translation." From requirement clarification, task scheduling, SQL development to result verification, multiple steps are often required. A significant amount of time for technical teams is consumed by repetitive, low-creativity data query work orders, severely restricting the real-time release of enterprise data value and the agile response capability for business decisions. Specifically, traditional enterprise data query models face the following five structural dilemmas: First, technical barriers – the insurmountable professional barrier of SQL language exists between business personnel and data; second, lengthy response cycles – from the time business personnel submit data requests to the time they obtain analysis results, it typically involves multiple time-consuming steps such as request clarification, task scheduling, SQL development, and result verification; third, lack of consistency – different technical personnel have different understandings of the same business indicators, leading to contradictory data results when the same question is queried at different times by different personnel, seriously damaging data credibility; fourth, lack of traceability of results – existing query systems generally lack a complete link tracing from business issues to data results, making it impossible to conduct effective compliance audits and accountability for data conclusions; fifth, numerous knowledge silos – core knowledge such as enterprise business terminology definitions, indicator standards, and data lineage are scattered across various heterogeneous document systems, lacking a unified structured knowledge management platform, and cannot be effectively utilized by intelligent systems.
[0003] The specific defects of existing technologies are as follows: (1) Traditional NL2SQL technology based on rule matching: The core limitations of this type of system are threefold: the rule coverage is extremely limited, the generalization ability is extremely poor, and the rule system has extremely low tolerance for errors. (2) End-to-end NL2SQL technology based on deep learning: There are problems such as model training being highly dependent on large-scale domain labeled data, the cost of customized business semantic labeling for enterprises being extremely high, the inability to perceive dynamic changes in enterprise business scope, the inability to meet compliance audit requirements, and serious lack of availability in actual production environments. (3) Retrieval Enhancement Generation (RAG) technology based on vector databases: It has problems such as limited granularity of semantic retrieval, serious lack of multi-hop reasoning ability, and semantic drift risk. (4) Engineering dilemma of existing knowledge graph construction technology: Enterprise-level engineering implementation has long faced the dual dilemma of "high construction cost and extremely difficult maintenance". (5) Inherent limitations of a single retrieval paradigm: The recall rate is seriously insufficient when dealing with semantically ambiguous and diverse queries. Summary of the Invention
[0004] To overcome the shortcomings of existing enterprise-level semantic knowledge graphs due to technological limitations, such as business semantic gaps, broken complex multi-hop reasoning links, excessively high knowledge graph construction costs, severely lagging knowledge updates, inability to guarantee consistency of interpretation, and lack of traceability of results, this invention provides an enterprise data intelligent question answering method based on semantic knowledge graphs and incremental updates. This method significantly reduces the cost of knowledge graph construction, significantly improves complex multi-hop reasoning capabilities, completely solves the problem of broken reasoning links, achieves an order-of-magnitude improvement in real-time knowledge update response speed, achieves industry-leading SQL generation accuracy, and fully meets enterprise-level standards in terms of data interpretability and compliance. The overall system performance indicators comprehensively surpass those of the best solutions in the same category.
[0005] The technical solution adopted by this invention to solve its technical problem is: The enterprise data intelligent question answering method based on semantic knowledge graphs and incremental updates includes the following steps: S1, determining the design principles of the overall technical concept; S2, multi-source heterogeneous enterprise document parsing and automated extraction of business knowledge: including three sub-steps: multi-source data access and adaptive semantic segmentation, automatic extraction of five types of entities and eight types of relations based on a large language model, and semantic normalization and multi-version alignment; S3, multi-level semantic knowledge graph construction and graph database persistence: including the mathematical formalization of the five-level semantic knowledge graph, based on Leiden or Louvain... The algorithm consists of three sub-steps: hierarchical semantic community detection, establishing a graph database persistence and high-performance composite index strategy; S4, determining the knowledge graph adaptive incremental update mechanism, including establishing a multimodal change perception and event triggering framework, establishing incremental parsing and idempotent difference merging algorithms, and version management and shadow mode gray-scale switching; S5, determining the dual-path retrieval mechanism of graph structure and vector semantic fusion, including precise entity retrieval, topic community aggregation retrieval, and dual-order retrieval result fusion and query plan generation; S6, knowledge graph-guided SQL generation and three-layer reverse verification, including context-constrained multi-candidate SQL generation prompt word engineering and establishing a three-layer serial reverse verification quality control system; S7, full-link data lineage tracing and traceable answer generation.
[0006] Furthermore, in step S1, the design principles include the semantic priority principle, the structured reasoning principle, the real-time knowledge principle, the full traceability principle, and the engineering feasibility principle.
[0007] Furthermore, in step S2, the multi-source data includes a data dictionary, indicator definition documents, business rule instructions, historical SQL case library, database DDL files, business training materials and operating specifications; in adaptive semantic segmentation, firstly, the hierarchical structure information of the multi-source data documents is extracted based on the document structure parser, and then, with semantic integrity as a constraint, the text is segmented using a sliding window strategy to generate text units with clear semantic boundaries.
[0008] Furthermore, in step S2, the five types of entities include business term nodes, technical indicator nodes, data table nodes, field nodes, and business rule nodes; the eight relationships include business terms mapped to calculated indicators, indicators calculated from specific fields, fields belonging to specific data tables, indicators constrained by business rules, bidirectional association of synonymous business terms, data lineage dependency between tables, relationship between derived indicators and basic indicators, and data tables constrained by permission rules; semantic normalization and multi-version caliber alignment include three processes: synonym disambiguation and standardization, entity attribute completion, and multi-version caliber alignment.
[0009] Furthermore, in step S3, the mathematical formalization of the five-layer semantic knowledge graph G is defined as follows: In the formula, For a set of nodes, Let be the set of relation edges. For node type label functions, For relation type labeling functions; Leiden algorithm's hierarchical semantic community detection modularity. Q The formula is as follows: In the formula, Adjacency matrix elements , For node degree ,m The sum of edge weights; indexing strategies include HNSW vector indexing, full-text search indexing, and composite attribute indexing.
[0010] Furthermore, in step S4, within the multimodal change perception and event triggering framework, enterprise business change signals are perceived in real time from five dimensions: database DDL change events, document version update events, business rule revision and approval events, SQL case feedback events, and scheduled inspection tasks. The incremental knowledge fusion formula involved in the incremental parsing and idempotent difference merging algorithm is as follows: In the formula, G' It is a new map ,G It is the original diagram. ΔG It is an incremental subgraph , ΔV is the incremental entity node set, and ΔE is the incremental relation edge set. In version management and shadow mode gray-scale switching, the difference rate of the SQL generation results of the two versions is compared. When the difference rate is lower than the threshold τ_diff = 3%, the version switch is automatically completed. When the difference rate exceeds the threshold, the system triggers a manual review alarm, and the version switch is manually executed after the data administrator reviews and confirms it.
[0011] Furthermore, in step S5, the precise entity retrieval actually employs a dual-mode retrieval fusion strategy, specifically through the formula... Ranking fusion combines and sorts the results from the two search paths, where, RRF It's about mutual ranking integration: R It is the set of all search paths ,k=60 It is a smoothing parameter rankᵣ(d) is The ranking of document d in the retrieval path r; topic community aggregation retrieval requires the following three steps for each target community: community subgraph traversal, local topic reasoning, and global answer synthesis; during the fusion of two-level retrieval results and the generation of the query plan, the following three key operations need to be performed during the fusion process: deduplication, conflict resolution, and information completion.
[0012] Furthermore, in step S6, the context constraint multi-candidate SQL generation prompt word project involves six mandatory requirements in the core constraint specifications of context constraint prompt words, including field constraints, caliber constraints, source labeling constraints, multi-candidate strategies, confidence labeling, and boundary declarations; the three-layer serial reverse verification quality control system includes a syntax verification layer, a logic verification layer, and a business rule compliance verification layer.
[0013] Furthermore, in step S7, the data lineage tracing and traceable answer can automatically generate a structured data lineage graph for each question-and-answer process, using the following formula: , It is a set of seven types of bloodline nodes. This is a directed edge-tracking set.
[0014] Compared with existing technologies, the beneficial effects of this invention are: significantly reduced knowledge graph construction costs, achieving a technological leap from days to hours; significantly improved complex multi-hop reasoning capabilities, completely resolving the problem of broken reasoning links; order-of-magnitude improvement in real-time knowledge update response speed; industry-leading SQL generation accuracy; fully meeting enterprise-level standards in terms of data result interpretability and compliance; and comprehensively leading the best solutions in its class in terms of overall system performance. In summary, this invention has promising application prospects. Attached Figure Description
[0015] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0016] Figure 1 This is a schematic diagram of the overall architecture of the multi-level semantic knowledge graph of this invention.
[0017] Figure 2 This is a flowchart of the NL2SQL conversion and knowledge graph guidance process of this invention.
[0018] Figure 3 This is a diagram of the full-link data lineage tracing architecture of this invention.
[0019] Figure 4 This is a flowchart of the intelligent question-answering method for enterprise data based on semantic knowledge graphs and incremental updates, as presented in this invention. Detailed Implementation
[0020] Figure 4 As shown, the enterprise data intelligent question answering method based on semantic knowledge graph and incremental updates includes the following steps: (1) Design principles for determining the overall technical concept: Specifically, a complete enterprise data intelligent question answering technology system driven by "multi-level semantic knowledge graph" as the core, with the overall architecture as follows: Figure 1 As shown, the entire technical solution follows the following five core design principles: 1) Semantic priority principle: All query processing takes business semantic understanding as the primary starting point. The knowledge graph is used to accurately anchor the semantics of business terms to ensure that the understanding of query intent does not drift semantically and to ensure the semantic correctness of SQL generation.
[0021] 2) Structured reasoning principle: Make full use of the graph structure characteristics of knowledge graphs to perform explicit multi-hop reasoning, transform the logical relationships implicit in business rules into computable graph paths, break through the reasoning limit of pure text semantic matching, and support complex multi-dimensional association query scenarios.
[0022] 3) Knowledge Real-Time Principle: Through an adaptive incremental update mechanism, ensure that the knowledge graph always remains strictly consistent with the latest business definitions of the enterprise, eliminate systemic deviations caused by knowledge lag, and ensure the continuous reliability of the system in a high-speed business iteration environment.
[0023] 4) Full traceability principle: Establish a complete data lineage tracing link for all question-and-answer processes to ensure that every data conclusion can be accurately traced back to the specific business definition document, calculation logic expression and database field, achieving 100% knowledge source labeling coverage.
[0024] 5) Engineering Feasibility Principle: The entire solution design is guided by production-level engineering implementation, fully considering system availability, response latency and operation and maintenance complexity under high concurrency scenarios, and ensuring that the technical solution is operable and economical for actual deployment.
[0025] (2) Multi-source heterogeneous enterprise document parsing and automated extraction of business knowledge 1) Multi-source data access and adaptive semantic segmentation: The system is designed with a multi-source heterogeneous data access framework for enterprise private domain documents, uniformly processing the following six types of core enterprise documents: a) Data Dictionary – contains database table structure, field descriptions, and business meaning annotations; b) Indicator definition document – including the formal definition, calculation logic, applicable boundaries and historical version change record of the business indicator; c) Business rules specification – including data filtering rules, business constraints, and exception handling guidelines; d) Historical SQL Case Library – High-quality historical query samples verified by business experts; e) Database DDL (Data Definition Language) file – contains the physical structure definition of the database tables; f) Business training materials and operating procedures – supplementary documents containing unstructured business knowledge.
[0026] Adaptive Semantic Chunking is performed on the original document: First, the hierarchical structure information of the document is extracted based on a document structure parser (supporting multiple formats such as PDF, Word, Markdown, HTML, and Excel); then, with semantic integrity as a constraint, a sliding window strategy is used to divide the text into chunks, generating text chunks with clear semantic boundaries between 512 and 2048 characters in length; each text chunk retains its complete structural path information in the original document (chapter title level, document source, version number, effective date), serving as a metadata anchor point for subsequent knowledge tracing, ensuring that every record of the knowledge graph can be traced back to the precise location in the original document.
[0027] 2) Automatic Extraction of Five Entities and Eight Relations Based on a Large Language Model: For each text unit, a specially designed Domain-Specific Extraction Prompt guides the large language model to identify the following five core entities and extract triplet relations. The definitions and key attributes of the five core entities are shown in Table 1 below:
[0028] Table 1 The following eight core semantic relationships are defined between the five types of nodes, forming the complete edge type system of the knowledge graph, as shown in Table 2 below:
[0029] Table 2 3) Semantic normalization and multi-version alignment The entity relationship extraction results undergo a three-stage semantic normalization process: The first stage is synonym disambiguation and standardization—using the BAAI / bge-m3 pre-trained embedding model to calculate the semantic similarity between candidate synonymous entities. When the similarity exceeds the threshold τ_syn = 0.92, they are automatically merged into the same standard entity, retaining the most complete description as the main name, and storing the rest as aliases to avoid retrieval ambiguity caused by synonym redundancy; The second stage is entity attribute completion—for entity nodes with incomplete attributes, knowledge completion is performed by tracing back to the original document context or using a large language model to ensure that the complete coverage of key attribute fields is not less than 95%; The third stage is multi-version caliber alignment—when there are multiple historical versions of the caliber definition for the same indicator, they are sorted in descending order by document effective date, the latest effective version is marked as status=ACTIVE, and historical versions are marked as status=DEPRECATED, and the complete version evolution chain is retained, supporting backtracking queries of any historical version to meet the time dimension compliance audit requirements of enterprise data governance.
[0030] (3) Construction of multi-level semantic knowledge graph and persistence of graph database 1) Mathematical formal definition of a five-layer semantic knowledge graph The formal definition of the multi-level semantic knowledge graph G constructed in this invention is as follows: it includes a heterogeneous graph structure composed of five types of entity nodes, and a high-dimensional semantic embedding vector carried by each node, as shown in the following formula: In the formula, knowledge graph is formally defined as follows: V For a set of nodes, E Let be the set of relation edges. Lv For node type label functions, Le For the relation type label function, the node set V consists of the union of five heterogeneous entity types, as shown in the following formula: In the formula, the node set consists of five categories: business term nodes, technical indicator nodes, data table nodes, field nodes, and business rule nodes.
[0031] in, : V → {BusinessTerm, Metric, DataTable, Column, BusinessRule} is a node type label function. E → {MAPS_TO, CALCULATED_BY, BELONGS_TO, GOVERNED_BY, SYNONYMOUS_WITH, DEPENDS_ON, DERIVES_FROM, CONSTRAINED_BY} is a label function for the relation type; each node v V carries a 1024-dimensional semantic embedding vector encoded by the BAAI / bge-m3 multilingual pre-trained embedding model. This vector integrates the node's name text, attribute description, and associated context information, serving as the core numerical representation for subsequent semantic similarity retrieval; simultaneously, each node carries a complete versioned meta-dataset. This includes: version ID (version_id), effective date (effective_date), expire date (expire_date), source document created (source_doc), and current status (status). {ACTIVE, DEPRECATED, PENDING}).
[0032] 2) Hierarchical semantic community detection based on Leiden / Louvain algorithm To support subsequent topic-based global community retrieval, this invention preferably employs the Leiden community detection algorithm to perform hierarchical semantic segmentation of the knowledge graph. When there are requirements for engineering compatibility, historical implementation, or lightweight deployment, the Louvain community detection algorithm can also be used as an equivalent alternative. Both algorithms aim to optimize modularity and improve the quality of community structure, clustering semantically closely related nodes into multiple subgraph communities, each community representing a unified business knowledge domain with a semantic theme. The Leiden community detection algorithm formula is as follows: In the formula, modularity Q Global definition: For elements of the adjacency matrix, for Node degree, m This is the sum of edge weights. δ Here, is the Kronecker delta function; during algorithm execution, the modularity gain ΔQ resulting from moving a single node i into community C is calculated using the following formula: In the formula, the modularity gain is... ΔQ:Σin For the sum of edge weights within the community, Σtot For the total degree of community nodes, ki,in Let be the sum of the weights of node i and the edges within the community.
[0033] In the preferred implementation, the Leiden algorithm further enhances community connectivity constraints based on the Louvain modularity optimization idea, reducing the risk of summary drift caused by disconnected or weakly connected components within a community. In the compatible implementation, the Louvain algorithm can still iteratively select node movement operations that maximize ΔQ until the global modularity Q converges. After community detection, a large language model is called to generate a semantic summary for each subgraph community. The summary content covers the business domain topics covered by the community, a list of core entities, descriptions of key relationships, and typical query examples. The summary text undergoes the same vectorization processing as the nodes to generate community summary vectors. It is stored in a vector index and used for semantic matching in subsequent topic aggregation retrieval.
[0034] 3) Graph database persistence and high-performance composite index strategy Persistent storage of knowledge graphs can be implemented using graph databases such as Neo4j 5.x / 2025.x that support vector indexing, full-text indexing, and native graph traversal. Alternatively, it can be implemented using graph databases such as NebulaGraph, JanusGraph, TigerGraph, or those with equivalent attribute graph capabilities. The preferred implementation fully utilizes the graph storage engine to achieve high-performance multi-hop relation traversal queries. Core storage and indexing strategies include: (a) HNSW vector indexing—semantic embedding vectors for all nodes. (a) Establish HNSW (Hierarchical Navigable Small World) approximate nearest neighbor vector index, supporting millisecond-level high-dimensional vector ANN (Approximate Nearest Neighbor) retrieval; (b) Full-text search index - establish a full-text inverted index for the business name (name) and aliases list of nodes; (c) Composite attribute index - establish a composite index for high-frequency filtering fields such as business domain, version number, effective period, and review status.
[0035] (4) Knowledge graph adaptive incremental update mechanism 1) Multimodal Change Perception and Event Triggering Framework: The system is designed with a multimodal change perception framework to perceive enterprise business change signals in real time from five dimensions: a) Database DDL change events – By monitoring the database's DDL operation logs (table creation, field addition, deletion, modification, index changes) through CDC (Change Data Capture) technology, the update pipeline of the affected nodes is automatically triggered; b) Document version update events – through integration with enterprise document management systems (Confluence, SharePoint, internal Wiki) Webhook callbacks enable real-time receipt of document version update notifications. e) Business rule revision approval event – By connecting to the enterprise approval workflow system, the graph update is automatically triggered after the rule revision is approved; d) SQL Case Feedback Events – When a user provides feedback on the correctness of the question and answer results, the system automatically analyzes the reasons for the deviation and triggers the verification and updating of relevant knowledge nodes; e) Scheduled inspection task - A full consistency check is performed every 24 hours to automatically repair outdated knowledge nodes caused by missed change events, ensuring zero blind spots in the knowledge map.
[0036] 2) Incremental parsing and idempotent difference merging algorithm For documents or change events that trigger updates, a standardized parsing pipeline, identical to that used in building the full knowledge graph, is executed to generate an incremental set of entity nodes ΔV and an incremental set of relation edges ΔE, forming an incremental subgraph ΔG = (ΔV, ΔE). The fusion operation of the incremental knowledge graph is expressed through the following set union operation: Incremental knowledge fusion in the formula: New graph G' From the original atlas G with incremental subgraph ΔG The union operation of the set of nodes and the set of edges constitutes 。
[0037] This merging operation achieves idempotency through Neo4j's MERGE semantics: existing nodes and edges with unchanged content undergo no-op; existing nodes with updated attributes undergo attribute overwriting (SET); entirely new nodes and edges undergo creation (CREATE); and obsolete nodes undergo soft deletion (marking status=DEPRECATED instead of physical deletion), preserving historical version chains to support traceability queries. The time complexity of the entire incremental update operation is O(|ΔV|+|ΔE|), independent of the full graph size, ensuring that the execution time of a single incremental update is strictly controlled within 10 minutes during peak business periods.
[0038] 3) Version management and shadow mode canary switching All knowledge graph nodes carry the following versioned metadata fields: version_id (unique version identifier), effective_date (effective date), expire_date (expire date, NULL indicates currently valid), created_by (source document), and status (ACTIVE / DEPRECATED / PENDING). After a new version of the knowledge graph node is updated, the system employs a "Shadow Mode Comparison" strategy: the old and new versions of the knowledge graph run in parallel, performing replay tests on real query logs from the past 7 days. The system compares the difference rate of the SQL generation results between the two versions. When the difference rate is lower than the threshold τ_diff = 3%, the version switch is completed automatically. When the difference rate exceeds the threshold, the system triggers a manual review alarm. The data administrator reviews and confirms the data and then manually performs the version switch to avoid introducing new semantic errors through automatic updates and to ensure the stability and controllability of the graph evolution.
[0039] (5) Dual-path retrieval mechanism that integrates graph structure and vector semantics Figure 2The overall NL2SQL conversion process of this invention is demonstrated, clearly showing how the knowledge graph is involved at each processing node: 1) Precise Entity Retrieval – Based on Dual-Mode Fusion Local Entity Retrieval After receiving the user's natural language query q, the system first uses the BAAI / bge-m3 embedding model to encode the query text into a 1024-dimensional semantic vector. Precise entity retrieval determines the most relevant set of entities by calculating the cosine similarity between eq and the semantic embedding vector ev of all entity nodes in the knowledge graph. The formula for calculating cosine similarity is defined as follows: In the formula, the cosine similarity formula is: eq·ev For vector dot product, ‖eq‖ / ‖ev‖ Let L2 be the L2 norm of the two vectors respectively.
[0040] To enhance the robustness of precise entity retrieval, a "dual-mode retrieval fusion" strategy is adopted in the actual implementation: vector semantic retrieval (recalling semantically similar entities) and full-text inverted index retrieval (recalling literal matching entities) are performed simultaneously, and the results from both retrieval paths are merged and ranked using the Reciprocal Rank Fusion (RRF) algorithm. The formula is as follows: In the formula, RRF Inter-ranking integration: R For the set of all search paths, k=60 For smoothing parameters, rankᵣ(d) For document d In search path r The ranking in the middle.
[0041] The system recalls the top-K (default K=10) entity nodes with the highest scores in cosine similarity and RRF fusion. For each recalled entity node, a depth-first graph traversal based on the Neo4j Cypher language is performed to extract the directly related subgraph centered on the entity (including its business terminology mapping, computational logic expression, belonging data table, key field list, and applicable business rules), forming a precise local subgraph knowledge fragment for the entity, serving as the precise knowledge context for the SQL generation stage. Simultaneously, the node ID sequence and edge type sequence of each graph traversal are fully recorded as the evidence chain for tracing the retrieval path.
[0042] 2) Thematic Community Aggregation Retrieval – Global Community Retrieval Based on Hierarchical Fusion The topic-based community aggregation retrieval is designed for complex query scenarios requiring global topic inference across multiple business entities. The system combines the user query vector `eq` with all community summary vectors. Perform cosine similarity calculations to select the Top-M (default M=3) target communities with the highest similarity. For each target community, perform the following three steps: a) Community Subgraph Traversal – Perform a complete association traversal on all core entity nodes within the target community to extract the community-level knowledge subgraph; b) Local topic reasoning – Input the community knowledge subgraph and user query into the large language model to generate a local reasoning answer for the community topic. c) Global Answer Synthesis – M local topic reasoning answers are integrated into a unified global answer through a hierarchical fusion strategy to supplement macro-level business context information that may be missed in precise entity retrieval.
[0043] 3) Fusion of two-stage search results and generation of query plan The precise entity retrieval results (a set of knowledge fragments from a local subgraph) are structurally fused with the topic community aggregated retrieval results (global topic reasoning answers) to generate a unified Knowledge-Enhanced Query Context (KEQC). The following three key operations are performed during the fusion process: a) Deduplication—eliminating duplicate entities in the two search results by precisely matching entity IDs; b) Conflict resolution – When multiple versions of the same entity exist, the latest valid version with status=ACTIVE shall be used first; c) Information completion – Using existing relationships in the graph, automatically complete the missing entity attributes in KEQC.
[0044] Based on KEQC, the system automatically generates a structured query plan, which includes: a set of target data tables T, a list of key field mappings F, a set of inter-table relationship conditions J, a set of data filtering rules W (semantic description of the WHERE clause), an aggregation logic description A, and sorting rules O, serving as a precise constraint blueprint for the downstream SQL generation stage.
[0045] (6) SQL generation and three-layer reverse verification guided by knowledge graph 1) Context-constrained multi-candidate SQL prompt word generation project The query plan and the user's original query are combined to form a context-constrained prompt (CCP). The CCP's core constraint specifications include the following six mandatory requirements: a) Field constraints — Only use the data table names and field names that have been verified in the knowledge graph. Guessing database objects that have not been verified by the graph is strictly prohibited. b) Definition Constraints – Strictly adhere to the business rules marked in the graph (filtering conditions, time windows, numerical boundaries, null value handling logic) to ensure that the generated SQL is completely consistent with the indicator definition standards; c) Source labeling constraints - Label the corresponding graph entity ID and business term source in the form of comments at the key calculation logic of SQL generation; d) Multi-candidate strategy – Generate N=3 semantically equivalent but different implementation paths candidate SQLs at once to improve the quality ceiling of the final selection; e) Confidence rating – Provide a confidence score (0 to 1) and a description of the main sources of uncertainty for each candidate SQL; f) Boundary declaration – When the knowledge graph coverage is insufficient to support the query, output a structured declaration of insufficient coverage instead of generating low-quality speculative SQL.
[0046] 2) Three-layer serial reverse verification quality control system For each candidate SQL, a three-layer serial reverse verification is performed. Only after passing the verification can the next layer be proceeded. If any layer fails verification, the SQL regeneration process is immediately triggered (up to 3 retries), and the failure details are recorded in the verification log for system iteration and optimization. The first layer is the Syntax Validation Layer. Based on the ANTLR syntax rules of the target database dialect, it performs a complete syntax tree parsing on the generated SQL. The checks include: the legality of SQL reserved word usage, the completeness of bracket matching, the legality of nested subquery structures, database dialect compatibility (MySQL 8.0 / PostgreSQL 14 / Hive 3.x / Spark SQL 3.x), and SQL injection risk detection (malicious pattern filtering based on lexical analysis). The target validation pass rate is ≥ 98%.
[0047] The second layer is the Logic Validation Layer, which performs in-depth query logic correctness checks, including six sub-checks: a) Field data type matching check; b) Completeness check of association conditions (Cartesian product risk detection); c) Aggregation logic consistency check (GROUP BY consistency with non-aggregated fields); d) Completeness check of null value handling (handling NULL values in key calculated fields); e) Query performance prediction check (force pagination when exceeding 1 million rows); f) Time logic reasonableness check (time range anomaly detection).
[0048] The third layer is the Business Rule Compliance Layer, which is the core verification mechanism with the most technological innovation value of this invention. It defines an SQL semantic parsing function SQLSemantic(sql) to extract a structured semantic representation S_sql of the core computational logic from the generated SQL; and extracts the target indicator standard definition Sgraph from the knowledge graph. The comprehensive score of business rule compliance, Conf_rule, is calculated using weighted cosine similarity (see formula below).
[0049] The formula for calculating the overall score of business rule compliance (Conf_rule) is as follows: In the formula, the business rule compliance score is: λ= 0.7 is the weighting factor. sim(·) For cosine similarity, Coverage_field for SQL Reference field coverage. When Conf_rule < θ_rule (default threshold θ_rule = 0.88), the system determines that the SQL business definition is inconsistent and triggers automatic regeneration (up to 3 times). After all three layers of validation pass, the system sorts all candidate SQL queries according to the overall quality score, as shown in the following formula: In the formula, the overall quality score is: w 1 = 0.20 (syntax) w 2 = 0.30 (logic) w 3 = 0.50 (Business Rules) — Business rules have the highest weight.
[0050] (7) Data lineage tracking and traceable answer generation Figure 3This invention demonstrates the architecture of the data lineage tracing system and a visualization of lineage in a real-world query case. The invention constructs a complete end-to-end data lineage tracing system, automatically generating a structured data lineage graph for each question-and-answer process. Its mathematical definition is: Data lineage diagram definition : _lineage e It consists of seven types of bloodline nodes. _lineage For directed tracking edge set , Process the parameter set for the node.
[0051] Bloodline Node Set _lineage contains seven types of processing nodes, in the following order: 1) QueryNode — Records the original natural language query text, query timestamp, user ID, and session ID; 2) IntentNode – Records the identified query intent type, confidence level, and core entity set; 3) GraphRetrievalNode — Records the graph retrieval path (node ID sequence, edge type sequence), the list of recalled entities, and the similarity score; 4) QueryPlanNode – Records the generated query plan, target data table set, and field mapping list; SQLGenerationNode – Records the candidate SQL set, generated model version, and confidence level of each candidate; 5) ValidationNode – Records detailed results of three-layer validation, pass / fail judgments, and caliber matching scores; 6) ExecutionNode — Records the final executed SQL, execution time, number of rows returned, and data version number.
[0052] The pedigree graph is persistently stored in an independent Neo4j pedigree database and provides a structured query interface through a REST API, supporting end-to-end tracing queries of any data conclusions, with a pedigree query response time of no more than 200ms.
[0053] Figure 4 As shown, the following are specific embodiments and typical application scenarios of the present invention. (1) The system deployment environment is shown in Table 3 below:
[0054] Table 3 (2) Knowledge Graph Construction Implementation Case - A Large Chain Retail Enterprise This paper uses a data-driven intelligent question-answering project of a large chain retail enterprise as a specific implementation case. The enterprise's data assets cover 218 core business database tables, 3,651 valid fields, 320 officially defined indicators, 847 business terms (including 1,203 synonym relationships), 196 business rule constraints, and a historical SQL case library containing 4,200 high-quality samples that have been manually verified. The results of the full-scale graph construction pipeline are shown in Table 4 below.
[0055] Table 4 Incremental update test: After the caliber of 23 indicators changed in a quarter, the incremental update pipeline was triggered; the incremental update completion time was 8.3 minutes (fully automated, with zero human intervention); the difference rate verified by shadow mode was 1.2% (far below the threshold of τ_diff=3%), and the version switch was completed automatically; historical versions were completely retained, and the accuracy of queries before and after the caliber change was not reduced.
[0056] 3) The comprehensive performance indicators of the production environment are summarized in Table 5 below:
[0057] Table 5 Table 6 below presents a systematic quantitative comparison between the present invention and existing technical solutions.
[0058] Table 6 The existing technologies have the following drawbacks: (1) Traditional NL2SQL technology based on rule matching: Early NL2SQL systems relied on manually predefined rule templates and keyword matching mechanisms. Typical examples include early natural language interface systems such as LUNAR (1978) and CHAT-80 (1982). The core limitations of such systems are threefold: First, the rule coverage is extremely limited, and the rule base needs to be manually modified every time the business scope changes, and the maintenance cost increases exponentially with the scale of the business; Second, the generalization ability is extremely poor, and it cannot handle expressions other than the rule templates at all. In actual tests, the accuracy rate in real enterprise query scenarios does not exceed 65%; Third, the rule system has extremely low tolerance for errors, and a single word deviation can lead to complete failure, resulting in extremely poor system reliability. (2) End-to-end NL2SQL technology based on deep learning: Pre-trained language models, represented by BERT (Bidirectional Encoder Representations from Transformers), T5 (Text-to-TextTransfer Transformer), and RSDSQL, have made significant progress on standard benchmark datasets such as Spider and WikiSQL. Some models have achieved an exact match accuracy of over 85% on the Spider test set. However, such methods have exposed severe limitations when dealing with enterprise private domain data: First, model training is highly dependent on large-scale domain-specific labeled data, and the cost of customized business semantic labeling for enterprises is extremely high; Second, the knowledge of pre-trained language models is limited to the training data and cannot perceive the dynamic changes in enterprise business definitions; Third, deep learning models are essentially parameterized black boxes, and the generated SQL statements lack interpretability and cannot meet compliance audit requirements; Fourth, when dealing with enterprise-level complex SQL involving multi-table joins, complex aggregation logic, and nested subqueries, the generation accuracy of such models drops sharply, and their usability in actual production environments is seriously insufficient. (3) Retrieval-Augmented Generation (RAG) technology based on vector database: The RAG (Retrieval-Augmented Generation) technology that has emerged in recent years provides factual constraints for large language models through real-time retrieval from external knowledge bases, which alleviates the model illusion problem to some extent.However, the "Naive RAG" technology, which is based on the vectorized storage of unstructured documents, has three fundamental defects in enterprise data question-answering scenarios: First, the granularity of semantic retrieval is limited—vector semantic similarity retrieval is essentially a soft matching based on statistical co-occurrence patterns, which cannot accurately capture the strict structured relationships between enterprise business entities, such as the precise mapping between "sales revenue" and the "sale_amount field," and the multi-table lineage dependency relationship between "refund rate" and the order table, refund table, and product table; Second, the multi-hop reasoning capability is severely insufficient—vector retrieval results are discrete collections of text fragments, lacking complete preservation of the relationship paths between entities. When faced with complex multi-hop reasoning queries that need to cross 3 to 5 layers of business entities, the reasoning link is prone to breakage; Third, the risk of semantic drift—when there are multiple versions of the definition document for the same business indicator, vector retrieval cannot determine the version priority, which can easily recall obsolete old definitions, leading to systemic semantic drift in the generated results. (4) Engineering dilemmas of existing knowledge graph construction technologies: As a core technology tool for structured knowledge management, knowledge graphs have long faced the dual dilemma of "high construction costs and extremely difficult maintenance" in their enterprise-level engineering implementation. Traditional enterprise knowledge graph construction relies heavily on large-scale manual annotation by domain experts. The construction cycle of typical projects is as long as 6 to 18 months, and the annotation cost is often several million yuan. More importantly, the completed static knowledge graph cannot respond in real time to the frequent changes in enterprise business - changes such as adjustment of indicator standards, addition of new business terms, and migration of database table structures occur dozens or even hundreds of times per month, and each manual graph update takes several days to several weeks. This leads to the common dilemma of enterprise knowledge graphs being "accurate during development but ineffective after going live", and ultimately becoming a data island that is not maintained, completely losing its core value of knowledge management. (5) Inherent limitations of a single retrieval paradigm: Existing NL2SQL systems generally adopt a single retrieval paradigm - either relying solely on graph structure retrieval or solely on vector semantic retrieval, each of which has its own insurmountable applicable boundaries. Graph-based retrieval performs well in precise matching scenarios with clear entity associations, but its recall rate is severely insufficient when dealing with semantically ambiguous and diverse queries. Vector-based semantic retrieval has strong generalization ability in semantic similarity matching, but it cannot preserve the structured reasoning path of knowledge. Currently, the industry lacks a technical solution that can organically integrate graph-based reasoning with vector-based semantic retrieval and adaptively switch retrieval strategies according to query type.
[0059] Figure 4As shown, the present invention achieves the following technical effects through the above technical solution: (1) The cost of knowledge graph construction is greatly reduced, achieving a qualitative leap from day-level to hour-level: Through the automated extraction mechanism enhanced by the large language model, the knowledge graph construction cycle that traditionally requires 6 to 18 months of manual annotation is compressed to a fully automated pipeline processing of 3 to 8 hours. Taking a large retail enterprise as an example: the total time for the full graph construction of 62 business documents is 163 minutes, the amount of manual input is reduced by more than 85%, the entity recognition accuracy rate is verified by manual sampling to reach 94.8%, the graph node coverage rate is 97.3%, and the graph quality surpasses the consistency level of manually annotated graphs of the same scale in most business scenarios. (2) The ability of complex multi-hop reasoning is significantly improved, and the problem of broken reasoning links is completely solved: The two-order retrieval paradigm based on graph structure completely preserves the association reasoning path of business entities across 3 to 5 layers through the Neo4j native graph traversal engine. The measured data shows that the first-attempt success rate of complex multi-hop queries is 12 percentage points higher than that of pure vector retrieval schemes (from 70.2% to 82.4%), which effectively solves the problem of the inference link breakage in complex enterprise query scenarios of traditional RAG technology. (3) The real-time knowledge update response speed is improved by a magnitude: the adaptive incremental update mechanism compresses the response time of the graph to changes in business scope from "weekly" to "minute" in the traditional scheme (the average time for a single incremental update is 8.3 minutes in actual measurement). The update operation is fully automated with zero human intervention. Historical versions are completely preserved. The gray-scale switching of shadow mode ensures the stability of the update and completely eliminates the problem of knowledge lag in static graphs. (4) SQL generation accuracy reaches industry-leading level: The three-layer reverse verification quality control system, combined with the semantic constraints of the knowledge graph, enables the SQL execution accuracy of NL2SQL to reach 95.7% on the enterprise private domain dataset: 14.5 percentage points higher than the pure vector RAG solution (81.2%), and 32.3 percentage points higher than the traditional rule solution (63.4%), creating the highest accuracy record for similar technical solutions in the enterprise private domain scenario. (5) Data result interpretability and compliance fully meet enterprise-level standards: The data lineage full-link tracking system achieves 100% traceability coverage of query results. Each data conclusion output externally carries complete knowledge source annotation (graph node ID, document source, calculation logic description), meeting the data compliance audit requirements of the financial industry, medical industry and other strongly regulated scenarios. The actual test showed a 41% reduction in business caliber consistency issues, a 58% decrease in ambiguous query work orders, and a caliber consistency score of 4.7 / 5.0.(6) The overall performance indicators of the system are superior to the best solutions in the same category: the average query response latency is 1.43 seconds (67% lower than the pure LLM solution), the user self-service query rate has increased from the baseline of 18% to 73%, the number of repetitive work orders of the enterprise data team has decreased by 78%, the data acquisition cycle has been shortened from an average of 2.3 days to real-time response, the system availability SLA reaches 99.94%, and the maximum concurrent query throughput supports 320 QPS, meeting the high availability and high concurrency requirements of enterprise production-level deployment.
[0060] It should be understood that although this specification describes the embodiments, the embodiments do not necessarily contain only one independent technical solution. This way of describing the specification is only for clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in the embodiments can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. An intelligent question-answering method for enterprise data based on semantic knowledge graphs and incremental updates, characterized in that: Includes the following steps: S1. Determine the design principles for the overall technical concept; S2, Multi-source heterogeneous enterprise document parsing and automated extraction of business knowledge: including three sub-steps: multi-source data access and adaptive semantic segmentation, automatic extraction of five types of entities and eight types of relations based on a large language model, and semantic normalization and multi-version caliber alignment. S3. Construction of multi-level semantic knowledge graph and persistence of graph database: including three sub-steps: mathematical formalization of five-level semantic knowledge graph, hierarchical semantic community detection based on Leiden or Louvain algorithm, and establishment of graph database persistence and high-performance composite index strategy; S4. Determine the adaptive incremental update mechanism for the knowledge graph: This includes three sub-steps: establishing a multimodal change awareness and event triggering framework, establishing incremental parsing and idempotent difference merging algorithms, and version management and shadow mode gray-scale switching. S5. Determine the dual-path retrieval mechanism for graph structure and vector semantic fusion: including three sub-steps: precise entity retrieval, topic community aggregation retrieval, and dual-order retrieval result fusion and query plan generation; S6. Knowledge Graph-Guided SQL Generation and Three-Layer Reverse Validation: This includes two sub-steps: generating multiple candidate SQL prompts for context constraints and establishing a three-layer serial reverse validation quality control system. S7. Data lineage tracking and traceable answer generation.
2. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, In step S1, the design principles include the semantic priority principle, the structured reasoning principle, the real-time knowledge principle, the full traceability principle, and the engineering feasibility principle.
3. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, Step S2, multi-source data includes data dictionary, indicator definition document, business rule manual, historical SQL case library, database DDL file, business training materials and operating specifications; In adaptive semantic chunking, the hierarchical structure information of multi-source data documents is first extracted based on the document structure parser. Then, with semantic integrity as a constraint, the text is chunked using a sliding window strategy to generate text units with clear semantic boundaries.
4. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, Step S2 involves five types of entities: business term nodes, technical indicator nodes, data table nodes, field nodes, and business rule nodes; and eight types of relationships: business terms mapped to calculated indicators, indicators calculated from specific fields, fields belonging to specific data tables, indicators constrained by business rules, bidirectional association of synonymous business terms, data lineage dependency between tables, relationship between derived indicators and basic indicators, and data tables constrained by permission rules. Semantic normalization and multi-version alignment include three processes: synonym disambiguation and standardization, entity attribute completion, and multi-version alignment.
5. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, In step S3, the mathematical formalization formula for the five-layer semantic knowledge graph G is defined as follows: In the formula, For a set of nodes, Let be the set of relation edges. For node type label functions, Here is the label function for relation types; the formula for the modularity Q of the hierarchical semantic community detection module in the Leiden algorithm is as follows: In the formula, For elements of the adjacency matrix, is the node degree, and m is the sum of edge weights; indexing strategies include HNSW vector indexing, full-text search indexing, and composite attribute indexing.
6. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, Step S4 establishes a multimodal change perception and event triggering framework, which perceives enterprise business change signals in real time from five dimensions: database DDL change events, document version update events, business rule revision and approval events, SQL case feedback events, and scheduled inspection tasks; the incremental knowledge fusion formulas involved in the incremental parsing and idempotent difference merging algorithms are as follows: In the formula, G' is the new graph, G is the original graph, ΔG is the incremental subgraph, ΔV is the incremental entity node set, and ΔE is the incremental relation edge set. In version management and shadow mode gray-scale switching, the difference rate of the SQL generation results of the two versions is compared. When the difference rate is lower than the threshold τ_diff = 3%, the version switch is automatically completed. When the difference rate exceeds the threshold, the system triggers a manual review alarm, and the version switch is manually executed after the data administrator reviews and confirms it.
7. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, In step S5, the precise entity retrieval actually employs a dual-mode retrieval fusion strategy, specifically through the formula... Ranking fusion merges and sorts the results from the two search paths. In the formula, RRF is mutual ranking fusion: R is the set of all search paths, k=60 is the smoothing parameter, and rankᵣ(d) is the ranking of document d in search path r. Thematic community aggregation retrieval requires the following three steps for each target community: community subgraph traversal, local topic reasoning, and global answer synthesis. During the fusion of two-level retrieval results and the generation of the query plan, the following three key operations need to be performed: deduplication, conflict resolution, and information completion.
8. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, Step S6, in the context constraint multi-candidate SQL generation prompt word project, the core constraint specifications of the context constraint prompt words include six mandatory requirements: field constraints, scope constraints, source labeling constraints, multi-candidate strategy, confidence labeling, and boundary declaration. The three-layer serial reverse verification quality control system includes a syntax verification layer, a logic verification layer, and a business rule compliance verification layer.
9. The intelligent question-answering method for enterprise data based on semantic knowledge graph and incremental updates according to claim 1, characterized in that, In step S7, the data lineage tracing and traceable answer can automatically generate a structured data link for each question-and-answer process. The formula used for the data lineage diagram is as follows: , It is a set of seven types of bloodline nodes. This is a directed edge-tracking set.
