Method, device and medium for constructing knowledge graph of ancient chinese medical books

By combining a domain dictionary and a pre-trained language model with a weakly supervised training strategy, and utilizing graph neural networks and cross-graph attention mechanisms, the high computational cost and reliance on manual annotation in the construction of knowledge graphs for ancient Chinese medicine texts are solved. This enables automated entity recognition and semantic relation extraction from ancient Chinese medicine texts, generating a global knowledge graph with semantic depth.

CN120509470BActive Publication Date: 2025-11-11CHENGDU UNIV OF TRADITIONAL CHINESE MEDICINE
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510998782.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2025-11-11
Estimated Expiration
2045-07-21

AI Technical Summary

Technical Problem

Existing technologies for constructing knowledge graphs of ancient Chinese medical texts suffer from problems such as high computational costs, reliance on manual annotation, insufficient representation of rare characters, limited handling of long-distance dependencies, and complex multimodal preprocessing. There is an urgent need for a more efficient, low-annotation-dependency, and comprehensive automatic construction method that can capture the semantic and structural relationships of ancient texts.

Method used

The algorithm employs a domain dictionary and a bidirectional maximum matching algorithm for word segmentation. It combines a domain pre-trained language model with a weakly supervised training strategy, and achieves entity recognition through pseudo-label expansion and domain adversarial training. It utilizes graph neural networks and attention mechanisms to construct a single-book knowledge graph, and achieves entity alignment and fusion of multiple ancient book graphs through a cross-graph attention mechanism.

Benefits of technology

It effectively improved the structured processing capabilities of ancient Chinese medicine texts, achieved automatic identification of key entities and accurate extraction of semantic relationships, constructed a single-book knowledge graph with semantic depth, and generated a unified global Chinese medicine knowledge graph, thereby improving the consistency of knowledge organization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120509470B_ABST
    Figure CN120509470B_ABST
Patent Text Reader

Abstract

This invention discloses a method, device, and medium for constructing a knowledge graph of ancient Chinese medicine texts, generating structured text data; constructing an entity recognition model based on a pre-trained language model in the field of traditional Chinese medicine for entity recognition; constructing a single-book graph structure using entities as nodes and their contextual semantics as initial edge weights; combining a graph neural network model to learn the representation of nodes, fusing the contextual features, positional information, and graph structure features of entities, extracting semantic relationships between entities, and constructing a single-book knowledge graph; fusing entities from multiple single-book knowledge graphs based on a cross-graph attention mechanism, constructing a cross-graph attention matrix, dynamically adjusting the entity matching threshold based on entity interaction strength and the number of common neighbors, performing entity alignment and edge weight fusion, and generating a global knowledge graph of ancient Chinese medicine texts. This invention achieves automatic entity and relationship recognition, knowledge graph construction, and multi-book knowledge ablation in ancient Chinese medicine texts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology for ancient Chinese medicine books, and in particular to methods, equipment, and media for constructing knowledge graphs of ancient Chinese medicine books. Background Technology

[0002] With the development of TCM digitization and knowledge graph technology, the automated construction of knowledge graphs for ancient TCM texts has become a key direction for realizing the intelligent utilization and cultural inheritance of these texts. Among these, entity extraction and relation extraction, as core components of knowledge graph construction, directly affect the quality and application value of the graph.

[0003] In terms of entity extraction technology, patent CN119761372A proposes a method for extracting entities from ancient Chinese books based on a deep active learning strategy. By integrating an active learning strategy with a deep neural network model, it improves the model's fitting ability while alleviating the problem of insufficient labeled data using an improved query strategy. The adoption of a dual encoder structure further optimizes the contextual semantic capture capability, improving entity extraction performance. However, it suffers from a complex model structure; the design of dual encoders and a hybrid loss function significantly increases computational costs and places high demands on hardware resources. Furthermore, active learning still relies on expert annotation, which, while reducing the amount of annotation, does not completely eliminate human intervention.

[0004] Patent CN116720512A discloses a method for extracting entities from ancient texts based on deep learning and artificial bee colony algorithms. By constructing a model containing an input layer, embedding layer, BiLSTM layer, and CRF layer, and using character sequences as input, the method leverages the bidirectional structure of BiLSTM to capture contextual information, combined with the labeled sequence output by the CRF layer, achieving accurate entity extraction from ancient texts and reducing the need for expert input. However, this method relies on pre-trained Word2vec character vectors, which are insufficient for representing rare characters or classical Chinese vocabulary unique to ancient texts. The introduction of the artificial bee colony algorithm adds extra optimization steps, potentially prolonging training time. Furthermore, it only addresses character-level annotation, neglecting word-level semantic relationships, thus limiting its ability to handle long-distance dependencies.

[0005] Patent CN118966226A proposes a method and system for extracting entity relationships from ancient Chinese texts based on deep learning. By integrating multimodal information, self-attention mechanisms, graph neural networks, and dynamic knowledge graph technology, it achieves accurate identification and extraction of entities and their relationships in ancient Chinese texts, effectively handling the complex grammatical structures of classical Chinese and capturing long-distance dependencies. Simultaneously, it improves knowledge management efficiency through real-time updates of the knowledge graph. However, this method's multimodal processing requires simultaneous parsing of text and images, resulting in high data preprocessing complexity; for example, image feature extraction using ResNet50 is time-consuming. The real-time update mechanism of the dynamic knowledge graph may face data consistency challenges. The combination of self-attention mechanisms and graph neural networks does not detail the parameter sharing strategy, potentially leading to model redundancy. Furthermore, the ability to extract implicit relationships from ancient texts is not explicitly mentioned.

[0006] In summary, although there are various ways to optimize entity extraction and relation extraction methods, problems such as high computational cost, reliance on manual annotation, insufficient representation of rare characters, limited handling of long-distance dependencies, and complex multimodal preprocessing still exist. There is an urgent need for a more efficient method for automatically constructing knowledge graphs that has low annotation dependency and can comprehensively capture the semantic and structural relationships of ancient books. Summary of the Invention

[0007] Based on the shortcomings of the existing technology, this invention provides a method, device, and medium for constructing knowledge graphs of ancient Chinese medicine books, which realizes automatic identification of entities and relationships in ancient Chinese medicine books, knowledge graph construction, and knowledge ablation of multiple books.

[0008] To address the aforementioned technical problems, the first aspect of this invention discloses a method for constructing a knowledge graph of ancient Chinese medical texts, the method comprising:

