Knowledge graph dynamic updating method based on large language model

By combining HDBSCAN clustering and chi-square test with Large Language Model (LLM), the problems of document clustering and entity co-occurrence in knowledge graphs are solved, enabling efficient and accurate dynamic updates of knowledge graphs, adapting to domain knowledge systems, and improving the consistency and reliability of knowledge graphs.

CN121833967APending Publication Date: 2026-04-10MENGLANG SUSTAINABLE DIGITAL TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing knowledge graph dynamic update technologies suffer from problems such as mixed document clustering topics, generalized core word extraction, distorted entity co-occurrence data, and low relationship generation efficiency. They cannot adapt to domain-specific knowledge systems and differences in entity association patterns, resulting in insufficient consistency and reliability of knowledge graphs.

Method used

HDBSCAN clustering and chi-square test are used to extract domain-specific core words. Combined with Large Language Model (LLM) for document attribution and entity type identification, the co-occurrence analysis window is dynamically adjusted, the relationship template is automatically expanded, and double checks and expert review are performed to form a closed-loop verification mechanism.

Benefits of technology

It achieves precise adaptation of domain knowledge systems, eliminates noise interference, truly reflects the strength of relationships between entities, improves the update efficiency and consistency of knowledge graphs, and ensures the accuracy and reliability of relationship generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121833967A_ABST
    Figure CN121833967A_ABST
Patent Text Reader

Abstract

The invention discloses a knowledge graph dynamic updating method based on a large language model, and relates to the technical field of natural language processing and knowledge graph crossing, and the method comprises the following steps: firstly, carrying out HDBSCAN clustering on documents in field corpus, extracting core word lists of all clusters in combination with chi-square test, and matching new documents to same topic clusters after field judgment; then, based on the same-cluster documents, entities are recognized and types are marked through LLM, and entity pair data are counted by dynamically adjusting a context window of co-occurrence analysis so as to construct a co-occurrence matrix; and finally, expanding a domain exclusive relation template, generating a new relation for a high-frequency unrelated entity pair in the co-occurrence matrix, and incorporating the new relation into the knowledge graph after reverse verification. According to the method, the field adaptability and the co-occurrence analysis precision are improved, and meanwhile, the knowledge graph updating accuracy and reliability are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of natural language processing and knowledge graph, in particular to a knowledge graph dynamic updating method based on a large language model. BACKGROUND

[0002] As the core carrier of the structured presentation of domain knowledge, the dynamic updating capability of the knowledge graph is the key to maintaining the timeliness and accuracy of knowledge. However, the existing knowledge graph dynamic updating technology still has the following defects: Firstly, the existing technology uses general document clustering algorithms and feature extraction methods to process domain corpora, which does not optimize the domain-specific knowledge system and term features, leading to mixed clustering topics and generalized core word extraction, and failing to accurately capture the core features of the subtopics in the domain. Secondly, the existing technology often uses fixed context windows to count entity co-occurrences, without considering the differences in different entity type association patterns, which cannot adapt to the different needs of "strong locality" and "weak locality" between entities, and is prone to include irrelevant noise or miss key associations, resulting in distorted entity pair co-occurrence data. Thirdly, the existing technology relies on single logical judgment for contradictory relationship detection, lacks cross-validation with domain knowledge graphs and expert review closed loop, and is prone to store contradictory relationships, which damages the consistency and reliability of the knowledge graph. Therefore, there is an urgent need for a knowledge graph dynamic updating method based on a large language model. SUMMARY

[0003] To overcome the shortcomings of the prior art, the present application provides a knowledge graph dynamic updating method based on a large language model, which solves the problems of relationship fixation, co-occurrence distortion and insufficient domain adaptation in existing knowledge graph updating.

[0004] To achieve the above purpose, the present application realizes the following technical scheme: a knowledge graph dynamic updating method based on a large language model, comprising: Step 1: HDBSCAN clustering is performed on the existing documents in each domain corpus to obtain a plurality of clustering clusters, and a core word table is extracted from each cluster based on chi-square test. For a new document, after determining its attribution domain, the semantic overlap degree of its screened core words with the core word table of each cluster in the domain is calculated using LLM, and it is matched to the cluster with the same theme; Step 2: Based on the documents in the same cluster, the entities of each document are recognized and labeled by LLM, the context window for co-occurrence analysis is dynamically adjusted for different entity types, and the co-occurrence frequency and average interval distance of entity pairs are counted to construct a co-occurrence matrix of entity pairs; Step3, predefine field-specific relationship templates, automatically extend relationship templates from existing documents using LLM, and for entity pairs with high frequency but no explicit relationship in the co-occurrence matrix, generate new relationships by matching the corresponding templates using LLM, store them in the temporary relationship library, and perform reverse verification on the new relationships in the temporary relationship library, and formally incorporate the verified new relationships into the knowledge graph.

