Question answering system based on diabetes knowledge graph and construction method
By constructing a knowledge graph in the field of diabetes and employing text enhancement and multi-view relationship extraction models, the shortcomings of existing technologies in handling complex medical terms and extracting entity relationships are addressed, resulting in an efficient and accurate diabetes knowledge graph construction and question-answering system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-12
- Publication Date
- 2026-04-10
AI Technical Summary
Existing technologies struggle to handle contextual variations and synonyms of complex medical terms when constructing diabetes knowledge graphs. Entity relationship extraction models lack structured domain knowledge utilization, leading to fragmented and inaccurate answers.
We employ a domain knowledge graph-based text enhancement method. By constructing a knowledge graph for the diabetes domain, we perform deep cleaning and enhancement on the original text. Combined with a multi-feature fusion entity boundary localization and multi-view relationship extraction model, we construct an end-to-end collaborative training framework to achieve semantic consistency between entity localization and relationship extraction.
It improves text standardization, solves the problem of enhanced text position offset backtracking, achieves efficient and accurate entity relation extraction and answer generation, and ensures semantic consistency of the knowledge extraction pipeline.
Smart Images

Figure CN121833908A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a question-answering system and its construction method based on a diabetes knowledge graph. Background Technology
[0002] Currently, the field of diabetes health management faces a massive amount of multi-source and continuously updated medical knowledge, primarily existing in unstructured or semi-structured texts such as academic literature, clinical guidelines, and electronic medical records. Patients, healthcare professionals, and the general public urgently need to efficiently and accurately access authoritative diabetes-related knowledge. Traditional keyword-matching-based information retrieval methods struggle to understand complex medical semantics and logical relationships, resulting in fragmented and inaccurate answers. Knowledge graph-based intelligent question-answering systems are considered an ideal solution to this need, with their core being the construction of a high-quality, structured domain knowledge graph.
[0003] The main drawbacks of the existing technology are as follows: Medical text cleaning often relies on static dictionaries and rules, making it difficult to handle complex contextual variations and synonyms of technical terms; methods for enhancing entity location mapping in text are simple but prone to boundary misalignment due to label insertion, affecting downstream tasks; entity relation extraction models typically rely solely on text semantics, lacking the utilization of structured domain knowledge and implicit reasoning paths; knowledge graph construction often involves independent design and optimization of each stage, and the fragmented process leads to the loss or inconsistency of semantic information during hierarchical transmission. Summary of the Invention
[0004] To address the problems in the prior art, this invention provides a question-answering system and its construction method based on a diabetes knowledge graph.
[0005] This invention is achieved through the following technical solution: A method for constructing a question-answering system based on a diabetes knowledge graph, comprising: S1. Construction of a diabetes knowledge graph; including the collection of diabetes knowledge text data, cleaning and structuring enhancement of diabetes knowledge text data, enhanced text parsing and entity boundary localization, construction of an entity relationship extraction module, knowledge graph model training, and triple acquisition and knowledge graph construction. S2, Problem Understanding Module Construction: This includes parsing the natural language questions input by the user, identifying diabetes-related entities in the questions, and linking them with nodes in the knowledge graph to determine the user's query intent; combining the identified entities and intent, this module transforms the natural language question into a structured query representation; S3, Answer Retrieval and Generation Module: This module includes traversing and retrieving structured queries generated by the question understanding module on the constructed diabetes knowledge graph. The answer generation component then converts the retrieved structured knowledge results into natural language sentences, which are returned to the user as the final answer.
[0006] Furthermore, the cleaning and structuring enhancement of the diabetes knowledge text data includes a text enhancement method based on domain knowledge graphs, which deeply cleans and enhances the original text by constructing a diabetes domain knowledge graph.
[0007] Furthermore, the text enhancement method based on domain knowledge graph also includes context-aware text enhancement, specifically including dynamically deciding whether to perform synonym replacement based on the associated concepts and context of the words in the domain knowledge graph, and inserting structured semantic tags before and after them.
[0008] Furthermore, the enhanced text parsing and entity boundary localization specifically calculates the parsing confidence of candidate text segments and performs boundary localization through multi-feature fusion, accurately mapping entities in the enhanced sequence back to the original text sequence.
[0009] Furthermore, the calculation of the resolution confidence of candidate text fragments includes parsing the structured tags in the enhanced text sequence, identifying all candidate text fragments marked by start and end tags, and for each candidate entity text fragment, calculating the resolution confidence to quantify its credibility as a real entity by fusing its semantic similarity features with the original text and its consistency features with the attached tags, expressed as: ; In the formula, This represents the text fragment representing the k-th candidate entity. The confidence level of the resolution; Indicates from enhanced text sequence The k-th candidate entity text fragment parsed from the data; Indicates the index of the candidate fragment, with a value range of 1. ; Indicates from enhanced text sequence The total number of candidate segments parsed from the data; Weight coefficients representing contextual similarity features; The weighting coefficients representing the label consistency feature; Represents candidate entity text fragments Contextual semantic similarity features; This indicates an indicator function that takes the value 1 when the condition is true and 0 otherwise. This represents the text fragment representing the k-th candidate entity. Corresponding start tag The entity type marked; Represents a valid set of medical entity types; Represents the label consistency function. This is the closing tag.
[0010] Furthermore, the boundary localization of the multi-feature fusion determines its start and end positions in the original text sequence by maximizing the boundary determination function that integrates deep semantic similarity, position offset penalty, medical saliency, and adjacent label constraints.
[0011] Furthermore, the entity relationship extraction module includes extracting the text context of fused entity pairs, knowledge graph topology information, and enhancing the semantics of structured tags in the text to construct a multi-view relationship extraction model, and introducing logical reasoning information from the graph through a relationship path attention mechanism.
[0012] Furthermore, the loss function of the relation extraction model is calculated as follows: ; In the formula, Represents the relation extraction loss function; This indicates the number of entity pairs in the training samples; This indicates the relation type, belonging to a predefined set of relations. ; Represents the set of all predefined relation types; Indicates the first The true relation type of each training sample; The model predicts the first... Each entity pair belongs to the relation type The probability, Indicates the first The first entity in the training samples Indicates the first The second entity in a training sample; This represents the weight coefficient of the L2 regularization term; Represents the L2 norm; This represents the set of all trainable parameters.
[0013] Furthermore, the construction of the diabetes knowledge graph also includes, after completing the training of the knowledge graph model and obtaining a stable entity localization and relation extraction model, processing all collected diabetes knowledge texts, automatically extracting structured knowledge, storing it in the form of triples, and finally constructing a diabetes domain knowledge graph.
[0014] This invention also provides a question-answering system based on a diabetes knowledge graph, which, based on the question-answering system construction method based on a diabetes knowledge graph as described above, includes: The diabetes knowledge graph construction module includes a diabetes knowledge text data collection submodule, a diabetes knowledge text data cleaning and structuring enhancement submodule, an enhanced text parsing and entity boundary localization submodule, a knowledge graph model training submodule, and a triple acquisition and knowledge graph construction submodule. The question understanding module is used to parse the natural language questions input by the user, identify diabetes-related entities in the questions, determine the user's query intent through an intent classification model, and combine the identified entities and intent to transform the natural language questions into a structured query representation. The answer retrieval and generation module is used to execute queries and organize answers. Specifically, it transforms the retrieved structured knowledge results into natural language sentences using predefined answer templates or sequence-to-sequence generation models, and returns these sentences to the user as the final answer.
[0015] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. A context-aware text enhancement method based on domain knowledge graphs is adopted to dynamically integrate terminology standardization and semantic tag insertion to improve text standardization; 2. A multi-feature fusion entity boundary precision localization mechanism is adopted, and the problem of position offset backtracking in enhanced text is solved by analyzing confidence and joint optimization loss; 3. Construct a multi-view relation extraction model that integrates text context, knowledge graph topology, and relation path attention; 4. Employ structured knowledge for medical logical reasoning to achieve an end-to-end collaborative training framework from text enhancement and entity localization to relation extraction, ensuring semantic consistency across all stages of the knowledge extraction pipeline. Attached Figure Description
[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic flowchart of a question-answering system construction method based on a diabetes knowledge graph according to an embodiment of this application; Figure 2 This is an example diagram of a triplet according to an embodiment of this application; Figure 3 This is an example diagram of a knowledge graph according to an embodiment of this application. Detailed Implementation
[0017] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0018] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, in the absence of conflict, the following embodiments and features in the embodiments can be combined with each other. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0019] It should also be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. The illustrations only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the shape, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.
[0020] See Figure 1 A method for constructing a question-answering system based on a diabetes knowledge graph includes the following steps: S1. Construction of a Diabetes Knowledge Graph S101, Collection of Diabetes Knowledge Text Data A comprehensive and authoritative collection of diabetes knowledge text data was conducted. Raw text data containing diabetes-related medical knowledge was systematically collected from multiple reliable sources. The specific collection process is as follows: The data primarily originates from publicly available authoritative medical literature databases, clinical guideline documents, anonymized electronic health record texts, and professional medical encyclopedias and textbooks. For example, relevant medical research papers, review articles, and abstracts were retrieved and downloaded from academic databases such as PubMed and CNKI using keywords such as "diabetes," "insulin," "blood glucose monitoring," and "diabetic complications." Simultaneously, treatment guidelines and consensus statements issued by international and domestic diabetes societies were collected, such as the American Diabetes Association (ADA) guidelines and the Chinese Diabetes Society (CDS) guidelines. Furthermore, under the premise of complying with ethical standards and data privacy protection, anonymized fragments of clinical electronic health records were obtained. These records contain authentic symptom descriptions, diagnostic conclusions, medication records, and other information. Additionally, diabetes-related term explanations and chapter content were extracted from professional medical encyclopedia websites or digital medical textbooks as an important supplement to basic conceptual knowledge.
[0021] All the collected raw text data together constitute the initial diabetes knowledge text corpus. To ensure the effective training of the subsequent entity relation extraction model, this step also requires fine-grained manual annotation of some of the collected text to construct an annotated dataset. The annotation work is completed by professionals with medical backgrounds, using a combination of sequence annotation and relation annotation.
[0022] First, entity boundaries and types are labeled using predefined entity category labels such as "disease", "drug", "examination item", "symptom", and "treatment method". The start and end positions and types of each entity are marked in the text sequence. Based on this, for entity pairs in the sentence, the relationship categories between them are further labeled, such as predefined semantic relationships such as "cause", "treatment", "examination diagnosis", and "symptom is".
[0023] After multiple rounds of annotation and consistency verification, high-quality training and validation samples are generated.
[0024] S102. Cleaning and Structural Enhancement of Diabetes Knowledge Text Data Diabetes knowledge text data contains dense professional medical terms, a large number of synonyms, abbreviations and non-standard expressions, resulting in serious text noise, excessive diversity of expressions and blurred entity boundaries. Conventional techniques usually use simple replacement or rule cleaning based on fixed dictionaries, which are difficult to cover the complex contextual variations of medical terms and cannot enhance the structured information of entity context.
[0025] This invention employs a text enhancement method based on domain knowledge graphs. By constructing a knowledge graph for the diabetes domain, it performs deep cleaning and enhancement on the original text to improve text standardization and model learnability. The specific steps are as follows: 1) Constructing a knowledge graph for the diabetes domain To systematically manage medical terminology and its semantic relationships, relevant concepts and predefined semantic relationships are extracted from a standard medical knowledge base to construct a domain knowledge graph. ; in, This represents a knowledge graph in the diabetes domain, serving as the foundational semantic data structure for term association queries, and includes a set of nodes. Sum of edges , Node set It contains all diabetes-related concepts extracted from a medical standard terminology database, such as "type 2 diabetes," "insulin," "glucose monitoring," and "diabetic nephropathy," with each node representing a standardized medical concept. edge set It contains various predefined semantic relationships connecting concept nodes, such as "synonym", "belongs to", "symptom is", etc., and each edge represents a specific semantic association between concepts.
[0026] In one implementation, the node set With edge set Extracted and constructed from publicly available medical knowledge graphs or standard terminology databases, such as... (Unified Medical Language System) )or (Systematic Medical Terminology—Clinical Terminology) The section on diabetes in the document ensures the authoritativeness and accuracy of terminology and relationships.
[0027] 2) Context-aware text enhancement Based on the constructed domain knowledge graph, context-aware text enhancement is performed on each word in the original text sequence. Specifically, based on the associated concepts and context of the word in the domain knowledge graph, a dynamic decision is made on whether to perform synonym replacement, and structured semantic tags are inserted before and after the word to annotate entity types and semantic relationships, thereby generating locally enhanced text fragments, represented as follows: ; In the formula, Indicates that for the first primitive symbols The generated locally enhanced text fragments insert structured tags that label entity types and semantic relationships before and after the original words and may replace the original words with their standard synonyms, representing local text units rich in standardized semantic information after knowledge graph enhancement; Indicates the first The original word symbols are the original diabetes knowledge text sequence. The first in Each character can be a word or a punctuation mark; The original diabetes knowledge text sequence represents the raw input provided by text sources such as medical literature and electronic health records, and the sequence format is as follows: ; This represents a string concatenation operation, used to join multiple string fragments sequentially into a complete string; Indicates the first primitive symbols Knowledge graph in the field of diabetes The corresponding concept node in the middle, if For non-technical terms not included in the knowledge graph, then Empty; Represents a concept node The start tag of the entity type, i.e., the concept node In the diabetes domain knowledge graph The entity types defined, such as "disease", "drug", "examination item", etc., used to provide entity category hint information; Indicates that before the th original token Insert a start tag of the entity type representing its corresponding concept node For example, if represents "metformin" and the type is "drug", then insert "<drug>"; Indicates that after the th original token Insert an end tag representing the semantic relationship between its corresponding concept node and its replacement word. For example, if represents "metformin" and the type is "drug", then the inserted end tag should be < / drug>; Represents a context-aware token replacement decision function, which decides to retain the th original token or replace it with its related word if there is an associated node , such that , then replace with , otherwise retain ; Represents the candidate concept node selected from the neighbor set to replace the th original token ; Represents the neighbor set of the concept node , that is, all associated nodes within one-hop neighborhood of the concept node in the diabetes domain knowledge graph , including synonyms, hypernyms, and other related concepts of Indicates the th original token 's context token set, usually defined as the window of tokens before and after, used to evaluate semantic similarity; This indicates the size of the context window; an example value is 3. Represents concept nodes The entity type end tag is used to mark the end position of the entity segment in the enhanced text. For example, if a concept node... If the name represents "metformin" and its type is "drug", then the inserted end tag is "". ”; Indicates the position index of the token, with a value range of 100. ; This indicates the length of the original diabetes knowledge text sequence, i.e., the total number of words contained in the sequence; The function that retrieves word vectors can be a pre-trained word embedding model, such as the last hidden state of a Word2Vec, GloVe, or BERT model. This represents the cosine similarity calculation function, used to calculate the cosine similarity between two vectors to quantify how close they are in the semantic space; This represents the averaging function, which averages the embedding vectors of all context words in the context word set to obtain a single vector representation of the overall context semantics of the current word; This represents the similarity replacement threshold, used to control the strictness of the replacement. An example value is 0.85.
[0028] It should be noted that, in In the function, when multiple neighboring nodes meet the replacement criteria, the node with the highest similarity should be selected for replacement. If there are multiple nodes... satisfy Then select the one with the highest similarity value. As a replacement word.
[0029] 3) Generate enhanced text sequences Each word in the original diabetes knowledge text sequence is sequentially augmented with context-aware text. By processing and fusing locally augmented text fragments generated from adjacent words, a complete cleaned and augmented text sequence is obtained. ; in, The term "cleaned and enhanced text sequence" refers to the result of processing the entire original text sequence. Represents cleaning and enhancing text sequences The first in One element; Represents elements in cleaning and enhancing text sequences The position index in the middle, the value range is ; Represents cleaning and enhancing text sequences The length of , due to the insertion of additional semantic tags, should by default satisfy . .
[0030] S103, Enhanced Text Parsing and Entity Boundary Localization The inclusion of inserted structured semantic tags in the enhanced text sequence can easily cause the text sequence to shift, making it difficult for conventional methods to directly trace back to the accurate location of entities in the original text sequence, resulting in inaccurate entity boundaries that relation extraction depends on.
[0031] This invention calculates the analytical confidence of candidate text fragments and performs boundary localization through multi-feature fusion, accurately mapping entities in the enhanced sequence back to the original text sequence. The specific steps are as follows: 1) Fragment parsing and confidence calculation based on tag context The structured labels in the enhanced text sequence are parsed to identify all candidate text segments marked by start and end labels. For each candidate entity text segment, the parsing confidence score is calculated to quantify its credibility as a real entity by fusing its semantic similarity features with the original text and its consistency features with the attached labels. This confidence score is expressed as follows: ; In the formula, This represents the text fragment representing the k-th candidate entity. The resolution confidence is used to assess the probability that the fragment corresponds to a real medical entity with accurate boundaries. The value ranges from [0,1], and the larger the value, the higher the confidence. Indicates from enhanced text sequence The k-th candidate entity text fragment parsed from the data, i.e., located at a certain start tag. Its corresponding closing tag The sequence of symbols between; Indicates the index of the candidate fragment, with a value range of 1. ; Indicates from enhanced text sequence The total number of candidate segments parsed from the data is specifically determined through parsing. All label pairs are analyzed, and then the text between each label pair is extracted as candidate entity text fragments. After excluding empty segments and segments containing only punctuation marks, the number of remaining segments is the total number of segments. ; This represents the weighting coefficient of the contextual similarity feature, used to adjust the contribution of semantic similarity in confidence calculation; an example value is 0.6. This represents the weighting coefficient for the label consistency feature, used to adjust the contribution of label coherence to the confidence score calculation. An example value is 0.4, and it satisfies... ; Represents candidate entity text fragments Contextual semantic similarity features reflect and The semantic matching degree of all possible segments is calculated as follows: ; This indicates an indicator function that takes the value 1 when the condition is true and 0 otherwise. Indicates the original text sequence The set of all possible n-gram segments The maximum value operation is to find the candidate segment. The most similar original fragment; This represents the text fragment representing the k-th candidate entity. The embedding vectors are obtained through a pre-trained language model in the medical field, specifically by dividing candidate entity text fragments. Input a pre-trained language model in the medical field (such as BioBERT, ClinicalBERT, or PubMedBERT), and then use one of the following strategies to obtain its representation as an embedding vector. That is: Strategy A, take the final hidden state of the [CLS] tag as the segment representation, or Strategy B, take the average of all word vectors in the segment as the segment representation; This represents the text fragment representing the k-th candidate entity. Corresponding start tag The entity type marked; This represents a valid set of medical entity types, for example, {disease, drug, examination, symptom}. This represents the label consistency function, used to evaluate candidate entity text fragments. With the corresponding start tag and closing tags Semantic coherence is calculated as follows: ; Represents the original text sequence The set of all possible n-gram segments; represents an n-gram segment in the original text sequence and belongs to the set ; represents the embedding vector of the original text segment obtained in the same way as ; represents the cosine similarity calculation function, which is used to measure the similarity degree of two vectors in the semantic space; represents the estimated position of the k-th candidate entity text segment in the enhanced sequence and the normalized distance from the actual position of the segment in the original sequence, measuring the offset between the estimated position of the candidate entity text segment in the enhanced sequence and the actual position of the original segment ; represents the Sigmoid activation function, which converts the label consistency score into a probability value for easy multiplication with the weight coefficient; represents the importance weight parameter vector, which is a trainable parameter used to calculate the importance weights of the joint representation of segments, start tags, and end tags; represents transpose; represents the context-aware vector representation of the segment ; represents the context-aware vector representation of the start tag ; represents the context-aware vector representation of the end tag ; represents the vector concatenation operation.
[0032] In the specific implementation, the start tag and its corresponding end tag are identified by parsing the structured tags in the enhanced text sequence . All pairs of start tags (such as <disease>) and end tags (such as < / disease>) are recognized. The rules for tag pairing include: the principle of pairing the nearest sibling tags, that is, the start tag is paired with the nearest end tag of the same type after it; tag nesting check, that is, ensuring correct tag nesting and avoiding cross; using a stack data structure to implement the tag pairing algorithm.
[0033] It should be noted that n-gram is a text representation method in natural language processing, referring to a sequence of n consecutive words (or characters). For example, 1-gram (unigram) represents a single word, such as "diabetes", 2-gram (bigram) represents two consecutive words, such as "type 2 diabetes", and 3-gram (trigram) represents three consecutive words, such as "blood glucose monitoring equipment".
[0034] In the specific implementation, it will include candidate entity text fragments. and its front and back labels ( , The local augmented text context is input into a pre-trained language model (such as BERT), and the corresponding text context is extracted from the model output. The average of the hidden states of all words is used as Take the corresponding and The hidden state of the marker as and .
[0035] 2) Precise entity boundary localization through multi-feature fusion For candidate segments with a resolution confidence level higher than a predetermined threshold, their start and end positions in the original text sequence are determined by maximizing a boundary decision function that integrates deep semantic similarity, positional offset penalty, medical saliency, and adjacent label constraints, as follows: ; In the formula, This represents the text fragment representing the k-th candidate entity. In the original text sequence Starting position index in and end position index This is used to map entities in the enhanced sequence back to the original text, providing accurate entity localization for relation extraction; Represents the set of candidate position intervals In the process, find the starting position that maximizes the objective function value. and end position The combination; Indicates the starting position index of the candidate; Indicates the candidate's ending position index; This represents the text fragment representing the k-th candidate entity. In the original text sequence The candidate position interval set is generated through preliminary semantic matching; This represents the fusion weight of the deep semantic similarity score, with an example value of 0.5, which controls the weight of the deep semantic similarity score. This represents the fusion weight of the position offset penalty term, with an example value of 0.1, which controls the weight of the position offset penalty term; This represents the fusion weight of medical significance features, with an example value of 0.3, which controls the weight of medical significance features. This represents the fusion weight of the adjacency label constraint features, with an example value of 0.2, and satisfies... Control the weights of the adjacency label constraint features; Representing the deep semantic similarity score, the cosine similarity between the representation vectors of two text segments is calculated using a Siamese network structure. Specifically, the Siamese network is used to... and Input pre-trained language models with shared weights (such as the BioBERT model) to obtain the representation vectors of the [CLS] tags, and then calculate the cosine similarity as... ; Represents the original text sequence The subsequence from position p to position q; This represents the position offset penalty term, which measures the prediction boundary. The degree of deviation from the estimated boundary is calculated as follows: ; This represents the strength coefficient of the position offset penalty, with an example value of 1.0, which controls the degree of penalty for deviations between the predicted boundary and the estimated boundary; Indicates the first Candidate entity text fragments The estimated start position index in the original text sequence, and in the enhanced text sequence In the middle, candidate entity text fragments The starting position corresponds to its start label. The subsequent position was recorded. Each word / tag in The corresponding original position in (in the generation) (Establish a mapping at the time) to estimate The starting position in the original sequence You can take exist The original position corresponding to the first token in the text is used as ; Indicates the first Candidate entity text fragments The estimated end position index in the original text sequence, compared with The principle is the same, through the established arrive Position mapping relationship, extract candidate entity text fragments exist The original position corresponding to the last word in the text is used as ; Represents the original text sequence Length; To represent medical saliency features, specific calculations are performed using medical domain dictionaries (such as UMLS) or pre-trained models. The average TF-IDF score or domain embedding similarity of the terms in the text is used as a medical significance feature; This represents the adjacency label constraint feature, specifically calculated by predicting the boundary. The normalized distance between the location and the nearest structured tag is obtained.
[0036] In the specific implementation, a sliding window is used to navigate through the original text sequence. Generate all possible n-gram segments and compute the relationship between each segment and the given information. Based on semantic similarity, select the location intervals of segments with similarity higher than a preset threshold (e.g., 0.7). As candidates, form a set .
[0037] It should be noted that constraints This is to ensure that the combined effect of features that positively promote accurate boundary localization (semantic, medical saliency, label constraints) is greater than the penalizing features that inhibit deviation, so that the model is generally motivated to find better boundaries, rather than just avoiding deviation.
[0038] 3) Joint optimization loss of parsing and localization To improve the accuracy of the parsing and localization models, a joint optimization loss is obtained by minimizing the binary cross-entropy loss of parsing confidence and the smoothing L1 loss of boundary localization, and by incorporating an overall confidence reward term. This loss is expressed as: ; In the formula, This represents the joint optimization loss, used to guide the model to learn accurate fragment parsing and boundary localization simultaneously; This represents the binary cross-entropy loss function, used to measure the difference between the analytical confidence of the model's prediction and the true label, guiding the model to learn to accurately determine whether a candidate entity text fragment is a true entity; This represents the text fragment representing the k-th candidate entity. The true confidence label, with a value of 1 or 0, indicates whether the fragment is a valid entity. It is obtained through manual annotation or existing standard entity annotation data. If the candidate entity text fragment... If it perfectly matches the boundary of a certain labeled entity, then Otherwise, it is 0; This represents the weighting coefficient of the boundary regression loss term, used to balance the classification loss and regression loss. An example value is 1.2. This represents the smoothed L1 loss function, used to calculate the regression error between the predicted boundary and the true boundary; This represents the text fragment representing the k-th candidate entity. The true boundary position index, representing the first The real entities corresponding to the candidate entity text fragments in the original text The start and end position indices in the data, if If so, the value is meaningless or set to 0. ; This represents the weighting coefficient of the overall confidence reward item, used to encourage the model to maintain high confidence in valid types of entities; an example value is 0.1. This represents a logarithmic function, with the default base being the natural constant.
[0039] This indicates that all types belong to the set of valid medical entity types. The set of indexes for candidate entity text fragments.
[0040] S104, Construct the entity relationship extraction module Extracting relationships between medical entities from text faces challenges such as semantic ambiguity and relationship diversity. Conventional methods mainly rely on textual context and are difficult to use structured domain knowledge to handle complex medical reasoning.
[0041] This invention integrates the textual context of entity pairs, knowledge graph topological information, and enhanced structured tag semantics in the text to construct a multi-view relationship extraction model. It also introduces logical reasoning information from the knowledge graph through a relationship path attention mechanism. The specific steps are as follows: 1) Entity pair representation that integrates text and graph topology For a pair of located entities and their corresponding knowledge graph nodes, a unified representation of the entity pair is constructed by concatenating their textual context representation, knowledge graph topological representation, and structured label semantic representation, and then fusing them via a feedforward neural network. This representation is as follows: ; In the formula, Represents entity pairs The fusion representation vector integrates the semantic information of the text context, knowledge graph structure, and enhanced tags to represent the joint semantic state of the pair of entities in a specific context and knowledge background. This indicates the first medical entity that has been located; This indicates the second medical entity that has been located; Represents entity pairs The context text representation vector is obtained by inputting entity pairs and the text between them into the encoder of a pre-trained language model and then taking the final hidden state with special labels. Represents entity pairs corresponding to graph nodes The knowledge graph topological representation vector is obtained by aggregating node and multi-hop neighborhood information through a message-passing neural network. Specifically, a graph neural network is used to encode the knowledge graph to obtain the nodes. and The two vectors are concatenated to form the topological representation vector of the knowledge graph. Representing entities and Knowledge graph in the field of diabetes The corresponding concept node pairs; Represents entity pairs The structured label semantic representation vector between two entities is obtained by aggregating the embedding vectors of all end labels between the two entities through a self-attention mechanism. Specifically, the embedding vectors of all end labels between the two entities are extracted and then aggregated through a self-attention mechanism to obtain the structured label semantic representation vector. This represents a feedforward neural network used for feature fusion, whose parameters are learned during training.
[0042] In one implementation, the feedforward neural network used for feature fusion is specifically a neural network with two fully connected layers, the first layer using... Activated, second layer not activated.
[0043] In one implementation, entity pairs and their contextual text are input into a pre-trained language model (such as the BioBERT model), and the final hidden state of the [CLS] tag is taken as the entity pair. The context text representation vector.
[0044] 2) Relationship path attention mechanism In the knowledge graph, find all relational paths connecting a pair of entity nodes. Calculate the importance weight of each path for relational reasoning in the current text context using an attention mechanism, denoted as: ; In the formula, This represents the m-th relation path. The importance weight reflects the contribution of the path to determining the current entity's relationship, and characterizes the path. Importance to current relational reasoning; Indicates the connection node and The m-th relation path is found by searching for connections in the knowledge graph using depth-first search. and The path length does not exceed a preset value (e.g., 3); m represents the index of the relation path. ; Indicates the connection node and The total number of relational paths is the total number of relational paths found, returned by the search algorithm. This represents the attention weight vector, which is a trainable parameter used to calculate the relevance score between the path representation and the entity pair representation; express transpose; This represents the m-th relation path. The vector representation is obtained by embedding the relation on the sequentially encoded path and then passing it through a recurrent neural network, through the path The relation type embedding sequence is input into an LSTM, and the final hidden state is taken as the m-th relation path. Vector representation of; This represents the LeakyReLU activation function, which introduces non-linearity to avoid gradient vanishing and allows small gradients for negative inputs.
[0045] Furthermore, a weighted aggregation of the path representation is performed to obtain a path context vector, and the path context vector is defined. Its encoding supports the evidence chain information for relational reasoning from a knowledge graph perspective, and the calculation method is represented as follows: .
[0046] 3) Classification of multi-view relationships By inputting the fused representation of entity pairs, path context vectors, and prior feature vectors of entity types into a fully connected layer, and then performing ReLU activation and Softmax normalization, the predicted probability distribution of relation types is obtained, expressed as: ; In the formula, Represents entity pairs Belongs to a predefined relation type The predicted probability represents the relationship type to which a given pair of entities belongs. The conditional probability; This indicates the relation type, belonging to a predefined set of relations. An example of the relation set is {cause, treat, examine and diagnose, symptom is}; The weight matrix representing the output layer of the relation classifier is a learnable parameter that characterizes the decision boundary of the relation classifier. This represents the number of ReLU activation functions, introducing non-linearity and enhancing the model's expressive power; This represents a prior feature vector based on entity type, for example, obtained by one-hot encoding the types of two entities, calculating their outer product, and flattening it. The weight matrix of the first layer of the relation classifier is a learnable parameter that performs a linear transformation on the concatenated multi-view feature vector. The bias vector represents the first layer of the relation classifier. It is a learnable parameter. The bias is added after the linear transformation, which enables the model to learn the hyperplane that does not pass through the origin, thereby enhancing the model's fitting ability. The bias vector representing the output layer of the relation classifier is a learnable parameter. This represents the Softmax function, which converts the output into a probability distribution.
[0047] In practical implementation, assume the entity and The types are respectively and They come from a predefined set of entity types. (e.g., {disease, medication, examination, symptom}), perform one-hot encoding on each type to obtain the first one-hot encoded vector. Second one-hot encoding vector Then, the outer product of the two one-hot encoded vectors is calculated and flattened to obtain the prior feature vector based on the entity type.
[0048] 4) Calculation of relation extraction loss function To train the multi-view relation extraction model, the relation extraction loss function is obtained by minimizing the cross-entropy loss of relation classification combined with L2 regularization to prevent overfitting, and is expressed as: ; In the formula, This represents the relation extraction loss function, used to train the relation extraction model. It optimizes the model parameters to prevent overfitting by minimizing the classification loss and regularization term. This indicates the number of entity pairs in the training samples; This indicates the relation type, belonging to a predefined set of relations. ; Represents the set of all predefined relation types, for example ; Indicates the first The true relation type of each training sample; The model predicts the first... Each entity pair belongs to the relation type The probability, Indicates the first The first entity in the training samples Indicates the first The second entity in a training sample; This represents the weight coefficient of the L2 regularization term, used to control the degree of constraint of the L2 regularization term. The example value is 0.1. Represents the L2 norm; This represents the set of all trainable parameters.
[0049] S105, Knowledge Graph Model Training After completing the enhanced text parsing and entity boundary localization, as well as building the multi-view relationship extraction module, the models involved need to be systematically trained to optimize their parameters so that they can accurately perform entity localization and relationship extraction tasks.
[0050] Training uses a collected and labeled dataset, which is divided into training, validation, and test sets.
[0051] First, the joint optimization model for parsing and localization in S103 is trained. The training objective of this model is to minimize its joint optimization loss function, that is, to iteratively update the model parameters through a gradient descent algorithm (such as the Adam optimizer). In each round of training, the model receives the original text sequence and its corresponding augmented text sequence as input, calculates the parsing confidence of each candidate segment and predicts the entity boundary, and then compares the prediction results with the manually labeled true confidence labels and true boundary positions. The binary cross-entropy loss and smoothing L1 loss are calculated, and the relation extraction loss is obtained by combining the overall confidence reward term. The model parameters are adjusted through backpropagation.
[0052] Then, the multi-view relation extraction model in S104 is trained. The training objective of this model is to minimize its relation extraction loss function. During training, the input consists of located entity pairs and their context, corresponding knowledge graph node information, and label information in the augmented text. The model learns to fuse text, graph topology, and label semantics, and weights and aggregates graph inference information through a relation path attention mechanism to ultimately predict the relation category. The relation extraction loss is formed by calculating the cross-entropy loss between the predicted relation probability distribution and the true relation label, and adding an L2 regularization term to guide the optimization of model parameters.
[0053] Both models were trained iteratively.
[0054] The criteria for stopping iteration mainly include two aspects: 1) Monitor the performance metrics on the validation set (such as precision, recall, and F1 score for entity localization tasks; and relation classification accuracy and macro-average F1 score for relation extraction tasks). When the metric no longer improves or begins to decline in multiple consecutive training rounds (such as 10 rounds), it is considered that the model has reached its optimal performance, and training is stopped in advance to avoid overfitting; 2) Set a maximum upper limit for the number of training rounds. When the training reaches this number of rounds, it is forcibly stopped to ensure that the training process does not continue indefinitely.
[0055] S106. Triple Acquisition and Knowledge Graph Construction After training the knowledge graph model and obtaining a stable entity localization and relation extraction model, all collected diabetes knowledge texts were processed to automatically extract structured knowledge, which was then stored in the form of triples. Finally, a diabetes domain knowledge graph was constructed. The specific process is as follows: Using the S102 text cleaning and structure enhancement method, the S103 enhanced text parsing and entity boundary localization model, and the S104 multi-view relation extraction model obtained in the previous steps, all diabetes knowledge texts collected in S101 (including all corpora other than the training set, validation set, and test set) are batch-processed. For each text segment, its enhanced text sequence is first generated using the S102 method; then, the trained S103 model is used to parse candidate entity segments in the enhanced sequence, calculate their parsing confidence, and accurately locate high-confidence segments to obtain the accurate boundaries and types of all medical entities in the original text; then, for all possible entity pair combinations in the text, the trained S104 relation extraction model is used, combined with the diabetes domain knowledge graph, to determine whether a predefined relation exists between each pair of entities and its specific relation type, filtering out relation prediction results with too low confidence. Finally, each identified valid relation instance is output as a triple in the form of "head entity-relation-tail entity", for example ("metformin", "treatment", "type 2 diabetes").
[0056] After processing all the text, all generated triples are collected to form the initial triple set. Following this, knowledge fusion and graph construction are performed: the triples extracted from the text are fused with the initial diabetes domain knowledge graph constructed in S102 (derived from standard terminology databases such as UMLS and SNOMEDCT). The fusion process includes entity alignment (linking entities extracted from the text with existing concept nodes in the knowledge graph or creating new nodes), relation merging, and conflict detection and resolution (e.g., handling cases where different relational claims exist between the same pair of entities, adjudicating based on the authority of the evidence source, frequency of occurrence, or model confidence). Ultimately, a unified, structured diabetes knowledge graph is formed, where nodes represent standardized diabetes-related concepts (diseases, drugs, symptoms, etc.), and edges represent verified, rich semantic relationships between concepts. This knowledge graph will serve as the core knowledge base for the question-answering system in S2.
[0057] In one embodiment, an example of the extracted triples is as follows: Figure 2 As shown.
[0058] S2, Problem Understanding Module Construction The question understanding module is responsible for parsing the natural language questions input by the user.
[0059] First, using an entity recognition component derived from the model technology in S103 and S104, diabetes-related entities in the question are identified and linked with nodes in the knowledge graph (entity linking) to determine the core concept being inquired about. Simultaneously, an intent classification model is used to determine the user's query intent, such as whether it belongs to a predefined category like "cause of illness inquiry," "treatment method inquiry," "symptom confirmation," or "medication usage consultation."
[0060] By combining the identified entities and intents, this module transforms natural language questions into a structured query representation, such as graph query statements (e.g., Cypher, SPARQL) or logical expressions, explicitly specifying the subject, relation type, or object to be searched from the knowledge graph.
[0061] S3, Answer Retrieval and Generation Module The answer retrieval and generation module executes the query and organizes the answer.
[0062] The system traverses and retrieves data from the constructed diabetes knowledge graph based on the structured queries generated by the question understanding module. For example, for a question like "What diseases can metformin treat?", the system will locate the "metformin" node and then search for all adjacent disease type nodes along the "treatment" relationship. The retrieved results may be a node, a group of nodes, a path, or a subgraph.
[0063] Finally, the answer generation component transforms the retrieved structured knowledge results into fluent and complete natural language sentences using predefined answer templates or sequence-to-sequence generation models, and returns these sentences to the user as the final answer.
[0064] The entire system is encapsulated as a complete application or service interface, with a user interface (such as a chat window or search box) that awaits user input for diabetes knowledge Q&A.
[0065] In one embodiment, a knowledge graph example is as follows: Figure 3 As shown.
[0066] Based on the constructed diabetes knowledge graph-based question-and-answer system, interaction with users and completion of diabetes knowledge questions and answers are achieved. When a user asks a natural language question about diabetes, the system initiates a complete question-and-answer process. For example: First, the system receives the user's question text, such as "What complications might occur if a diabetic patient experiences numbness in their feet?" Then, the problem understanding module begins its work: using the built-in medical entity recognition model (inherited from the technology accumulated in S103 and S104) to perform word segmentation and entity recognition on the problem, identifying key entities such as "diabetic patient" and "numbness in the foot," and linking them to standard concept nodes such as "diabetes" and "limb numbness" in the knowledge graph. At the same time, the intent classification model analyzes the problem and determines that its intent belongs to "complication query"; Then, based on the linked entities and the identified intent, the system generates structured queries for the knowledge graph. For example, the query might be constructed as: finding a path starting from the "diabetes" node, connecting to disease nodes with "numbness in the feet" as a symptom through relationships such as "causes" or "complications are"; Then, the answer retrieval module executes the query in the diabetes knowledge graph. The system traverses the graph, starting from the "diabetes" node, searching for the set of complication nodes connected by the "cause" relationship, and then filtering out those nodes connected by the "symptom is" relationship with "limb numbness" (a standardized concept synonymous with "foot numbness"). Suppose the query result finds the node "diabetic peripheral neuropathy"; Finally, the answer generation module, based on the retrieved result "diabetic peripheral neuropathy," combined with the question's intent and predefined answer sentence templates, organizes and generates the final natural language answer: "Numbness in the feet in diabetic patients may be a complication of diabetic peripheral neuropathy. It is recommended to seek medical attention promptly for a neurological function test." The system presents this answer to the user through the user interface, completing a full question-and-answer interaction.
[0067] Based on this, the question-and-answer system can efficiently and accurately utilize the structured diabetes knowledge graph in the background to answer users' questions about various aspects such as the disease, symptoms, medication, and care.
[0068] In this implementation, a context-aware text enhancement method based on domain knowledge graphs is adopted, dynamically integrating terminology standardization and semantic tag insertion to improve text standardization; a multi-feature fusion entity boundary precision localization mechanism is employed, using analytical confidence and joint optimization loss to solve the problem of positional offset backtracking in enhanced text; a multi-view relation extraction model integrating text context, knowledge graph topology, and relation path attention is constructed; and structured knowledge is used for medical logical reasoning to achieve an end-to-end collaborative training framework from text enhancement and entity localization to relation extraction, ensuring semantic consistency in each stage of the knowledge extraction pipeline.
[0069] This invention also proposes a question-answering system based on a diabetes knowledge graph, which, based on the question-answering method based on a diabetes knowledge graph as described above, includes: The diabetes knowledge graph construction module includes a diabetes knowledge text data collection submodule, a diabetes knowledge text data cleaning and structuring enhancement submodule, an enhanced text parsing and entity boundary localization submodule, a knowledge graph model training submodule, and a triple acquisition and knowledge graph construction submodule. The question understanding module is used to parse the natural language questions input by the user, identify diabetes-related entities in the questions, determine the user's query intent through an intent classification model, and combine the identified entities and intent to transform the natural language questions into a structured query representation. The answer retrieval and generation module is used to execute queries and organize answers. Specifically, it transforms the retrieved structured knowledge results into natural language sentences using predefined answer templates or sequence-to-sequence generation models, and returns these sentences to the user as the final answer.
[0070] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Various modifications and improvements made by those skilled in the art to the technical solutions of the present invention without departing from the spirit of the present invention should fall within the protection scope defined by the claims of the present invention.
Claims
1. A method for constructing a question-answering system based on a diabetes knowledge graph, characterized in that, include: S1. Construction of a diabetes knowledge graph; including the collection of diabetes knowledge text data, cleaning and structuring enhancement of diabetes knowledge text data, enhanced text parsing and entity boundary localization, construction of an entity relationship extraction module, knowledge graph model training, and triple acquisition and knowledge graph construction. S2, Problem Understanding Module Construction: This includes parsing the natural language questions input by the user, identifying diabetes-related entities in the questions, and linking them with nodes in the knowledge graph to determine the user's query intent. By combining the identified entities and intents, this module transforms natural language questions into a structured query representation; S3, Answer Retrieval and Generation Module; This includes traversing and retrieving structured queries generated by the question understanding module on the constructed diabetes knowledge graph, and then converting the retrieved structured knowledge results into natural language sentences, which are returned to the user as the final answer.
2. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 1, characterized in that, The cleaning and structuring enhancement of the diabetes knowledge text data includes a text enhancement method based on domain knowledge graphs. By constructing a diabetes domain knowledge graph, the original text is deeply cleaned and enhanced.
3. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 2, characterized in that, The text enhancement method based on domain knowledge graph also includes context-aware text enhancement, which specifically includes dynamically deciding whether to perform synonym replacement based on the associated concepts and context of the words in the domain knowledge graph, and inserting structured semantic tags before and after them.
4. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 1, characterized in that, The enhanced text parsing and entity boundary localization specifically calculates the parsing confidence of candidate text segments and performs boundary localization through multi-feature fusion, accurately mapping entities in the enhanced sequence back to the original text sequence.
5. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 4, characterized in that, The calculation of the resolution confidence of candidate text fragments includes parsing the structured tags in the enhanced text sequence, identifying all candidate text fragments marked by start and end tags, and for each candidate entity text fragment, calculating the resolution confidence to quantify its credibility as a real entity by fusing its semantic similarity features with the original text and its consistency features with the attached tags, expressed as: ; In the formula, This represents the text fragment representing the k-th candidate entity. The confidence level of the resolution; Indicates from enhanced text sequence The k-th candidate entity text fragment parsed from the data; Indicates the index of the candidate fragment, with a value range of 1. ; Indicates from enhanced text sequence The total number of candidate segments parsed from the data; Weight coefficients representing contextual similarity features; The weighting coefficients representing the label consistency feature; Represents candidate entity text fragments Contextual semantic similarity features; This indicates an indicator function that takes the value 1 when the condition is true and 0 otherwise. This represents the text fragment representing the k-th candidate entity. Corresponding start tag The entity type marked; Represents a valid set of medical entity types; Represents the label consistency function. This is the closing tag.
6. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 4, characterized in that, The multi-feature fusion boundary localization determines the start and end positions in the original text sequence by maximizing the boundary determination function that integrates deep semantic similarity, position offset penalty, medical saliency, and adjacent label constraints.
7. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 1, characterized in that, The entity relationship extraction module includes extracting the text context of fused entity pairs, knowledge graph topology information, and enhancing the semantic meaning of structured tags in the text to construct a multi-view relationship extraction model, and introducing logical reasoning information from the graph through a relationship path attention mechanism.
8. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 7, characterized in that, The loss function of the relation extraction model is calculated as follows: ; In the formula, Represents the relation extraction loss function; This indicates the number of entity pairs in the training samples; This indicates the relation type, belonging to a predefined set of relations. ; Represents the set of all predefined relation types; Indicates the first The true relation type of each training sample; The model predicts the first... Each entity pair belongs to the relation type The probability, Indicates the first The first entity in the training samples Indicates the first The second entity in a training sample; This represents the weight coefficient of the L2 regularization term; Represents the L2 norm; This represents the set of all trainable parameters.
9. The method for constructing a question-answering system based on a diabetes knowledge graph according to claim 6, characterized in that, The construction of the diabetes knowledge graph also includes, after completing the training of the knowledge graph model and obtaining a stable entity localization and relation extraction model, processing all collected diabetes knowledge texts, automatically extracting structured knowledge, storing it in the form of triples, and finally constructing a diabetes domain knowledge graph.
10. A question-answering system based on a diabetes knowledge graph, comprising the construction method as described in any one of claims 1 to 9, including: The diabetes knowledge graph construction module includes a diabetes knowledge text data collection submodule, a diabetes knowledge text data cleaning and structuring enhancement submodule, an enhanced text parsing and entity boundary localization submodule, a knowledge graph model training submodule, and a triple acquisition and knowledge graph construction submodule. The question understanding module is used to parse the natural language questions input by the user, identify diabetes-related entities in the questions, determine the user's query intent through an intent classification model, and combine the identified entities and intent to transform the natural language questions into a structured query representation. The answer retrieval and generation module is used to execute queries and organize answers. Specifically, it transforms the retrieved structured knowledge results into natural language sentences using predefined answer templates or sequence-to-sequence generation models, and returns these sentences to the user as the final answer.
Citation Information
Patent Citations
Method and system for adaptively extracting domain knowledge of waste incineration large model based on dynamic confidence evaluation
CN120297268A
Text sentiment analysis method and system based on dynamic semantic segmentation and feature perception
CN120562424A
Government affair text auditing method and system based on knowledge graph reasoning
CN120874852A
Method for constructing knowledge graph nodes based on large model and image-text association
CN120893540A
Enterprise knowledge base content retrieval method and device based on event graph, equipment and storage medium
CN121071101A