[0009] Acquire data from ancient Chinese medicine texts and then standardize the data.

[0010] By combining domain dictionaries to construct word segmentation priority rules, setting minimum matching length and dictionary priority, and using a bidirectional maximum matching algorithm to segment ancient Chinese medicine books into words, structured text data is generated.

[0011] An entity recognition model is constructed based on a pre-trained language model in the field of traditional Chinese medicine. The entity recognition model is weakly supervised by a pseudo-label expansion method and cross-language semantic transfer is achieved by introducing domain adversarial training. The model outputs entities and their corresponding entity annotation results.

[0012] Using the entities as nodes and the contextual semantics of the entities as initial edge weights, a single-book graph structure is constructed; combining a graph neural network model to perform representation learning on the nodes, fusing the contextual features, positional information and graph structure features of the entities, and using an attention mechanism to extract semantic relationships between entities, a single-book knowledge graph is constructed.

[0013] Based on the cross-graph attention mechanism, entities from multiple single-book knowledge graphs are fused. A cross-graph attention matrix with weights equal to the product of semantic similarity, structural similarity, and path similarity is constructed. The matching threshold of entities is dynamically adjusted according to the entity interaction strength and the number of common neighbors. Entity alignment and edge weight fusion are performed to generate a global knowledge graph of ancient Chinese medicine books.

[0014] In some implementations, weakly supervised training is performed through pseudo-label expansion, including:

[0015] Extract entity classification pairs from the domain dictionary, where the entity classification pairs are initial positive samples;

[0016] Entity feature vectors are extracted using the pre-trained language model, and the cosine similarity between entity feature vectors is calculated. Based on the cosine similarity, extended entities are determined, resulting in an extended pseudo-label training set. The extended pseudo-label training set includes automatically labeled entities, the segments containing the entities, and relation triples.

[0017] Calculate the semantic similarity between entities and text fragments, and select text fragments with confidence scores higher than a preset confidence threshold;

[0018] When at least two of the entities exist in multiple text fragments, the two entities have a potential relationship, resulting in a weakly supervised training sample; the weakly supervised training sample includes text fragments, entity label sequences, and relationship labels.

[0019] In some implementations, domain adversarial training is introduced to achieve cross-stylist semantic transfer, including:

[0020] A gradient inversion layer is set in the BERT layer and the task layer of the pre-trained language model to invert the gradients of the ancient book feature vector and the modern Chinese medicine feature vector output by the BERT layer.

[0021] The gradient-inverted feature vectors of ancient books and modern TCM feature vectors are input into a domain discriminator to determine the source of the corpus.

[0022] Based on the entity recognition cross-entropy loss function and the domain adversarial loss function, a weighted combination of task loss functions is constructed to optimize the entity recognition model.

[0023] In some implementations, the domain adversarial loss function is:

[0024]

[0025] in, For domain adversarial loss function; The features output by the BERT layer Distribution of ancient book data; This represents a sample from the distribution of ancient text data. x Calculate the expectation; G is the neighborhood discriminator;

[0026] The task loss function is:

[0027]

[0028] in, For domain adversarial loss function, The cross-entropy loss function for entity recognition. For balancing parameters.

[0029] In some implementations, a single-book graph structure is constructed using the entity as a node and the entity's contextual semantics as initial edge weights. A graph neural network model is then used to learn the representations of the nodes, fusing the entity's contextual features, location information, and graph structure features. An attention mechanism is used to extract semantic relationships between entities, thus constructing a single-book knowledge graph, including:

[0030] By traversing all entities and extracting entity pairs and their contextual fragments based on the co-occurrence relationships of entities in ancient texts, a set of entity pairs is formed.

[0031] The text of the context fragment is encoded into word vectors, and a multi-head self-attention mechanism is used to extract the context features of entity pairs to generate fused semantic feature vectors of entity pairs.

[0032] A graph structure is constructed based on the co-occurrence relationship of entities, and the fused semantic feature vector is used as the initial feature of the nodes. Multi-layer representation learning is performed on the nodes through a graph convolutional network to obtain node features containing global semantic information.

[0033] The entity pair feature vectors output by the graph neural network are aggregated and classified to determine the relationship type between entities and generate entity relationship triples; the entity relationship triples include source entity, target entity, relationship category, context fragment, confidence level and source book;

[0034] Using entities as nodes and triple relationships as edges, combined with attribute information, a dynamically updated single-book knowledge graph is constructed.

[0035] In some implementations, entities from multiple single-book knowledge graphs are fused based on a cross-graph attention mechanism to construct a cross-graph attention matrix with weights equal to the product of semantic similarity, structural similarity, and path similarity. The matching threshold for entities is dynamically adjusted based on the entity interaction strength and the number of common neighbors, including:

[0036] Construct a cross-graph attention matrix, the weights of which are determined by the product of semantic similarity, structural similarity and path similarity between entity pairs;

[0037] Calculate entity interaction vectors based on the cross-graph attention matrix;

[0038] The matching threshold is dynamically adjusted based on the interaction strength between entities, the number of common neighbors, and path similarity.

[0039] In some implementations, it also includes:

[0040] Receive newly added single-book graphs containing new entity and relationship information, as well as existing global knowledge graph data;

[0041] Calculate the semantic similarity, structural similarity, and path similarity between each entity in the newly added single-book graph and entities in the global graph, and prioritize entity alignment based on matching items with high structural similarity;

[0042] For entities that have completed alignment, the newly added relationship paths are automatically mapped to the corresponding nodes in the global knowledge graph, their neighbor structure and relationship path features are updated, dynamic inheritance of entity relationships is realized, and the updated global knowledge graph is output.

[0043] In some implementations, the entity interaction vector is calculated using the following formula:

[0044]

[0045] in, For entities Interaction vectors, For entities in other maps, For entities and Cross-graph attention weights;

[0046] The matching threshold is adjusted using the following formula:

[0047]

[0048] in As the initial threshold, This is an adjustment factor for the intensity of entity interaction. For entity pairs;

[0049] It is a comprehensive index of cross-graph common neighbors and path similarity.

[0050] In a second aspect, a computer device is disclosed, characterized in that it includes: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed by the steps of the method for constructing a knowledge graph of ancient Chinese medical books as described above.

[0051] Thirdly, a computer storage medium is disclosed, on which a computer program is stored, wherein when the computer program is executed by a processor, it implements the method for constructing a knowledge graph of ancient Chinese medical books as described in any of the above.