[0005] As a further scheme of the present application, the specific operation of HDBSCAN clustering on the existing documents in each field corpus is as follows: Pretreat the existing documents in the field, and convert each document into a semantic vector of a predetermined dimension by calling the Sentence-BERT model; Cluster the semantic vectors of each document using the HDBSCAN algorithm, and calculate the silhouette coefficient of each cluster. If the silhouette coefficient is <G1, split the cluster. If the overall silhouette coefficient is <G2, re-cluster after pretreating the documents again, wherein G1 and G2 are silhouette coefficient thresholds and G1 < G2. For each cluster, extract the title and abstract of all documents, and call the large language model LLM to generate the topic name of the cluster.

[0006] As a further scheme of the present application, the specific steps for splitting the cluster with a silhouette coefficient <G1 are as follows: Calculate the arithmetic mean of all semantic vectors in the cluster, and use it as the cluster center. Calculate the cosine distance between the semantic vectors of the documents in the cluster and the cluster center, remove the document with the largest distance, update the semantic vectors of the remaining documents in the cluster, recalculate the new cluster center and the silhouette coefficient, and repeat the above steps until the silhouette coefficient of the cluster is >G1. Collect all removed document semantic vectors, calculate their cosine distances with other cluster centers, and assign them to the corresponding cluster with the smallest distance. Recalculate the silhouette coefficient for all clusters. If they are all >G1, the splitting is complete. Otherwise, repeat the above steps.

[0007] As a further scheme of the present application, the specific operation of extracting a core word list from each cluster based on the chi-square test is as follows: For each document in the cluster, first calculate the word frequency of each word using TF-IDF, remove low-frequency words with a word frequency < a predetermined threshold, and then call LLM to filter field-specific terms and output them as [core word, importance score]. Calculate the document coverage rate of each cluster = number of documents containing the core word / total number of documents in the cluster. Calculate the association between the core word and the cluster using the chi-square test, and the specific formula is as follows: Wherein, A represents the number of documents containing the core word in the cluster, B represents the number of documents not containing the core word in the cluster, C represents the number of documents containing the core word in other clusters, and D represents the number of documents not containing the core word in other clusters; If a core word meets the chi-square value, document coverage rate and word frequency, which are not less than the corresponding preset threshold value, it is included in the core word list of the cluster, and the domain expert is removed to eliminate the error core word and supplement the missing core word.

[0008] As a further scheme of the application, the specific steps of matching to the specific topic cluster according to the semantic overlap degree are as follows: The new document text is input into the pre-trained BERT multi-classification model, if the output probability is greater than or equal to 80%, the domain to which it belongs is determined, otherwise it is marked as a cross-domain document and does not participate in subsequent matching; The core word of the new document is extracted by using TF-IDF and LLM, and the output format is [core word, importance score]; For each core word of the new document, the semantic similarity between each core word in the core word list of each cluster is calculated by calling LLM, and the importance score of the core word is multiplied, and then the sum is divided by the total number of core words of the new document to obtain the overlap degree score. The cluster corresponding to the highest overlap degree score is selected as the matched same topic cluster.

[0009] As a further scheme of the application, the context window of the co-occurrence analysis is dynamically adjusted for different entity types, and the specific steps are as follows: Based on the documents in the cluster, the common features of high-frequency entities are extracted by calling LLM, and the entity type is automatically generated to form a dynamic type library in the cluster; For each sentence of the document in the cluster, the context of the sentence is embedded in the prompt word when the entity is recognized by calling LLM, and the entity in the current sentence is recognized and matched with the dynamic type library in the cluster. The output format is [entity, type, matching basis], and the context of the sentence represents the previous and next sentences of the sentence; The co-occurrence frequency of the type pair in the document in the cluster is counted, the correlation density Cd=type pair co-occurrence document number / total number of documents in the cluster is calculated, if Cd is greater than or equal to Cdmax, it is classified as high-density correlation, if Cdmin≤Cd The basic window is set to M consecutive sentences, if it is a high-density correlation type pair, the window is expanded to 2XM consecutive sentences, if it is a medium-density correlation type pair, the basic window is maintained, and if it is a low-density correlation type pair, the window is reduced to [M / 2] consecutive sentences, wherein [ ] represents the integral symbol.

[0010] As a further scheme of the application, the specific steps of constructing the co-occurrence matrix of the entity pair are as follows: The specific steps for constructing the co-occurrence matrix of entity pairs are as follows: For the entity pairs in the window, the LLM is called to calculate the semantic correlation, and a correlation score is output. The correlation score control interval is [1, 10], and only when the score is greater than or equal to 6, the co-occurrence frequency is counted to obtain the effective co-occurrence frequency. The original distance of the entity pair is calculated in units of sentences, that is, the original distance = |entity 1 sentence serial number-entity 2 sentence serial number|, and the average interval distance = total original distance / effective co-occurrence frequency is calculated. For each entity pair in the co-occurrence matrix, the maximum weight = frequency weight * distance weight is calculated, and the matrix index is constructed according to the entity type. The frequency weight = effective co-occurrence frequency / total number of documents in the cluster, and the distance weight = 1 / average original distance.

