A medical knowledge graph construction method and system based on a large language model
Patent Information
- Application Number
- CN202610853610.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-12
- Publication Date
- 2026-09-11
AI Technical Summary
传统的医学知识图谱构建方法主要依赖领域专家手动整理和标注,存在构建周期长、更新速度慢、难以覆盖前沿知识等缺陷
本发明提供了一种差异化Prompt模板与双源数据融合机制,融合了临床真实世界证据的动态属性与文献指南的静态属性,克服了单一数据源知识覆盖不全的缺陷;通过五维度质控智能体与三级闭环处置机制,识别并修正大语言模型输出的无依据内容及逻辑错误,提升医学知识的规范性;此外,提出了双层控制变量动态对齐算法及双源属性交织合并策略,实现了从高噪声个体路径到群体共性规律的提炼,以及时序与条件的精准融合;并且支持基于多因素条件与时序锚点的动态路径推理,能够输出符合临床真实演化规律的个性化疾病演化路径及置信度,为临床早期预警与决策提供精准支持。
Smart Images

Figure CN122734097A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of medical knowledge engineering and natural language processing, and more specifically, to a method and system for constructing a medical knowledge graph based on a large language model. Background Technology
[0002] Medical knowledge graphs are a core foundation of smart healthcare, organizing scattered medical knowledge into structured, reasonable knowledge networks, and are widely used in scenarios such as clinical decision support, drug development, and intelligent consultation. Traditional methods for constructing medical knowledge graphs mainly rely on manual compilation and annotation by domain experts, which suffers from drawbacks such as long construction cycles, slow update speeds, and difficulty in covering cutting-edge knowledge. In recent years, some studies have attempted to use natural language processing (NLP) techniques to automatically extract entities and relationships from medical texts; however, limited by the generalization capabilities of traditional deep learning models, their extraction performance on complex semantics and long-distance dependencies is poor. In particular, most existing methods only process static knowledge, failing to effectively integrate real-world clinical case data with authoritative literature and guidelines, and ignoring the temporal dynamics, multi-factor conditions, and probability weights of events in disease evolution. Therefore, how to efficiently and automatically construct a dynamic medical knowledge graph that can accommodate authoritative and standardized knowledge, reflect real-world clinical patterns, and support temporal reasoning is a pressing technical problem that needs to be solved. Summary of the Invention
[0003] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention provide a method and system for constructing a medical knowledge graph based on a large language model, in order to solve the problems mentioned in the background art.
[0004] To achieve the above objectives, the present invention provides the following technical solution: S1. Extract medical candidate entities and dictionary attributes through a large language model, and generate a static framework with both ontology hierarchy and medical dictionary functions through rule verification and manual quality control, and import it into a graph database. S2. Parallel acquisition of multi-center real electronic medical record data and domain literature and guide data, differential preprocessing of the two types of data to form a dual-source input data stream; S3. Based on the differentiated Prompt template, drive the large language model to perform a single synchronous extraction of the dual-source input data to obtain structured information; S4. The structured information is verified for compliance through a multi-dimensional quality control intelligent agent. The compliance verification includes at least content fidelity verification and time sequence integrity verification. Data that passes the verification is allowed to pass, while data that fails the verification is intercepted or sent to a closed loop for manual review, and quality control qualified data is output. S5. Dynamic graph construction: Anchor entities in the quality control qualified data to nodes of the static framework, and overlay the multi-factor condition set, time-series anchor points and probability weights as dynamic attributes onto the relation edges to construct and store a dynamic time-series disease knowledge graph; S6. Disease Path Reasoning: Based on the multi-factor condition set, temporal anchors and probability weights in the dynamic temporal disease knowledge graph, perform temporal reasoning of disease evolution paths and output candidate evolution paths and confidence levels.
[0005] Preferably, in step S1, the system uses a large language model as an auxiliary extraction tool. By designing specialized entity extraction prompt word templates, the system drives the large language model to automatically parse medical concepts, terminology definitions, and hierarchical relationships, thereby extracting candidate medical entities and their dictionary attributes. The dictionary attributes include the entity's standard name, common aliases, abbreviations, English equivalents, and a unique identifier for the standard entity. The system calls an internal rule verification engine to automatically verify the extraction results, checking whether the entity name is empty, whether the standard entity ID conforms to the predetermined encoding standard, whether the alias forms a circular reference with the standard name, and whether there are abnormal associations in the hierarchical relationship that violate ontology constraints. Data that fails the verification is pushed to the manual sampling quality control stage for review and correction by medical experts.
[0006] Preferably, in step S2, for multi-center real electronic medical record data, the system acquires the medical record text after de-identification processing, and uses a combination of regular expressions and named entity recognition to automatically detect and de-identify and replace privacy information; abnormal characters and non-standard punctuation are cleaned, and the data is aggregated and sorted by time according to a three-level structure of patient, consultation time, and document type to form a time-series medical record document set; for medical literature and clinical guideline data, the system acquires the full text of the literature or guideline document, extracts it into plain text format, and performs regular chapter segmentation and paragraph annotation according to the chapter title structure; finally, the data is merged and output as a dual-source input data stream with a unified format and traceability by document source and paragraph index.
[0007] Preferably, in step S3, two sets of differentiated Prompt templates with different structures and focuses are configured for electronic medical record data and literature / guideline data. For electronic medical record data, a medical record-specific Prompt template is used, requiring the model to standardize the time description, extract the set of multi-factor conditions and logical combinations related to state transitions or clinical outcomes, and output the initial probability weights based on frequency terms or relative frequencies. For literature / guideline data, a literature-specific Prompt template is used, requiring the model to identify the medical recommendation level and map it to the initial probability weights, extract the standardized ontology relationship types, time constraints, and applicable population ranges within the predefined whitelist, and output the source guideline name and version number.
[0008] Based on the constraints and guidance of differentiated Prompt templates, the large language model synchronously outputs structured information during a single inference process, including entities, relations, multi-factor condition sets, temporal anchors, probability weights, original text evidence, and source type labels. For the electronic medical record data, the system also uses patient state evolution chain extraction based on the vertical time axis to extract the state time series axis, explicit triggering factors, implicit background confounding factors, and outcome states and effects.
[0009] Preferably, in step S4, the multi-dimensional quality control agent invokes a rule engine containing five independent verification dimensions to perform compliance verification. The five dimensions include: content fidelity verification for detecting inferential and unfounded content added to the model; relationship compliance verification for verifying whether the extracted relationship types belong to a preset whitelist; entity normalization verification for comparing extracted entities with a static framework dictionary to detect synonym redundancy and unnormalized entities; logical consistency verification for detecting logical contradictions and condition set syntax errors within the same document; and temporal integrity verification for detecting the format specifications and physical rationality of temporal anchors.
[0010] The system performs a three-level closed-loop processing based on the verification score: Level 1 is direct pass, which applies to data that meets the requirements in all verification dimensions and is directly released; Level 2 is warning level automatic correction, which applies to data with formatting errors, unnormalized synonyms, or non-standard time sequence formats, and is released after the system performs automatic correction; Level 3 is rejection level manual review and diversion, which applies to data with inferential or unfounded content (i.e., the illusion of content fidelity), unmapped relationship types, logical contradictions, or errors in the physical meaning of time sequence, and is pushed by the system to the expert review platform for manual review and correction.
[0011] Preferably, in step S5, the system extracts the set of independent variables, the set of dependent variables, and the set of fixed control variables from the state transition events of individual patients, and represents the heterogeneous state transition events as structured sample points; the system executes a two-layer dynamic alignment algorithm for control variables to extract the common relationship flow of the medical record group. The first layer is a self-comparison within the patient, controlling the fixed variables to remain unchanged and comparing the state transitions before and after the intervention; the second layer is dynamic clustering across patient groups, screening patient subgroups with homogeneous fixed variables, and quantitatively observing the statistical net effect of changes in the target confounding variables.
[0012] When the system summarizes the common relationship flow of medical record groups and the normative relationship flow of literature, it performs ontology node alignment of dual-source entities, anchoring the names of various entities to the same ontology node in the static framework; for dual-source relationship records pointing to the same pair of standard entities and with consistent relationship labels, it performs node and relationship edge attribute merging based on graph topology, including temporal axis fusion and condition set tree merging, and uses a cross-calibration algorithm based on data source reliability strength to calculate the final probability weight on the merged relationship edge; in the attributes of each merged relationship edge, the system attaches dual-source evidence branches from literature guidelines and electronic medical records in parallel.
[0013] The technical effects and advantages of this invention are as follows: This invention provides a differentiated Prompt template and a dual-source data fusion mechanism, integrating the dynamic attributes of real-world clinical evidence with the static attributes of literature guidelines, overcoming the shortcomings of incomplete knowledge coverage from a single data source. Through a five-dimensional quality control agent and a three-level closed-loop processing mechanism, it identifies and corrects unsubstantiated content and logical errors in the output of large language models, improving the standardization of medical knowledge. Furthermore, it proposes a dual-layer control variable dynamic alignment algorithm and a dual-source attribute interleaving and merging strategy, achieving the extraction of common patterns from high-noise individual paths to group-wide patterns, as well as precise fusion of temporal and conditional data. It also supports dynamic path reasoning based on multi-factor conditions and temporal anchors, enabling the output of personalized disease evolution paths and confidence levels that conform to real-world clinical evolution patterns, providing precise support for early clinical warning and decision-making. Attached Figure Description
[0014] Figure 1 This is a schematic diagram of the main flow of the overall method of the present invention.
[0015] Figure 2 This is a schematic diagram of the dynamic graph construction and path reasoning process of the present invention. Detailed Implementation
[0016] 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.
[0017] S1. Extract medical candidate entities and dictionary attributes through a large language model, and generate a static framework with both ontology hierarchy and medical dictionary functions through rule verification and manual quality control, and import it into a graph database. In S1, the system first obtains raw medical entity data from the medical knowledge base, uses a large language model as an auxiliary extraction tool, and drives the large language model to automatically parse the medical concepts, terminology definitions and hierarchical relationships in the knowledge base by designing a special entity extraction prompt word template, and extracts candidate medical entities and their dictionary attributes. The dictionary attributes include the entity standard name, common aliases, abbreviations, English corresponding names and standard entity unique identifiers. After completing the large language model-assisted extraction, the system calls the internal rule verification engine to automatically verify the extraction results. The internal rule verification includes checking whether the entity name is empty, whether the standard entity ID conforms to the predetermined encoding specification, whether the alias forms a circular reference with the standard name, and whether there are abnormal associations in the hierarchical relationship that violate ontology constraints. For low-confidence or questionable data that fails the rule verification, the system marks them and pushes them to the manual sampling quality control stage, where medical experts review and correct the accuracy of the extraction results. For candidate data that passes the rule verification, they directly enter the static framework assembly stage.
[0018] Through the aforementioned three-stage semi-automated construction process—LLM-assisted extraction, automatic rule validation, and manual sampling quality control—the system generates a static framework that combines ontology-level functionality with a medical dictionary function. The ontology-level functionality defines the classification and hierarchical relationships between medical entities such as diseases, symptoms, drugs, and examination items. The medical dictionary function provides multi-caliber name mappings and standardized coding indexes for each entity node. After completing the static framework construction, the system pre-imports the framework into the Neo4j graph database in the form of nodes and basic attributes using Cypher statements or corresponding batch import interfaces.
[0019] S2. Parallel acquisition of multi-center real electronic medical record data and domain literature and guide data, differential preprocessing of the two types of data to form a dual-source input data stream; In S2, during the dual-source data input and preprocessing, the system accesses two types of heterogeneous data sources in parallel: one is historical real electronic medical record data from multiple medical centers, and the other is authoritative medical literature and clinical practice guidelines texts that have undergone peer review. For multi-center real electronic medical record data, the system first obtains de-identified medical record texts from each center through an interface or data platform that complies with security standards. The data range covers various document types such as admission records, progress notes, discharge summaries, laboratory reports, imaging reports, and nursing records. After acquiring the raw data, the system performs targeted and differentiated preprocessing: First, it uses a hybrid method combining regular expressions and named entity recognition to automatically detect and de-identify personal privacy information such as patient names, ID numbers, hospital numbers, and contact information in the medical record text, ensuring that the data cannot be reverse-linked to specific patients in subsequent processing stages; Second, it cleans abnormal characters, OCR recognition errors, and garbled encoding in the medical record text, and uniformly replaces various non-standard punctuation marks with standard delimiters (such as converting full-width punctuation to half-width and replacing consecutive spaces with single spaces); Then, it aggregates and sorts all medical records for each patient according to a three-level structure of patient, consultation time, and document type, forming a time-seriesd medical record document collection covering the complete hospitalization cycle or follow-up cycle, with each patient as the unit; For any unstructured free text paragraphs, the system reasonably segments them according to the principle of semantic integrity, while retaining the original hard line breaks and paragraph numbers, etc., as structured segmentation markers for subsequent source tracing and location.
[0020] For medical literature and clinical guidelines data, the system obtains full-text literature or guideline PDF documents that meet the subject scope through automated web crawlers or standard literature database interfaces. Then, it uses PDF parsing tools to extract the document content into plain text format and performs regular chapter segmentation and paragraph labeling according to the chapter title structure of the document. Each segmentation unit is associated with the unique identifier of the original literature, chapter name and paragraph number. After completing the differential preprocessing of the two types of data, the system merges the time-series medical record document set from electronic medical records with the structured paragraph units from literature guidelines and outputs a dual-source input data stream with a uniform format and traceability by document source and paragraph index. This data stream contains both continuous observation data of clinical pathways and authoritative definition data of standardized medical knowledge.
[0021] S3. Based on the differentiated Prompt template, drive the large language model to perform a single synchronous extraction on the dual-source input data to obtain multiple types of structured information such as entities, relationships, multi-factor condition sets, time-series anchors and probability weights. In S3, the LLM multidimensional extraction based on differential prompts feeds the dual-source input data streams output from S2 to the large language model, and configures two sets of differential prompt templates with different structures and focuses for electronic medical record data and literature guide data, driving the large language model to simultaneously complete the extraction of multidimensional structured information in a single inference process. For multi-center real electronic medical record data, a dedicated medical record Prompt template is used. The template first requires the model to standardize and transform various time descriptions appearing in the medical record. The structure of the dedicated medical record Prompt template includes: a system role setting section, used to anchor the role of the large model as a "senior clinical data structure extraction expert"; a task description section, used to explicitly require the model to extract state evolution chains and multi-dimensional attributes from the medical record text; a JSON Schema constraint section, used to define the output format containing multiple key-value pairs such as entities, relationships, multi-factor condition sets, time series anchors, probability weights, original evidence, and source type tags, and to enforce restrictions on the data type and nesting rules of each key-value pair; and a Few-shot example section, containing at least one labeled medical record fragment and its corresponding multi-dimensional JSON output sample to guide the model to align with the output paradigm. Secondly, the template requires the model to extract a set of multifactorial conditions related to a certain state transition or clinical outcome from the medical record text. The set of conditions includes explicitly recorded test indicator thresholds (such as "absolute neutrophil count less than 0.5 × 10^9 / L"), medication records (such as "after cyclosporine administration"), and operational events (such as "after hematopoietic stem cell transplantation"). The template also requires the model to identify the logical combination relationships between these conditions, including nested AND and OR structures. For example, for the state of "post-transplant thrombotic microvascular disease", the template guides the model to extract a composite conditional expression in the form of "(post-transplant) AND ((tacrolimus glutamate concentration > 15 ng / mL) OR (calmodulin inhibitor exposure))". Furthermore, the medical record template emphasizes the extraction dimension of probability weights, requiring the model to output the initial probability weights of the relationship or state transition based on the frequency terms described in the medical record (such as "occurred in most patients", "occurred in about 30% of cases", "rare complication", etc.) or by estimating the relative frequency of events in the same patient group, as a basic reference value for calibration with real-world evidence; the medical record template also mandates that the model simultaneously output the original text fragments supporting each extraction result. For domain literature guideline data, a literature-specific Prompt template is used. This template focuses on extracting standardized ontology relations and defined temporal anchors and disease evolution paths. The literature template first requires the large language model to identify the explicitly marked medical recommendation levels in the guideline text and directly map these recommendation levels to initial probability weights (e.g., level A is mapped to 0.60, level B to 0.45, and level C to 0.30), serving as the basic confidence level for this knowledge. Secondly, the template guides the model to extract standardized ontology relation types explicitly defined in the guideline. These relation types are limited to a predefined whitelist to reduce the risk of the large language model developing relation type illusions. Regarding temporal anchors, the literature template requires the model to extract the time constraints described in the guidelines, such as "within 30 days after transplantation," "lasting at least two weeks," or "acute phase (within 48 hours of onset)," and convert them into standardized temporal expressions for storage. For the extraction of multi-factor condition sets, the literature template focuses on extracting the multi-indicator combined diagnostic criteria or treatment indications explicitly listed in the guidelines. The system requires the model to fully parse these conditions and their logical relationships into structured expressions. Furthermore, the literature template also requires the model to extract the applicable population range for each piece of knowledge (e.g., "for adult patients with relapsed / refractory B-cell acute lymphoblastic leukemia") as an additional constraint for subsequent knowledge application, and simultaneously output the source guide name, version number, and specific entry number of this knowledge to achieve strict source traceability. After configuring the two sets of differentiated Prompt templates, the system fills the preprocessed medical record data and literature data into the corresponding templates, and sequentially calls the large language model API or the locally deployed inference interface for batch extraction. For each input text, the large language model, based on the constraints and guidance of the Prompt template, synchronously outputs JSON structured information covering multiple dimensions during one inference process, including: entities, relationships, multi-factor condition sets, time series anchors, probability weights, original text evidence, and source type tags, etc. 1. Entity: Includes entity name, type, and suggested standardized ID. 2. Relationship: Includes relationship type label and direction. 3. Multi-factor condition set: expressed in a JSON structure with nested AND / OR operators. 4. Timing Anchor Point: Normalized Time Offset Expression 5. Probability weights: Floating-point numbers between 0 and 1 6. Original text evidence: Original text fragments supporting the extraction results. 7. Source type label: Indicate that it comes from "EHR" or "Guideline" Through the above-mentioned differentiated template-driven one-time multidimensional extraction design, the system ensures that medical record data and literature guidelines each have their own extraction focus, while outputting structured knowledge units with unified format, complete dimensions, and direct use in downstream quality control processes, providing standardized data input for subsequent multi-source fusion and dynamic map construction.
[0022] Specifically, the large language model extraction for medical record data further employs a longitudinal time-axis state evolution chain extraction mechanism; when ingesting continuous electronic medical record data of a specific patient from a single center or multiple centers, the system extracts the overall dynamic state change flow of that patient according to the following dimensions: 1. Extract the state time series axis, that is, the absolute or relative time points when the patient's state transitions occur during the entire hospitalization or follow-up period; for example, T0 admission → T+3d sudden high fever → T+7d progression to TA-TMA → T+14d remission; 2. Extract explicit triggers, i.e., medical interventions or accompanying events clearly recorded in the medical record at each state transition; for example, the use of specific immunosuppressants or the occurrence of cytomegalovirus infection; 3. Extract implicit background confounding factors, namely the patient's individualized background baseline at the time of the change in condition, as the benchmark for subsequent control variable analysis; 4. Extract the outcome status and impact, that is, the direct clinical impact of the change in status; for example, changes in organ function impairment indicators, prolonged hospital stay, or forced discontinuation of medication; Through the above longitudinal extraction, the system integrates fragmented information scattered across multiple medical record documents into a complete individual clinical trajectory, providing a structured data foundation for extracting common patterns from high-noise individual paths using the two-level control variable method in subsequent steps.
[0023] S4. The multi-dimensional quality control intelligent agent performs compliance verification on the various types of structured information. The compliance verification includes at least content fidelity verification and time sequence integrity verification. Data that passes the verification is released, and data that fails the verification is intercepted or sent to a closed loop for manual review. Quality control qualified data is output. In S4, the JSON structured information output by the large language model in S3 is input into the multi-dimensional quality control agent. The quality control agent calls a rule engine containing five independent verification dimensions to perform compliance verification on each extracted result. Based on the verification score, it performs a three-level closed-loop process of "direct pass / warning level automatic correction / rejection level manual review and diversion" and finally outputs qualified quality control data. The first dimension is content fidelity verification. This verification module verifies whether the extraction results of the large language model are faithful to the original text and detects inferential and unfounded content added by the model. Specifically, the system adopts a method combining secondary verification based on the large model and rule matching: for the entity, relation, and original text evidence fields in each extraction result, the system calculates the semantic similarity between the extracted triples and the original text evidence fragments (e.g., using a pre-trained language model to calculate vector cosine similarity). When the similarity is greater than a preset threshold, it is judged as a semantic match. For extraction items that cannot be found in the original text, the system marks them as "unfounded illusions". The system marks any model that adds causal explanations or clinical inferences to the original text as "extrapolative hallucination". Any extraction result marked as any type of hallucination will fail the content fidelity check and will be assigned a corresponding deduction weight according to the severity of the hallucination. The second dimension is relationship compliance verification; this verification module verifies whether the extracted relationship type belongs to the system's preset relationship type whitelist; the system defines a set of medical relationship types applicable to the target disease field during the static framework construction stage, including core relationship types such as "progression", "concurrence", "manifestation", "recommended treatment", "contraindications", "etiology", "risk factors", and "differential diagnosis"; for each directed relationship extracted from medical records or literature, the verification module extracts its relationship label and performs precise matching with the legal relationship types in the whitelist; If the relationship tag is not in the whitelist, the system will judge based on the matching similarity: if there is a spelling error or format difference, it will enter the automatic correction process to try to correct it to the closest whitelist type; if the relationship tag has no reasonable mapping relationship with any type in the whitelist, it will be judged as a relationship type violation, and the data will enter the rejection level processing process. The third dimension is entity normalization verification; this verification module compares the extracted entities with the static framework dictionary constructed by S1 to detect unnormalized entities and synonym redundancy issues; specifically, the system first extracts candidate words from the name field of the extracted entities, and then performs a combination of fuzzy matching and exact matching in the "standard name", "alternative name", "abbreviation" and "English name" fields of the static framework dictionary in turn; If a candidate word can uniquely match a standard entity ID in the static framework, the verification passes, and the system automatically completes the entity ID into the extraction result. If a candidate word matches multiple candidate entities, the system performs disambiguation judgment based on the context semantics. If automatic disambiguation fails, the entity is marked as "ambiguous pending review" and sent for manual review. If a candidate word cannot match any entity in the static framework dictionary, the system determines the entity as an "unnormalized entity" and triggers a warning-level correction process, attempting to map it to the closest standard entity through an edit distance algorithm or synonym inference based on a large model. If mapping fails, the entity is marked as pending review, and the entity is recorded as a potential expansion candidate for the static framework dictionary for manual review to determine whether to include it in the dictionary. In addition, the module also detects whether there are different names pointing to the same standard entity in the same extraction result set. For the detected synonym redundancy, the system automatically replaces it with the standard entity name to ensure the uniqueness and consistency of entity alignment. The fourth dimension is logical consistency verification; this verification module detects logical contradictions between different extraction results within the same document, as well as the integrity of logical operations in the multi-factor condition set; in terms of relational logic, the system checks whether there are contradictory relation extractions within the same document, such as simultaneously extracting conflicting relations of "disease A progresses to disease B" and "disease A never progresses to disease B", or abnormal situations such as the extracted temporal relations forming directed cycles; In terms of logical verification of multi-factor condition sets, the system parses the AND / OR nested structure in the condition set and checks for syntax errors such as empty conditions, invalid logical operators, mismatched parentheses, or redundant nesting; at the same time, it verifies whether each condition item in the condition set is a verifiable clinical indicator or event expression, and excludes condition descriptions that are semantically ambiguous or cannot be operated. For detected logical contradictions or conditional structure errors, the system handles them in a tiered manner according to the severity of the error: for formatting issues that can be automatically corrected, the system performs automatic correction; for semantic logical contradictions, the system sends the relevant conflicting data to a closed-loop manual review process for expert judgment and decision-making. The fifth dimension is the temporal integrity verification; this verification module checks the format standardization and physical rationality of the temporal anchor field; in terms of format standardization, the system verifies whether the temporal anchor conforms to the preset standardized expression format, for example, the relative time offset must be in the form of "T±nd" or "T±n days / weeks / months", and the absolute time point must contain a clear time reference system. For time series expressions that do not conform to the format specifications, the system attempts to automatically convert or correct them. If the correction fails, it is marked as a format error. In terms of physical rationality, the system calls a pre-built standard medical time series constraint rule library. This rule library is based on authoritative medical textbooks and clinical guidelines and stores the common sense of time constraints for the evolution of various diseases in the form of triples (source state, target state, maximum time series window) and binary pairs (preceding event, subsequent event). The system queries this rule library to determine whether the value of the time series anchor point is within a reasonable range. For example, it checks whether the time window for "progressing to a certain acute complication" exceeds the maximum latency period of the complication recorded in the rule library, or whether the order of occurrence of two time series events violates the necessary order in the rule library. For extraction results that obviously violate medical common sense in terms of time series, the system determines that the time series integrity check fails and sends it to the rejection level processing procedure.
[0024] After completing the item-by-item verification across the aforementioned multiple dimensions, the system comprehensively scores each extraction result and triggers a three-level closed-loop process based on the score range: Level 1 is "Direct Pass," applicable to data that meets all verification dimensions or has only very minor non-semantic issues that have been automatically corrected. This type of data is directly allowed to proceed to step S5, the dynamic graph construction stage. Level 2 is "Warning-Level Automatic Correction," applicable to data with formatting errors, unnormalized synonyms, or non-standard temporal formats that can be automatically corrected. After performing automatic correction, the system generates a correction log and marks the corrected data as "Automatically Corrected" before allowing it to proceed to the next stage. Level 3 is "Reject-Level Manual Review and Triage," applicable to data with serious issues such as illusions of content fidelity, inability to map relationship types, logical contradictions that cannot be automatically resolved, or errors in temporal and physical meaning. The system packages this type of data along with the original text fragment, the large language model extraction results, and the specific reasons for verification failure, and pushes it to the expert review platform for manual review and correction by medical experts. The expert-corrected data re-enters the quality control process until it passes verification or is ultimately marked as invalid and discarded. Through the aforementioned five-dimensional rule engine and three-level closed-loop processing mechanism, the system filters out inferential and unfounded content generated by the large language model, outputting structured data that conforms to medical norms, logical consistency, and content fidelity verification rules. All data that passes the quality control process, whether directly or after correction, is uniformly aggregated into a quality control qualified dataset, which serves as the standard input for constructing the S5 dynamic graph.
[0025] S5. Dynamic graph construction: Anchor entities in the quality control qualified data to nodes of the static framework, and overlay the multi-factor condition set, time-series anchor points and probability weights as dynamic attributes onto the relation edges to construct and store a dynamic time-series disease knowledge graph; In S5, because the patient state change streams extracted longitudinally in S3 contain individual differences and baseline confounding, the state change streams of all individual patients extracted longitudinally in S3 and subjected to quality control are first aggregated and mapped to a unified mathematical feature space; specifically, the system extracts three types of feature variables from each state transition event: the first type is the set of independent variables. The first category includes the clinical indicators recorded before the transfer and the medical interventions implemented; the second category is the set of dependent variables. The first category includes the target state type of the state transition and the direct clinical impact of the transition; the second category is a set of fixed control variables. This includes the patient's underlying disease type, age, gender, baseline renal function, and other inherent individual attributes that do not change with the intervention within this observation window; Through the above feature mapping, the heterogeneous state transition events that were originally scattered across various patient medical records are uniformly represented as follows: Structured sample points; After completing the multidimensional feature space mapping, the system executes a two-level control variable dynamic alignment algorithm to quantitatively extract statistically significant common relationship flows of medical record groups from high-noise individual clinical pathways.
[0026] The first layer involves common population stratification and dynamic alignment across time periods: The system stratifies patients based on key procedures or intervention types (e.g., whether a transplant or specific medication replacement is performed), candidate time windows, and baseline control conditions, aligning state transition events across different time periods. For example, by comparing patient groups who were not ill in the first two time periods but developed the disease and progressed in subsequent time periods, the system statistically analyzes the differences in state transitions across different populations, procedures, and time windows. This allows for the aggregation of relationships across patient groups and the initial screening of potentially common candidate influencing factors.
[0027] The second layer is the net effect analysis of control variables: Based on the common population and candidate influencing factors obtained in the first layer, the system further performs one-hot encoding on the categorical variables in the fixed control variable set C, standardizes the continuous variables, and concatenates them to form a patient feature vector; then, the K-Prototypes clustering algorithm is used to calculate the feature distance between patients. In order to explicitly eliminate the clinical practice heterogeneity, follow-up baseline drift, and sample selection bias caused by cross-medical center data sources, the system introduces an adaptive distance operator with type weights in this step. The feature distance is defined as the sum of the weighted Euclidean distance of the continuous variables and the weighted Hamming distance of the categorical variables. By dynamically adjusting the weight ratio of the two types of variables, the common subgroup characteristics determined by the disease state rather than the hospital attributes are maximized, thereby dividing the patient group into several subgroups with homogeneous C values (intra-cluster distance less than a preset threshold). Within this subgroup, the system uses propensity score matching (PSM) to control for other confounding variables to remain consistent, allowing only one target influencing factor to change. Then, by calculating the odds ratio (OR) and 95% confidence interval of this variable to state transition, the statistical net effect of the change of this variable on the state transition time window and clinical outcome is quantitatively observed, thereby extracting statistically significant common relationship flows of the medical record group. Using the methods described above, the system can estimate causal effect sizes approximating randomized controlled trials from real-world observational data, including the odds ratio of a risk factor leading to state transition and the daily average effect size of a protective factor shortening disease duration. Based on these statistically significant effect sizes, the system generates a common relationship flow among the patient population, where each piece of knowledge includes the actual sample size, effect size, and significance test results. value; After extracting common patterns from medical records, the system summarizes the common relationship flow of medical record groups extracted in the previous step with the literature normative relationship flow directly extracted from the literature guidelines in S3. Before merging the two types of data streams, the spatial misalignment problem caused by different entity naming methods is resolved. Specifically, the system performs ontology node alignment for dual-source entities: extracting the source and destination entity names from each relation record in both data streams, uniformly consulting the static framework dictionary constructed by S1, and utilizing the mapping relationships between pre-stored standard names, aliases, abbreviations, English names, and standard entity IDs in the dictionary, various common names, aliases, or abbreviations (such as "neutropenia" commonly found in medical records and "neutropenia" in guidelines, or "myocardial infarction" in medical records and "acute myocardial infarction" in guidelines) are anchored to the same ontology node in the graph database. The anchoring process employs a strategy of prioritizing exact matching, supplemented by fuzzy matching and context disambiguation. For entities that cannot be automatically anchored, the system pushes them to the manual review stage for final judgment. Through the above spatial registration operation, similar entities from heterogeneous data sources are unified under the same node identifier in the static framework. After entity anchoring is completed, the system performs topological interleaving and merging of relation edge attributes on dual-source relation records that point to the same pair of standard entities (i.e., the same source node and target node) and have the same relation labels. Specifically, it is divided into two parallel dimensions: temporal axis fusion and condition set tree platform merging. In terms of time series fusion, the system performs interval intersection calculations on the relatively broad time series descriptions given in the literature guidelines and the high-precision time series offset windows extracted after the analysis of control variables in medical records; assuming the literature time series interval is... The time interval of the medical records is The merged temporal anchor attribute for: like If the interval is non-empty, a composite time-series anchor attribute is generated that combines the guidance of literature standards with the accuracy of real-world statistics; if the intersection is empty, the system marks the time-series conflict and pushes it for manual review, whereby experts determine whether to take real-world data or literature guidelines as the standard, or mark the relationship as having cross-population heterogeneity.
[0028] Regarding the merging of condition set trees, the system performs a logical tree alignment operation on the theoretical trigger condition sets recorded in the literature guidelines and the real clinical specific indicators / threshold constraints extracted from the common relationships in medical records; let the literature condition set be represented as a logical expression. The medical record condition set is represented as a logical expression. The system uses the AND merging operation of the logic tree to combine two-source conditions. and Parsing each node into an Abstract Syntax Tree (AST), generating a new root node with the logical operator "AND", and then... AST and The ASTs are used as the left and right subtrees of the root node, respectively; then the system traverses the merged AST, and if duplicate leaf node conditions are detected at the same level, deduplication and merging are performed; if the lower-level logic is detected... AND or OR Then it simplifies to The fused set of multi-factor conditions This is the AST structure after merging and simplifying.
[0029] For example, if the literature specifies that a certain state transition requires both condition A and condition B to be satisfied simultaneously, that is... Statistical analysis of medical records shows that in a homogeneous patient population in the real world, patients who meet both A and B almost always also have indicator C exceeding a certain threshold (such as C-reactive protein > 50 mg / L). Then the set of conditions after fusion is ; If the literature specifies that condition A or condition B must be met, that is... If the medical record data shows that only A is statistically significant while B does not appear, then the system can be adjusted to... B is marked as a rare condition and assigned a low probability weight; After fusing the condition set and the time series axis, the dual-source probabilistic weighted cross-calibration algorithm uses a cross-calibration algorithm based on the data source confidence strength to calculate the final probability weights on the merged relation edges. To dynamically suppress and correct the distortion of initial probability weights of relation edges caused by probability illusions inherent in large language models, text extraction noise, and biases in local medical samples, the system constructs a dual-driven dynamic cross-calibration mechanism that balances the medical prior level of authoritative literature with the net effect of real-world evidence. The specific calculation method is as follows: in, As the basic weight of the literature, This is the real-world gain correction value; The basic weight of the literature is assigned by the evidence level or recommendation level recorded in the literature guidelines. The specific mapping rules are as follows: Level A recommendation or Level 1 evidence is mapped to 0.60, Level B recommendation or Level 2 evidence is mapped to 0.45, Level C recommendation or Level 3 evidence is mapped to 0.30, and expert opinion or case report is mapped to 0.15. The mapping value is adjusted according to the evidence grading standards of the specific disease area. The calculation method is as follows: in, This represents the effect size calculated from the medical record data. This represents mapping the effect size to... The normalization function of the interval, The preset global scaling factor (value is 0.2); To ensure the mathematical consistency and convergence stability of the final synthesized map during long-chain disease pathway reasoning, the system also introduces a hard-boundary normalization truncation operator and a smooth decay function in the calibration module: if the calculated... Outside the range [0, 1], the system will forcibly truncate the output based on the direction of overflow, and use the Sigmoid transformation function to perform smooth compression mapping for probability outputs that are close to the extreme value, thereby avoiding logical conflicts such as confidence explosion or probability zeroing in subsequent multi-level serial inference. After completing all the above merging and calibration operations, the system writes the final relation edges and all their dynamic attributes into the graph database. To ensure the traceability and credibility of knowledge, the system uses a unified data structure to concurrently mount complete evidence fragments from both data sources in the attributes of each merged relation edge; specifically, the attributes contain... The "Guideline" evidence branch records the guideline entry number, guideline name and version number, original text excerpt, and the level of evidence or recommendation assigned to that document; it also includes... The "EHR" branch of evidence records the results of medical record data analysis that support this knowledge, including the number of sample patients used to extract this common pattern. The name of the statistical method used, and the specific significance test. The value or confidence interval CI = [lower, upper], and a typical medical record excerpt (desensitized) that can represent the clinical impact; Through the parallel mounting of the above dual-source evidence links, the final dynamic temporal disease knowledge graph is a knowledge unit with a complete evidence archive. After completing the above six sub-steps, the system anchors entities to the static framework nodes constructed by S1, and overlays multi-factor condition sets, time-series anchors, and probability weights as dynamic attributes onto the relation edges, ultimately constructing a dynamic time-series disease knowledge graph in the Neo4j graph database.
[0030] S6. Disease Path Reasoning: Based on the multi-factor condition set, temporal anchors and probability weights in the dynamic temporal disease knowledge graph, perform temporal reasoning of disease evolution paths and output candidate evolution paths and confidence scores. In the S6 disease path reasoning, the system, based on the dynamic temporal disease knowledge graph built in S5, performs temporal reasoning on the disease evolution path under given clinical input conditions, and outputs the path with the highest confidence and its corresponding confidence. This reasoning process utilizes the dynamic attributes such as the multi-factor condition set, temporal anchors and probability weights stored on the graph relation edges, which can simulate the real laws of multi-indicator combination and disease temporal evolution in clinical practice. When the system receives a specific clinical reasoning request, the request includes the patient's current state information, such as the current disease diagnosis name, the acute symptoms that have appeared, the recent test index values, the intervention measures that have been taken, and the known patient baseline characteristics. The system first uses the disease or symptom entity in the current state as the starting node, and explores multiple paths in the dynamic temporal disease knowledge graph using a breadth-first or heuristic search strategy to obtain all possible target state nodes that can be reached from the current state and the sequence of directed relation edges they have traversed. For each candidate evolutionary path, the system sequentially performs condition matching evaluation and time feasibility verification on each relation edge along the path. In terms of condition matching evaluation, the system extracts a multi-factor condition set stored in the relation edge attributes. This condition set is expressed as a nested AND / OR logical network structure, representing the joint clinical indicator constraints required for the state transition. The system compares the patient's clinical indicator values included in the inference request with each condition in the condition set. For example, the condition set may require "absolute neutrophil count < If the input index is >50 mg / L and C-reactive protein is >50 mg / L, the system verifies whether the input index simultaneously meets both threshold judgments. For the OR branch in the condition set, the branch can be matched as long as any sub-condition is met. If the input information is insufficient to determine whether a condition is met, the system marks the condition as "to be supplemented" and records the missing key information. Only when all the must-reach conditions in the condition set (i.e., the minimum set of conditions that cannot be bypassed after the logic tree is simplified) are met is the relation edge considered to be a successful condition match.
[0031] In terms of temporal feasibility verification, the system extracts the temporal anchor points stored in the relation edge attributes. These anchor points represent a standard temporal offset interval relative to a certain reference event. For example, [T+7d, T+14d] represents the period between the 7th and 14th day after the reference event. Based on the patient's actual medical history timeline, the system determines whether the actual time interval between the current time point and the reference event falls within the temporal anchor point interval. If a patient's actual time interval is earlier than the lower limit of the interval, the system marks the relation as a future triggerable state. If it is later than the upper limit of the interval, the system determines that the relation has exceeded the feasible time window and is no longer included in the current inference path. If the actual time interval falls within the interval, the temporal feasibility is determined to be passed. For complex paths with multiple temporal constraints, the system verifies the rationality of each temporal anchor point relative to its respective reference event in turn. After completing condition matching and time feasibility verification for all candidate paths, the system calculates a comprehensive confidence score for each verified path; for an evolutionary path of length L: Where N represents a state node and R represents a relational edge between nodes; Its path confidence The calculation is performed by combining the cumulative product of the probability weights of each relation edge on the path with a weighted correction based on the temporal matching degree. The specific calculation method is as follows: Where i represents the index of the relation edge on the path. For relation edges The final probability weights, product terms This represents the joint probability of each state transition occurring sequentially along the path, serving as the basic estimate of path confidence. This is represented as a time-series matching correction factor, with a value range of (0,1]. Its value is determined by the degree of matching between the set of time-series anchor points on the path and the patient's actual time interval. The specific calculation formula is a piecewise function: When the actual time interval... Falling into the time series anchor interval hour, when Earlier than the lower limit of the range (i.e., future triggerable states) when Later than the upper limit of the interval When (i.e., deviating from the time window), For all relation edges on the path Take the product of all the steps and use it as the timing correction factor for the entire path.
[0032] After calculating the confidence scores of all candidate paths, the system sorts the paths from highest to lowest confidence score and outputs the paths with the highest scores. The optimal evolution path ( (The default value is 3 to 5). Each path simultaneously outputs the following information: the sequence of state nodes and relation types on the path, the overall confidence score of the path, a list of multi-factor conditions required to trigger transitions in each segment, the predicted time window for each transition, and a list of key clinical information currently missing from the input. In addition, the system provides a visualization function for the path, presenting the evolutionary path as a node-edge graph, which can be clicked to expand and view the details of dual-source evidence for any relation edge (including excerpts from literature guidelines and statistical information from medical records supporting the path). Through the above disease path reasoning mechanism, the system can provide clinicians with personalized disease evolution prediction and clinical decision-making references based on the current patient status, supporting various intelligent medical application scenarios such as early warning, treatment plan selection, and prognostic assessment.
[0033] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for constructing a medical knowledge graph based on a large language model, characterized in that, include: S1. Extract medical candidate entities and dictionary attributes through a large language model, and generate a static framework with both ontology hierarchy and medical dictionary functions through rule verification and manual quality control, and import it into a graph database. S2. Parallel acquisition of multi-center real electronic medical record data and domain literature and guide data, differential preprocessing of the two types of data to form a dual-source input data stream; S3. Based on the differentiated Prompt template, drive the large language model to perform a single synchronous extraction of the dual-source input data to obtain structured information; S4. The structured information is verified for compliance through a multi-dimensional quality control intelligent agent. The compliance verification includes at least content fidelity verification and time sequence integrity verification. Data that passes the verification is allowed to pass, while data that fails the verification is intercepted or sent to a closed loop for manual review, and quality control qualified data is output. S5. Dynamic graph construction: Anchor entities in the quality control qualified data to nodes of the static framework, and overlay the multi-factor condition set, time-series anchor points and probability weights as dynamic attributes onto the relation edges to construct and store a dynamic time-series disease knowledge graph; S6. Disease Path Reasoning: Based on the multi-factor condition set, temporal anchors and probability weights in the dynamic temporal disease knowledge graph, perform temporal reasoning of disease evolution paths and output candidate evolution paths and confidence levels.
2. The method of claim 1, wherein the method is based on a large language model. In step S1, the system employs a large language model as an auxiliary extraction tool. By designing specialized entity extraction prompt templates, the system drives the large language model to automatically parse medical concepts, terminology definitions, and hierarchical relationships, extracting candidate medical entities and their dictionary attributes. The dictionary attributes include the entity's standard name, common aliases, abbreviations, English equivalents, and a unique identifier for the standard entity. The system calls an internal rule validation engine to automatically validate the extraction results, checking whether the entity name is empty, whether the standard entity ID conforms to the predetermined encoding standard, whether the alias forms a circular reference with the standard name, and whether there are abnormal associations in the hierarchical relationship that violate ontology constraints. Data that fails the validation is pushed to the manual sampling quality control stage for review and correction by medical experts.
3. The method of claim 1, wherein the method is based on a large language model. In step S2, for multi-center real electronic medical record data, the system acquires the de-identified medical record text and uses a combination of regular expressions and named entity recognition to automatically detect and de-identify privacy information; abnormal characters and non-standard punctuation are cleaned, and the data is aggregated and sorted by time according to a three-level structure of patient, consultation time, and document type to form a time-series medical record document set; for medical literature and clinical guideline data, the system acquires the full text of the literature or guideline document, extracts it into plain text format, and performs regular chapter segmentation and paragraph annotation according to the chapter title structure; finally, the data is merged and output as a dual-source input data stream with a unified format and traceability by document source and paragraph index.
4. The method of claim 1, wherein the method is based on a large language model. In S3, two sets of differentiated Prompt templates with different structures and focuses are configured for electronic medical record data and literature guideline data. For electronic medical record data, a medical record-specific Prompt template is used, requiring the model to standardize the time description, extract the set of multi-factor conditions and logical combinations related to state transitions or clinical outcomes, and output the initial probability weights based on frequency terms or relative frequencies. For literature guideline data, a literature-specific Prompt template is used, requiring the model to identify the medical recommendation level and map it to the initial probability weights, extract the standardized ontology relationship types, time constraints, and applicable population scope within the predefined whitelist, and output the source guideline name and version number.
5. The method for constructing a medical knowledge graph based on a large language model according to claim 4, characterized in that: In S3, the large language model outputs structured information synchronously during an inference process based on the constraints and guidance of the differentiated Prompt template. For the electronic medical record data, the system also uses patient state evolution chain extraction based on the vertical time axis to extract the state time series axis, explicit triggering factors, implicit background confounding factors, and outcome state and impact.
6. The method for constructing a medical knowledge graph based on a large language model according to claim 1, characterized in that: In S4, the multi-dimensional quality control agent invokes a rule engine containing five independent verification dimensions to perform compliance verification. These five dimensions include: content fidelity verification for detecting inferential and unfounded content added to the model; relationship compliance verification for verifying whether the extracted relationship types belong to a preset whitelist; entity normalization verification for comparing extracted entities with a static framework dictionary to detect synonym redundancy and unnormalized entities; logical consistency verification for detecting logical contradictions and condition set syntax errors within the same document; and temporal integrity verification for detecting the format specifications and physical rationality of temporal anchors.
7. The method for constructing a medical knowledge graph based on a large language model according to claim 6, characterized in that: In S4, the system performs a three-level closed-loop processing based on the verification score: the first level is direct pass, which is applicable to data that meets the requirements in all verification dimensions and is directly released; The second level is the warning level automatic correction, which is applicable to data with formatting errors, unnormalized synonyms, or non-standard time sequence formats. The system will release the data after performing automatic correction. The third level is the rejection level, which is subject to manual review and triage. It applies to data containing inferential or unfounded content, data with unmapped relationship types, logical contradictions, or errors in temporal or physical meaning. The system pushes the data to the expert review platform for manual review and correction.
8. The method for constructing a medical knowledge graph based on a large language model according to claim 1, characterized in that: In S5, the system extracts the set of independent variables, the set of dependent variables, and the set of fixed control variables from the state transition events of individual patients, and represents the heterogeneous state transition events as structured sample points; the system executes a two-layer control variable dynamic alignment algorithm to extract the common relationship flow of the medical record group. The first layer is the patient's own before and after comparison, and the fixed variables are kept unchanged to compare the state transitions before and after the intervention. The second layer involves dynamic clustering across patient groups to screen patient subgroups with homogeneous fixed variables and quantitatively observe the statistical net effect of changes in target confounding variables.
9. The method for constructing a medical knowledge graph based on a large language model according to claim 8, characterized in that: In S5, when the system summarizes the common relationship flow of the medical record group and the standard relationship flow of the literature, it performs the ontology node alignment of the dual-source entities and anchors the names of various entities to the same ontology node of the static frame; for dual-source relationship records that point to the same pair of standard entities and have the same relationship labels, it performs node and relationship edge attribute merging based on graph topology, including time axis fusion and condition set tree merging, and uses a cross-calibration algorithm based on the data source reliability strength to calculate the final probability weight on the merged relationship edge; The system attaches dual-source evidence branches from literature guidelines and electronic medical records in parallel to the attributes of each merged relation edge.
10. A medical knowledge graph construction system based on a large language model, using the medical knowledge graph construction method based on a large language model as described in any one of claims 1-9, characterized in that: The static framework building module is used to extract medical candidate entities and dictionary attributes through a large language model, and after rule verification and manual quality control, generate a static framework that has both ontology hierarchy and medical dictionary functions, and import it into the graph database. The dual-source preprocessing module is used to acquire multi-center real electronic medical record data and domain literature and guideline data in parallel, and perform differentiated preprocessing on the two types of data to form a dual-source input data stream; The multidimensional extraction module is used to drive the large language model to perform a single synchronous extraction on the dual-source input data based on the differentiated Prompt template, and obtain structured information such as entities, relations, multi-factor condition sets, time-series anchors and probability weights. The quality control module is used to perform compliance verification on the various structured information through a multi-dimensional quality control intelligent agent. The compliance verification includes at least content fidelity verification and time sequence integrity verification. Data that passes the verification is allowed to pass, data that fails the verification is intercepted or sent to a closed loop for manual review, and quality control qualified data is output. The dynamic graph construction module is used to anchor entities in the quality control qualified data to nodes of the static framework, and to overlay the multi-factor condition set, time-series anchor points and probability weights as dynamic attributes onto the relation edges to construct and store a dynamic time-series disease knowledge graph. The path reasoning module is used to perform temporal reasoning of disease evolution paths based on the multi-factor condition set, temporal anchor points and probability weights in the dynamic temporal disease knowledge graph, and output candidate evolution paths and confidence scores.