[0052] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0053] The method, device, and medium for constructing a knowledge graph of ancient Chinese medicine texts provided in this application can effectively improve the structured processing capability of ancient Chinese medicine texts under conditions without manual annotation. By introducing a domain dictionary and a bidirectional maximum matching algorithm for word segmentation, combined with a domain-pre-trained language model and a weakly supervised training strategy, automatic identification of key entities in the ancient texts is achieved. Simultaneously, graph neural networks and attention mechanisms are used to fuse entity context and structural information, accurately extracting semantic relationships between entities and constructing a single-book knowledge graph with semantic depth. A cross-graph attention mechanism is used to achieve entity alignment and fusion between multiple ancient text graphs, automatically constructing a unified global Chinese medicine knowledge graph, improving the consistency of knowledge organization, and providing a solid foundation for subsequent intelligent retrieval and reasoning. Attached Figure Description

[0054] Figure 1 This is a schematic diagram of a method for constructing a knowledge graph of ancient Chinese medical books provided by the present invention;

[0055] Figure 2 This is a flowchart illustrating step S31 of a method for constructing a knowledge graph of ancient Chinese medical texts provided by the present invention.

[0056] Figure 3 This is a flowchart illustrating step S32 of a method for constructing a knowledge graph of ancient Chinese medical texts provided by the present invention.

[0057] Figure 4 This is a flowchart illustrating step S4 of a method for constructing a knowledge graph of ancient Chinese medical texts provided by the present invention.

[0058] Figure 5 This is a flowchart illustrating step S5 of a method for constructing a knowledge graph of ancient Chinese medical texts provided by the present invention.

[0059] Figure 6 This is a flowchart illustrating step S6 of the method for constructing a knowledge graph of ancient Chinese medical texts provided by the present invention. Detailed Implementation

[0060] To better understand and implement this invention, the technical solutions in the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0061] The terms “comprising” and “having” and any variations thereof in this invention are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or modules is not necessarily limited to those steps or modules that are explicitly listed, but may include other steps or modules that are not explicitly listed or that are inherent to such processes, methods, products or devices.

[0062] The embodiments of the present invention disclose a method for constructing a knowledge graph of ancient Chinese medicine books. Taking into account the characteristic of unlabeled data in ancient Chinese medicine books, the method combines a corpus of Chinese medicine with transfer learning, weakly supervised entity extraction and dynamic graph fusion technology to achieve automatic identification of entities and relationships in ancient Chinese medicine books, knowledge graph construction and knowledge ablation of multiple books.

[0063] like Figure 1 As shown, this method includes:

[0064] Step S1: Obtain data from ancient Chinese medicine books and standardize the data.

[0065] To achieve a structured understanding of ancient Chinese medicine texts and subsequent knowledge graph construction, we first acquired data on ancient Chinese medicine texts, including 700 historical Chinese medicine texts and a knowledge base in the field of traditional Chinese medicine. These texts were provided in GBK or UTF-8 encoding formats, and their sources include classic literature such as the *Huangdi Neijing*, *Compendium of Materia Medica*, *Treatise on Febrile Diseases*, and *Prescriptions Worth a Thousand Gold Pieces*. The knowledge base in the field of traditional Chinese medicine contains more than 50,000 entities, covering eight entity categories: medicinal materials, prescriptions, diseases, acupoints, internal organs, symptoms, processing methods, and diagnostic terms.

[0066] In the data normalization stage, the data from ancient Chinese medicine texts was cleaned. Regular expressions were used to filter punctuation, tabs, spaces, and other non-linguistic characters. The text was structured using paragraph segmentation logic, empty paragraphs and redundant line breaks were removed, and the text format was standardized to construct a normalized text set, denoted as […]. ,in,( ) indicates that the processed ancient text of the i-th book is used for subsequent semantic enhancement processing.

[0067] Extracting entity sets from a corpus of traditional Chinese medicine. ,in Indicates the firstc The j th entity of the class, that is, mapping each entity to its corresponding classification, such as "Atractylodes macrocephala - medicinal material", "honey-fried - processing method", to establish a mapping relationship and form a domain dictionary of entity-classification , where C is the entity classification set.

[0068] Step S2: Combine the domain dictionary to construct a word segmentation priority rule, set the minimum matching length and dictionary priority, and use the bidirectional maximum matching algorithm to segment the traditional Chinese medicine ancient book data to generate structured text data;

[0069] To improve the effect of the text in subsequent entity recognition tasks, the bidirectional maximum matching word segmentation algorithm (Bi-MMF) is adopted in this embodiment. This method combines two strategies of forward maximum matching (FMM) and backward maximum matching (BMM), and ensures the accuracy of the word segmentation result through conflict resolution rules such as dictionary priority, word length priority, and single character filtering. During the word segmentation process, the minimum matching length is set to 2 characters to prevent non-independent characters such as "yellow" and "white" from being misrecognized as entities. If there is a conflict in the forward and backward word segmentation results, for example, "Atractylodes macrocephala" can be used as a medicinal material with a priority p = 1, and can also be regarded as a processing method with a priority p = 3, then according to the preset entity priority judgment result, the word segmentation result with a higher priority is taken. Then "Atractylodes macrocephala" is a processing method. In some other cases, for example, the matching conflict between "Poria cocos" and "white + Poria cocos", the longer "Poria cocos" is preferentially selected as the word segmentation result to retain its complete semantic structure.

[0070] After word segmentation, each ancient book text is converted into structured text data. This structured text data includes the ancient book text data set after cleaning and word segmentation, and the domain dictionary data set. The ancient book text data set includes the Bi-MMF word segmentation result, its corresponding word nature, and candidate entity categories. The output data set at this time contains two parts: one is the text set after cleaning + word segmentation corresponding to each ancient book, where each word has a semantic boundary, which is convenient for subsequent model recognition processing; the other is the standardized constructed traditional Chinese medicine domain dictionary, which includes entity text, entity classification, and priority labels, providing a semantic benchmark for subsequent weak supervision training and cross-book fusion.

[0071] This embodiment completes the normalization, entity explicitization, and semantic enhancement processing of the original ancient book text without relying on manual annotation by integrating domain knowledge and rule algorithms, and significantly improves the model's understandability and structural transferability of the traditional Chinese medicine language system in a low-resource environment.