[0011] As a further scheme of the present application, the automatic extension of the relationship template from the existing documents by using the LLM includes: Based on the domain core knowledge, a pre-defined basic template is constructed, and the template format is unified as: [entity type A]-relationship word-[entity type B]; Q documents are randomly extracted from the documents in the same cluster, and the LLM is called to extract the relationships not covered by the basic template. For the relationships not covered by the basic template extracted by the LLM, the same relationship is merged by calculating the string similarity, the standardized new relationship is classified into the basic template according to the level, and the domain experts are invited to review the standardized new template, and the relationship not meeting the domain logic is deleted.

[0012] As a further scheme of the present application, the specific steps for generating a new relationship by matching the corresponding template through the LLM are as follows: From the co-occurrence matrix, the entity pairs satisfying the following conditions are selected: ① the co-occurrence frequency is greater than or equal to q times; ② there is no recorded relationship in the existing knowledge graph; ③ the co-occurrence weight is greater than or equal to Sim, wherein q represents a high co-occurrence frequency threshold, and Sim represents a high co-occurrence weight threshold; For each entity pair, all co-occurrence window texts recorded in the co-occurrence matrix are extracted, and the LLM is called for template matching to obtain the new relationship of the target entity pair; According to the matching degree of the new relationship and all recorded co-occurrence window texts, a score is output: if the text clearly supports the relationship, the matching degree score is output from the interval [8, 10]; if the text indirectly supports the relationship, the matching degree score is output from the interval [5, 7]; if the text does not meet the explicit support relationship and the indirect support relationship, the matching degree score is output from the interval [1, 4]; The new relationship with a score greater than or equal to 6 is retained and stored in a temporary relationship library, otherwise the new relationship is marked as low confidence, and manual review is triggered.

[0013] As a further scheme of the present application, the reverse verification of the new relationship in the temporary relationship library specifically comprises: A reverse contradiction rule of the relationship in the predefined field is defined and stored in the contradiction mapping library, and the specific format is: {relationship X: [contradiction relationship 1, contradiction relationship 2, …]}; For each new relationship in the temporary relationship library: it is judged whether the new relationship is contradictory to other relationships in the temporary relationship library; the new relationship is compared with all the recorded co-occurrence window texts again to judge whether there is a semantic conflict; if there is an item that does not pass, it is marked as to be investigated; The new relationship that passes the check is verified by reasoning with the existing association in the field knowledge graph, and it is judged whether the new relationship conflicts with the existing knowledge; For the new relationship to be investigated or whether it conflicts with the existing knowledge: if the expert determines that it is a false positive contradiction, it is modified and then stored; if it is confirmed as a contradictory relationship, the new relationship is deleted; the new relationship that passes all the verification is formally included in the knowledge graph.

[0014] The present application provides a knowledge graph dynamic updating method based on a large language model, which has the following advantages compared with the prior art: (1) The present application groups the field corpus documents by HDBSCAN clustering, screens the cluster-specific core words in combination with the chi-square test, and generates cluster topic names using LLM, solving the problem of mixed field topics and core word generalization caused by general processing in the prior art. At the same time, when matching new documents, the cluster is accurately attributed based on the field classification model and the semantic overlap degree, which adapts to the characteristics of the field knowledge system and avoids cross-domain noise interference; (2) The present application dynamically adjusts the context window according to the entity type correlation density to adapt to the differences in correlation patterns of different entity types, avoiding irrelevant co-occurrence caused by fixed windows. At the same time, the LLM is used to screen effective co-occurrences and calculate weights to eliminate entity pairs that have physical co-occurrence but no semantic association, so that the co-occurrence matrix can truly reflect the correlation strength and closeness between entities; (3) The present application uses LLM to automatically expand the field relationship template, and performs double-checking, knowledge graph cross-verification and expert review on the generated relationship, forming a closed-loop verification mechanism, solving the problem of low relationship generation efficiency and difficult contradiction relationship filtering in the prior art. BRIEF DESCRIPTION OF DRAWINGS

[0015] Figure 1 The present application is a step flowchart; Figure 2 The present application is a step flowchart for HDBSCAN clustering of field documents; Figure 3 The present application is a step flowchart for dynamically adjusting the context window of co-occurrence analysis. DETAILED DESCRIPTION

[0016] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0017] As Figure 1 The present application provides a knowledge graph dynamic updating method based on a large language model. As an embodiment of the present application, the following steps are specifically included: Step 1, clustering the existing documents in the corpus of each field by HDBSCAN to obtain a plurality of clustering clusters, and extracting a core vocabulary table from each cluster based on chi-square test, and after determining the attribution field of the obtained new document, calculating the semantic overlap degree of the screened core words of the new document with the core vocabulary table of each cluster in the field by LLM, and matching to the cluster with the same theme; Step 2, based on the documents in the same cluster, identifying the entities of each document and marking the types by LLM, dynamically adjusting the context window of co-occurrence analysis for different entity types, and counting the co-occurrence times and average interval distance of entity pairs to construct a co-occurrence matrix of entity pairs; Step 3, predefining a field-specific relationship template, automatically expanding the relationship template from the existing documents by LLM, and for the high-frequency but no explicit relationship entity pairs in the co-occurrence matrix, generating new relationships by matching the corresponding templates by LLM, storing them in a temporary relationship library, and performing reverse verification on the new relationships in the temporary relationship library, and formally including the new relationships that pass the verification into the knowledge graph.

