A Method for Constructing a Disease Knowledge Graph for Musk Deer Based on the GPLinker Model
Patent Information
- Application Number
- CN202610708699.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-21
- Publication Date
- 2026-08-11
AI Technical Summary
[0005]为了解决现有林麝疾病知识图谱构建方法无法准确识别实体边界,导致知识抽取质量低的问题,本发明提供了基于GPLinker模型的林麝疾病知识图谱构建方法,所述方法包括:
[0072]By constructing a boundary awareness module that combines multi-scale convolution with boundary prediction, the high-dimensional semantic features output by the pre-trained language model BERT are enhanced. A probability-driven gating mechanism is used to dynamically generate boundary weights, which reconstruct hidden features based on the probability distribution of predicted labels. This achieves selective amplification of entity boundary signals and effective suppression of background noise, enabling targeted enhancement of entity boundary signals and physical isolation from background noise, thus solving the challenges of recognizing nested and long entity boundaries. Using the spatial boundary probability distribution as a gating trigger signal, the hidden features of BERT are reconstructed. This process, through element-wise nonlinear mapping, selectively amplifies the magnitude of entity edge feature responses and suppresses background noise, thereby providing high signal-to-noise ratio features for subsequent modules. This significantly improves the recognition accuracy of nested entities and long entity boundaries, effectively solving the ambiguity and offset problems of traditional models in locating complex entity boundaries, thus enhancing the robustness and accuracy of entity boundary detection.
Smart Images