[0072] Step S3: Construct an entity recognition model based on a pre-trained language model in the field of traditional Chinese medicine. The entity recognition model is weakly supervised by a pseudo-label expansion method and cross-language semantic transfer is achieved by introducing domain adversarial training. The model outputs entities and their corresponding entity annotation results.

[0073] To achieve automatic entity recognition in ancient Chinese medicine texts, this application constructs an entity recognition model based on a pre-trained language model in the field of traditional Chinese medicine. Addressing the issues of complex language structure and lack of labeled data in ancient Chinese medicine texts, it integrates semantic representation learning, pseudo-label expansion, and domain adversarial training techniques to effectively extract core TCM entities such as "medicinal materials," "symptoms," and "prescriptions" from unlabeled ancient texts.

[0074] The pre-trained language model employs a combined BERT-BiLSTM-CRF structure as the foundation for the entity recognition model. The BERT layer is initialized using a language model specifically pre-trained on corpora in the field of Traditional Chinese Medicine (TCM) to enhance its encoding capability for mixed texts containing Classical Chinese and TCM terminology. Structured text data is then used. t The input is fed into the BERT layer to generate a contextual semantic representation for each Chinese character. That is,

[0075]

[0076] in, The output of the BERT model is a sequence of word-level feature vectors, with dimensions equal to the sequence length multiplied by the hidden layer dimension; each element... Indicates the first in the text t Each character contains a context-fused semantic feature vector that incorporates information from both the preceding and following text.

[0077] Word-level feature vector sequence output by the BERT model Input to BiLSTM layer:

[0078]