[0018] As an embodiment of the present application, it is implemented on the basis of the first embodiment, and the difference lies in that the embodiment includes: Step 1, clustering the existing documents in the corpus of each field by HDBSCAN to obtain a plurality of clustering clusters, and extracting a core vocabulary table from each cluster based on chi-square test; The above-mentioned field refers to a category formed around a specific professional theme or industry, which has a unique knowledge system and terminology system, such as the medical field, the financial field; And the existing documents in the field usually have the characteristics of mass, dispersion and mixed theme, such as the medical database which may have tens of thousands of blood sugar related documents covering treatment, diagnosis, prognosis and other sub-themes, if not clustered, the documents will be in a disordered state, at the same time, if the features are directly extracted from the full amount of field documents, the mixed terms of different themes will cause "feature pollution"; Therefore, it is necessary to perform HDBSCAN clustering on existing documents in different field corpora, and extract core term lists from each cluster based on chi-square test, which is specifically performed as follows: For each document in the cluster, first calculate the importance of words using TF-IDF, filter low-frequency words with word frequency < preset threshold, and then call LLM to filter domain-specific terms, which are used as core terms. The output format is [core term, importance score (0-10 points)]. For example, the following command can be used to extract professional terms related to 'blood glucose targeted therapy' from the following documents, excluding general terms (such as patients, research), and the output format is [core term, importance score (1-10 points)]. The relative importance of words in a single document is quantified by TF-IDF, and a portion of low-frequency words that do not meet the requirements are filtered. Then, LLM is used for semantic filtering, which improves the accuracy of single-document core terms. Collect the core terms of all documents in the cluster. Use the collections library in Python to count the frequency of each core term and calculate the document coverage rate = number of documents containing the core term / total number of documents in the cluster. Calculate the relevance of core terms to the cluster using chi-square test. The specific formula is as follows: Where A represents the number of documents in the cluster containing the core term, B represents the number of documents in the cluster not containing the core term, C represents the number of documents in other clusters containing the core term, and D represents the number of documents in other clusters not containing the core term. The relevance of core terms to the cluster can be converted into two categorical variables: whether the core term appears (yes / no) and whether the document belongs to the target cluster (yes / no), which forms a 2x2 contingency table. A, B, C, and D correspond to the frequency of the four cells, respectively. The larger the value, the stronger the relevance between the appearance of the core term and the belonging to the target cluster, i.e., the core term is more likely to be a specific feature of the cluster. If a core term meets the condition of chi-square value ≥ (strong relevance), document coverage rate ≥ Dc (common occurrence), and word frequency ≥ Wf (high frequency), it is included in the core term list of the cluster, where is the chi-square threshold, Dc is the document coverage rate threshold, and Wf is the word frequency threshold, which need to be set according to actual conditions. After obtaining the core term list of each cluster, a second review by domain experts is performed to delete incorrect core terms and supplement missing core terms. For the new documents obtained, after determining their belonging domain, the semantic overlap between the filtered core terms of the new documents and the core term lists of the clusters in the domain is calculated using LLM, and the new documents are matched to the clusters with the same theme according to the semantic overlap, which is specifically performed as follows: Call a pre-trained domain classification model, such as a BERT-based multi-class model, input new document text, output domain probability. If the highest probability is ≥80%, the domain is determined; otherwise, it is marked as a cross-domain document and does not participate in subsequent matching. TF-IDF and LLM are used to extract the core words of new documents, and the output format is [core words, importance score (0-10 points)]; For each core word in the new document, LLM is called to calculate the semantic similarity with each core word in the core word list of each cluster, and multiplied by the importance score of that core word. The sum is then divided by the total number of core words in the new document to obtain the overlap score. The cluster with the highest overlap score is selected as the matched cluster of the same topic.

