A method for establishing knowledge database based on language model
By constructing and updating the domain knowledge graph and optimizing the knowledge database of the language model with user feedback, the problem of insufficient knowledge coverage in niche areas is solved, and efficient and accurate knowledge graph generation and update are achieved.
Patent Information
- Application Number
- CN202510055807.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2045-01-14
AI Technical Summary
The generative language model lacks coverage of knowledge databases in niche industries or specific fields, resulting in inaccurate user responses and difficulty in understanding, affecting user experience.
The domain knowledge graph is constructed based on public domain data, the initial knowledge graph is generated through the graph prediction model, and dynamic updates are updated through user Q&A feedback to optimize the private domain knowledge graph, including cleaning data, building edge relationships, generating confidence graphs and iterative replacement nodes.
It has achieved efficient integration of cross-domain knowledge and customized construction of private domains, improved the accuracy and applicability of niche domain knowledge graphs, and enhanced the practical value of the language model.
Smart Images

Figure CN119990291B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and more specifically, to a method for establishing a knowledge database based on a language model. Background Art
[0002] Generative language models, with their knowledge database built on massive amounts of internet data, have demonstrated significant versatility in a wide range of cross-domain and cross-industry applications, effectively improving the work efficiency of practitioners in multiple fields and industries. However, despite their excellent versatility, generative language models lack sufficient coverage of their knowledge database when it comes to niche industries or specific fields. Due to the scarcity of specialized data in niche industries or fields, language models struggle to fully acquire and accurately understand the knowledge in these specific fields, resulting in limited performance in relevant application scenarios. Therefore, in actual applications, users in niche industries or fields may face problems such as inaccurate answers and difficulty understanding due to the lack of knowledge in the language model, which affects the user experience. Summary of the Invention
[0003] The present invention provides a method for establishing a knowledge database based on a language model, which solves the technical problems raised in the background technology.
[0004] The present invention provides a method for establishing a knowledge database based on a language model, comprising:
[0005] Step 1: Build domain knowledge graphs for several domains based on public domain data. The domain knowledge graphs include root nodes, child nodes, node features of child nodes, and edge relationships of child nodes.
[0006] Step 2: Based on the similarity of the root nodes of different domain knowledge graphs, edge relationships are constructed between different domain knowledge graphs to obtain a public domain knowledge graph.
[0007] Step 3: Based on the public domain knowledge graph as training data, a graph prediction model is constructed, and the initial knowledge graph of the target private domain is generated through the graph prediction model;
[0008] Step 4: Configure the initial knowledge graph as the knowledge database of the target private domain, match it with several private domain users for question and answer, and obtain the question and answer knowledge graphs of several private domain users. Then, generate a confidence graph based on the question and answer knowledge graphs of several private domain users.
[0009] Step 5: Replace the sub-nodes of the initial knowledge graph with the sub-nodes of the confidence graph to obtain an updated knowledge graph;
[0010] Step 6, repeat steps 4 and 5 until At least one updated knowledge graph in the first cycle At least one updated knowledge graph similarity in each cycle By presetting the similarity threshold, the private domain knowledge graph of the target private domain is obtained.
[0011] Furthermore, domain knowledge graphs in several fields are constructed based on public domain data, including:
[0012] The public domain data is cleaned, part-of-speech identified, and word segmented to obtain several domain names and corresponding knowledge entities. The domain names are mapped as the root nodes of the domain knowledge graph, and the knowledge entities are mapped as child nodes of the domain knowledge graph. The interpretations of the knowledge entities are used as features of the child nodes.
[0013] Extract other knowledge entities from the interpretation of the knowledge entity to obtain the dependency relationship between the knowledge entities; and establish edge relationships between child nodes based on the dependency relationship between the knowledge entities.
[0014] Furthermore, according to the similarity of the root nodes of different domain knowledge graphs, edge relationships are constructed between different domain knowledge graphs, including:
[0015] Map the domain names corresponding to the root nodes of different domain knowledge graphs to the word vector space to obtain the word vector representation corresponding to the domain name;
[0016] Calculate the cosine similarity of the word vectors corresponding to the domain name. If the cosine similarity is greater than the corresponding preset threshold, an exogenous edge relationship is constructed between the child nodes of the corresponding domain knowledge graph, as follows:
[0017] The sub-nodes in the domain knowledge graph are divided according to their degrees with the root node, and the sub-nodes with the same degree are divided into a group to obtain to Group child nodes;
[0018] Based on the mathematical operation tree algorithm, domain knowledge graph The dependency relationship of the a-th child node of the i-th group of child nodes, and the domain knowledge graph The dependency relationship of the b-th child node of the i-th group of child nodes is formulated to obtain mathematical operation trees a and b;
[0019] Calculate the structural similarity between mathematical operation tree a and mathematical operation tree b. The calculation formula is as follows:
[0020] ;
[0021] in, Indicates the structural similarity between mathematical operation tree a and mathematical operation tree b, represents the minimum number of edit operations from mathematical operation tree a to mathematical operation tree b, Represents the total number of tree nodes of the mathematical operation tree a, Represents the total number of tree nodes of the mathematical operation tree b, 、 and denote the first linear weight, the second linear weight and the third linear weight respectively, represents the index weight;
[0022] If the structural similarity between mathematical operation tree a and mathematical operation tree b is greater than the corresponding preset threshold, then the domain knowledge graph The a-th child node of the i-th group of child nodes and the domain knowledge graph An external edge relationship is established between the bth child node of the i-th group of child nodes.
[0023] Furthermore, based on the public domain knowledge graph as training data, a graph prediction model is constructed, including:
[0024] Step 7: Randomly select a domain knowledge graph from the public domain knowledge graph as a sample graph, use the features of the child nodes in the sample graph as sample labels, and use the public domain knowledge graph excluding the sample graph as a training sample;
[0025] Step 8: Repeat step 7 to obtain several training samples and corresponding sample labels;
[0026] Step 9: The graph prediction model inputs the training sample and outputs the prediction features of the corresponding sub-nodes in the sample graph through the exogenous edge relationship;
[0027] Step 10: Based on the predicted features and sample labels, the hyperparameters of the hidden layer of the graph prediction model are reversely optimized and updated using the mean square error loss function.
[0028] Furthermore, the calculation formula of the hidden layer of the graph prediction model is as follows:
[0029] ;
[0030] ;
[0031] ,and ;
[0032] in, Indicates the hidden layer's response to the sample graph The predicted features of child nodes, represents the child node interaction weight correction factor, Indicates the hidden layer The correction matrix of hidden units, Indicates the first The feature set of the child nodes that establish the exogenous edge relationship between the child nodes, Indicates the first child nodes, Indicates the first child nodes, Indicates the first The sum of the number of external edge relationships and edge relationships of child nodes, Indicates the first The sum of the number of external edge relationships and edge relationships of child nodes, Indicates the first The child nodes in the hidden layer The features of hidden units, Indicates the first The child nodes in the hidden layer The features of hidden units, Indicates the hidden layer The weight matrix of hidden units, , represents the natural base, Indicates the L2 norm square operation, Indicates the hidden layer The correction matrix of hidden units, Indicates size , and the diagonal elements are 1 and the rest of the elements are 0, express activation function, express Activation function.
[0033] Furthermore, the graph prediction model is used to generate an initial knowledge graph for the target private domain, including:
[0034] Obtain the private domain name of the target private domain, match the private domain name with several domain names in the public domain knowledge graph based on the cosine similarity of word vectors, obtain the domain name with the largest cosine similarity value with the private domain name, and use the structure of the domain knowledge graph corresponding to the domain name as the basic structure of the initial knowledge graph of the target private domain, and the exogenous edge relationship of the corresponding domain knowledge graph as the basic exogenous edge relationship of the initial knowledge graph;
[0035] The knowledge entity of the first-degree child node of the corresponding domain knowledge graph is used as the knowledge entity of the first-degree child node of the basic structure of the initial knowledge graph. Based on the basic exogenous edge relationship and the edge relationship contained in the basic structure of the initial knowledge graph, the first-degree child nodes of the initial knowledge graph are sequentially generated through the graph prediction model. The predicted features of the degree sub-nodes are used to obtain the initial knowledge graph; among them, Degree represents the maximum degree of a child node in the infrastructure of the initial knowledge graph.
[0036] Furthermore, a question-and-answer knowledge graph of several private domain users is obtained, and a confidence graph is generated based on the question-and-answer knowledge graph of several private domain users, including:
[0037] Clean, identify parts of speech, and segment user answers to obtain question-answer knowledge entities and corresponding question-answer interpretations.
[0038] Extract other question-answer knowledge entities from the question-answer interpretation of the question-answer knowledge entity to obtain the dependency relationship between the question-answer knowledge entities;
[0039] Map the question-answering knowledge entities to question-answering nodes in the question-answering knowledge graph, use the corresponding question-answering interpretations as the features of the question-answering nodes, and establish question-answering edge relationships between question-answering nodes based on dependency relationships to obtain the question-answering knowledge graph;
[0040] Get the maximum degree of each question-answer knowledge graph;
[0041] Combine the Q&A knowledge graphs of several private domain users to make voting decisions, including:
[0042] Get the question-answer knowledge graph including the yth question-answer node and calculate the weighted score of the yth question-answer node :
[0043] ;in, represents the total number of question-answer knowledge graphs including the yth question-answer node, express The index of Indicates the The maximum degree of a question-answer knowledge graph;
[0044] Judgment weighted score >Preset the node score threshold, then retain the yth question-answer node, and get all the retained question-answer nodes;
[0045] Based on all retained question and answer nodes, a confidence graph is built.
[0046] Furthermore, the sub-nodes of the confidence graph are replaced with the sub-nodes of the initial knowledge graph, including:
[0047] The confidence map The features of the child nodes and the initial knowledge graph The child nodes are mapped to the word vector space respectively to obtain the embedding vector and , , , Indicates the The total number of word segments in the text of the features of the child nodes, Indicates the The total number of word segments in the text of the features of the child nodes, ;
[0048] Embedding vector The subvector in ,calculate With embedding vector The scaled dot product attention weight of each sub-vector in is given by:
[0049] ;in, Represents the embedding vector in With embedding vector in The scaled dot product attention weights, represents the learning weight matrix, Represents the transpose of a vector;
[0050] By scaling the dot product attention weights on the embedding vector Calculate the weighted vector for each sub-vector of to obtain the comprehensive attention vector. The formula of the comprehensive attention vector is as follows:
[0051] ;in, represents the comprehensive attention vector;
[0052] Calculate the embedding vector The subvector in The cosine similarity with the comprehensive attention vector is used to obtain the embedding vector The subvector in With embedding vector Matching score ;
[0053] Based on subvector , calculate the embedding vector With embedding vector The correlation degree is calculated as follows:
[0054] ;in, Represents the embedding vector With embedding vector degree of relevance;
[0055] If the correlation is greater than the preset correlation threshold, the first The child nodes are included in the confidence graph The replacement target of the child node is The replacement target set of child nodes;
[0056] According to the replacement target set of each child node in the confidence graph, several replacement schemes are obtained. Each replacement scheme is used to replace the initial knowledge graph to generate several replacement knowledge graphs.
[0057] Furthermore, the sub-nodes of the confidence graph are updated to the nodes of the initial knowledge graph, including:
[0058] Each replacement knowledge graph is updated using the graph prediction model. The update includes:
[0059] Update the unreplaced child nodes in the replacement knowledge graph;
[0060] The replaced sub-nodes, edge relationships and exogenous edge relationships in the replacement knowledge graph are used as input to the graph prediction model to obtain the prediction features of the graph prediction model for the non-replaced sub-nodes. The prediction features are used as the update features of the replaced sub-nodes in the replacement knowledge graph to obtain the updated knowledge graph.
[0061] Furthermore, the private domain knowledge graph of the target private domain is obtained, including:
[0062] When reaching the During the second cycle, the graph tool is used to analyze the The first cycle Updated knowledge graph and The largest common subgraph of any updated knowledge graph obtained in the second cycle;
[0063] Jordi If there is at least one updated knowledge graph in the updated knowledge graph obtained in the second cycle that is exactly the same as the largest common subgraph, the largest common subgraph will be used as the private domain knowledge graph of the target private domain.
[0064] The beneficial effects of this invention lie in: by combining public-domain knowledge graphs with private-domain needs, and dynamically optimizing the generation of private-domain knowledge graphs using graph prediction models and user feedback, this approach enables efficient cross-domain knowledge integration and customized private-domain construction. Its most significant benefit is the ability to rapidly generate high-quality knowledge graphs in niche domains or data-scarce scenarios. It also improves the accuracy and applicability of knowledge graphs through iterative updates, significantly enhancing the practical value and scalability of language models. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 It is a flow chart of a method for establishing a knowledge database based on a language model of the present invention;
[0066] Figure 2It is a construction diagram of the spectrum prediction model of the present invention. DETAILED DESCRIPTION
[0067] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that these embodiments are discussed solely to enable those skilled in the art to better understand and implement the subject matter described herein, and that the functions and arrangements of the elements discussed may be varied without departing from the scope of this specification. Various examples may omit, substitute, or add various processes or components as needed. In addition, features described with respect to some examples may also be combined in other examples.
[0068] like Figures 1 and 2 As shown, a method for establishing a knowledge database based on a language model includes:
[0069] Step 1: Build domain knowledge graphs for several domains based on public domain data. The domain knowledge graphs include root nodes, child nodes, node features of child nodes, and edge relationships of child nodes.
[0070] Step 2: Based on the similarity of the root nodes of different domain knowledge graphs, edge relationships are constructed between different domain knowledge graphs to obtain a public domain knowledge graph.
[0071] Step 3: Based on the public domain knowledge graph as training data, a graph prediction model is constructed, and the initial knowledge graph of the target private domain is generated through the graph prediction model;
[0072] Step 4: Configure the initial knowledge graph as the knowledge database of the target private domain, match it with several private domain users for question and answer, and obtain the question and answer knowledge graphs of several private domain users. Then, generate a confidence graph based on the question and answer knowledge graphs of several private domain users.
[0073] Step 5: Replace the sub-nodes of the initial knowledge graph with the sub-nodes of the confidence graph to obtain an updated knowledge graph;
[0074] Step 6, repeat steps 4 and 5 until At least one updated knowledge graph in the first cycle At least one updated knowledge graph similarity in each cycle By presetting the similarity threshold, the private domain knowledge graph of the target private domain is obtained.
[0075] In one embodiment of the present invention, domain knowledge graphs for several domains are constructed based on public domain data, including:
[0076] Clean the public domain data, identify the word nature, and perform word segmentation to obtain a number of domain names and corresponding knowledge entities; map the domain names to the root nodes of the domain knowledge graph, map the knowledge entities to the sub-nodes of the domain knowledge graph, and use the definitions of the knowledge entities as the features of the sub-nodes.
[0077] Extract other knowledge entities in the definitions of the knowledge entities to obtain the dependency relationships between the knowledge entities; and establish edge relationships between the sub-nodes based on the dependency relationships between the knowledge entities.
[0078] Specifically, remove redundant, irrelevant, or non-standard data from the public domain data to improve the efficiency and accuracy of subsequent processing, including: deleting HTML tags, special characters (such as @#$%^, etc.), and invisible characters (such as line breaks). Unify the case (such as converting all to lowercase), and delete extra spaces. Remove stop words (such as "de", "shi", "le") to retain words with actual semantics. Clear duplicate records to ensure data uniqueness. Identify and correct possible spelling mistakes (for pinyin, abbreviations, etc.). Tools used include: filtering irrelevant words through the stop word library provided by spaCy in Python, and cleaning noise using the re (regular expression) module. Removing duplicates from the data table using Pandas. Detecting and filtering non-target language data (such as non-Chinese content in multi-language mixed data) using LangDetect. Identify the word nature of each word in the sentence to further extract key information such as domain names and entities, including: loading the segmented text data. Assigning the corresponding word nature tags to each word (such as nouns, verbs, etc.). Extracting specific word natures according to requirements, such as nouns (domain names) and entity names. Tools used include: HanLP. Implementing text segmentation into words or phrases through Jieba to facilitate the construction of node and edge relationships in the knowledge graph.
[0079] Specifically, the definition of knowledge entity 1 includes knowledge entity 2 and knowledge entity 3. Then, establish edge relationships between knowledge entity 2 and knowledge entity 3 and knowledge entity 1 respectively.
[0080] In an embodiment of the present invention, construct edge relationships between different domain knowledge graphs according to the similarity of the root nodes of different domain knowledge graphs, including:
[0081] Map the domain names corresponding to the root nodes of different domain knowledge graphs to the word vector space to obtain the word vector representations corresponding to the domain names;
[0082] Calculate the cosine similarity of the word vectors corresponding to the domain names. If the cosine similarity is greater than the corresponding preset threshold, construct external edge relationships between the sub-nodes of the corresponding domain knowledge graphs, specifically as follows:
[0083] The sub-nodes in the domain knowledge graph are divided according to their degrees with the root node, and the sub-nodes with the same degree are divided into a group to obtain to Group child nodes;
[0084] Based on the mathematical operation tree algorithm, domain knowledge graph The dependency relationship of the a-th child node of the i-th group of child nodes, and the domain knowledge graph The dependency relationship of the b-th child node of the i-th group of child nodes is formulated to obtain mathematical operation trees a and b;
[0085] Calculate the structural similarity between mathematical operation tree a and mathematical operation tree b. The calculation formula is as follows:
[0086] ;
[0087] in, Indicates the structural similarity between mathematical operation tree a and mathematical operation tree b, represents the minimum number of edit operations from mathematical operation tree a to mathematical operation tree b, Represents the total number of tree nodes of the mathematical operation tree a, Represents the total number of tree nodes of the mathematical operation tree b, 、 and denote the first linear weight, the second linear weight and the third linear weight respectively, represents the index weight;
[0088] If the structural similarity between mathematical operation tree a and mathematical operation tree b is greater than the corresponding preset threshold, then the domain knowledge graph The a-th child node of the i-th group of child nodes and the domain knowledge graph An external edge relationship is established between the bth child node of the i-th group of child nodes.
[0089] It should be noted that the operation of mapping to the word vector space can also be implemented by word2vec.
[0090] Specifically, the semantic relevance between domains is determined by mapping the root nodes (i.e., domain names) of knowledge graphs from different domains to word vector spaces and calculating their cosine similarity. If the similarity exceeds a preset threshold, exogenous edge relationships are established between the child nodes of the corresponding graphs. Furthermore, the child nodes are grouped by their connectivity, and the dependencies between them are formulated using a mathematical operation tree. The structural similarity of the trees is calculated (based on the minimum number of edit operations). If the structural similarity between the two trees exceeds a threshold, cross-graph edges are established between the child nodes, thereby achieving the fusion and integration of knowledge from different domains.
[0091] For example, for knowledge entity 1, knowledge entity 2, and knowledge entity 3, knowledge entity 2 plus knowledge entity 3 equals knowledge entity 1. Then map knowledge entity 1, knowledge entity 2, knowledge entity 3, and the plus sign to nodes in the mathematical operation tree, connect knowledge entity 2 and knowledge entity 3 to the plus sign, and connect the plus sign to knowledge entity 1, to obtain the mathematical operation tree of knowledge entity 1, knowledge entity 2, and knowledge entity 3.
[0092] In one embodiment of the present invention, a graph prediction model is constructed based on a public domain knowledge graph as training data, including:
[0093] Step 7: Randomly select a domain knowledge graph from the public domain knowledge graph as a sample graph, use the features of the child nodes in the sample graph as sample labels, and use the public domain knowledge graph excluding the sample graph as a training sample;
[0094] Step 8: Repeat step 7 to obtain several training samples and corresponding sample labels;
[0095] Step 9: The graph prediction model inputs the training sample and outputs the prediction features of the corresponding sub-nodes in the sample graph through the exogenous edge relationship;
[0096] Step 10: Based on the predicted features and sample labels, the hyperparameters of the hidden layer of the graph prediction model are reversely optimized and updated using the mean square error loss function.
[0097] Specifically, a domain knowledge graph is selected from the public knowledge graph as a sample in the training data to extract subnode features for model training. A knowledge graph is randomly selected from the public knowledge graph collection, such as the "Medical Domain Knowledge Graph" or the "Physics Domain Knowledge Graph." The set of subnodes in this domain knowledge graph is determined. The features of these subnodes are extracted. Output: The extracted subnode features are used as labels for training data (for supervised learning). By repeatedly selecting domain knowledge graphs, a sufficient sample set is constructed to ensure diversity and coverage of model training. Different domain knowledge graphs are continuously randomly selected from the public knowledge graph. For each selected domain knowledge graph, subnode features are extracted and corresponding training labels are generated. These training samples and labels are accumulated to form a complete training dataset. Through multiple random selections, as many domains as possible in the public knowledge graph are covered, improving the generalization ability and applicability of the model. The graph prediction model uses the training samples to predict subnode features and generates predicted features corresponding to the actual labels. The training samples are then input into the graph prediction model. The model generates features based on exogenous edge relationships (i.e., dependencies between child nodes) through internal computation. It outputs predicted features for each child node in the sample graph, such as the node's category, attribute, or relationship description. The prediction model must accurately restore the true characteristics of the child nodes based on the input training sample features so that they can be compared with the labels for optimization. By comparing the model's predictions with the actual labels, the error is calculated and the model's hyperparameters are adjusted to gradually improve the model's prediction accuracy. The error between the model-generated predicted features of child nodes and the actual sample labels is calculated. The mean squared error loss function is used to quantify the error. Based on the magnitude of the error, the model's hidden layer hyperparameters (such as node weights and connection weights) are adjusted to reduce the error. The training and optimization process is repeated until the model's prediction error reaches an acceptable range. By continuously optimizing the model, it becomes able to more accurately predict child node features, providing a reliable foundation for constructing new knowledge graphs. This method achieves accurate prediction of child node features in knowledge graphs through random sampling and feature generation based on exogenous edge relationships, combined with supervised learning and loss optimization. This process lays the technical foundation for the subsequent construction and dynamic update of private domain knowledge graphs.
[0098] In one embodiment of the present invention, the calculation formula of the hidden layer of the graph prediction model is as follows:
[0099] ;
[0100] ;
[0101] ,and ;
[0102] in, Indicates the hidden layer's response to the sample graph The predicted features of child nodes, represents the child node interaction weight correction factor, Indicates the hidden layer The correction matrix of hidden units, Indicates the first The feature set of the child nodes that establish the exogenous edge relationship between the child nodes, Indicates the first child nodes, Indicates the first child nodes, Indicates the first The sum of the number of external edge relationships and edge relationships of child nodes, Indicates the first The sum of the number of external edge relationships and edge relationships of child nodes, Indicates the first The child nodes in the hidden layer The features of hidden units, Indicates the first The child nodes in the hidden layer The features of hidden units, Indicates the hidden layer The weight matrix of hidden units, , represents the natural base, Indicates the L2 norm square operation, Indicates the hidden layer The correction matrix of hidden units, Indicates size , and the diagonal elements are 1 and the rest of the elements are 0, express activation function, express Activation function.
[0103] Specifically, by aggregating the features of child nodes and their neighboring nodes, the model can simulate the dependencies between child nodes and their context. The introduction of weight matrices and correction matrices allows the model to automatically optimize the strength of feature interactions based on specific tasks. The activation function and feature normalization ensure the model's nonlinearity and numerical stability. The evaluation table for the practical application of the graph prediction model is as follows:
[0104]
[0105] Among them, the test dataset represents the knowledge graph dataset of different fields; the number of nodes represents the number of nodes contained in the graph; the number of edges represents the number of edges connecting nodes in the graph; the prediction accuracy represents the degree of matching between the model's predicted features of sub-nodes and actual labels; the number of hidden layers of the graph prediction model represents the depth and complexity of the model; the comparative improvement represents the improvement in prediction accuracy compared with traditional graph prediction methods.
[0106] In one embodiment of the present invention, generating an initial knowledge graph for a target private domain using a graph prediction model includes:
[0107] Obtain the private domain name of the target private domain, match the private domain name with several domain names in the public domain knowledge graph based on the cosine similarity of word vectors, obtain the domain name with the largest cosine similarity value with the private domain name, and use the structure of the domain knowledge graph corresponding to the domain name as the basic structure of the initial knowledge graph of the target private domain, and the exogenous edge relationship of the corresponding domain knowledge graph as the basic exogenous edge relationship of the initial knowledge graph;
[0108] The knowledge entity of the first-degree child node of the corresponding domain knowledge graph is used as the knowledge entity of the first-degree child node of the basic structure of the initial knowledge graph. Based on the basic exogenous edge relationship and the edge relationship contained in the basic structure of the initial knowledge graph, the first-degree child nodes of the initial knowledge graph are sequentially generated through the graph prediction model. The predicted features of the degree sub-nodes are used to obtain the initial knowledge graph; among them, Degree represents the maximum degree of a child node in the infrastructure of the initial knowledge graph.
[0109] Specifically, the closest domain is found by calculating the cosine similarity between the word vectors of the target private domain name and several domain names in the public knowledge graph. Cosine similarity quantifies the semantic similarity between the private domain name and each domain name. The domain name with the highest semantic similarity is selected and the target private domain knowledge graph is initialized based on the knowledge graph structure of that domain. First-degree child nodes (child nodes directly connected to the root node) are extracted from the selected domain knowledge graph as the base nodes of the initial graph. All edge relationships (including exogenous edge relationships) in the base structure are retained. This results in an initial knowledge graph that contains a portion of the structure and associations of the selected domain. Using a graph prediction model, features of deeper nodes are generated layer by layer based on the subnode features and exogenous edge relationships of the initial structure. This process expands from first-degree child nodes to multi-degree child nodes (such as second- and third-degree nodes). For example, features of first-degree child nodes are obtained based on the graph prediction model. These first-degree node features are then used as input to the graph prediction model to obtain features of second-degree child nodes, and this cycle repeats. The result is a complete initial knowledge graph containing all predicted node features.
[0110] For example, when generating a knowledge graph for the private domain "electric vehicles," the domain name "automotive design" has the highest similarity, so its corresponding knowledge graph is selected as the foundation. The structure of the knowledge graph for "automotive design" is obtained, for example, with the root node being "automotive design," and the first-degree child nodes being "the significance of automotive design," "the concept of automotive design," "the actual function of automotive," and "the future of automotive design." Accordingly, "electric vehicles" serves as the root node of the private domain knowledge graph, and its first-degree child nodes are "the significance of electric vehicles," "the concept of electric vehicles," "the function of electric vehicles," and "the future of electric vehicles."
[0111] In one embodiment of the present invention, obtaining a question-and-answer knowledge graph of several private domain users and generating a confidence graph based on the question-and-answer knowledge graph of the several private domain users include:
[0112] Clean, identify parts of speech, and segment user answers to obtain question-answer knowledge entities and corresponding question-answer interpretations.
[0113] Extract other question-answer knowledge entities from the question-answer interpretation of the question-answer knowledge entity to obtain the dependency relationship between the question-answer knowledge entities;
[0114] Map the question-answering knowledge entities to question-answering nodes in the question-answering knowledge graph, use the corresponding question-answering interpretations as the features of the question-answering nodes, and establish question-answering edge relationships between question-answering nodes based on dependency relationships to obtain the question-answering knowledge graph;
[0115] Get the maximum degree of each question-answer knowledge graph;
[0116] Combine the Q&A knowledge graphs of several private domain users to make voting decisions, including:
[0117] Get the question-answer knowledge graph including the yth question-answer node and calculate the weighted score of the yth question-answer node :
[0118] ;in, represents the total number of question-answer knowledge graphs including the yth question-answer node, express The index of Indicates the The maximum degree of a question-answer knowledge graph;
[0119] Judgment weighted score >Preset the node score threshold, then retain the yth question-answer node, and get all the retained question-answer nodes;
[0120] Based on all retained question and answer nodes, a confidence graph is built.
[0121] Specifically, this method structures the Q&A content of multiple private users. First, user answers are cleaned, segmented, and part-of-speech identified to extract the core knowledge entities and their interpretations. Dependencies between these knowledge entities are then extracted to generate a Q&A knowledge graph for each user. In these graphs, nodes represent knowledge entities, and edges represent logical or semantic relationships between entities. Subsequently, each Q&A knowledge graph is traversed to calculate the importance of each node and quantify its contribution to the graph. Incorporating statistical data from multi-user Q&A queries, this method employs a voting strategy to filter nodes that appear frequently across multiple graphs, removing nodes with low confidence and retaining only those with high confidence. Finally, a comprehensive confidence graph is constructed based on the selected high-confidence nodes. This confidence graph fully integrates knowledge feedback from multiple users, ensuring that the knowledge structure represented is more accurate, authoritative, and widely applicable, providing a reliable foundation for optimizing private knowledge graphs.
[0122] In one embodiment of the present invention, replacing the sub-nodes of the initial knowledge graph with the sub-nodes of the confidence graph includes:
[0123] The confidence map The features of the child nodes and the initial knowledge graph The child nodes are mapped to the word vector space respectively to obtain the embedding vector and , , , Indicates the The total number of word segments in the text of the features of the child nodes, Indicates the The total number of word segments in the text of the features of the child nodes, ;
[0124] Embedding vector The subvector in ,calculate With embedding vector The scaled dot product attention weight of each sub-vector in is given by:
[0125] ;in, Represents the embedding vector in With embedding vector in The scaled dot product attention weights, represents the learning weight matrix, Represents the transpose of a vector;
[0126] By scaling the dot product attention weights on the embedding vector Calculate the weighted vector for each sub-vector of to obtain the comprehensive attention vector. The formula of the comprehensive attention vector is as follows:
[0127] ;in, represents the comprehensive attention vector;
[0128] Calculate the embedding vector The subvector in The cosine similarity with the comprehensive attention vector is used to obtain the embedding vector The subvector in With embedding vector Matching score ;
[0129] Based on subvector , calculate the embedding vector With embedding vector The correlation degree is calculated as follows:
[0130] ;in, Represents the embedding vector With embedding vector degree of relevance;
[0131] If the correlation is greater than the preset correlation threshold, the first The child nodes are included in the confidence graph The replacement target of the child node is The replacement target set of child nodes;
[0132] According to the replacement target set of each child node in the confidence graph, several replacement schemes are obtained. Each replacement scheme is used to replace the initial knowledge graph to generate several replacement knowledge graphs.
[0133] Specifically, by gradually integrating high-confidence nodes in the confidence graph into the initial knowledge graph, dynamic optimization of the initial graph is achieved, including:
[0134] The sub-node features in the confidence graph and the sub-node features in the initial knowledge graph are mapped to a high-dimensional word vector space to generate corresponding embedding vectors. Converting text features to embedding vectors facilitates the subsequent calculation of similarity and association between nodes in the high-dimensional space. Each node feature is represented as an embedding vector that contains the semantic information of the feature.
[0135] For each sub-component of the embedding vector, an attention mechanism is used to calculate its importance within the overall embedding vector. The attention mechanism weights the sub-features to determine which components are most critical to the node's identity. This emphasizes the semantic importance of each sub-feature, generating a comprehensive attention vector. Each sub-feature of the embedding vector is assigned an attention weight, resulting in a comprehensive semantic representation.
[0136] Nodes in the confidence graph are compared with nodes in the initial knowledge graph in the embedding space, and their cosine similarity is calculated as a matching score. This similarity metric determines whether a node in the confidence graph is suitable for replacing a node in the initial knowledge graph. A matching score is generated for each node to assess their semantic consistency.
[0137] Based on the matching scores, the node association is further calculated. The association reflects the overall correlation between nodes in the graph, not just the similarity of individual features. This comprehensive consideration of the semantic similarity of nodes and the dependencies of the graph structure improves the accuracy of replacement operations. A correlation value is generated for each pair of nodes; the higher the correlation, the more reasonable the replacement.
[0138] If the correlation between a node in the confidence graph and a node in the initial knowledge graph exceeds a preset threshold, the node in the initial knowledge graph is added to the target set of replacements for the confidence graph. This process filters out suitable replacement nodes in the initial knowledge graph, providing a basis for graph updates. A replacement target set is generated, containing all nodes that meet the replacement criteria.
[0139] Based on the replacement target set, we construct multiple replacement schemes, each corresponding to a replacement combination of the initial knowledge graph nodes. Through diverse replacement schemes, we explore different node update paths. This results in several replacement knowledge graphs, each based on a different replacement scheme.
[0140] The replacement scheme is applied to the initial knowledge graph to generate an updated knowledge graph. Through iterative replacement, the node features of the knowledge graph are dynamically optimized, making it more accurate and comprehensive. The new knowledge graph incorporates high-confidence node features from the confidence graph and expands and optimizes the initial graph through the replacement scheme.
[0141] In one embodiment of the present invention, updating the nodes of the initial knowledge graph with the child nodes of the confidence graph includes:
[0142] Each replacement knowledge graph is updated using the graph prediction model. The update includes:
[0143] Update the unreplaced child nodes in the replacement knowledge graph;
[0144] The replaced sub-nodes, edge relationships and exogenous edge relationships in the replacement knowledge graph are used as input to the graph prediction model to obtain the prediction features of the graph prediction model for the non-replaced sub-nodes. The prediction features are used as the update features of the replaced sub-nodes in the replacement knowledge graph to obtain the updated knowledge graph.
[0145] In one embodiment of the present invention, obtaining a private domain knowledge graph of a target private domain includes:
[0146] When reaching the During the second cycle, the graph tool is used to analyze the The first cycle Updated knowledge graph and The largest common subgraph of any updated knowledge graph obtained in the second cycle;
[0147] Jordi If there is at least one updated knowledge graph in the updated knowledge graph obtained in the second cycle that is exactly the same as the largest common subgraph, the largest common subgraph will be used as the private domain knowledge graph of the target private domain.
[0148] Specifically, this method generates multiple updated knowledge graphs during each replacement cycle, where the correct replacement solution is always included in all replacement solutions. Because the user-provided confidence graph is smaller than the initial knowledge graph, the replacement operation primarily involves gradually adjusting the initial knowledge graph based on locally high-confidence content. Therefore, the correct replacement solution, because it conforms to the logic of the confidence graph, is the first to achieve stability (i.e., "fastest convergence") in the generated updated knowledge graph. During this process, the updated knowledge graph generated by each replacement solution in each cycle is compared with its parent. When the maximum common subgraph generated by a replacement solution in a given cycle is completely consistent with the updated knowledge graph in the previous cycle, it indicates that the current replacement operation matches the correct replacement solution. Because the correct replacement solution has the optimal adjustment logic and aligns with the confidence graph, it prioritizes forming a stable structure. Therefore, the first time the maximum common subgraph is completely consistent with any updated knowledge graph in a given cycle, it indicates that the correct replacement solution has been found and has successfully converged to the target private domain knowledge graph.
[0149] The above describes the embodiments of this embodiment, but this embodiment is not limited to the above specific implementation methods. The above specific implementation methods are merely illustrative and not restrictive. Ordinary technicians in this field can also make many forms based on the inspiration of this embodiment, all of which are protected by this embodiment.
Claims
1. A method for establishing a knowledge database based on a language model, characterized in that: include: Step 1: Build domain knowledge graphs for several domains based on public domain data. The domain knowledge graphs include root nodes, child nodes, node features of child nodes, and edge relationships of child nodes. Step 2: Based on the similarity of the root nodes of different domain knowledge graphs, edge relationships are constructed between different domain knowledge graphs to obtain a public domain knowledge graph. Step 3: Based on the public domain knowledge graph as training data, a graph prediction model is constructed, and the initial knowledge graph of the target private domain is generated through the graph prediction model; Step 4: Configure the initial knowledge graph as the knowledge database of the target private domain, and match several private domain users for question and answer to obtain question and answer knowledge graphs of several private domain users, and generate a confidence graph based on the question and answer knowledge graphs of several private domain users, including: cleaning, part-of-speech recognition and word segmentation of user answers to obtain question and answer knowledge entities and corresponding question and answer interpretations in user answers; extracting other question and answer knowledge entities in the question and answer interpretations of question and answer knowledge entities to obtain dependency relationships between question and answer knowledge entities; mapping question and answer knowledge entities to question and answer nodes of the question and answer knowledge graph, using the corresponding question and answer interpretations as features of the question and answer nodes, and establishing question and answer edge relationships between question and answer nodes based on dependency relationships to obtain a question and answer knowledge graph; obtaining the maximum degree of each question and answer knowledge graph; and combining the question and answer knowledge graphs of several private domain users to make voting decisions, specifically including: obtaining a question and answer knowledge graph including the yth question and answer node, and calculating the weighted score of the yth question and answer node. : ;in, represents the total number of question-answer knowledge graphs including the yth question-answer node, express The index of Indicates the The maximum degree of a question-answer knowledge graph; judge the weighted score > Preset the node score threshold, then retain the yth question-answer node, and obtain all the retained question-answer nodes; based on all the retained question-answer nodes, establish a confidence graph; Step 5: Replace the sub-nodes of the initial knowledge graph with the sub-nodes of the confidence graph to obtain an updated knowledge graph; Step 6, repeat steps 4 and 5 until At least one updated knowledge graph in the first cycle At least one updated knowledge graph similarity in each cycle By presetting the similarity threshold, the private domain knowledge graph of the target private domain is obtained.
2. The method for establishing a knowledge database based on a language model according to claim 1, characterized in that: Build domain knowledge graphs in several fields based on public domain data, including: The public domain data is cleaned, part-of-speech identified, and word segmented to obtain several domain names and corresponding knowledge entities. The domain names are mapped as the root nodes of the domain knowledge graph, and the knowledge entities are mapped as child nodes of the domain knowledge graph. The interpretations of the knowledge entities are used as features of the child nodes. Extract other knowledge entities from the interpretation of the knowledge entity to obtain the dependency relationship between the knowledge entities; and establish edge relationships between child nodes based on the dependency relationship between the knowledge entities.
3. The method for establishing a knowledge database based on a language model according to claim 2, characterized in that: Based on the similarity of the root nodes of different domain knowledge graphs, edge relationships are constructed between different domain knowledge graphs, including: Map the domain names corresponding to the root nodes of different domain knowledge graphs to the word vector space to obtain the word vector representation corresponding to the domain name; Calculate the cosine similarity of the word vectors corresponding to the domain name. If the cosine similarity is greater than the corresponding preset threshold, an exogenous edge relationship is constructed between the child nodes of the corresponding domain knowledge graph, as follows: The sub-nodes in the domain knowledge graph are divided according to their degrees with the root node, and the sub-nodes with the same degree are divided into a group to obtain to Group child nodes; Based on the mathematical operation tree algorithm, domain knowledge graph The dependency relationship of the a-th child node of the i-th group of child nodes, and the domain knowledge graph The dependency relationship of the b-th child node of the i-th group of child nodes is formulated to obtain mathematical operation trees a and b; Calculate the structural similarity between mathematical operation tree a and mathematical operation tree b. The calculation formula is as follows: ; in, Indicates the structural similarity between mathematical operation tree a and mathematical operation tree b, represents the minimum number of edit operations from mathematical operation tree a to mathematical operation tree b, Represents the total number of tree nodes of the mathematical operation tree a, Represents the total number of tree nodes of the mathematical operation tree b, 、 and denote the first linear weight, the second linear weight and the third linear weight respectively, represents the index weight; If the structural similarity between mathematical operation tree a and mathematical operation tree b is greater than the corresponding preset threshold, then the domain knowledge graph The a-th child node of the i-th group of child nodes and the domain knowledge graph An external edge relationship is established between the bth child node of the i-th group of child nodes.
4. The method for establishing a knowledge database based on a language model according to claim 3, characterized in that: Based on the public domain knowledge graph as training data, a graph prediction model is constructed, including: Step 7: Randomly select a domain knowledge graph from the public domain knowledge graph as a sample graph, use the features of the child nodes in the sample graph as sample labels, and use the public domain knowledge graph excluding the sample graph as a training sample; Step 8: Repeat step 7 to obtain several training samples and corresponding sample labels; Step 9: The graph prediction model inputs the training sample and outputs the prediction features of the corresponding sub-nodes in the sample graph through the exogenous edge relationship; In step 10, based on the predicted features and sample labels, the hyperparameters of the hidden layer of the graph prediction model are reversely optimized and updated using the mean square error loss function.
5. The method for establishing a knowledge database based on a language model according to claim 4, characterized in that: The calculation formula of the hidden layer of the graph prediction model is as follows: ; ; ,and ; in, Indicates the hidden layer's response to the sample graph The predicted features of child nodes, represents the child node interaction weight correction factor, Indicates the hidden layer The correction matrix of hidden units, Indicates the first The feature set of the child nodes that establish the exogenous edge relationship between the child nodes, Indicates the first child nodes, Indicates the first child nodes, Indicates the first The sum of the number of external edge relationships and edge relationships of child nodes, Indicates the first The sum of the number of external edge relationships and edge relationships of child nodes, Indicates the first The child nodes in the hidden layer The features of hidden units, Indicates the first The child nodes in the hidden layer The features of hidden units, Indicates the hidden layer The weight matrix of hidden units, , represents the natural base, Indicates the L2 norm square operation, Indicates the hidden layer The correction matrix of hidden units, Indicates size , and the diagonal elements are 1 and the rest of the elements are 0, express activation function, express Activation function.
6. The method for establishing a knowledge database based on a language model according to claim 5, characterized in that: Generate an initial knowledge graph for the target private domain through the graph prediction model, including: Obtain the private domain name of the target private domain, match the private domain name with several domain names in the public domain knowledge graph based on the cosine similarity of word vectors, obtain the domain name with the largest cosine similarity value with the private domain name, and use the structure of the domain knowledge graph corresponding to the domain name as the basic structure of the initial knowledge graph of the target private domain, and the exogenous edge relationship of the corresponding domain knowledge graph as the basic exogenous edge relationship of the initial knowledge graph; The knowledge entity of the first-degree child node of the corresponding domain knowledge graph is used as the knowledge entity of the first-degree child node of the basic structure of the initial knowledge graph. Based on the basic exogenous edge relationship and the edge relationship contained in the basic structure of the initial knowledge graph, the first-degree child nodes of the initial knowledge graph are sequentially generated through the graph prediction model. The predicted features of the degree sub-nodes are used to obtain the initial knowledge graph; among them, Degree represents the maximum degree of a child node in the infrastructure of the initial knowledge graph.
7. The method for establishing a knowledge database based on a language model according to claim 6, characterized in that: Replace the sub-nodes of the confidence graph with the sub-nodes of the initial knowledge graph, including: The confidence map The features of the child nodes and the initial knowledge graph The child nodes are mapped to the word vector space respectively to obtain the embedding vector and , , , Indicates the The total number of word segments in the text of the features of the child nodes, Indicates the The total number of word segments in the text of the features of the child nodes, ; Embedding vector The subvector in ,calculate With embedding vector The scaled dot product attention weight of each sub-vector in is given by: ;in, Represents the embedding vector in With embedding vector in The scaled dot product attention weights, represents the learning weight matrix, Represents the transpose of a vector; By scaling the dot product attention weights on the embedding vector Calculate the weighted vector for each sub-vector of to obtain the comprehensive attention vector. The formula of the comprehensive attention vector is as follows: ;in, represents the comprehensive attention vector; Calculate the embedding vector The subvector in The cosine similarity with the comprehensive attention vector is used to obtain the embedding vector The subvector in With embedding vector Matching score ; Based on subvector , calculate the embedding vector With embedding vector The correlation degree is calculated as follows: ;in, Represents the embedding vector With embedding vector degree of relevance; If the correlation is greater than the preset correlation threshold, the first The child nodes are included in the confidence graph The replacement target of the child node is The replacement target set of child nodes; According to the replacement target set of each child node in the confidence graph, several replacement schemes are obtained. Each replacement scheme is used to replace the initial knowledge graph to generate several replacement knowledge graphs.
8. The method for establishing a knowledge database based on a language model according to claim 7, characterized in that: Update the nodes of the initial knowledge graph with the child nodes of the confidence graph, including: Each replacement knowledge graph is updated using the graph prediction model. The update includes: Update the unreplaced child nodes in the replacement knowledge graph; The replaced sub-nodes, edge relationships and exogenous edge relationships in the replacement knowledge graph are used as input to the graph prediction model to obtain the prediction features of the graph prediction model for the non-replaced sub-nodes. The prediction features are used as the update features of the replaced sub-nodes in the replacement knowledge graph to obtain the updated knowledge graph.
9. The method for establishing a knowledge database based on a language model according to claim 8, characterized in that: Get the private domain knowledge graph of the target private domain, including: When reaching the During the second cycle, the graph tool is used to analyze the The first cycle Updated knowledge graph and The largest common subgraph of any updated knowledge graph obtained in the next cycle; Jordi If there is at least one updated knowledge graph in the updated knowledge graph obtained in the second cycle that is exactly the same as the largest common subgraph, the largest common subgraph will be used as the private domain knowledge graph of the target private domain.
Citation Information
Patent Citations
Large model training deployment method and system based on knowledge graph
CN117332852A