Method, device and medium for constructing domain knowledge graph based on large language model
By using domain corpus and open source encyclopedia knowledge graph to retrieve relevant information in the construction of domain knowledge graphs, and combining large language models to generate and correct triplets, the problem of inaccurate extraction in the existing technology is solved, achieving efficient and high-precision Knowledge graph construction.
Patent Information
- Application Number
- CN202411429343.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-14
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-10-14
AI Technical Summary
The prior art requires extensive expertise and manual intervention in building domain knowledge graphs, and methods based on large language models are susceptible to context noise and knowledge hallucinations, resulting in inaccurate extracted triplets and affecting the credibility of knowledge graphs. Spend.
By identifying the specified entities, retrieving relevant contexts and triplet examples using the domain corpus and open source encyclopedia knowledge graph, generating triplets in combination with large language models, and error detection and correction are performed to ensure the accuracy and relevance of triplets.
It significantly improves the accuracy of domain knowledge graph construction, reduces the impact of context noise and knowledge illusion, realizes automatic, accurate and controllable triple extraction, and improves natural language processing efficiency.
Smart Images

Figure CN118939812B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of domain knowledge graph construction, and in particular to a method for constructing a domain knowledge graph based on a large language model. Background Art
[0002] Knowledge graphs are structured data that represent human knowledge in a structured way. Existing knowledge graphs consist of a set of fact triples, which are head entities, relations, and tail entities. In recent years, knowledge graphs have been successfully applied to various fields, including medical science, biology, and social networks.
[0003] However, currently constructing domain knowledge graphs requires extensive expertise and manual intervention, which severely limits the practical application of domain knowledge graph construction.
[0004] With the development of large language models, methods for constructing knowledge graphs based on large language models have emerged. They extract triples from the original corpus by leveraging the prior knowledge stored in the large language model. However, existing construction methods face two challenges. First, the direct extraction of triples from the original context causes contextual noise in the input, which may distract the attention of the large language model and thus reduce its performance. Second, there is knowledge hallucination in the output, that is, it may generate content that is absurd or unfaithful to the source content, thereby generating some domain-irrelevant or incorrect triples. These incorrect triples may further propagate their errors to the next round of iterations, significantly affecting the credibility of the constructed domain knowledge graph.
[0005] Therefore, how to use large language models to automatically build professional and accurate general domain knowledge graphs to improve the efficiency of natural language processing in fields such as medicine, and ultimately improve the performance of natural language systems in fields such as medicine is a problem that needs to be solved.
[0006] In view of this, the present invention is proposed. Summary of the invention
[0007] The purpose of the present invention is to provide a method, device and medium for constructing a domain knowledge graph based on a large language model, which can use the large language model as a domain expert to improve the accuracy of domain knowledge graph construction, thereby solving the above-mentioned technical problems existing in the prior art.
[0008] The objective of the present invention is achieved through the following technical solutions:
[0009] A method for constructing a domain knowledge graph based on a large language model, comprising:
[0010] Step 1: determine the specified entity according to the domain knowledge graph to be constructed, and retrieve the most relevant context from the corresponding text domain corpus through the domain corpus retriever;
[0011] Step 2, retrieve the most relevant triples from the open source encyclopedia knowledge graph through an open knowledge retriever as triple examples;
[0012] Step 3, according to a predetermined input template, the specified entity, the most relevant context obtained in step 1, the triple example obtained in step 2, and the corresponding instruction are connected as inputs of the large language model, and the triples output by the large language model are stored in a memory;
[0013] Step 4, performing error detection on the triples output by the large language model stored in the memory of step 3 to obtain the error type;
[0014] Step 5, counting the number of error types in step 4, if the number of error types is lower than a predetermined threshold, giving relevant prompts according to the error types in step 4, re-prompting the large language model to generate and output a corrected triple, and storing the corrected triple in a memory, otherwise deleting the triple from the memory;
[0015] Step 6, determine whether the triples obtained in step 5 need to generate the next level. If not, directly merge the obtained triples into the new level of the generated domain knowledge graph. Otherwise, repeat steps 1 to 5 above. After reaching the preset number of triples, the construction of the domain knowledge graph is completed.
[0016] A processing device, comprising:
[0017] at least one memory for storing one or more programs;
[0018] At least one processor can execute one or more programs stored in the memory. When the one or more programs are executed by the processor, the processor can implement the method described in the present invention.
[0019] A readable storage medium stores a computer program, which can implement the method described in the present invention when the computer program is executed by a processor.
[0020] Compared with the prior art, the method, device and medium for constructing a domain knowledge graph based on a large language model provided by the present invention have the following beneficial effects:
[0021] Given a domain corpus, the processing power of a large language model can be used to automatically, accurately, and controllably extract triples. First, the present invention has achieved state-of-the-art accuracy in triple extraction under various settings, and the effect is significantly better than existing methods. Since the present invention can solve the problems of contextual noise and knowledge hallucination, the advantages of a large language model in triple extraction are fully utilized. Secondly, the present invention is a simple and effective method that can be effectively extended to various domain text corpora to achieve efficient and high-precision construction of domain knowledge graphs. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0023] Figure 1 A flowchart of a method for constructing a domain knowledge graph based on a large language model provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in combination with the specific content of the present invention; it is obvious that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments, which does not constitute a limitation of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.
[0025] First, the terms that may be used in this article are explained as follows:
[0026] The term “and / or” means that either or both of them can be realized at the same time. For example, X and / or Y means both “X” or “Y” and “X and Y”.
[0027] The terms "include", "comprises", "contains", "has" or other descriptions with similar semantics should be interpreted as non-exclusive inclusion. For example, including certain technical feature elements (such as raw materials, components, ingredients, carriers, dosage forms, materials, dimensions, parts, components, mechanisms, devices, steps, procedures, methods, reaction conditions, processing conditions, parameters, algorithms, signals, data, products or products, etc.) should be interpreted as including not only certain technical feature elements explicitly listed, but also other technical feature elements known in the art that are not explicitly listed.
[0028] The term "consisting of..." means excluding any technical feature elements not explicitly listed. If this term is used in a claim, it will make the claim closed, so that it does not contain technical feature elements other than the technical feature elements explicitly listed, except for the conventional impurities related to them. If this term only appears in a clause of a claim, it only limits the elements explicitly listed in the clause, and the elements recorded in other clauses are not excluded from the overall claim.
[0029] Unless otherwise specified or limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example: it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this article can be understood according to specific circumstances.
[0030] The orientation or position relationship indicated by terms such as "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", etc. are based on the orientation or position relationship shown in the drawings and are only for the convenience and simplification of description, and do not explicitly or implicitly indicate that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation of this document.
[0031] The scheme provided by the present invention is described in detail below. The contents not described in detail in the embodiments of the present invention belong to the prior art known to professionals in the field. If the specific conditions are not specified in the embodiments of the present invention, they are carried out according to the conventional conditions in the field or the conditions recommended by the manufacturer. If the manufacturers are not specified in the reagents or instruments used in the embodiments of the present invention, they are all conventional products that can be purchased commercially.
[0032] like Figure 1 As shown, an embodiment of the present invention provides a method for constructing a domain knowledge graph based on a large language model, including:
[0033] Step 1: determine the specified entity according to the domain knowledge graph to be constructed, and retrieve the most relevant context from the corresponding text domain corpus through the domain corpus retriever;
[0034] Step 2, retrieve the most relevant triples from the open source encyclopedia knowledge graph through an open knowledge retriever as triple examples;
[0035] Step 3, according to a predetermined input template, the specified entity, the most relevant context obtained in step 1, the triple example obtained in step 2, and the corresponding instruction are connected as inputs of the large language model, and the triples output by the large language model are stored in a memory;
[0036] Step 4, performing error detection on the triples output by the large language model stored in the memory of step 3 to obtain the error type;
[0037] Step 5, counting the number of error types in step 4, if the number of error types is lower than a predetermined threshold, giving relevant prompts according to the error types in step 4, re-prompting the large language model to generate and output a corrected triple, and storing the corrected triple in a memory, otherwise deleting the triple from the memory;
[0038] Step 6, determine whether the triples obtained in step 5 need to generate the next level. If not, directly merge the obtained triples into the new level of the generated domain knowledge graph. Otherwise, repeat steps 1 to 5 above. After reaching the preset number of triples, the construction of the domain knowledge graph is completed.
[0039] Preferably, in step 1 of the above method, the domain knowledge graph to be constructed is any one of a rice knowledge graph, a user association network knowledge graph, a medical knowledge graph, and a paper citation knowledge graph;
[0040] Preferably, in step 1 of the above method, the designated entity is a domain name of the domain in which the domain knowledge graph to be constructed is located or a set of randomly selected nouns in the domain.
[0041] Preferably, in step 1 of the above method, the corresponding text domain corpus refers to a collection of multiple text data collected and organized in the corresponding domain; each text data comes from at least one of books, articles, news, blogs, papers, social media, and web pages.
[0042] Preferably, in step 1 of the above method, the domain corpus retriever divides the corresponding text domain corpus into sentences, arranges the relevant sentences in descending order of relevance according to the frequency of occurrence of the specified entity, and then connects them into a text list, and connects the text list into a fixed-length text as the most relevant context obtained by the retrieval, and the fixed length of the text is set to an effective length not exceeding the input length of the large language model used, wherein the descending order of relevance is to sort in descending order according to the number of occurrences of the entity in the sentence, and the more times the entity appears in the sentence, the higher the relevance, and vice versa. For example, if the specified entity appears 5 times in the content of sentence a and 3 times in the content of sentence b, then according to the relevance a>b, that is, a is ranked before b in the text list.
[0043] Preferably, in step 2 of the above method, the open source encyclopedia knowledge graph is a knowledge graph based on open source technology and data;
[0044] In step 2, the search strategy of the open knowledge searcher is divided into three cases, including:
[0045] Case 1: If the specified entity appears in the open source encyclopedia knowledge graph, the specified entity is used as the head entity, and a maximum of 10 cases are retrieved in the open source encyclopedia knowledge graph as triple examples;
[0046] Case 2: If the specified entity does not appear in the open source encyclopedia knowledge graph, the specified entity is marked as a sub-entity, and the sub-entity is used as the head entity. A maximum of 10 cases are retrieved in the open source encyclopedia knowledge graph as triple examples;
[0047] Case 3: If neither the specified entity nor the labeled sub-entity appears in the open source encyclopedia knowledge graph, 10 triples in the open source encyclopedia knowledge graph are randomly selected as triple examples.
[0048] Preferably, in step 3 of the above method, the input template is: {relevant context}+"Please extract all triples related to "+{specified entity}+" from the above text, and the triples are output with "+{specified entity}+" as the head entity and strictly in the format of the following example sub-triplets, but do not output the following triple example".
[0049] Preferably, in step 4 of the above method, error detection includes: quantity detection, format detection and conflict detection, wherein:
[0050] The quantity detection is to detect that if the number of triples is less than a preset threshold, it is classified as an error type of insufficient quantity;
[0051] The format detection is to detect the error type that is classified as a format error if the triple does not conform to the example format;
[0052] The conflict detection is to perform a comprehensive conflict detection for each triple using the rules in Rule-Hub. If a conflict exists, it is classified as a conflict error type. The conflict error includes: head entity error and head-tail inconsistency error.
[0053] Preferably, in step 5 of the above method, the predetermined threshold is 50% of the total number of output triplets.
[0054] Preferably, in step 5 of the above method, the relevant prompt given is determined according to the error type, including:
[0055] If the error type is insufficient quantity, the relevant prompt given is: "Please regenerate strictly according to the requirements and pay attention to generating enough triplets";
[0056] If the error type is a format error, the relevant prompt given is: "Please regenerate strictly according to the format requirements, and pay attention to the format of the example triple";
[0057] If the error type is a formatted header entity error, the relevant prompt is: "Please regenerate strictly according to the requirements. Note that the header entity must be {specified entity}", where {specified entity} is filled in according to the actual situation;
[0058] If the error type is a format error or a head-tail inconsistency error, the relevant prompt given is: "Please regenerate strictly according to the format and requirements. Note that the head and tail entities are usually inconsistent."
[0059] Preferably, the pruning process in step 6 of the above method is based on a binary classification model obtained by fine-tuning the T5 model on the open source encyclopedia knowledge graph DBpedia;
[0060] Train the T5 model as follows: collect training data from DBpedia and select a subset of head entities as representatives of the “growing” category, and collect an equivalent subset of tail entities, excluding those entities that overlap with the list of head entities, to form representatives of the “pruning” category;
[0061] During fine-tuning, these entity texts are used as input and the corresponding labels “grown” or “pruned” as output targets.
[0062] The embodiment of the present invention further provides a processing device, including:
[0063] at least one memory for storing one or more programs;
[0064] At least one processor can execute one or more programs stored in the memory, and when the one or more programs are executed by the processor, the processor can implement the above method.
[0065] The embodiments of the present invention further provide a readable storage medium storing a computer program, which can implement the above method when the computer program is executed by a processor.
[0066] In summary, the construction method of the embodiment of the present invention, under the condition of a given domain corpus, can utilize the processing power of a large language model to automatically, accurately and controllably extract triples through an entity-induced tree search method, and an organic combination with generation, verification and pruning processes. First, the present invention has achieved the most advanced accuracy in triple extraction under various settings, and the effect is significantly better than the existing methods. Since the present invention can solve the problems of contextual noise and knowledge hallucination, it can give full play to the advantages of a large language model in triple extraction. Secondly, the present invention is a simple and effective method that can be effectively extended to various domain text corpora to achieve efficient and high-precision construction of domain knowledge graphs.
[0067] In order to more clearly demonstrate the technical solution and technical effects provided by the present invention, the knowledge graph construction system method provided by the embodiment of the present invention is described in detail with specific examples below.
[0068] Example 1
[0069] An embodiment of the present invention provides a method for constructing a domain knowledge graph based on a large language model, which introduces a large language model through an entity-induced tree search method and an organic combination with generation, verification and pruning processes to achieve excellent performance in the task of constructing a domain knowledge graph.
[0070] The method for constructing a domain knowledge graph based on a large language model includes the following steps:
[0071] Step 1: For a specified entity, the most relevant context is retrieved from the corresponding text domain corpus through the domain corpus retriever, which is then used as part of the input of the large language model.
[0072] The specified entity is usually a domain name or a set of randomly selected nouns in the domain. For example, for the rice domain, the specified entity can be a domain name "rice"; the specified entity can be a set of randomly selected nouns in the domain ["rice", "Longjing 12", "rice seedling disease", "sand leafhopper"].
[0073] The corresponding text domain corpus refers to a large collection of text data collected and organized in a specific field. These text data can come from various sources, including books, articles, news, blogs, papers, social media, web pages, etc. For example, a corpus in the rice field may include professional books in the rice field, agricultural reports, agricultural news, and agricultural websites, while a corpus in the medical field may include medical literature, clinical reports, and medical news.
[0074] The domain corpus retriever is used to return a list of related texts. The domain corpus retriever includes two algorithms and processes: text segmentation and word matching. Text segmentation uses the python built-in split() function, and word matching uses the python built-in count() function. Specifically, the domain corpus retriever divides the text domain corpus into sentences using the python built-in split() function, and then uses the python built-in count() function to count the frequency of occurrence of entities (i.e. keywords), and then sorts the related sentences in descending order of relevance according to the frequency of occurrence, and then connects them into a text list, and further connects the text list into a fixed-length text as the most relevant context obtained by the retrieval. The text length setting depends on the selected large language model to ensure that the input length of the large language model does not exceed the specified effective length.
[0075] Step 2: Retrieve the most relevant triples from the open source encyclopedia knowledge graph as triple examples through the open knowledge retriever.
[0076] An open source encyclopedia knowledge graph is a knowledge graph based on open source technology and data, which usually includes a wide range of topics and concepts, as well as the relationships between them. For example, DBpedia, Wikidata, and YAGO.
[0077] The search strategies of the open knowledge searcher can be divided into three situations, including:
[0078] Case 1: If the specified entity appears in the open source encyclopedia knowledge graph, the specified entity is used as the head entity, and a maximum of 10 cases are retrieved as examples. For example, taking "rice seedling disease" as the head entity, the search results include [[rice seedling disease, Chinese name, Fusarium moniliforme Sheld], [rice seedling disease, Latin name, Fusarium moniliforme Sheld], [rice seedling disease, damaged part, whole plant], [rice seedling disease, harmful crop, rice], [rice seedling disease, kingdom, fungi], [rice seedling disease, phylum, Ascomycota fungi]], a total of 6 triples;
[0079] Case 2: If the specified entity does not appear in the open source encyclopedia knowledge graph, the entity will be marked as a sub-entity, and the sub-entity will be used as the head entity, and up to 10 cases will be retrieved as examples. For example, given the entity "micropropagation", if it does not appear in the open source encyclopedia knowledge graph, it will be marked as two sub-entities "micro" and "propagation", and then retrieved from the open knowledge graph again;
[0080] Case 3: Neither the specified entity nor the labeled sub-entities appear in the open source encyclopedia knowledge graph, so 10 triples in the knowledge graph are randomly selected as examples.
[0081] Step 3, according to the input template, connect the specified entity, the most relevant context obtained in step 1, the triple example obtained in step 2 and the corresponding instruction as the input of the large language model, and store the triple output of the large language model in the memory.
[0082] The input template is: {Related context}+"Please extract all triples related to "+{specified entity}+" from the above text. The triples must be output with "+{specified entity}+" as the head entity and strictly in the format of the following example sub-triplets, but do not output the following example triples." An example of the input template is: \n"+{triplet example}+"\n......Please continue to output", where {Related context}, {specified entity} and {triplet example} are filled in according to the actual situation.
[0083] Step 4: Perform error detection on the triples output by the large language model stored in the memory of step 3 to obtain the error type.
[0084] There are three types of error detection, and the resulting error types are also divided into three types, including:
[0085] Type 1: Quantity detection: If the number of triplets is less than the preset threshold (the default is 3), it will be classified as "insufficient quantity";
[0086] Type 2: Format detection: If the triple does not conform to the example format, it will be classified as a format error. Furthermore, if the head entity does not match the predefined entity, it will be classified as a head entity error. If the head entity and the tail entity are the same, it will be classified as a head-tail contradiction;
[0087] Type 3: Conflict Detection: Comprehensive conflict detection is performed for each triple using the rules in Rule-Hub. If there is a conflict, it is classified as a conflict error. For example, ensuring that a person's birth time is before their death time, and that a person's age is not negative, etc.
[0088] Step 5, counting the number of error types in step 4, if the number of error types is lower than a predetermined threshold, providing corresponding prompts according to the error types in step 4, re-prompting the large language model to generate and output a corrected triplet, and storing the corrected triplet, otherwise, deleting the triplet from the memory.
[0089] The number of error types includes error types occurring in quantity detection, format detection, and conflict detection, and the predetermined threshold range is 0 to the total number of output triplets.
[0090] The corresponding prompt is determined according to the error type, including: if the error type is "insufficient quantity", the corresponding prompt is: "Please regenerate strictly according to the requirements, and pay attention to generating enough triples"; if the error type is "format error", the corresponding prompt is: "Please regenerate strictly according to the format requirements, and pay attention to the format of the example triples"; if the error type is "head entity error", the corresponding prompt is: "Please regenerate strictly according to the requirements, and pay attention that the head entity must be {specified entity}", where {specified entity} is filled according to the actual situation; if the error type is "head-tail contradiction", the corresponding prompt is: "Please regenerate strictly according to the format and requirements, and pay attention that the head and tail entities are usually inconsistent."
[0091] Step 6: Determine whether the corrected triples in Step 5 (i.e., the triples that have passed the verification process) need to be generated at the next level. If there is no need to generate at the next level, directly merge them into the new level of the generated knowledge graph; otherwise, repeat the above steps until the construction of the domain knowledge graph is completed.
[0092] The pruning process in Step 6 of the above method is to fine-tune the T5 model on the open-source encyclopedia knowledge graph DBpedia to obtain a binary classification model. To train this T5 model, training data is collected from DBpedia, and a part of the head entities are selected as representatives of the "growing" category, and an equivalent subset of tail entities is collected, excluding those entities that overlap with the head entity list, to form the representatives of the "pruning" category. During fine-tuning, these entity texts are used as inputs, and the corresponding labels "growing" or "pruning" are used as output targets. For example, the triples that need to be generated at the next level can be [rice, disease, bakanae disease of rice], and bakanae disease of rice can be used as a meaningful head entity for further generation at the next level, while the triples that do not need to be generated at the next level can be [You 03 You 66, plant height, 84.9 cm], and 84.9 cm, as a leaf node, does not need to grow further.
[0093] The comparison of the existing knowledge graph construction methods and the domain knowledge graph construction method based on large language models of the present invention in terms of the triple extraction precision rate is shown in Table 1. The domain knowledge graph construction method based on large language models of the present invention has greatly improved the triple extraction precision rate, and greatly improved the knowledge graph construction efficiency.
[0094] Table 1 shows the comparison data of the existing knowledge graph construction method and the construction method of the present invention in terms of the triple extraction precision rate
[0095] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0096] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed in the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims. The information disclosed in the background technology section of this article is only intended to deepen the understanding of the overall background technology of the present invention, and should not be regarded as an admission or in any form that the information constitutes prior art known to those skilled in the art.
Claims
1. A method for constructing a domain knowledge graph based on a large language model, characterized in that: include: Step 1: determine the specified entity according to the domain knowledge graph to be constructed, and retrieve the most relevant context from the corresponding text domain corpus through the domain corpus retriever; Step 2, retrieve the most relevant triples from the open source encyclopedia knowledge graph through an open knowledge retriever as triple examples; Step 3, according to a predetermined input template, the specified entity, the most relevant context obtained in step 1, the triple example obtained in step 2, and the corresponding instruction are connected as inputs of the large language model, and the triples output by the large language model are stored in a memory; Step 4, performing error detection on the triples output by the large language model stored in the memory of step 3 to obtain the error type; Step 5, counting the number of error types in step 4, if the number of error types is lower than a predetermined threshold, giving relevant prompts according to the error types in step 4, re-prompting the large language model to generate and output a corrected triple, and storing the corrected triple in a memory, otherwise deleting the triple from the memory; Step 6, determine whether the triples obtained in step 5 need to generate the next level. If it is not necessary to generate the next level, directly merge the corrected triples into the new level of the generated domain knowledge graph. Otherwise, repeat steps 1 to 5 above. After reaching the preset number of triples, the construction of the domain knowledge graph is completed.
2. The method for constructing a domain knowledge graph based on a large language model according to claim 1, characterized in that: In the step 1, the domain knowledge graph to be constructed is any one of a rice knowledge graph, a user association network knowledge graph, a medical knowledge graph, and a paper citation knowledge graph; In step 1, the designated entity is a domain name of the domain where the domain knowledge graph to be constructed is located or a set of nouns randomly selected in the domain; In the step 1, the corresponding text domain corpus refers to a collection of multiple text data collected and organized in the corresponding domain; Each text data comes from at least one of books, articles, news, blogs, papers, social media, and web pages; In step 1, the most relevant context is retrieved from the corresponding text domain corpus by a domain corpus retriever in the following manner, including: The corresponding text domain corpus is segmented into sentences by a domain corpus retriever, and the segmented sentences are sorted in descending order of relevance according to the frequency of occurrence of a specified entity and then connected into a text list, and the text list is connected into a fixed-length text as the most relevant context obtained by the retrieval, and the fixed length of the text is set to an effective length not exceeding the input length limit of the large language model used, wherein the relevance descending order is to sort in descending order according to the number of occurrences of the entity in the sentence.
3. The method for constructing a domain knowledge graph based on a large language model according to claim 1 or 2, characterized in that: In step 2, the open source encyclopedia knowledge graph is a knowledge graph based on open source technology and data; In step 2, the search strategy of the open knowledge searcher is divided into three cases, including: Case 1: If the specified entity appears in the open source encyclopedia knowledge graph, the specified entity is used as the head entity, and a maximum of 10 cases are retrieved in the open source encyclopedia knowledge graph as triple examples; Case 2: If the specified entity does not appear in the open source encyclopedia knowledge graph, the specified entity is marked as a sub-entity, and the sub-entity is used as the head entity. A maximum of 10 cases are retrieved in the open source encyclopedia knowledge graph as triple examples; Case 3: If neither the specified entity nor the labeled sub-entity appears in the open source encyclopedia knowledge graph, 10 triples in the open source encyclopedia knowledge graph are randomly selected as triple examples.
4. The method for constructing a domain knowledge graph based on a large language model according to claim 1 or 2, characterized in that: In step 3, the predetermined input template is: {related context}+"Please extract all triples related to "+{specified entity}+" from the above text, and the triples are output with "+{specified entity}+" as the head entity and strictly in the format of the following example sub-triplets, but do not output the following triple example".
5. The method for constructing a domain knowledge graph based on a large language model according to claim 1 or 2, characterized in that: In step 4, error detection includes: quantity detection, format detection and conflict detection, wherein: The quantity detection is to detect that if the number of triples is less than a preset threshold, it is classified as an error type of insufficient quantity; The format detection is to detect the error type that is classified as a format error if the triple does not conform to the example format; The conflict detection is to perform a comprehensive conflict detection for each triplet using the rules in the Rule-Hub. If a conflict exists, it is classified as a conflict error type. The conflict error includes: head entity error and head-tail inconsistency error.
6. The method for constructing a domain knowledge graph based on a large language model according to claim 1 or 2, characterized in that: In step 5, the predetermined threshold is 50% of the total number of output triplets.
7. The method for constructing a domain knowledge graph based on a large language model according to claim 1 or 2, characterized in that: In step 5, the related prompts given are determined according to the error type, including: If the error type is insufficient quantity, the relevant prompt given is: "Please regenerate strictly according to the requirements and pay attention to generating enough triplets"; If the error type is format error, the relevant prompt given is: "Please regenerate strictly according to the format requirements, and pay attention to the format of the example triple"; If the error type is a formatted header entity error, the relevant prompt is: "Please regenerate strictly according to the requirements. Note that the header entity must be {specified entity}", where {specified entity} is filled in according to the actual situation; If the error type is a format error or a head-tail inconsistency error, the relevant prompt given is: "Please regenerate strictly according to the format and requirements. Note that the head and tail entities are usually inconsistent." 8. The method for constructing a domain knowledge graph based on a large language model according to claim 1 or 2, characterized in that: In step 6, the model for determining whether the triples obtained in step 5 need to be generated at the next level is a binary classification model obtained by fine-tuning the T5 model on the open source encyclopedia knowledge graph DBpedia; The T5 model is trained in the following manner: training data is collected from the open source encyclopedia knowledge graph DBpedia, where there are a large number of triple lists stored in the form of head entities, relations, and tail entities; a predetermined number of head entities are randomly selected from the triple lists as entity sets of the growing categories, and an equal number of pruned entity sets are randomly collected, wherein all the pruned entity sets contain tail entities, and the tail entities are required not to overlap with the entities in the head entity list; During fine-tuning, supervised fine-tuning and cross entropy loss function are adopted, that is, these entity texts are used as input of the T5 model, with corresponding label growth or pruning as the labels to be predicted.
9. A processing device, characterized in that: include: at least one memory for storing one or more programs; At least one processor is capable of executing one or more programs stored in the memory, and when the one or more programs are executed by the processor, the processor is capable of implementing the method described in any one of claims 1 to 8.
10. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 can be implemented.
Citation Information
Patent Citations
Government affair service field multi-strategy fusion dialogue method based on knowledge graph
CN116628172A
Autonomous open schema construction from unstructured text
US20220300544A1