[0019] Step 2: Based on documents in the same cluster, use LLM to identify entities and label their types, and dynamically adjust the context window of co-occurrence analysis for different entity types; The association patterns between entities are closely related to their types, and the topic consistency of documents in the same cluster provides a stable context for entity type identification and association analysis. Some entity types have "strong locality" (concentrated in the immediate context), while others have "weak locality" (dispersed in a wider context). Using a fixed window cannot accommodate this difference. For example, for strongly local entity pairs, the association is usually directly expressed in the same sentence or adjacent sentences. If the window is too large, irrelevant co-occurrences will be included, introducing noise. For weakly local entity pairs, the association may be scattered across multiple sentences in a paragraph, such as "Among patients, smokers account for 60%, ..., the 5-year survival rate of this group is lower than that of non-smokers". If the window is too small, key associations, such as the cross-sentence association between "smokers" and "survival rate", will be missed. After dynamically adjusting the context window for co-occurrence analysis for different entity types, recording only the co-occurrence of type combinations would lose the differences between specific entities. Knowledge graphs require relationships between specific entities, not abstract type relationships. Therefore, it is necessary to record the co-occurrence frequency and average interval distance of entity pairs to construct a co-occurrence matrix. The specific steps are as follows: For entity pairs within the window, LLM is called to calculate semantic relevance and output a relevance score. This relevance score is controlled within the range of [1, 10]. Only when the score is ≥6 is it included in the co-occurrence count to obtain the effective co-occurrence count. Filter out entity pairs that "physically co-occur but have no actual relationship" to ensure that the number of co-occurrences reflects the true semantic relationship; The original distance between entity pairs is calculated on a sentence-by-sentence basis, i.e., original distance = |sentence number of entity 1 - sentence number of entity 2|. The average interval distance is calculated as total original distance / effective co-occurrence count. For each entity pair in the co-occurrence matrix, calculate the frequency weight, distance weight, and get the maximum weight = frequency weight x distance weight, the frequency weight = effective co-occurrence number / total number of documents in the cluster, reflecting the universality of the entity pair, the distance weight = 1 / average original distance, reflecting the close association of the entity pair; Construct matrix index by entity type, support fast query of co-occurrence data of specific type pair, such as all entities under "third generation EGFR inhibitor" type as row, "EGFR sensitive mutation" type as column; Redundancy merge for reverse entity pair, keep the record with higher weight, such as "A-B" weight is 0.6, "B-A" weight is 0.5, only keep "A-B".

[0020] Step3, predefine domain specific relationship template, and automatically expand from existing documents using LLM, the specific operation is: Based on the core knowledge of the field, predefine the basic template according to the core and sub relationship two levels, the template format is unified as: [entity type A]-relationship word-[entity type B], for example, the core relationship is: [drug]-treatment-[disease], [drug]-inhibition-[gene variation], [gene variation]-cause-[disease], the relationship words are treatment, inhibition and cause respectively, the sub relationship is the extension under the core relationship: [drug]-preferential treatment-[specific subtype disease], [drug]-partial inhibition-[gene variation], the relationship words are preferential treatment and partial inhibition respectively; Randomly select Q articles from the same cluster, call LLM to extract the relationship expression not covered by the basic template, the instruction to LLM can be expressed as: extract the relationship between 'drug, gene variation and disease' from the following documents, the format is '[entity type A]-new relationship word-[entity type B]', and it is required that it does not appear in the basic template; The documents in the same cluster contain the accumulated sub relationship in the field, and the semantic understanding ability of LLM can break through the limitation of fixed template and mine the relationship that may be missed by artificial predefinition; For the relationship not covered by the basic template extracted by LLM, merge the synonymous relationship through string similarity calculation (such as Levenshtein distance), standardize the new relationship according to the level, and invite domain experts to review the standardized new template and delete the relationship that does not conform to the field logic; For the entity pair with high frequency but no clear relationship in the co-occurrence matrix, match the most possible template through LLM and generate new relationship, the specific operation is: Filtering entity pairs from the co-occurrence matrix that meet the following conditions: ① Co-occurrence frequency ≥ q times (high frequency, implying potential strong association); ② No recorded relationship in the existing knowledge graph (i.e., "relationship missing"); ③ Co-occurrence weight ≥ Sim (i.e., "close association"), where q represents the high co-occurrence frequency threshold, and Sim represents the high co-occurrence weight threshold; High-frequency and close co-occurrence entity pairs are more likely to have undiscovered relationships, and targeted processing can improve the efficiency of knowledge graph completion; For each target entity pair, extract all co-occurrence window texts recorded in the co-occurrence matrix, and call LLM for template matching to obtain the new relationship of the target entity pair; While generating the new relationship, LLM scores it based on the matching degree between the new relationship and all recorded co-occurrence window texts. The scoring logic is as follows: if the text explicitly supports the relationship, output a matching degree score from the interval [8, 10]; if the text indirectly supports the relationship, output a matching degree score from the interval [5, 7]; if the text does not meet the above two conditions, output a matching degree score from the interval [1, 4]; Set the scoring threshold to 6 points, keep relationships with scores ≥ 6 points, and store them in the temporary relationship library. If the score is < 6 points, mark the relationship as low confidence and trigger manual review; After storing the new relationship in the temporary relationship library, it also needs to be verified in reverse to filter logically inconsistent relationships, including: Predefine the reverse contradiction rules of relationships within a domain and store them in the contradiction mapping library. The specific format is: {relationship X: [contradictory relationship 1, contradictory relationship 2,...]}, for example, if there is [A] - treatment - [B], then [A] - cause - [B] is a contradictory relationship; if there is [A] - completely suppresses - [B], then [A] - cannot suppress - [B] is a contradictory relationship; For each new relationship in the temporary relationship library, call LLM to perform a two-item check: Determine whether the new relationship is contradictory to other relationships in the temporary relationship library; Compare the new relationship with all recorded co-occurrence window texts again to determine whether there is a semantic conflict; If one of the two-item checks fails, mark it as "to be investigated"; Verify the relationship that passes the two-way check with the existing knowledge in the domain knowledge graph, and determine whether the new relationship conflicts with the existing knowledge. Cross-validation of the knowledge graph can filter relationships that are "supported by local context but contradict global knowledge," ensuring the global consistency of the relationship; The new relationship marked as "to be checked" or cross-validation conflict is finally determined by a domain expert in combination with the original document and domain knowledge: if the expert determines that it is a false positive conflict, such as a misjudgment caused by expression ambiguity, the new relationship is corrected and stored; if it is confirmed as a contradictory relationship, the new relationship is deleted, and the reason for the contradiction is recorded, such as "document data error"; finally, the new relationship that passes all verifications is formally incorporated into the knowledge graph.