Figure CN122549560A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and more specifically, to a method for constructing a disease knowledge graph of the musk deer based on the GPLinker model. Background Technology
[0002] The forest musk deer is a Class I protected wild animal in my country. Its natural musk secretions are not only a rare animal-derived medicinal material but also an indispensable strategic resource in traditional Chinese medicine, with significant clinical application value. However, with the wild forest musk deer population declining sharply due to historical overhunting and habitat destruction, and resources nearing depletion, artificial breeding has gradually become the main way to ensure a sustainable supply of musk.
[0003] Despite the continuous development of artificial breeding methods, musk deer farming faces frequent occurrences of various diseases in actual production, such as common purulent diseases, respiratory infectious pneumonia, and severe stress responses caused by environmental changes. These health problems seriously threaten the survival rate and productivity of the population, and have become a key bottleneck restricting the steady development of the musk deer farming industry.
[0004] Currently, in texts related to diseases of the musk deer, medical entities often contain long and complex words or nested structures, and the boundaries of these entities are significantly ambiguous, making it difficult to accurately define the specific scope of various entities during entity recognition. Incorrect boundary recognition leads to entity truncation, which in turn causes subsequent relationship extraction failures. For example, in text 1: "Etiology of pneumonia: Inflammation of lung tissue caused by pathogens such as bacteria and mycoplasma," the model easily identifies lung tissue inflammation as lung tissue rather than complete lung tissue inflammation. This truncation results in an incomplete disease entity, making it impossible to correctly establish the disease-symptom relationship. In text 2: "Musk deer pneumonia can be treated with azithromycin 15-18 mg / kg or ciprofloxacin 3 ml / kg," the model easily identifies 15-18 mg / kg as 18 mg / kg. The semantic connection between the dosage unit mg / kg and the modified object (azithromycin) is partially severed, resulting in incomplete extraction of drug dosage information and affecting the accurate construction of the drug-dosage relationship. This truncation also leads to an incomplete disease entity, making it impossible to correctly establish the disease-symptom relationship. Summary of the Invention
[0005] To address the problem that existing methods for constructing knowledge graphs of musk deer diseases cannot accurately identify entity boundaries, resulting in low-quality knowledge extraction, this invention provides a method for constructing knowledge graphs of musk deer diseases based on the GPLinker model. The method includes:
[0006] A disease corpus, entity types, relation types, and GPLinker joint extraction model for the musk deer were constructed. The disease corpus was annotated to obtain several word segments.
[0007] The GPLinker joint extraction model includes an encoding module for converting text into semantic vectors, a boundary awareness module for enhancing semantic vectors, and a GPLinker module for extracting entities and relationships, which are connected in sequence.
[0008] The labeled disease corpus, entity types, and relation types are input into the GPLinker joint extraction model. The encoding module extracts multi-scale semantic features from the disease corpus. The boundary awareness module obtains the probability distribution of boundary labels corresponding to each word segment based on the multi-scale semantic features. The boundary labels include a first label for identifying the start of an entity and a second label for identifying the interior of an entity. The sum of the probabilities of the first label and the second label is obtained based on the probability distribution to obtain a gating weight signal. The gating weight signal and the multi-scale semantic features are fused to obtain enhanced features.
[0009] The GPLinker module obtains target entities and target relationships between target entities based on the enhanced features, obtains triples based on the target entities and the entity relationships, and obtains a knowledge graph of forest musk deer diseases based on the triples.
[0010] This method innovatively designs a Boundary-Aware Module (BAM), which enhances the high-dimensional semantic features output by the pre-trained language model BERT by constructing a BAM that combines multi-scale convolution with boundary prediction. Utilizing a probability-driven gating mechanism, boundary weights are dynamically generated. These weights reconstruct hidden features based on the probability distribution of predicted labels, achieving selective amplification of entity boundary signals and effective suppression of background noise. This targeted enhancement of entity boundary signals and physical isolation from background noise addresses the challenges of recognizing nested and long entity boundaries. By using the spatial boundary probability distribution as a gating trigger signal to reconstruct the hidden features of BERT, this process selectively amplifies the magnitude of entity edge feature responses and suppresses background noise through element-wise nonlinear mapping. This provides high signal-to-noise ratio features for subsequent modules, significantly improving the recognition accuracy of nested and long entity boundaries. It effectively solves the ambiguity and offset problems of traditional models in locating complex entity boundaries, thereby enhancing the robustness and accuracy of entity boundary detection.
[0011] Furthermore, the formula for calculating the gating weight signal is as follows:
[0012] ;
[0013] ;
[0014] The formula for calculating the enhanced features is:
[0015] ;
[0016] in, Represents the boundary prediction matrix. This represents a multilayer perceptron. This represents the high-dimensional hidden layer representation matrix. Indicates the gating weight signal, and Let these represent the probabilities of the first label and the second label, respectively. Indicates enhanced features, Represents multi-scale semantic features. Represents the boundary weight parameters. This represents element-wise multiplication. This represents the normalization function.
[0017] Furthermore, the encoding module includes several convolutional layers, all of which have odd-numbered kernel sizes. The specific steps for the encoding module to extract multi-scale semantic features from the disease corpus include:
[0018] The convolutional layer extracts the high-dimensional hidden layer representation matrix of the disease corpus, obtains initial features based on the high-dimensional hidden layer representation matrix, and fuses the high-dimensional hidden layer representation matrix and the initial features to obtain multi-scale semantic features.
[0019] The formula for calculating multi-scale semantic features is as follows:
[0020] ;
[0021] ;
[0022] ;
[0023] in, This represents the high-dimensional hidden layer representation matrix. Represents the BERT model. This represents the annotated disease corpus. Indicates initial features, This indicates a projection operation. Represents the ReLU activation function. The convolution kernel dimension is... convolutional layers, This indicates a splicing operation. Represents the set of convolution kernel sizes. Indicates the kernel size. Represents multi-scale semantic features. Indicates the fusion layer. Indicates the number of word segments.
[0024] A multi-path parallel in-phase convolutional topology is constructed in the coding layer, and an odd number of convolutional kernels are specifically selected to form an isotropic multi-granularity receptive field.
[0025] Furthermore, the specific steps by which the GPLinker module obtains the target entity and the target relationship between the target entities based on the enhanced features include:
[0026] Sentence representation is obtained based on the enhanced features;
[0027] For each entity type, each position representation in the sentence representation is mapped to a start vector and an end vector based on the first feedforward layer and the second feedforward layer, respectively; the position span of any two position representations is obtained, the entity score of the position span belonging to the entity type is obtained, and the target entity is obtained based on the entity score;
[0028] Construct a quintuple, which includes the relation type, the start and end positions of the subject entity, and the start and end positions of the object entity;
[0029] The relation score is obtained based on the five-tuple and the sentence representation, and the target relation is obtained based on the relation score. The relation score includes the subject entity first-to-last consistency score, the object entity first-to-last consistency score, the subject and object first-to-last matching score under each relation type, and the subject and object last-to-last matching score under each relation type.
[0030] Furthermore, the formula for calculating the entity score is as follows:
[0031] ;
[0032] ;
[0033] ;
[0034] ;
[0035] in, and They represent the positions respectively. Entity types as both start and end points The vector representation of , , , and Both represent entity types Entity type matrix, Indicates position Multi-scale semantic features Indicates the position after rotation after position encoding. Arrive at the location Entity type The original score of the entity span, and Representing positions respectively and location The rotation matrix, Indicates position The rotation matrix, Indicates the location Entity type as the endpoint The vector representation of , This indicates the transpose operation. Indicates entity type index, and Both represent position indices.
[0036] Furthermore, the specific steps for obtaining a relation score based on the quintuple and the sentence representation include:
[0037] A scoring function is constructed based on the quintuple, and the relation score is obtained based on the scoring function and the sentence representation.
[0038] The calculation formula for the scoring function is as follows:
[0039] ;
[0040] in, This represents the scoring function. This indicates the subject entity consistency score. This indicates the score for consistency between the beginning and end of the object entity. Indicates the subject With object In relation types The first match score is below. Indicates the subject With object In relation types The tail matching score below, These represent the header and tail indices of the subject entity, respectively. These represent the head index and tail index of the object entity, respectively. Indicates the type of relation.
[0041] Furthermore, during the training phase, a score matrix is obtained based on the scoring function, a weighted binary cross-entropy loss is obtained based on the score matrix, a total loss is obtained based on the weighted binary cross-entropy loss, and the GPLinker joint extraction model is updated based on the total loss.
[0042] The formula for calculating the weighted binary cross-entropy loss is as follows:
[0043] ;
[0044] in, This represents the weighted binary cross-entropy loss. Represents the score matrix, Represents the true label matrix, and These represent the false positive penalty weight and the false negative penalty weight, respectively. This indicates the position in the loss function calculation layer score matrix. Arrive at the location Entity type Input score, and Let them represent the negative sample set and the positive sample set, respectively. Indicates the entity type index.
[0045] In professional texts on musk deer diseases, the number of real entities (positive samples) is far less than that of non-entities (negative samples), exhibiting an extremely sparse distribution. The sparse multi-label cross-entropy loss function used by GPLinker by default is not optimized for this type of sample imbalance, causing the model to be easily overwhelmed by a large number of negative sample signals during training. Since the cost of underreporting is far higher than that of false positives, the model tends to adopt a conservative prediction strategy to reduce overall loss, resulting in a large number of real entities failing to be identified. This is especially severe where entity boundaries are blurred, as the lack of targeted penalties for boundary classification loss exacerbates the underreporting phenomenon.
[0046] Clinical records of musk deer are typically concise, with each sentence often containing multiple parallel symptoms, various medications, and their corresponding dosages, forming a highly dense network of relationships. To ensure accuracy, traditional models tend to make conservative predictions during the relationship extraction stage, discarding potential relationships with insufficient confidence, resulting in the omission of many true relationships. For example, in the text "In the early stages of disease in musk deer, intramuscular injection of penicillin 40,000-60,000 IU / kg body weight and streptomycin 80,000-100,000 IU / kg," the baseline model might only identify one triplet (penicillin, dosage, 40,000-60,000 IU / kg), while missing other parallel relationships such as (streptomycin, dosage, 80,000-100,000 IU / kg).
[0047] Due to the aforementioned issues, the overall recall rate of the system is low, making it difficult to effectively cover and capture all relevant entities and their relationships, which further affects the completeness and accuracy of information extraction.
[0048] The GPLinker framework is used to decompose the entity relation extraction task into four collaborative sub-tasks. A weighted sparse multi-label cross-entropy loss function is introduced, and by setting penalty weight coefficients at the algorithm level, the model is forced to capture weak entity signals in an environment with extremely sparse samples. This cost-sensitive learning mechanism effectively improves global recall and the completeness of disease triplet extraction for musk deer while maintaining high precision.
[0049] To address the severe sample imbalance problem caused by the extremely low entity density in forest musk deer disease texts, a weighted sparse multi-label cross-entropy loss algorithm is designed. This loss function increases the penalty cost for missed detections by introducing an asymmetric weight factor, especially for the classification loss of entity boundaries, which is penalized with a gain.
[0050] To address the issue that the sparse multi-label cross-entropy loss function used by GPLinker by default is prone to being overwhelmed by negative sample signals and having a higher cost for false positives than for false negatives when processing highly sparse professional text, a penalty weight is introduced to artificially increase the loss score for false negatives. This forces the model to prioritize the prediction probability of positive samples when updating parameters, thus making it more sensitive to weak entity signals in the feature space. This effectively avoids the problem of the model adopting a conservative strategy to reduce loss, resulting in a large number of real entities not being identified.
[0051] By increasing the penalty weight for missed detections, the direct goal is to address the problem of incomplete or undetectable long-tail entity recognition. This asymmetric penalty mechanism effectively guides the model to find the optimal solution at the balance between missed detections and false positives, significantly improving the model's recall capability for sparse entities.
[0052] Manually setting penalty weights reduces the risk of automatic weight calculations getting stuck in local optima due to the extreme imbalance between positive and negative sample feedback in the early stages of training; it also prevents the model from reducing the weights of positive samples too much in the early stages in order to quickly reduce loss, thereby ensuring that the model can learn stably and effectively extract entity information in the entity relationship extraction task.
[0053] Furthermore, the total loss includes single-task loss and entity span loss, and the formula for calculating the total loss is as follows:
[0054] ;
[0055] ;
[0056] ;
[0057] ;
[0058] in, Indicates the total loss. Indicates the loss of the entity span. and Let represent the discriminant loss for the start and end positions in the quintuple, respectively. Indicates the score of the initial boundary of the relation body. Indicates the score at the termination boundary of the relationship. This represents the activation function. This represents the true label matrix of relation heads in a relation recognition task. This represents the true label matrix of the relation tail in the relation recognition task. Represents the normalization factor. Represents a collection of entity types. Indicates the number of word segments. The first element in the true label matrix representing the entity recognition task. Line number The value of the column, Indicates a relation type index.
[0059] Furthermore, the method also includes:
[0060] Construct a hierarchical structure of entity types and association rules between entities at different levels. The hierarchical structure includes a top level, an attribute layer, an intervention layer, and a correlation layer. The association rules include binary rules and distance constraint rules. Each level corresponds to a boundary predictor. Each boundary predictor contains a parallel start position classifier and an end position classifier.
[0061] The high-dimensional hidden layer representation matrix is input into the boundary predictor to obtain the initial prediction probability and the final prediction probability of each level. The boundary feature matrix of each level is constructed based on the initial prediction probability and the final prediction probability.
[0062] The mask matrix for each level is constructed based on the binary rule and the distance constraint rule;
[0063] Based on the boundary feature matrix and the mask matrix, obtain the attention weights between any two layers;
[0064] The boundary feature matrix is weighted and aggregated based on the attention weights to obtain an enhanced boundary feature matrix.
[0065] The initial features are obtained based on the enhanced boundary feature matrix.
[0066] A domain knowledge guidance layer is introduced, which uses the hierarchical structure of the musk deer disease ontology to guide boundary identification before BAM. The inter-level cross-attention mechanism is introduced, which can use the inherent relationship between entities at different levels to guide and constrain each other, so that the boundary information of high-level entities (such as diseases) can effectively guide the identification of low-level entities (such as symptoms), thus solving the problem of blurred boundaries between nested entities and similar entities.
[0067] Furthermore, the formula for calculating attention weights is as follows:
[0068] ;
[0069] in, Represents the attention weight matrix. Represents the normalization function. and These represent the boundary feature matrices of the target level and the source level, respectively. and They represent linear transformation matrices, Indicates the scaling factor. Represents the mask matrix, This indicates the transpose operation. Indicates the target level index. This indicates the source level index.
[0070] By embedding domain association rules into the inter-level attention mechanism in the form of a mask, the model can focus on semantically related positions when interacting with cross-level boundary features, thereby achieving efficient integration of domain knowledge and model structure. This provides strong prior guidance for the accurate identification of nested entities and similar entity boundaries in forest musk deer disease texts.
[0071] One or more technical solutions provided by this invention have at least the following technical effects or advantages:
[0072] By constructing a boundary awareness module that combines multi-scale convolution with boundary prediction, the high-dimensional semantic features output by the pre-trained language model BERT are enhanced. A probability-driven gating mechanism is used to dynamically generate boundary weights, which reconstruct hidden features based on the probability distribution of predicted labels. This achieves selective amplification of entity boundary signals and effective suppression of background noise, enabling targeted enhancement of entity boundary signals and physical isolation from background noise, thus solving the challenges of recognizing nested and long entity boundaries. Using the spatial boundary probability distribution as a gating trigger signal, the hidden features of BERT are reconstructed. This process, through element-wise nonlinear mapping, selectively amplifies the magnitude of entity edge feature responses and suppresses background noise, thereby providing high signal-to-noise ratio features for subsequent modules. This significantly improves the recognition accuracy of nested entities and long entity boundaries, effectively solving the ambiguity and offset problems of traditional models in locating complex entity boundaries, thus enhancing the robustness and accuracy of entity boundary detection. Attached Figure Description
[0073] The accompanying drawings, which are provided to further illustrate embodiments of the invention and constitute a part of this invention, are not intended to limit the scope of the invention.
[0074] Figure 1 This is a flowchart illustrating the method for constructing a disease knowledge graph of the musk deer based on the GPLinker model;
[0075] Figure 2 This is a schematic diagram of the GPLinker joint extraction model, in which... and These represent candidate features for the entity head and candidate features for the entity tail, respectively. and These represent the association features of the head entity and the tail entity in the triple, respectively. RoPE indicates that the rotation position encoding can perceive the relative distance deviation between two words.
[0076] Figure 3 This is a schematic diagram of a partial knowledge graph of diseases of the musk deer. Detailed Implementation
[0077] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that, where there is no conflict, the embodiments of the present invention and the features thereof can be combined with each other.
[0078] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0079] Example 1
[0080] refer to Figures 1-3 This embodiment provides a method for constructing a disease knowledge graph of the musk deer based on the GPLinker model. The method includes:
[0081] A disease corpus, entity types, relation types, and a GPLinker joint extraction model for musk deer are constructed. The disease corpus is annotated to obtain several word segments. Text data related to musk deer breeding and disease prevention are collected, and the collected text data is cleaned, denoised, and segmented. Data augmentation is performed to construct a musk deer disease corpus. Entity types and relation types in the musk deer disease domain are defined, and the corpus is annotated.
[0082] Entity types include: disease name, etiology, treatment methods, drugs, preventive measures, symptoms, complications, dosage, etc., as shown in Table 1.
[0083] Table 1. Physical Types of Diseases in Musk Deer
[0084] disease Disease Name Palatitis, gingivitis, cheilitis, etc. drug Medications used in treatment Analgin Prevention methods Disease prevention methods Provide ample drinking water and a balanced diet. dose Drug dosage Analgin 0.3 mL / kg Treatment Disease treatment methods Intramuscular injection Etiology Causes of disease Hot weather and insufficient water intake symptom Symptoms of the disease Characterized by feeding difficulties, chewing difficulties, and drooling.
[0085] Relationship types include: disease etiology, disease treatment methods, treatment drugs, treatment drug dosage, disease prevention methods, disease symptoms, and disease complications, as shown in Table 2.
[0086] Table 2 Disease Relationship Types of Musk Deer
[0087] Manifestation disease symptom The reason is disease Etiology Prevention methods are disease Prevention methods Dosage is drug dose Treatment measures are disease Treatment Concurrent disease disease Medicine is Treatment drug
[0088] The GPLinker joint extraction model includes an encoding module for converting text into semantic vectors, a boundary awareness module for enhancing semantic vectors, and a GPLinker module for extracting entities and relationships, which are connected in sequence.
[0089] The existing basic model architecture, GPLinker, is an end-to-end joint extraction model based on word pair classification. It utilizes a global pointer mechanism to calculate the relative position scores between tokens through rotational position encoding, unifying entity recognition and relation extraction into a region classification problem on a matrix. This embodiment inserts a boundary-aware module between the BERT encoding layer and the GPLinker layer.
[0090] The labeled disease corpus, entity type, and relation type are input into the GPLinker joint extraction model, and the encoding module extracts multi-scale semantic features of the disease corpus.
[0091] The encoding module includes several convolutional layers, all of which have odd-numbered kernel sizes. The specific steps for the encoding module to extract multi-scale semantic features from the disease corpus include:
[0092] The convolutional layer extracts the high-dimensional hidden layer representation matrix of the disease corpus. This process establishes the association of semantic mapping in the continuous vector space, providing underlying support for multi-scale feature reconstruction. Initial features are obtained based on the high-dimensional hidden layer representation matrix, and multi-scale semantic features are obtained by fusing the high-dimensional hidden layer representation matrix and the initial features.
[0093] The formula for calculating multi-scale semantic features is as follows:
[0094] (1)
[0095] (2)
[0096] (3)
[0097] in, This represents the high-dimensional hidden layer representation matrix. Represents the BERT model. This represents the annotated disease corpus. Indicates initial features, This indicates a projection operation. Represents the ReLU activation function. The convolution kernel dimension is... convolutional layers, This indicates a splicing operation. Represents the set of convolution kernel sizes. Indicates the kernel size. Represents multi-scale semantic features. Indicates the fusion layer. Indicates the number of word segments.
[0098] In this embodiment, given a sentence , which includes First, mark a tag. Each tag in the dataset is processed by BERT (Encoding Module) to extract a context-dependent high-dimensional hidden layer representation matrix. , , The dimension is represented by the matrix output of the pre-trained language model BERT-Chinese-base. The processing utilizes a set of multi-scale one-dimensional convolutional layers. right Feature extraction is performed, and the results are concatenated with... Fusion, resulting in fusion characteristics .
[0099] In this embodiment, We construct parallel multi-scale scanning structures to capture boundary geometric features at the character, word, and phrase levels, respectively.
[0100] The boundary awareness module obtains the probability distribution of the boundary label corresponding to each word based on the multi-scale semantic features. The boundary label includes a first label for identifying the start of the entity and a second label for identifying the interior of the entity. For example, the probability coupling value of B and I in the BIO label system is extracted as a gating signal. The gating mechanism is combined with the parallel convolution topology, so that the model can adaptively enhance the boundaries of forest musk deer disease entities of different lengths (characters, words, phrases).
[0101] The sum of probabilities of the first label and the second label is obtained based on the probability distribution to obtain a gating weight signal; the gating weight signal and the multi-scale semantic features are fused to obtain enhanced features;
[0102] A boundary detector was constructed based on the gating attention mechanism, and its principle is to predict... BIO tags for the vector features of each text after being segmented by the existing tokenizer Boundary weights, By summing the probabilities of labels B and I, where B (Begin) represents the entity's origin and I (Inside) represents the entity's interior, this design generates an extremely high signal-to-noise ratio gain. It can accurately identify entity regions and suppress non-entity background noise. Through a gating amplification mechanism, it makes entity features more identifiable in the vector space, significantly improving the model's recall ability for long-tailed and complex boundary entities.
[0103] The formula for calculating the gating weight signal is as follows:
[0104] (4)
[0105] (5)
[0106] The formula for calculating the enhanced features is:
[0107] (6)
[0108] in, Represents the boundary prediction matrix. This represents a multi-layer perceptron that maps high-dimensional input features onto a BIO three-class classification space. This represents the high-dimensional hidden layer representation matrix. Indicates the gating weight signal, and Let these represent the probabilities of the first label and the second label, respectively. Indicates enhanced features, Represents multi-scale semantic features. These represent boundary weight parameters, enabling the model to better distinguish between entities and non-entities. This represents element-wise multiplication. This represents the normalization function.
[0109] The GPLinker module obtains target entities and target relationships between target entities based on the enhanced features. The specific steps include: obtaining sentence representations based on the enhanced features; the feedforward layer maps each position representation in the sentence representation to a start vector and an end vector; obtaining the position span between any two position representations; obtaining the entity score of the entity type to which the position span belongs; and obtaining the target entity based on the entity score.
[0110] The formula for calculating the entity score is as follows:
[0111] (7)
[0112] (8)
[0113] (9)
[0114] The ROPE position encoding used in entity representation satisfies:
[0115] (10)
[0116] in, and They represent the positions respectively. Entity types as both start and end points The vector representation of , , , and Both represent entity types Entity type matrix, Indicates position Multi-scale semantic features Indicates the position after rotation following RoPE position encoding. Arrive at the location Entity type The original score of the entity span, and Representing positions respectively and location The rotation matrix, Indicates position The rotation matrix, Indicates the location Entity type as the endpoint The vector representation of , This indicates the transpose operation. Indicates entity type index, and Both represent position indices. Used to determine the position information of entities or relationships in a matrix. Location information Injected into the starting vector. Location information Injected into the endpoint vector.
[0117] Construct a quintuple, which includes the relation type, the start and end positions of the subject entity, and the start and end positions of the object entity;
[0118] The specific steps for obtaining a relation score based on the quintuple and the sentence representation include:
[0119] A scoring function is constructed based on the quintuple, and the relation score is obtained based on the scoring function and the sentence representation.
[0120] The calculation formula for the scoring function is as follows:
[0121] (11)
[0122] in, This represents the scoring function; if the function value is greater than 0, it means the model considers the score to be... arrive The fragment is a legitimate entity. This represents the subject entity consistency score, used to identify all potential subjects in a sentence. This represents the consistency score of the object entity, used to identify all potential objects in a sentence. Indicates the subject With object In relation types The first-match score refers to the score in the relationship. Next, do the starting points of the subject and the object match? Indicates the subject With object In relation types The tail matching score refers to the score in the relationship. Next, check if the endpoints of the subject and object match. These represent the header and tail indices of the subject entity, respectively. These represent the head index and tail index of the object entity, respectively. Indicates the type of relation.
[0123] The target relation is obtained based on the relation score, which includes the subject entity first-to-last consistency score, the object entity first-to-last consistency score, the subject and object first-to-last matching score under each relation type, and the subject and object last-to-last matching score under each relation type.
[0124] Based on the target entity and the entity relationship, a triple (i.e., head entity, relationship, tail entity) is obtained, and a knowledge graph of musk deer diseases is obtained based on the triple.
[0125] like Figure 3 As shown, the text "The symptoms of pneumonia in the musk deer are wheezing" is annotated and segmented, then input into the GPLinker joint extraction model. Each token is used to extract context-related high-dimensional hidden layer representations through BERT (encoding module). In the boundary enhancement module, multi-scale feature extraction is employed. The matrix output by BERT The processing utilizes a set of multi-scale one-dimensional convolutional layers. right Feature extraction is performed to obtain features Boundary detector prediction The boundary weights of the BIO tags for each word segmentation vector feature are taken as the sum of the probabilities of the B and I tags. and will and Fusion, achieving feature fusion and enhancement, to obtain For each entity type, the GPLinker module extracts the entity and relation through the entity scoring formula (7)-(10) and the scoring function formula (11), thereby forming a triplet.
[0126] Example 2
[0127] Based on Example 1, in this example, during the training phase, a score matrix is obtained based on the scoring function, a weighted binary cross-entropy loss is obtained based on the score matrix, a total loss is obtained based on the weighted binary cross-entropy loss, and the GPLinker joint extraction model is updated based on the total loss.
[0128] The formula for calculating the weighted binary cross-entropy loss is as follows:
[0129] (12)
[0130] in, This represents the weighted binary cross-entropy loss. The score matrix represents the set of predicted scores generated from all possible entity or relation triples. Represents the true label matrix, and These represent the false positive penalty weight and the false negative penalty weight, respectively. This indicates the position in the loss function calculation layer score matrix. Arrive at the location Entity type Input score, and Let them represent the negative sample set and the positive sample set, respectively. This represents the entity type index. The scoring function and the loss function have a close topological relationship. The scoring function is responsible for measuring entity boundaries and triplet relationships in the feature space, and its output is directly used as the weighted binary cross-entropy loss function. The input variables are defined by the asymmetric weight coefficients introduced through the loss function. This allows the model to perform gradient enhancement on low-confidence regions generated by the scoring function, thus achieving closed-loop optimization between prediction evaluation and parameter updates.
[0131] The total loss includes single-task loss and entity span loss, and the formula for calculating the total loss is as follows:
[0132] (13)
[0133] (14)
[0134] (15)
[0135] (16)
[0136] in, Indicates the total loss. Indicates the loss of the entity span. and Let represent the discriminant loss for the start and end positions in the quintuple, respectively. Indicates the score of the initial boundary of the relation body. Indicates the score at the termination boundary of the relationship. Indicates activation function, This represents the true label matrix of the relation heads in the relation recognition task. This represents the true label matrix of the relation tail in the relation recognition task. represents the normalization factor, and represents the total number of all possible entity span combinations. Represents a collection of entity types. Indicates the number of word segments. The first element in the true label matrix representing the entity recognition task. Line number The value of the column, Indicates a relation type index.
[0137] coefficient is By balancing the gradient magnitudes among subtasks through arithmetic averaging, the model is ensured not to be biased towards a single task during joint training, thus achieving consistent and collaborative optimization of entity recognition and relation extraction at the algorithm's underlying level.
[0138] Example 3
[0139] Based on the above embodiments, in this embodiment, the method further includes:
[0140] A hierarchical structure of entity types and association rules between entities at different levels are constructed. The hierarchical structure includes a top level (disease), an attribute layer (symptoms, pathogens, pathological changes), an intervention layer (drugs, treatment measures, preventive measures), and a related layer (animal parts, environmental factors, geographical regions). This hierarchical structure reflects the cognitive logic from the disease itself to clinical manifestations / causes, to treatment interventions, and finally to the relevant background.
[0141] The association rules include binary rules and distance constraint rules. Binary rules only indicate whether a valid association exists between two levels. For example, the rule "disease-symptom" is valid, while "disease-geographic region" is invalid. Distance constraint rules only apply when the distance between entities at two levels in the text is less than a certain threshold. For example, the boundaries between the entities "disease" and "symptom" must be no more than 10 tokens (the smallest basic unit the model processes in text).
[0142] Each level corresponds to a boundary predictor. Each boundary predictor includes a parallel start position classifier (used to predict whether the current position is the start position of an entity at that level) and an end position classifier (used to predict whether the current position is the end position of an entity at that level). For example, the calculation formula for the start position classifier is as follows:
[0143] (17)
[0144] in, Representation of features hierarchical The predicted probability of the starting position. This represents the sigmoid activation function. and Representing levels The trainable weights and biases, Representing the features in the high-dimensional hidden layer representation matrix The calculation process for the ending position classifier is similar to that for the starting position classifier.
[0145] The high-dimensional hidden layer representation matrix is input into the boundary predictor to obtain the initial prediction probability and the final prediction probability of each level. The boundary feature matrix of each level is constructed based on the initial prediction probability and the final prediction probability.
[0146] Based on the binary rules and the distance constraint rules, a mask matrix for each level is constructed; if the rule base does not contain a mask matrix, then... Layer to For effective layer association, all elements of the mask matrix are set to negative numbers (or very large negative numbers), indicating a complete prohibition of information flow in that direction. For allowed layer pairs, fine-grained masking is further performed using distance thresholds. Specifically, for each position in the sequence (target layer), only positions in its source layer that are within a preset distance are allowed. Positions with a distance greater than the preset distance are set to negative numbers. The binary rule acts as an allow / disallow switch, while the distance constraint provides fine-grained control over the range; together, they achieve a mathematical expression of semantic association.
[0147] Using the first To enhance the boundary information of the first layer The boundary features of the layer are used to obtain the attention weights between any two layers based on the boundary feature matrix and the mask matrix.
[0148] The formula for calculating attention weights is as follows:
[0149] (18)
[0150] in, Represents the attention weight matrix. Represents the normalization function. and These represent the boundary feature matrices of the target level and the source level, respectively. and They represent linear transformation matrices, Indicates the scaling factor. Represents the mask matrix, This indicates the transpose operation. Indicates the target level index. Indicates the source level index;
[0151] The boundary feature matrix is weighted and aggregated based on the attention weights to obtain an enhanced boundary feature matrix.
[0152] The formula for calculating the enhanced boundary feature matrix is as follows:
[0153] (19)
[0154] in, Represents the features in the enhanced boundary feature matrix , Representation layer normalization, This represents a feedforward neural network. Represents a trainable linear transformation matrix;
[0155] The initial features are obtained based on the enhanced boundary feature matrix.
[0156] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0157] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for constructing a disease knowledge graph of the musk deer based on the GPLinker model, characterized in that, The method includes: A disease corpus, entity types, relation types, and GPLinker joint extraction model for the musk deer were constructed. The disease corpus was annotated to obtain several word segments. The GPLinker joint extraction model includes an encoding module for converting text into semantic vectors, a boundary awareness module for enhancing semantic vectors, and a GPLinker module for extracting entities and relationships, which are connected in sequence. The labeled disease corpus, entity types, and relation types are input into the GPLinker joint extraction model. The encoding module extracts multi-scale semantic features from the disease corpus. The boundary awareness module obtains the probability distribution of boundary labels corresponding to each word segment based on the multi-scale semantic features. The boundary labels include a first label for identifying the start of an entity and a second label for identifying the interior of an entity. The sum of the probabilities of the first label and the second label is obtained based on the probability distribution to obtain a gating weight signal. The gating weight signal and the multi-scale semantic features are fused to obtain enhanced features. The GPLinker module obtains target entities and target relationships between target entities based on the enhanced features, obtains triples based on the target entities and the entity relationships, and obtains a knowledge graph of forest musk deer diseases based on the triples.
2. The method for constructing a disease knowledge graph of the musk deer based on the GPLinker model according to claim 1, characterized in that, The formula for calculating the gating weight signal is as follows: ; ; The formula for calculating the enhanced features is: ; in, Represents the boundary prediction matrix. This represents a multi-layer perceptron. This represents the high-dimensional hidden layer representation matrix. Indicates the gating weight signal, and Let these represent the probabilities of the first label and the second label, respectively. Indicates enhanced features, Represents multi-scale semantic features. Represents the boundary weight parameters. This represents element-wise multiplication. This represents the normalization function.
3. The method for constructing a disease knowledge graph of the musk deer based on the GPLinker model according to claim 1, characterized in that, The encoding module includes several convolutional layers, all of which have odd-numbered kernel sizes. The specific steps for the encoding module to extract multi-scale semantic features from the disease corpus include: The convolutional layer extracts the high-dimensional hidden layer representation matrix of the disease corpus, obtains initial features based on the high-dimensional hidden layer representation matrix, and fuses the high-dimensional hidden layer representation matrix and the initial features to obtain multi-scale semantic features. The formula for calculating multi-scale semantic features is as follows: ; ; ; in, This represents the high-dimensional hidden layer representation matrix. Represents the BERT model. This represents the annotated disease corpus. Indicates initial features, This indicates a projection operation. Represents the ReLU activation function. The convolution kernel dimension is... Convolutional layers, This indicates a splicing operation. Represents the set of convolution kernel sizes. Indicates the kernel size. Represents multi-scale semantic features. Indicates the fusion layer. Indicates the number of word segments.
4. The method for constructing a disease knowledge graph of the musk deer based on the GPLinker model according to claim 1, characterized in that, The specific steps by which the GPLinker module obtains target entities and target relationships between target entities based on the enhanced features include: Sentence representation is obtained based on the enhanced features; For each entity type, each position representation in the sentence representation is mapped to a start vector and an end vector based on the first feedforward layer and the second feedforward layer, respectively; the position span of any two position representations is obtained, the entity score of the position span belonging to the entity type is obtained, and the target entity is obtained based on the entity score; Construct a quintuple, which includes the relation type, the start and end positions of the subject entity, and the start and end positions of the object entity; The relation score is obtained based on the five-tuple and the sentence representation, and the target relation is obtained based on the relation score. The relation score includes the subject entity first-to-last consistency score, the object entity first-to-last consistency score, the subject and object first-to-last matching score under each relation type, and the subject and object last-to-last matching score under each relation type.
5. The method for constructing a disease knowledge graph of the musk deer based on the GPLinker model according to claim 4, characterized in that, The formula for calculating the entity score is as follows: ; ; ; ; in, and They represent the positions respectively. Entity types as start and end points The vector representation of , , , and Both represent entity types Entity type matrix, Indicates position Multi-scale semantic features Indicates the position after rotation after position encoding. Arrive at the location Entity type The original score of the entity span, and Representing positions respectively and location The rotation matrix, Indicates position The rotation matrix, Indicates the location Entity type as the endpoint The vector representation of , This indicates the transpose operation. Indicates entity type index, and Both represent position indices.
6. The method for constructing a disease knowledge graph of the musk deer based on the GPLinker model according to claim 5, characterized in that, The specific steps for obtaining a relation score based on the quintuple and the sentence representation include: A scoring function is constructed based on the quintuple, and the relation score is obtained based on the scoring function and the sentence representation. The calculation formula for the scoring function is as follows: ; in, This represents the scoring function. This indicates the subject entity consistency score. This indicates the score for consistency between the beginning and end of the object entity. Indicates the subject With object In relation types The first match score is below. Indicates the subject With object In relation types The tail matching score below, These represent the header and tail indices of the subject entity, respectively. These represent the head index and tail index of the object entity, respectively. Indicates the relation type.
7. The method for constructing a knowledge graph of diseases of the musk deer based on the GPLinker model according to claim 6, characterized in that, During the training phase, a score matrix is obtained based on the scoring function, a weighted binary cross-entropy loss is obtained based on the score matrix, a total loss is obtained based on the weighted binary cross-entropy loss, and the GPLinker joint extraction model is updated based on the total loss. The formula for calculating the weighted binary cross-entropy loss is as follows: ; in, This represents the weighted binary cross-entropy loss. Represents the score matrix, Represents the true label matrix, and These represent the false positive penalty weight and the false negative penalty weight, respectively. This indicates the position in the loss function calculation layer score matrix. Arrive at the location Entity type Input score, and Let them represent the positive sample set and the negative sample set, respectively. Indicates the entity type index.
8. The method for constructing a disease knowledge graph of the musk deer based on the GPLinker model according to claim 7, characterized in that, The total loss includes single-task loss and entity span loss, and the formula for calculating the total loss is as follows: ; ; ; ; in, Indicates the total loss. Indicates the loss of the entity span. and Let represent the discriminant loss for the start and end positions in the quintuple, respectively. Indicates the score of the initial boundary of the relation body. Indicates the score at the termination boundary of the relationship. This represents the activation function. This represents the true label matrix of the relation heads in the relation recognition task. This represents the true label matrix of the relation tail in the relation recognition task. Represents the normalization factor. Represents a collection of entity types. Indicates the number of word segments. The first element in the true label matrix representing the entity recognition task. Line number The value of the column, Indicates a relation type index.
9. The method for constructing a disease knowledge graph of the musk deer based on the GPLinker model according to claim 3, characterized in that, The method further includes: Construct a hierarchical structure of entity types and association rules between entities at different levels. The hierarchical structure includes a top level, an attribute layer, an intervention layer, and a correlation layer. The association rules include binary rules and distance constraint rules. Each level corresponds to a boundary predictor. Each boundary predictor contains a parallel start position classifier and an end position classifier. The high-dimensional hidden layer representation matrix is input into the boundary predictor to obtain the initial prediction probability and the final prediction probability of each level. The boundary feature matrix of each level is constructed based on the initial prediction probability and the final prediction probability. The mask matrix for each level is constructed based on the binary rule and the distance constraint rule; Based on the boundary feature matrix and the mask matrix, obtain the attention weights between any two layers; The boundary feature matrix is weighted and aggregated based on the attention weights to obtain an enhanced boundary feature matrix. The initial features are obtained based on the enhanced boundary feature matrix.
10. The method for constructing a knowledge graph of diseases of the musk deer based on the GPLinker model according to claim 9, characterized in that, The formula for calculating attention weights is: ; in, Represents the attention weight matrix. Represents the normalization function. and These represent the boundary feature matrices of the target level and the source level, respectively. and They represent linear transformation matrices, Indicates the scaling factor. Represents the mask matrix, This indicates the transpose operation. Indicates the target level index. This indicates the source level index.