[0079] The system captures the contextual dependencies of sentences in both the forward and backward directions, and then concatenates them to form a representation that integrates global semantics. Specifically, the forward LSTM... ( For the hidden state of the forward LSTM at time step t, capture the context information from left to right; This is the hidden state from the previous time step. Then, it feeds into the LSTM. middle For the hidden state of the backward LSTM at time step t, capture the right-to-left context information; This represents the hidden state at the next time step. Feature concatenation, or feature sequence that integrates contextual information, is the process of combining features from different contexts. The dimension is sequence length × (hidden layer dimension × 2), which integrates bidirectional contextual information to alleviate ambiguity in entity boundaries caused by the omission of subjects and objects in ancient books.

[0080] Feature sequence The data is fed into a CRF layer, where conditional random fields are used to model possible entity label sequences using the Viterbi algorithm.

[0081]

[0082] Output the optimal label sequence to predict the label for each character, such as B-medicinal material, I-disease, O (non-entity), etc. For the predicted entity label sequence, such as [B-medicinal material, I-medicinal material, O, B-disease, ...], The tag for the t-th character, such as B-medicinal herb, indicates the start of the entity. The preceding character serves as the label, used to model label transition probabilities. For example, "B-medicinal herb" can only be followed by "I-medicine" or "O". The label transition probabilities are calculated for the CRF model, and the optimal path is solved using the Viterbi algorithm. This yields the entity label sequence. This section marks whether each character belongs to an entity and the entity annotation results.

[0083] Furthermore, due to the lack of sufficient manually labeled data in ancient Chinese medical texts, a weakly supervised pseudo-label expansion mechanism was employed during the model training phase. This pseudo-label expansion method was used for weakly supervised training, such as... Figure 2 As shown, it includes:

[0084] Step S311: Extract entity classification pairs from the domain dictionary, where the entity classification pairs are the initial positive samples. Using seed entities extracted from the Traditional Chinese Medicine domain dictionary, such as labeling “Rhizoma Rehmanniae-Medicinal Herbs” as B-Medicinal Herbs and “Cough-Symptoms”, initialize the pseudo-label set. These entities are considered initial positive samples and are directly used to label the corresponding segments appearing in the training text.

[0085] Step S312: Extract entity feature vectors through the pre-trained language model, calculate the cosine similarity between entity feature vectors, determine extended entities based on cosine similarity, and obtain an extended pseudo-label training set; the extended pseudo-label training set includes automatically labeled entities, the segment containing the entity, and relation triples.

[0086] To broaden the coverage of training data, this embodiment introduces a semantic similarity strategy. By calculating the cosine similarity between the seed entity vector and the unlabeled segment, semantically similar entity segments are automatically identified. The cosine similarity is calculated using the following formula:

[0087]

[0088] If the cosine similarity is not less than the cosine similarity threshold , , then is labeled as an entity of the same type as e. In some embodiments, the cosine similarity threshold can be set to 0.7, and can be adjusted according to the actual situation. For example, "shengdi" and "shengdihuang" are semantically similar, and after meeting the similarity threshold, "shengdi" is also labeled as a medicinal material entity. Thus, pseudo labels are automatically generated. This extended training set not only includes automatically labeled entities, but also includes the context fragments where they are located and potential relationship triples inferred from co-occurrence information.

[0089] Step S313: Calculate the semantic similarity between the entity and the text fragment, and select the text fragments with a confidence higher than the preset confidence threshold;

[0090] In addition, calculate the semantic similarity between the seed entity and the context fragment through the Sentence - BERT model, identify the entity combinations implied in the context, and select the text fragments with a confidence higher than the preset confidence threshold as additional training samples. For example, if the similarity between the context containing "shengdi" and "huang" and "shengdihuang" is greater than 0.8, then this fragment is adopted for training data expansion and labeled as B - medicinal material, I - medicinal material.

[0091] Step S314: When at least two of the said entities exist in multiple text fragments, there is a potential relationship between the two said entities, and a weakly supervised training sample is obtained; the weakly supervised training sample includes the text fragment, the entity label sequence, and the relationship label.

[0092] When it is detected that at least two of the said entities exist in multiple text fragments, there is a potential relationship between the two said entities. For example, when "shengdihuang" and "xuexu syndrome" co - occur frequently, a "treatment" relationship candidate can be generated. Finally, a weakly supervised training sample is constructed, and the weakly supervised training sample includes the text fragment, the entity label sequence, and the relationship label, which is used for model fine - tuning training.

[0093] Furthermore, to solve the differences in the语体 structure between the ancient book language style and modern traditional Chinese medicine corpus, domain adversarial training is introduced to achieve cross -语体 semantic migration and improve the cross -语体 generalization ability of the model. As Figure 3 shown, it specifically includes:

[0094] Step S321: Set a gradient reversal layer in the BERT layer and the task layer of the pre - trained language model, and perform gradient reversal on the ancient book feature vector and the modern traditional Chinese medicine feature vector output by the BERT layer.

[0095] During training, the entity recognition model simultaneously receives corpus samples from ancient texts and modern Chinese medicine literature, and extracts their character-level features respectively. Gradient inversion layers (GRL) are set in the BERT layer and task layer of the pre-trained language model to invert the gradients of the ancient text feature vectors and the modern Chinese medicine feature vectors output by the BERT layer. This makes it impossible for the model to distinguish between two different corpus sources. For example, the association pattern of "medicinal materials - symptoms".

[0096] Step S322: Input the gradient-reversed feature vectors of ancient books and modern TCM feature vectors into the domain discriminator to determine the source of the corpus.

[0097] The gradient-reversed feature vectors from ancient books and modern TCM feature vectors are input into a domain discriminator to determine the source of the corpus. The domain discriminator attempts to distinguish the source, but because the features are reversed, the training objective causes the entity recognition model to confuse the two, thus learning a more general semantic representation of the entity.

[0098] Step S323: Based on the entity recognition cross-entropy loss function and the domain adversarial loss function, construct a weighted combination of task loss functions to optimize the entity recognition model.

[0099] The domain adversarial loss function is:

[0100]

[0101] in, The features output by the BERT layer Distribution of ancient book data; This represents a sample from the distribution of ancient text data. x Find the expectation; G is the domain discriminator, which forces the model to confuse domain differences by maximizing the domain discrimination error.

[0102] The task loss function is , We optimize label prediction using the cross-entropy loss function for entity recognition. We use a domain-specific adversarial loss function to optimize cross-domain generalization capabilities. As a balancing parameter, 0.1 is generally used.

[0103] Based on the entity recognition cross-entropy loss function and the domain adversarial loss function, a weighted combination task loss function is constructed to optimize the entity recognition model. This improves recognition accuracy while ensuring that the model has strong cross-domain transfer capabilities.

[0104] Step S4: Using the entity as a node and the contextual semantics of the entity as the initial edge weights, construct a single-book graph structure; combine the graph neural network model to perform representation learning on the node, integrate the contextual features, position information and graph structure features of the entity, and use the attention mechanism to extract semantic relationships between entities to construct a single-book knowledge graph.

[0105] After entity recognition is completed, semantic relationships between entities are automatically extracted from the identified entities, and a single-book knowledge graph containing entity nodes and relationship edges is constructed, such as... Figure 4 As shown, it specifically includes:

[0106] Step S41: Traverse all entities and extract entity pairs and their contextual fragments based on the co-occurrence relationship of entities in ancient texts to form a set of entity pairs;

[0107] The system iterates through the annotated entities in ancient texts and generates a set of entity pairs by statistically analyzing the co-occurrence relationships between entities in local contexts. For example, in the *Compendium of Materia Medica*, if "rehmannia root" and "blood deficiency syndrome" appear in the same passage, the system records the entity pair. (e 1 ,e 2 ) It extracts context fragments from the original text, with a default window of 50 characters before and after, forming context samples, for example... [(e 1 ,e 2 [context),...] .

[0108] Step S42: Encode the text of the context fragment into word vectors, and use a multi-head self-attention mechanism to extract the context features of entity pairs to generate fused semantic feature vectors of entity pairs;

[0109] To capture the semantic relationships between entity pairs within their context, a multi-head self-attention mechanism is introduced after word vector embedding. By constructing three sets of vectors—query (Q), key (K), and value (V)—attention scores are calculated in parallel across multiple attention heads, thus modeling the contextual semantic dependencies between entity pairs. The formula for calculating the attention score is as follows:

[0110]

[0111] For learnable parameters, Used for scaling.

[0112] After concatenating all attention head outputs and applying a linear mapping, we obtain the fused semantic feature vector Z of the generated entity pairs. This vector represents the semantic relationship strength and directionality of the entity pairs in their textual context.

[0113] Step S43: Construct a graph structure based on the co-occurrence relationship of entities, and use the fused semantic feature vector as the initial feature of the nodes. Then, perform multi-layer representation learning on the nodes through a graph convolutional network to obtain node features containing global semantic information.

[0114] Based on the aforementioned entity pairs and their fused semantic feature vector Z, a graph structure is constructed to infer global relationships. All identified entities serve as nodes in the graph, and co-occurrence relationships between different entities are constructed as edges, with initial edge weights derived from their attention semantic features. The entity pair fused semantic feature vector Z is used as the initial node features of the graph neural network (GCN), and an adjacency matrix A is constructed by combining entity co-occurrence frequencies. Self-loops are then added to obtain... This forms a structural connection diagram between entities.

[0115] In graph neural networks, the system normalizes the adjacency matrix:

[0116]

[0117] in, It is a degree matrix.

[0118] Perform graph convolution operations hierarchically:

[0119]

[0120] For the first l Layer features, For learnable weights, This is the activation function.

[0121] By gradually aggregating the features of neighboring nodes to the target node, a node feature that ultimately contains information about the global graph structure is formed. .

[0122] Step S44: Aggregate and classify the entity pair feature vectors output by the graph neural network to determine the relationship type between entities and generate entity relationship triples; the entity relationship triples include source entity, target entity, relationship category, context fragment, confidence level and source book;

[0123] Using the entity pair features output by GCN as input, this algorithm aggregates and classifies the relationships between entity pairs. By concatenating or weighting the final representation vectors of two nodes, the algorithm inputs them into a fully connected layer and then into a Softmax classifier to predict the specific semantic relationship type between the entity pairs, such as "treatment," "composition," and "main treatment." Finally, the results are output as triples, with each relationship containing: source entity, target entity, relationship type, confidence score, context fragment, and source ancient text, such as ("Rehmannia glutinosa", "blood deficiency syndrome", "treatment", 0.92, context, "Compendium of Materia Medica").

[0124] Step S45: Using entities as nodes and triple relationships as edges, and combining attribute information, construct a dynamically updated single-book knowledge graph.

[0125] Entities are represented as nodes, and semantic relationships between entities are represented as edges. The graph structure is characterized by clear semantics, rich attributes, and a well-defined structure. At the node level, the system supports unified modeling of multiple types of entity nodes, including but not limited to traditional Chinese medicine semantic categories such as "medicinal materials," "diseases," "prescriptions," "processing methods," and "symptoms." Each node not only contains basic attributes, such as the entity's text content and category, but also includes statistical information such as a list of source books and frequency of occurrence, used to analyze the breadth and importance of the entity's dissemination in ancient books.

[0126] To support subsequent cross-book fusion and similarity calculation, each node stores feature vectors obtained from graph neural network inference. These vectors can be considered semantic embeddings of entities and are the core basis for structural alignment and graph aggregation. The node storage format is as follows:

[0127]

[0128] In constructing edges, a relation triplet is used as the basis. Each triplet (entity A, entity B, relation R) is mapped to a directed edge in the graph. The edge type is a predefined relation category, such as "treatment," "composition," "contraindication," "main treatment," etc., derived from model prediction results or remote supervision hypotheses. Each edge's attributes include relation type. Co-occurrence frequency Semantic confidence and its weights The weights of the edges are calculated using a weighted function that balances statistical frequency and model confidence.

[0129]

[0130] middle, To balance statistical frequency and model confidence, ; For the number of co-occurrences, It is a relation type.

[0131] Calculating edge weights assigns higher graph weights to edges that occur frequently and whose model predictions are reliable, thus granting them greater structural influence in subsequent graph operations. In this embodiment, the edge storage format is as follows:

[0132]

[0133] The overall data structure of the graph is organized and stored using standard graph formats. Typically, nodes, edges, and their attribute information are stored in a graph database format such as Neo4j, which facilitates graph querying and visualization. Alternatively, it can be exported as a structured file format such as GraphML or JSON, which facilitates integration with external systems or offline analysis.

[0134] Step S5: Based on the cross-graph attention mechanism, entities from multiple single-book knowledge graphs are fused to construct a cross-graph attention matrix with weights equal to the product of semantic similarity, structural similarity, and path similarity. The matching threshold of entities is dynamically adjusted according to the entity interaction strength and the number of common neighbors. Entity alignment and edge weight fusion are then performed to generate a global knowledge graph of ancient Chinese medicine books.

[0135] To address the fragmented knowledge across different books, such as multiple names for the same medicine or different treatments for the same symptom, in the knowledge graph of ancient Chinese medicine texts, this paper proposes a method to fuse multiple individual book graphs. This is achieved by constructing a cross-graph attention mechanism to align entities and integrate relation weights, ultimately generating a unified global knowledge graph of ancient Chinese medicine texts. Specifically:

[0136] To achieve semantic representation alignment across graph entities, a semantic embedding model for domain entities is constructed using a corpus of Traditional Chinese Medicine (TCM). This process is based on the Sentence-BERT structure and incorporates a triplet loss function for training. The triplet loss function is as follows:

[0137]

[0138] Where d is the cosine distance. These are the anchor point, positive example, and negative example entities, respectively.

[0139] The training samples are derived from a domain dictionary. "Similar entities," such as "ginseng-white ginseng," are extracted as positive pairs, while entities of different categories, such as "ginseng-cough," are randomly combined as negative pairs. This results in a training sample set with the structure (anchor, positive, negative). The goal is to shorten the distance between synonymous entities in the semantic embedding space while simultaneously distinguishing entities of different categories as much as possible, thereby obtaining a trained Sentence-BERT model and an entity fusion semantic feature vector mapping table.

[0140] Automated alignment of entities in multiple single-book graphs is performed. First-order neighbor information and path patterns of entities are extracted from each graph, such as "ginseng → treatment → blood deficiency" or "white ginseng → treatment → qi deficiency," to construct graph structural feature representations. Then, the system calculates the similarity of entity pairs in three dimensions: semantic similarity, measured by cosine distance in the Sentence-BERT embedding space; structural similarity, represented by the overlap and connection density of the entity's neighbor nodes; and path similarity, obtained by comparing the relationship path patterns of two entities and calculating the maximum structural matching score.

[0141] To address the shortcomings of the minimum distance matching method in graph interaction, precise alignment is achieved through multi-dimensional graph structure fusion, automating the alignment process for entities in multiple single-book graphs. First, first-order neighbor information and path patterns of entities are extracted from each single-book knowledge graph, such as "ginseng → treatment → blood deficiency" or "white ginseng → main treatment → qi deficiency," to construct graph structure feature representations.

[0142] Semantic similarity, structural similarity, and path similarity are calculated for entity pairs respectively. Semantic similarity is measured using the cosine distance in the Sentence-BERT embedding space, specifically:

[0143]

[0144] Structural similarity is represented by the overlap and connection density of the entity's neighboring nodes:

[0145]

[0146] Path similarity is obtained by comparing the relationship path patterns of two entities and calculating the maximum structural matching score:

[0147]

[0148] like Figure 5 As shown, step S5 further includes:

[0149] Step S51: Construct a cross-graph attention matrix, wherein the weights of the cross-graph attention matrix are determined by the product of semantic similarity, structural similarity and path similarity between entity pairs.

[0150] The weights are the product of the similarity scores of the three dimensions mentioned above:

[0151]

[0152] For semantic similarity, For structural similarity, Path similarity. The cross-graph attention matrix represents the structural semantic fusion strength between each pair of entities from different graphs.

[0153] Step S52: Calculate the entity interaction vector based on the cross-graph attention matrix.

[0154] Based on the cross-graph attention matrix, the interaction vector of each target entity is calculated, which is the semantic features of neighboring entities fused from other graphs, to achieve cross-graph information aggregation and enhance the global consistency of entity representation.

[0155] The entity interaction vector is:

[0156] ,

[0157] For entities Interaction vectors, For entities in other maps, For entities and Cross-graph attention weights.

[0158] Step S53: Dynamically adjust the matching threshold based on the interaction strength between entities, the number of common neighbors, and path similarity.

[0159] To ensure the accuracy and adaptability of entity matching, a dynamic interaction threshold adjustment mechanism is introduced. Based on a comprehensive score of the entity interaction strength, the number of common neighbors, and the path structure overlap for each pair of entities in the attention matrix, the matching threshold for whether entities should be merged is dynamically updated.

[0160] The matching threshold is adjusted using the following formula:

[0161]

[0162] in As the initial threshold, For entity pairs;

[0163] It is a comprehensive index of cross-graph common neighbors and path similarity.

[0164] For example, when two entities score highly across three dimensions and exhibit similar adjacency structures across multiple graphs, such as "ginseng → treatment → blood deficiency" and "white ginseng → treatment → qi deficiency," the matching threshold can be appropriately lowered to merge them into the same entity node. Conversely, if the structures are significantly different, even if they are semantically similar, they may be retained as independent entities to prevent erroneous merging.

[0165] After entity alignment is complete, automated graph fusion is performed based on the alignment mapping table M and the original graph data, including node attribute merging and edge weight fusion. Node attribute merging includes retaining multiple names as aliases, merging source books, and accumulating occurrence frequencies. Edge weight fusion includes, for example, proportionally weighting the edge weights in a single book graph with cross-graph attention weights to obtain unified edge attributes. For example, retaining the path "treatment-blood deficiency syndrome".

[0166] Edge weight calculation integrates single-book edge weights and cross-graph interaction weights. For example,

[0167]

[0168] For single-book edge weights, For cross-graph attention weights.

[0169] Ultimately, the generated global knowledge graph nodes contain cross-graph structural features, edges contain interaction weights, preserve the semantic structure between entities in the original graph, and unify name representation, semantic boundaries, and cross-document semantic mapping relationships.

[0170] Furthermore, when adding new ancient books, entities can be automatically extracted and automatically identified, compared, and integrated to ensure the sustainable evolution of the knowledge graph structure and maintain consistency in cross-graph interactions.

[0171] like Figure 6 As shown, it specifically includes:

[0172] Step S61: Receive the newly added single-book graph containing new entity and relationship information, as well as the existing global knowledge graph data;

[0173] Step S62: Calculate the semantic similarity, structural similarity, and path similarity between each entity in the newly added single-book graph and entities in the global graph, and prioritize entity alignment based on matching items with high structural similarity;

[0174] Step S63: For entities that have completed alignment, automatically map the newly added relationship paths to the corresponding nodes in the global knowledge graph, update their neighbor structure and relationship path features, realize the dynamic inheritance of entity relationships, and output the updated global knowledge graph.

[0175] For example, when a new ancient book, "Qianjin Fang", is input, the system first cleans, segments, identifies entities and extracts relationships from its text through the aforementioned steps S1 to S4, and constructs a single-book knowledge graph corresponding to the ancient book, which contains entity nodes, such as "Silla ginseng", "Joseon" and the semantic relationships between them, such as "place of origin".

[0176] To correctly integrate this single-book graph into the global graph, entity alignment was performed on each entity sequentially. Taking "Sinra Ginseng" as an example, its semantic embedding vector was first extracted, and semantic similarity was calculated by calling the embedding vectors of all medicinal material entities in the global graph. At the same time, its structural features were extracted, such as the "origin" relationship path between this entity and "North Korea," and its structure was compared with the relationship path of the entity "Ginseng" in the global graph. It was found that both have the pattern "→origin → North Korea."

[0177] At this point, the system calculates a matching score based on semantic similarity, structural similarity, and path similarity. If the score exceeds a set threshold, "Xinluo Ginseng" and "Ginseng" are determined to be the same entity. Accordingly, "Xinluo Ginseng" is treated as one of the aliases for "Ginseng," and its node attributes are merged. Meanwhile, *Qianjin Fang* is retained as a new source book, and the entity's frequency of occurrence is accumulated. In this embodiment, nodes with high structural similarity are prioritized for matching to improve the accuracy and robustness of entity alignment and avoid potential mismatches that might arise from relying solely on semantic similarity. By comparing the graph topology features of entities, such as neighbor relationships, connection patterns, and path structures, it is possible to more accurately determine whether two entities have the same semantic role in different graphs. For example, if two medicinal materials are linked to similar symptoms or prescriptions in their respective ancient texts through relationships such as "treatment" or "composition," they may be the same entity even if their names differ. Prioritizing structural similarity helps maintain the consistency of the overall semantic structure of the graph, thereby improving the reliability and expression quality of cross-book knowledge fusion.

[0178] While updating node attributes, the mapping path is further updated. For example, the relationship path "Silla Ginseng → Origin → North Korea" is mapped to "Ginseng → Origin → North Korea", and the edge weight of this edge is updated according to the fusion strategy. For example, the weight is set to the weighted average of the original edge weight and the attention score of the new path.

[0179] If the new entity does not have a similar node in the global graph, such as adding an acupoint name or a rare medicinal herb name, the entity will be automatically inserted into the graph as a brand new node, its attributes will be initialized, and all its original edges will be connected.

[0180] After the update is complete, an incremental alignment report is generated, recording the processing method for each new entity in this round of import, including: whether to merge, the merge target, the merge method, the number of newly added relationship paths, edge weight adjustment records, etc. This report can be reviewed by users and facilitates subsequent model feedback and optimization.

[0181] The method for constructing a knowledge graph of ancient Chinese medicine texts provided in this application effectively enhances the structured processing capability of ancient Chinese medicine texts without manual annotation. By introducing a domain dictionary and a bidirectional maximum matching algorithm for word segmentation, combined with a domain-pre-trained language model and a weakly supervised training strategy, automatic identification of key entities in the ancient texts is achieved. Simultaneously, graph neural networks and attention mechanisms are used to fuse entity context and structural information, accurately extracting semantic relationships between entities and constructing a single-book knowledge graph with semantic depth. A cross-graph attention mechanism enables entity alignment and fusion among multiple ancient text graphs, automatically constructing a unified global TCM knowledge graph, improving the consistency of knowledge organization, and providing a solid foundation for subsequent intelligent retrieval and reasoning.

[0182] Based on the same inventive concept, the present invention also provides a computer device, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed the steps of the above-described method for constructing a knowledge graph of ancient Chinese medical texts.

[0183] The processing methods for computer devices can be referred to the description of the methods above, and will not be repeated here.

[0184] This application also provides a non-transitory machine-readable storage medium storing an executable program, which, when run by a microprocessor, causes the processor to execute the method provided in the above embodiments.

[0185] This invention discloses a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program causes a computer to perform the described methods.

[0186] This invention discloses a computer program product including a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform the described method.

[0187] The embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0188] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.

[0189] Finally, it should be noted that the embodiments disclosed in this invention are merely preferred embodiments of this invention and are only used to illustrate the technical solutions of this invention, not to limit it. Although this invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this invention.

Claims

1. A method for constructing a knowledge graph of ancient Chinese medical texts, characterized in that, The method includes: Acquire data from ancient Chinese medicine texts and then standardize the data. By combining domain dictionaries to construct word segmentation priority rules, setting minimum matching length and dictionary priority, and using a bidirectional maximum matching algorithm to segment ancient Chinese medicine books into words, structured text data is generated. An entity recognition model is constructed based on a pre-trained language model in the field of traditional Chinese medicine. The entity recognition model is weakly supervised by a pseudo-label expansion method and cross-language semantic transfer is achieved by introducing domain adversarial training. The model outputs entities and their corresponding entity annotation results. Using the entities as nodes and the contextual semantics of the entities as initial edge weights, a single-book graph structure is constructed; combining a graph neural network model to perform representation learning on the nodes, fusing the contextual features, positional information and graph structure features of the entities, and using an attention mechanism to extract semantic relationships between entities, a single-book knowledge graph is constructed. Based on the cross-graph attention mechanism, entities from multiple single-book knowledge graphs are fused. A cross-graph attention matrix with weights equal to the product of semantic similarity, structural similarity, and path similarity is constructed. The matching threshold of entities is dynamically adjusted according to the entity interaction strength and the number of common neighbors. Entity alignment and edge weight fusion are performed to generate a global knowledge graph of ancient Chinese medicine books.

2. The method for constructing a knowledge graph of ancient Chinese medical texts according to claim 1, characterized in that, Weakly supervised training through pseudo-label expansion includes: Extract entity classification pairs from the domain dictionary, where the entity classification pairs are initial positive samples; Entity feature vectors are extracted using the pre-trained language model, and the cosine similarity between entity feature vectors is calculated. Based on the cosine similarity, extended entities are determined, resulting in an extended pseudo-label training set. The extended pseudo-label training set includes automatically labeled entities, the segments containing the entities, and relation triples. Calculate the semantic similarity between entities and text fragments, and select text fragments with confidence scores higher than a preset confidence threshold; When at least two of the entities exist in multiple text fragments, the two entities have a potential relationship, resulting in a weakly supervised training sample; the weakly supervised training sample includes text fragments, entity label sequences, and relationship labels.

3. The method for constructing a knowledge graph of ancient Chinese medical texts according to claim 2, characterized in that, Introducing domain adversarial training to achieve cross-stylist semantic transfer includes: A gradient inversion layer is set in the BERT layer and the task layer of the pre-trained language model to invert the gradients of the ancient book feature vector and the modern Chinese medicine feature vector output by the BERT layer. The gradient-reversed feature vectors of ancient books and modern TCM feature vectors are input into a domain discriminator; the domain discriminator is used to determine the source of the corpus to which it belongs. Based on the entity recognition cross-entropy loss function and the domain adversarial loss function, a weighted combination of task loss functions is constructed to optimize the entity recognition model.

4. The method for constructing a knowledge graph of ancient Chinese medical books according to claim 3, characterized in that, The domain adversarial loss function is: in, For domain adversarial loss function; The features output by the BERT layer Distribution of data on ancient Chinese medicine texts; This represents a sample from the distribution of data from ancient Chinese medical texts. x Calculate the expectation; G is the neighborhood discriminator; The task loss function is: in, For domain adversarial loss function, The cross-entropy loss function for entity recognition. These are the balancing parameters.

5. The method for constructing a knowledge graph of ancient Chinese medical texts according to claim 3, characterized in that, Using the entities as nodes and their contextual semantics as initial edge weights, a single-book graph structure is constructed. A graph neural network model is then used to learn the representations of the nodes, fusing the entities' contextual features, location information, and graph structure features. An attention mechanism is used to extract semantic relationships between entities, thus constructing a single-book knowledge graph, including: By traversing all entities and extracting entity pairs and their contextual fragments based on the co-occurrence relationships of entities in ancient texts, a set of entity pairs is formed. The text of the context fragment is encoded into word vectors, and a multi-head self-attention mechanism is used to extract the context features of entity pairs to generate fused semantic feature vectors of entity pairs. A graph structure is constructed based on the co-occurrence relationship of entities, and the fused semantic feature vector is used as the initial feature of the nodes. Multi-layer representation learning is performed on the nodes through a graph convolutional network to obtain node features containing global semantic information. The entity pair feature vectors output by the graph neural network are aggregated and classified to determine the relationship type between entities and generate entity relationship triples; the entity relationship triples include source entity, target entity, relationship category, context fragment, confidence level and source book; Using entities as nodes and triple relationships as edges, combined with attribute information, a dynamically updated single-book knowledge graph is constructed.

6. The method for constructing a knowledge graph of ancient Chinese medical texts according to claim 2, characterized in that, Based on a cross-graph attention mechanism, entities from multiple single-book knowledge graphs are fused. A cross-graph attention matrix is ​​constructed with weights equal to the product of semantic similarity, structural similarity, and path similarity. The matching threshold of entities is dynamically adjusted according to the entity interaction strength and the number of common neighbors, including: Construct a cross-graph attention matrix, the weights of which are determined by the product of semantic similarity, structural similarity and path similarity between entity pairs; Calculate entity interaction vectors based on the cross-graph attention matrix; The matching threshold is dynamically adjusted based on the interaction strength between entities, the number of common neighbors, and path similarity.

7. The method for constructing a knowledge graph of ancient Chinese medical books according to claim 6, characterized in that, Also includes: Receive newly added single-book graphs containing new entity and relationship information, as well as existing global knowledge graph data; Calculate the semantic similarity, structural similarity, and path similarity between each entity in the newly added single-book graph and entities in the global graph, and prioritize entity alignment based on matching items with high structural similarity; For entities that have completed alignment, the newly added relationship paths are automatically mapped to the corresponding nodes in the global knowledge graph, their neighbor structure and relationship path features are updated, dynamic inheritance of entity relationships is realized, and the updated global knowledge graph is output.

8. The method for constructing a knowledge graph of ancient Chinese medical texts according to claim 6, characterized in that, The entity interaction vector is calculated using the following formula: in, For entities Interaction vectors, For entities in other maps, For entities and Cross-graph attention weights; The matching threshold is adjusted using the following formula: in As the initial threshold, This is an adjustment factor for the intensity of entity interaction. For entity pairs; It is a comprehensive index of cross-graph common neighbors and path similarity.

9. A computer device, characterized in that, include: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed by the steps of the method for constructing a knowledge graph of ancient Chinese medical texts as claimed in any one of claims 1-8.

10. A computer storage medium, characterized in that, It stores a computer program, which, when executed by a processor, implements the steps of the method for constructing a knowledge graph of ancient Chinese medical books as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Chinese ancient book entity extraction method based on deep active learning strategy

    CN119761372A

  • Workshop safety protection system based on laser radar

    CN111427055A

  • Ancient book text entity relationship extraction method and system based on deep learning

    CN118966226A