[0021] As Embodiment Three of the present application, the present embodiment further discloses a method for HDBSCAN clustering of existing documents in different field corpora based on Embodiments One and Two, as shown in Figure 2 The specific content includes: The existing documents in the field are preprocessed, for example, the text is cleaned using the nlt library of Python, including removing punctuation, stop words, redundant paragraphs, etc., only the core content is retained, and the Sentence-BERT model is called to convert each document into a semantic vector of a predetermined dimension; The traditional bag-of-words model cannot capture semantic associations, while the vector generated by the Sentence-BERT through the pre-trained context understanding capability can more accurately reflect the overall semantics of the document, providing high-quality input for clustering; The HDBSCAN algorithm is used to cluster the semantic vectors of the above documents, which can automatically identify the topic clusters naturally formed in the field compared to K-means which needs to pre-set the number of clusters, and has strong fault tolerance to noise documents (such as mixed review); The silhouette coefficient of each cluster is calculated, if the silhouette coefficient of a cluster is <G1, indicating that the similarity of the documents in the cluster is low, the cluster needs to be split; if the overall silhouette coefficient is <G2, the documents are preprocessed again and then clustered, wherein G1 and G2 are silhouette coefficient thresholds and G1 <G2; The specific steps for splitting the cluster with a silhouette coefficient <G1 are as follows: Calculate the arithmetic mean of the semantic vectors of all documents in the cluster, and take it as the cluster center; Calculate the cosine distance between the semantic vector of each document in the cluster and the cluster center, the greater the distance, the farther the document deviates from the cluster theme, remove the document with the largest distance, and update the semantic vectors of the remaining documents in the cluster, recalculate the new cluster center and the silhouette coefficient, and repeat the above steps, remove the semantic vector farthest from the current cluster center each time, until the silhouette coefficient of the cluster is >G1; Collect all the removed document semantic vectors, calculate their cosine distances with all cluster centers (the smaller the distance, the more matched the semantics), and assign each removed vector to the cluster corresponding to the smallest distance; Recalculate the profile coefficients for all clusters (including the original cluster after optimization and the cluster receiving the elimination vector), if all > G1, then complete the splitting, otherwise, repeat the above steps (for new unqualified clusters); For each cluster, extract the titles and abstracts of all documents, and call the large language model LLM to generate a topic name, for example, the following instructions can be used: "Based on the following document titles and abstracts, summarize its core topic with no more than 5 words - [list of document titles]".

[0022] As Embodiment Four of the present application, this embodiment further discloses a method for dynamically adjusting the context window of co-occurrence analysis for different entity types based on Embodiments One, Two and Three, as shown in the following figure: Figure 3 The specific process is as follows: Based on the documents in the same cluster, call LLM to extract the common features of high-frequency entities and automatically generate entity types to form an intra-cluster dynamic type library, for example, the instruction to LLM is as follows: "The following entities are from lung cancer targeted therapy documents: osimertinib, amatinib, and fumitebin. Please summarize their common features and name a dedicated type", and the LLM outputs the type as "third-generation EGFR inhibitor", and repeat this process to generate all types; For each sentence of the documents in the cluster, call LLM to identify entities by embedding the context of the sentence in the prompt words, identify the entities in the current sentence and match the intra-cluster dynamic type library, and the output format is [entity, type, matching basis], wherein the context of the sentence represents the previous sentence and the next sentence of the sentence; Context anchoring allows LLM to more accurately determine the meaning of entities, solving the problem of ambiguous entity reference in isolated sentences, for example, in the sentence "The objective response rate of the drug is 70%", "the drug" is correctly identified as [osimertinib, third-generation EGFR inhibitor, context reference] by LLM in combination with the context "clinical trials of osimertinib show..."; Statistical co-occurrence frequency of "type pair" in the documents in the cluster, calculate the correlation density Cd = number of documents with co-occurrence of type pair / total number of documents in the cluster, if Cd ≥ Cdmax, it is classified as high-density correlation, if Cdmin ≤ Cd < Cdmax, it is classified as medium-density correlation, and if Cd < Cdmin, it is classified as low-density correlation; Correlation density reflects the general correlation of type pairs in the topic cluster, providing data basis for subsequent window adjustment and avoiding subjective setting; The specific rules for dynamically scaling the context window based on the correlation density are as follows: If the pair is of high density, the window is enlarged to 2xM consecutive sentences, in which case the cross-paragraph association is more likely to be meaningful; if the pair is of medium density, the basic window is maintained; if the pair is of low density, the window is reduced to [M / 2] consecutive sentences, in which case only the close-range co-occurrence is meaningful, where [ ] represents the rounding symbol, and M needs to be pre-set according to the actual situation.

[0023] Some data in the above formula are dimensionless for numerical calculation, and the contents not described in detail in the specification all belong to the prior art known to those skilled in the art.

[0024] The above examples are only used to illustrate the technical method of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical method of the present application.

Claims

1. A method for updating a knowledge graph based on a large language model, characterized in that, include: Step 1: Perform HDBSCAN clustering on existing documents in the corpus of each domain to obtain several clusters. Extract the core vocabulary from each cluster based on the chi-square test. For new documents, after determining their domain, use LLM to calculate the semantic overlap between the selected core words and the core vocabulary of each cluster in that domain, and match them to clusters with the same topic. Step 2: Based on documents in the same cluster, use LLM to identify entities in each document and label their types. Dynamically adjust the context window of co-occurrence analysis for different entity types, and count the number of co-occurrences and average interval distance of entity pairs to construct the co-occurrence matrix of entity pairs. Step 3: Predefine domain-specific relationship templates. Use LLM to automatically expand relationship templates from existing documents. For entity pairs in the co-occurrence matrix that are high-frequency but have no clear relationship, use LLM to match the corresponding templates to generate new relationships, store them in a temporary relationship library, and perform reverse verification on the new relationships in the temporary relationship library. The verified new relationships are then formally incorporated into the knowledge graph.

2. The method of claim 1, wherein the method further comprises: The specific operations for HDBSCAN clustering of existing documents in corpora of various domains are as follows: Preprocess existing documents in the domain and call the Sentence-BERT model to transform each document into a semantic vector of a preset dimension; The HDBSCAN algorithm is used to cluster the semantic vectors of each document, and the silhouette coefficient of each cluster is calculated. If the silhouette coefficient is less than G1, the cluster is split. If the overall contour coefficient is less than G2, the documents are re-preprocessed and clustered again, where G1 and G2 are contour coefficient thresholds and G1 is less than G2. For each cluster, extract the titles and summaries of all documents, and call the Large Language Model (LLM) to generate the topic name for that cluster. 3.The method of claim 2, wherein, The specific steps for splitting clusters with a profile coefficient < G1 are as follows: Calculate the arithmetic mean of all semantic vectors in the cluster and use it as the cluster center; Calculate the cosine distance between the semantic vector of a document within a cluster and the cluster center, remove the document with the largest distance, update the semantic vector of the remaining documents within the cluster, recalculate the new cluster center and silhouette coefficient, repeat the above steps, removing the semantic vector farthest from the current cluster center each time, until the silhouette coefficient of the cluster > G1. Collect the semantic vectors of all removed documents, calculate their cosine distances to other cluster centers, and assign them to the clusters with the smallest distances. Recalculate the silhouette coefficients for all clusters. If all are greater than G1, the splitting is complete; otherwise, repeat the above steps. 4.The method of claim 1, wherein, The specific steps for extracting the core vocabulary from each cluster based on the chi-square test are as follows: For each document within the cluster, first use TF-IDF to calculate the word frequency of each word, remove low-frequency words with a word frequency < preset threshold, then call LLM to filter domain-specific terms and use them as core words, with the output format being [core words, importance score]; Calculate the document coverage rate for each cluster = number of documents containing the core keyword / total number of documents within the cluster; The chi-square test is used to calculate the correlation between core words and clusters. The specific formula is as follows: where A represents the number of documents in the cluster containing the core word, B represents the number of documents in the cluster not containing the core word, C represents the number of documents in other clusters containing the core word, and D represents the number of documents in other clusters not containing the core word. If a core word meets the chi-square value, document coverage, and word frequency, which are not less than the corresponding preset threshold value, it is included in the core word list of the cluster. Then, the domain expert removes the wrong core word and supplements the missing core word. 5.The method of claim 1, wherein, The specific steps of matching to the specific cluster with the same theme according to the semantic overlap degree are as follows: The new document text is input into the pre-trained BERT multi-classification model. If the output probability is greater than or equal to 80%, the domain to which the new document belongs is determined. Otherwise, the new document is marked as a cross-domain document and does not participate in subsequent matching. The core words of the new document are extracted by using TF-IDF and LLM, and the output format is [core word, importance score]. For each core word of the new document, the semantic similarity between the core word and each core word in the core word list of each cluster is calculated by calling LLM, and the importance score of the core word is multiplied. After summation and division by the total number of core words of the new document, the overlap degree score is obtained. The cluster corresponding to the highest overlap degree score is selected as the matched cluster with the same theme. 6.The method of claim 1, wherein, The context window of the co-occurrence analysis is dynamically adjusted according to different entity types, which specifically includes: Based on the documents in the cluster, the common features of high-frequency entities are extracted by calling LLM, and the entity types are automatically generated to form a dynamic type library within the cluster. For each sentence of the document in the cluster, the context of the sentence is embedded in the prompt word when identifying the entity by calling LLM. The entity in the current sentence is identified and matched with the dynamic type library within the cluster. The output format is [entity, type, matching basis]. The context of the sentence represents the previous and next sentences of the sentence. The co-occurrence frequency of "type pairs" in the documents within the cluster is counted, and the correlation density Cd is calculated as the number of documents in which the type pair co-occurs divided by the total number of documents within the cluster. If Cd is greater than or equal to Cdmax, it is classified as high-density correlation. If Cdmin is less than or equal to Cd and less than Cdmax, it is classified as medium-density correlation. If Cd is less than Cdmin, it is classified as low-density correlation. Cdmin and Cdmax are the lower and upper limits of the correlation density. The basic window is set to M consecutive sentences. If it is a high-density correlation type pair, the window is expanded to 2×M consecutive sentences. If it is a medium-density correlation type pair, the basic window is maintained. If it is a low-density correlation type pair, the window is reduced to [M / 2] consecutive sentences. [ ] represents the integer symbol. 7.The method of claim 1, wherein, The specific steps of constructing the co-occurrence matrix of entity pairs are as follows: For the entity pairs in the window, the semantic correlation is calculated by calling LLM, and the correlation score is output. The correlation score control interval is [1, 10]. Only when the score is greater than or equal to 6 points, the co-occurrence frequency is counted to obtain the effective co-occurrence frequency. The original distance of the entity pair is calculated in units of sentences, which is original distance = |sentence number of entity 1 - sentence number of entity 2|. The average interval distance is calculated as total original distance / effective co-occurrence frequency. For each entity pair in the co-occurrence matrix, the maximum weight is calculated as frequency weight × distance weight, and the matrix index is constructed according to the entity type. The frequency weight is effective co-occurrence frequency / total number of documents within the cluster, and the distance weight is 1 / average original distance. 8.The method of claim 1, wherein, The relationship templates are automatically expanded from the existing documents by using LLM, which includes: Based on the core knowledge of the field, a pre-defined basic template is constructed, and the template format is unified as: [Entity Type A]-relation word-[Entity Type B]; Randomly select Q articles from the same cluster of documents, and call LLM to extract relationships that are not covered by the basic template; For the relationships extracted by LLM that are not covered by the basic template, merge the synonymous relationships by string similarity calculation, and classify the standardized new relationships into the basic template according to the hierarchy. Invite domain experts to review the standardized new template, and delete the relationships that do not conform to the domain logic. 9.The method of claim 1, wherein, The specific steps of generating new relationships through LLM matching corresponding templates are as follows: Select entity pairs from the co-occurrence matrix that meet the following conditions: ① co-occurrence frequency ≥ q times; ② no recorded relationship in the existing knowledge graph; ③ co-occurrence weight ≥ Sim, where q represents the high co-occurrence frequency threshold, and Sim represents the high co-occurrence weight threshold; For each entity pair, extract all co-occurrence window texts recorded in the co-occurrence matrix, and call LLM for template matching to obtain new relationships for the target entity pair; According to the matching degree of the new relationship with all recorded co-occurrence window texts, score: if the text clearly supports the relationship, output the matching degree score from the interval [8, 10]; if the text indirectly supports the relationship, output the matching degree score from the interval [5, 7]; if the text does not conform to the explicit support relationship and indirect support relationship, output the matching degree score from the interval [1, 4]; Keep new relationships with scores ≥ 6 and store them in the temporary relationship library, otherwise, mark the new relationship as low confidence and trigger manual review. 10.The method of claim 1, wherein, The specific steps of reverse verification of new relationships in the temporary relationship library include: Predefine the reverse contradiction rules of relationships in the field, and store them in the contradiction mapping library, with the specific format as: {relationship X: [contradictory relationship 1, contradictory relationship 2,...]}; For each new relationship in the temporary relationship library: judge whether the new relationship is contradictory to other relationships in the temporary relationship library; compare the new relationship with all recorded co-occurrence window texts again to determine whether there is a semantic conflict; if there is an item that does not pass, it is marked as to be investigated; Infer and verify the new relationship that passes the check with the existing relationship in the domain knowledge graph, and determine whether the new relationship conflicts with the existing knowledge; For new relationships that are to be investigated or conflict with existing knowledge: if the expert determines that it is a false positive contradiction, modify and store it; if it is confirmed as a contradictory relationship, delete the new relationship; the new relationship that passes all verifications is officially incorporated into the knowledge graph.