A knowledge graph construction method and device, electronic equipment and storage medium

By acquiring a set of subtexts, determining the target text category, and using target prompt word engineering, triples are extracted using a specified large model. This solves the problem of low confidence in knowledge graphs and enables the construction of high-confidence knowledge graphs, which are applicable to professional fields such as medicine, finance, and law.

CN121009197BActive Publication Date: 2026-02-10ZHEJIANG LAB
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511538380.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-27
Publication Date
2026-02-10
Estimated Expiration
2045-10-27

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively improve the confidence level of knowledge graphs, especially in professional fields such as medicine, finance, and law, where knowledge graph construction methods lack precision and accuracy.

Method used

By acquiring a set of subtexts, the target text category is determined based on a pre-built mapping relationship. Triples are extracted from the subtexts using target prompt word engineering and a specified large model. A knowledge graph is then constructed, including techniques such as generating predefined and custom ontologies, validating model scoring, and fine-tuning low-rank matrices.

Benefits of technology

It improves the granularity and confidence of knowledge graphs, meets the high confidence requirements of professional fields, expands the application areas, and reduces development and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121009197B_ABST
    Figure CN121009197B_ABST
Patent Text Reader

Abstract

The application provides a knowledge graph construction method and device, electronic equipment and storage medium, and relates to the field of knowledge graph. A subtext set used for constructing a knowledge graph of a specified field is obtained; based on a pre-constructed mapping relationship, a target text category corresponding to each subtext in the subtext set is obtained; the mapping relationship is a corresponding relationship between a subtext and a text category; from a prompt word engineering set constructed according to the target text category, a target prompt word engineering corresponding to the target text category is determined; based on the target prompt word engineering, a triple is extracted from the subtext by a specified large model; and the knowledge graph is constructed based on the triple. Each triple is extracted from each subtext in the subtext set, and the prompt word engineering set used when the triple is extracted is pre-constructed according to the text category, so that each triple extracted from the subtext set is more accurate and accurate, thereby improving the confidence of the knowledge graph constructed based on the triple.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of knowledge graph, and in particular to a knowledge graph construction method and device, an electronic device, and a storage medium. BACKGROUND

[0002] A knowledge graph is a structured semantic network used to describe the relationship between entities and entities, and can visualize complex knowledge in a graphical manner. The confidence of a knowledge graph is crucial, especially in professional fields such as medicine, finance, and law. A knowledge graph with high confidence can provide solid and reliable knowledge support for related decisions based on the knowledge graph. Therefore, a knowledge graph construction method that can improve the confidence of a knowledge graph is needed. SUMMARY

[0003] Therefore, the present application provides a knowledge graph construction method, which comprises:

[0004] obtaining a set of subtexts for constructing a knowledge graph of a specified field;

[0005] Based on a pre-constructed mapping relationship, obtaining a target text category corresponding to each subtext in the set of subtexts; the mapping relationship is the correspondence between subtexts and text categories;

[0006] From the set of prompt word engineering constructed according to the target text category, determine the target prompt word engineering corresponding to the target text category;

[0007] Based on the target prompt word engineering, extracting triples from the subtext by a specified large model;

[0008] Based on the triples, constructing the knowledge graph.

[0009] Optionally, the pre-constructed mapping relationship comprises:

[0010] obtaining an original text for constructing the knowledge graph;

[0011] determining an initial text category included in the original text by a specified classification model;

[0012] dividing the original text into each subtext according to the initial text category to obtain the set of subtexts;

[0013] determining a matching value between the subtext and the corresponding initial text category; the matching value is used to represent the confidence of the subtext belonging to the corresponding initial text category;

[0014] extract a first subtext with a matching value greater than a preset value, and add a corresponding relationship between the first subtext and an initial text category corresponding to the first subtext to the mapping relationship;

[0015] extract a second subtext with a matching value not greater than the preset value, obtain an added text category of the second subtext, and add a corresponding relationship between the second subtext and the added text category corresponding to the second subtext to the mapping relationship.

[0016] Optionally, the constraint condition in the prompt word engineering includes:

[0017] extract a keyword of the subtext;

[0018] determine a target predefined ontology corresponding to the subtext from a predefined ontology set constructed according to the target text category;

[0019] when the keyword belongs to the target predefined ontology, generate a triple based on the target predefined ontology;

[0020] when the keyword does not belong to the target predefined ontology, generate a custom ontology according to the keyword, and generate a triple based on the custom ontology.

[0021] Optionally, the constructing a predefined ontology set according to the target text category includes:

[0022] constructing each predefined ontology according to each target text category corresponding to each subtext, and adding each predefined ontology to the predefined ontology set;

[0023] after generating the custom ontology according to the keyword, obtain a verification result; the verification result includes a pass result used to represent that the custom ontology passes artificial verification;

[0024] when the verification result is the pass result, add the custom ontology to the predefined ontology set.

[0025] Optionally, after the extracting the triple from the subtext by the specified large model based on the target prompt word engineering, the method further includes:

[0026] scoring the current triple by a verification model to obtain a quality score; the quality score is used to represent a confidence of the triple; the quality score is positively correlated with the confidence;

[0027] when the quality score is greater than a first threshold value, the current triple is taken as the triple;

[0028] When the quality score is greater than the second threshold and less than or equal to the first threshold, a corrected triplet is obtained for the current triplet, and the corrected triplet is used as the current triplet. The process then proceeds to the step of scoring the current triplet using a validation model to obtain a quality score; the second threshold is less than the first threshold.

[0029] When the quality score is less than or equal to the second threshold, the current triplet is removed.

[0030] Optionally, after using the current triple as the triple, the method further includes:

[0031] Add a low-rank matrix to a specified layer in the specified large model;

[0032] The triplet and its corresponding subtext are used to form a training sample;

[0033] The specified large model is fine-tuned using the training samples to adjust the parameters of the low-rank matrix.

[0034] Optionally, after extracting triples from the subtext using a specified large model based on the target prompt word engineering, the method further includes:

[0035] Identify the source object in the triple; the source object includes at least one of proper nouns and factual knowledge;

[0036] Obtain tracing information associated with the object to be traced from a specified knowledge base in the specified domain;

[0037] Extract triplet elements from the source information; the triplet elements include at least one of entity, relation, and attribute.

[0038] Based on the triplet elements, a tracing triplet associated with the object to be traced is generated, and the tracing triplet is added to the triplet corresponding to the subtext.

[0039] This application also provides a knowledge graph construction apparatus, the apparatus comprising:

[0040] The subtext set acquisition module is used to acquire a subtext set for constructing a knowledge graph in a specified domain.

[0041] The target category acquisition module is used to acquire the target text category corresponding to each subtext in the subtext set based on a pre-built mapping relationship; the mapping relationship is the correspondence between subtexts and text categories;

[0042] The target prompt word determination module is used to determine the target prompt word project corresponding to the target text category from the prompt word project set constructed according to the target text category;

[0043] The triplet extraction module is used to extract triplets from the subtext based on the target prompt word project and by specifying a large model.

[0044] The knowledge graph construction module is used to construct the knowledge graph based on the triples.

[0045] This application also provides an electronic device, including:

[0046] Memory, used to store computer programs;

[0047] A processor, used to implement the steps of any of the above-described knowledge graph construction methods when executing the computer program.

[0048] This application also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described knowledge graph construction methods.

[0049] In summary, this application provides a method, apparatus, electronic device, and storage medium for constructing a knowledge graph. The process involves: obtaining a set of sub-texts for constructing a knowledge graph in a specified domain; obtaining the target text category corresponding to each sub-text in the sub-text set based on a pre-constructed mapping relationship; the mapping relationship being the correspondence between sub-texts and text categories; determining the target prompt word project corresponding to the target text category from a set of prompt word projects constructed based on the target text category; extracting triples from the sub-texts based on the target prompt word project using a specified large model; and constructing the knowledge graph based on the triples.

[0050] As can be seen, this application extracts triples from each subtext in the subtext set separately; on the other hand, the set of prompt words used when extracting triples is pre-constructed according to the text category, so as to utilize the target prompt word engineering corresponding to the subtext to extract triples from the subtext more specifically, making the extracted triples more refined and accurate, thereby improving the confidence of the knowledge graph constructed based on triples. Attached Figure Description

[0051] Figure 1 A first flowchart illustrating a knowledge graph construction method provided in this application;

[0052] Figure 2 A second flowchart of a knowledge graph construction method provided in this application;

[0053] Figure 3A third flowchart illustrating a knowledge graph construction method provided in this application;

[0054] Figure 4 A schematic diagram of the structure of a knowledge graph construction device provided in this application;

[0055] Figure 5 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation

[0056] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0057] Please refer to Figure 1 , Figure 1 A first flowchart of a knowledge graph construction method provided in this application, the method comprising:

[0058] S101. Obtain the sub-text set used to construct a knowledge graph for a specified domain.

[0059] The knowledge graph construction method provided in this application is applicable to various fields. The specified fields can be general fields containing a large amount of common sense knowledge, or professional fields such as medicine, finance and law. This application does not make any special limitations on these fields.

[0060] The aforementioned sub-text set is obtained by dividing the original text used to construct a knowledge graph for a specific domain according to certain text categories. Different original texts include different text categories. For example, when constructing a knowledge graph for a book in the field of social development, this book is the original text, and its text categories might include economic development, social development, and cultural development, etc. For original text in the medical field, its text categories might include basic medicine and clinical medicine, etc. Subsequent embodiments will introduce the method for determining the text categories included in the original text, which will not be elaborated here.

[0061] S102. Based on the pre-built mapping relationship, obtain the target text category corresponding to each subtext in the subtext set; the mapping relationship is the correspondence between subtexts and text categories.

[0062] To improve the precision of the triples required for constructing a knowledge graph, this application extracts triples for each subtext in the subtext set separately. Furthermore, it pre-constructs a set of prompt word projects based on the target text category corresponding to each subtext, with each prompt word project in the set corresponding to a target text category. When constructing the knowledge graph, for each subtext, a target prompt word project is selected from the prompt word project set based on the target text category corresponding to that subtext. Then, this target prompt word project is used to extract triples from the subtext in a more targeted manner.

[0063] To achieve the above objectives, this application pre-constructs a mapping relationship based on the correspondence between subtexts and text categories. The method for constructing this mapping relationship will be explained in subsequent embodiments and will not be elaborated here. Based on this, when constructing a knowledge graph, the target text category corresponding to each subtext in the subtext set can be determined using the above mapping relationship, so as to subsequently determine the target prompt word project based on the target text category.

[0064] S103. From the set of prompt word projects constructed based on the target text category, determine the target prompt word project corresponding to the target text category.

[0065] As mentioned above, this application pre-constructs a set of prompt word projects based on the target text categories. This set includes prompt word projects that correspond one-to-one with each target text category. The constraints on these prompt word projects will be explained in subsequent embodiments and will not be repeated here.

[0066] When constructing a knowledge graph, based on the target text category corresponding to the previously determined subtext, target prompt word projects are determined from the prompt word project set. Then, the target prompt word projects are used to extract triples from the subtext in a targeted manner, thereby improving the precision of the triples required for constructing the knowledge graph.

[0067] S104. Based on target prompt word engineering, extract triples from subtexts by specifying a large model.

[0068] After determining the target prompt word project corresponding to the subtext, the specified large model is guided to extract triples from the subtext based on the target prompt word project. This application does not impose any special limitations on the type of the specified large model or the process of the specified large model extracting triples, and can be adjusted according to actual needs.

[0069] S105. Construct a knowledge graph based on triples.

[0070] After extracting triples from all subtexts in the subtext set using a specified large model, a knowledge graph is constructed based on each triple. This application does not impose any particular limitations on the specific process of constructing the knowledge graph. For example, the triples corresponding to each subtext are deduplicated and standardized to unify the representation of entities, relations, and attributes; then, steps such as entity alignment, relation fusion, attribute fusion, and conflict resolution are performed to complete the construction of a knowledge graph for the specified domain.

[0071] In summary, this application provides a method for constructing a knowledge graph, comprising: obtaining a set of sub-texts for constructing a knowledge graph of a specified domain; obtaining the target text category corresponding to each sub-text in the sub-text set based on a pre-constructed mapping relationship; the mapping relationship being the correspondence between sub-texts and text categories; determining the target prompt word project corresponding to the target text category from a set of prompt word projects constructed based on the target text category; extracting triples from the sub-texts based on the target prompt word project using a specified large model; and constructing a knowledge graph based on the triples.

[0072] As can be seen, this application extracts triples from each subtext in the subtext set separately. Furthermore, the cue word engineering set used for triple extraction is pre-constructed based on text categories. This allows for more targeted extraction of triples from subtexts using the target cue word engineering corresponding to each subtext, improving the precision of the extracted triples and thus enhancing the confidence of the knowledge graph constructed based on the triples. This meets the confidence requirements of knowledge graphs in fields such as medicine, finance, and law, expanding the application scope. Moreover, the knowledge graph construction method provided in this application is relatively simple, and the development and maintenance costs are controllable.

[0073] The process of constructing the mapping relationship is explained below.

[0074] As an optional implementation, the mapping relationship is pre-built, including:

[0075] Obtain the raw text used to construct the knowledge graph;

[0076] By specifying a classification model, the initial text categories included in the original text are determined;

[0077] The original text is divided into subtexts according to the initial text category, resulting in a set of subtexts;

[0078] Determine the matching value between the subtext and the corresponding initial text category; the matching value is used to characterize the confidence that the subtext belongs to the corresponding initial text category;

[0079] Extract the first subtext whose matching value is greater than the preset value, and add the correspondence between the first subtext and the initial text category corresponding to the first subtext to the mapping relationship;

[0080] Extract the second subtext whose matching value is not greater than a preset value, obtain the new text category of the second subtext, and add the correspondence between the second subtext and the new text category corresponding to the second subtext to the mapping relationship.

[0081] In this embodiment, the original text used to construct the knowledge graph is first obtained, and then the initial text categories included in the original text are determined by a specified classification model. This embodiment does not impose any particular limitations on the type of specified large model or the specific process for determining the initial text categories. For example, appropriate prompt word engineering can be used to guide the specified classification model to recognize and understand the overall content of the original text, and then determine the initial text categories included in the original text. Subsequently, experts in the specified domain use the initial text categories determined by the specified classification model as a reference, and adjust the initial text categories based on their domain expertise. This approach can both improve the efficiency of determining the initial text categories by utilizing the specified classification model and improve the accuracy of the determined initial text categories by utilizing the professional opinions of domain experts.

[0082] After determining the initial text categories, the original text is divided into subtexts according to these categories, resulting in a set of subtexts. These initial categories are not equivalent to the original text's own categorization; rather, they represent a reclassification of the original text from the perspective of text categories. For example, a book in the field of social development might contain articles categorized by date. However, when constructing the knowledge graph, the initial text categories identified as economic development, social development, and cultural development are determined. Based on these initial categories, the book is then divided into subtexts related to economic development, social development, and cultural development. This demonstrates that for non-standardized original text within a specified domain, dividing it according to text categories to obtain standardized subtexts, then extracting triples from each subtext, and constructing the knowledge graph ensures the confidence level of the knowledge graph.

[0083] Please refer to Figure 2 , Figure 2 This is a second flowchart of a knowledge graph construction method provided in this application. After dividing the original text into subtexts according to the initial text category, the matching value between the subtext and the corresponding initial text category is further determined. The matching value represents the confidence that the subtext belongs to the corresponding initial text category. This embodiment does not limit the specific implementation of determining the matching value. For example, the large model is guided to determine the core theme or main intent of the subtext, and it is judged whether the core theme or main intent can be accurately described by the initial text category corresponding to the subtext, and a matching value is generated based on the judgment result.

[0084] For the first subtext with a matching value greater than a preset value, it indicates a high confidence level that the first subtext belongs to the corresponding initial text category. The correspondence between the first subtext and its corresponding initial text category is added to the mapping relationship. This ensures that the mapping relationship can be used to accurately determine the target prompt word and accurately extract triples from the subtext.

[0085] For second subtexts with a matching value no greater than a preset value, it indicates that the confidence level of the second subtext belonging to the corresponding initial text category is low. If the target prompt word engineering corresponding to the initial text category is directly used to extract triples from the second subtext, the quality of the extracted triples may be poor. Therefore, this embodiment obtains the newly added text category corresponding to the second subtext and adds the correspondence between the second subtext and the corresponding newly added text category to the mapping relationship. This embodiment does not specifically limit the method for determining the newly added text category. For example, experts in a designated field can manually supplement the newly added text category corresponding to the second subtext based on their professional knowledge.

[0086] The above preset values ​​can be set according to actual needs. For example, when the confidence level of the knowledge graph is required to be high in a specific field, the preset value can be increased.

[0087] In summary, this embodiment divides the original text into sub-texts according to the initial text category. Based on the matching value between the sub-text and the corresponding initial text category, a mapping relationship between the sub-text and the text category is constructed to ensure the accuracy of extracting triples from the sub-text and improve the confidence of the constructed knowledge graph.

[0088] The constraints in the prompt word project are explained below.

[0089] As an optional implementation, the constraints in the prompt word engineering include:

[0090] Extract keywords from subtext;

[0091] From the set of predefined ontologies constructed based on the target text category, determine the target predefined ontology corresponding to the subtext;

[0092] When the keyword belongs to the target predefined ontology, a triple is generated based on the target predefined ontology;

[0093] When the keyword does not belong to the target predefined ontology, a custom ontology is generated based on the keyword, and triples are generated based on the custom ontology.

[0094] In this embodiment, by setting constraints in the aforementioned prompt word engineering, a designated large model is guided to extract keywords from the subtext. Keywords may include words belonging to entities, relations, and attributes. A target predefined ontology corresponding to the subtext is determined from a predefined ontology set. The predefined ontology set includes target predefined ontologs that correspond one-to-one with each target text category. The target predefined ontology defines the entities, relations, and attributes involved in the corresponding target text category. When a keyword belongs to a target predefined ontology, a triple is generated based on the target predefined ontology. When a keyword does not belong to a target predefined ontology, the designated large model generates a custom ontology based on the keyword and generates a triple based on the custom ontology.

[0095] Please refer to Figure 2 , Figure 2 This is a second flowchart of a knowledge graph construction method provided in this application. Figure 2 As shown, on the one hand, the large model is specified to determine the target predefined ontology from a multi-dimensional set of predefined ontology, so as to extract triples from the subtext based on the target predefined ontology and the corresponding prompt words; on the other hand, the large model is specified to generate a custom ontology to supplement the set of predefined ontology when the keywords in the subtext do not belong to the target predefined ontology.

[0096] In summary, this embodiment pre-constructs a predefined ontology set based on the target text category, guides the specified large model to determine the target predefined ontology based on the target text category corresponding to the sub-text through constraints in the prompt word engineering, and allows the specified large model to generate a custom ontology when the predefined ontology set is incomplete, ensuring the precision of the extracted triples.

[0097] In addition, constraints in the prompt word project can also include: defining the specified domain, the output format of the extracted triples, etc., and the constraints in the prompt word project can be adjusted according to actual needs.

[0098] As an optional implementation, a predefined ontology set is constructed based on the target text category, including:

[0099] Based on the target text category corresponding to each subtext, construct each predefined ontology and add each predefined ontology to the predefined ontology set;

[0100] After generating a custom ontology based on keywords, obtain the verification results; the verification results include the pass result used to characterize the custom ontology passing manual verification;

[0101] When the verification result is successful, the custom ontology is added to the predefined ontology collection.

[0102] In this embodiment, a predefined ontology is constructed based on the target text category of each subtext, with different target text categories corresponding to different predefined ontologies. Even when constructing a knowledge graph from highly non-standardized and discrete text features of the original text, triples can be extracted specifically based on the predefined ontologies corresponding to each subtext, thereby improving the confidence of the knowledge graph constructed based on triples.

[0103] When adding a custom ontology to a specified large model, the specified large model outputs the custom ontology for manual verification by experts. Once the custom ontology passes manual verification, it is then added to the predefined ontology set. By introducing expert verification, the use of predefined ontology containing implicit errors to extract triples is avoided, ensuring the confidence level of the final constructed knowledge graph.

[0104] In summary, the predefined ontology set constructed in this embodiment includes both predefined ontology designed by experts based on the target text category and verified custom ontology generated by a specified large model, making the predefined ontology set more comprehensive.

[0105] As an optional embodiment, after extracting triples from subtexts using a specified large model based on target cue word engineering, the method further includes:

[0106] The current triples are scored using a validation model to obtain a quality score; the quality score is used to characterize the confidence level of the triples; the quality score is positively correlated with the confidence level.

[0107] When the quality score is greater than the first threshold, the current triplet is taken as the triplet.

[0108] When the quality score is greater than the second threshold and less than or equal to the first threshold, obtain the corrected triplet for the current triplet, and use the corrected triplet as the current triplet. Then proceed to the step of scoring the current triplet through the validation model to obtain the quality score; the second threshold is less than the first threshold.

[0109] When the quality score is less than or equal to the second threshold, the current triplet is removed.

[0110] In this embodiment, the current triples are scored using a validation model to obtain a quality score that characterizes the confidence level of the triples. A higher quality score indicates a higher confidence level for the triples. Based on the quality score of the current triples, the current triples are then differentiated.

[0111] Specifically, when the quality score is greater than the first threshold, the current triplet is taken as the triplet; when the quality score is greater than the second threshold but less than or equal to the first threshold, the triplet after correction is obtained; the corrected triplet can be the triplet obtained after expert correction; then the corrected triplet is taken as the current triplet and its quality score is determined; when the quality score is less than or equal to the second threshold, the current triplet is removed to avoid affecting the quality of the knowledge graph.

[0112] In addition, please refer to Figure 2 , Figure 2 This is a second flowchart illustrating a knowledge graph construction method provided in this application. When the confidence requirement for the knowledge graph is relatively high in a specific domain, the current triples, quality scores, and subtexts can all be output. Experts in the specified domain can then perform differential verification on the current triples based on the quality scores and the subtexts, and use the verified triples as the triples for subsequent knowledge graph construction. For example, when the quality score is high, experts can perform rapid verification on the current triples based on the subtexts; when the quality score is low, experts can perform fine-grained verification and adjustment on the current triples based on the subtexts.

[0113] This embodiment does not impose any special limitations on the values ​​of the first and second thresholds; they can be set according to actual needs. For example, when the confidence level of the knowledge graph is required to be high in a specific domain, the values ​​of the first and second thresholds can be increased.

[0114] As an optional embodiment, after using the current triplet as a triplet, the method further includes:

[0115] Add a low-rank matrix to a specified layer in a specified large model;

[0116] The triples and their corresponding subtexts are combined to form training samples;

[0117] Fine-tuning of a large model using training samples adjusts the parameters of the low-rank matrix.

[0118] In this embodiment, triples and sub-texts are also used to form training samples for fine-tuning the specified large model, thereby improving its ability to understand domain-specific and complex sentence structures. The triples used in the training samples are those with a quality score greater than a first threshold, i.e., triples with high confidence. The high quality of the training samples ensures the effectiveness of fine-tuning the specified large model and improves the accuracy of the constructed knowledge graph.

[0119] Please refer to Figure 2 , Figure 2 The second flowchart of the knowledge graph construction method provided in this application can also be as follows: Figure 2As shown, expert-verified triples and their corresponding sub-texts are used as training samples to fine-tune a specified large model. The quality of the training samples is also relatively high, ensuring the effectiveness of fine-tuning the specified large model and improving the accuracy of the constructed knowledge graph.

[0120] Furthermore, the LoRA (Low-Rank Adaptation) training method is adopted, which adjusts only the parameters of the low-rank matrix in the specified large model during fine-tuning training, avoiding the risk of overfitting and ensuring the confidence of the constructed knowledge graph.

[0121] Please refer to Figure 3 , Figure 3 The third flowchart of a knowledge graph construction method provided in this application.

[0122] As an optional embodiment, after extracting triples from subtexts using a specified large model based on target cue word engineering, the method further includes:

[0123] S301. Identify the source object in the triple; the source object includes at least one of proper nouns and factual knowledge;

[0124] S302. Obtain tracing information associated with the object to be traced from a specified knowledge base in a specified domain; extract triple elements from the tracing information; triple elements include at least one of entity, relation, and attribute;

[0125] S303. Based on the triplet elements, generate a source tracing triplet associated with the object to be traced, and add the source tracing triplet to the triplet corresponding to the subtext.

[0126] In this embodiment, based on a designated knowledge base within a designated domain, external tracing is performed on the objects to be traced in the triples to obtain tracing information associated with the objects in the designated knowledge base. It is important to emphasize that the objects to be traced in this embodiment only include at least one of proper nouns and factual knowledge to avoid introducing interfering information. The designated knowledge base can be selected according to actual needs; for example, a knowledge base consisting of Wikipedia entries belonging to a designated domain can be used as tracing information for the entries associated with the objects to be traced.

[0127] Subsequently, triplet elements are extracted from the source information, source triplets associated with the object to be traced are generated based on the triplet elements, and the source triplets are added to the triplets corresponding to the subtext to enhance the richness and practicality of the knowledge graph constructed based on the triplets.

[0128] In summary, this embodiment, based on a specified database, performs external tracing of the objects to be traced in the triples, and generates tracing triples based on the obtained tracing information. This serves as supplementary information when constructing the knowledge graph, enriching its content. Furthermore, this embodiment performs external tracing of proper nouns and / or factual knowledge within the triples after extracting them using a specified large model, avoiding the introduction of noise and ensuring the confidence level of the final constructed knowledge graph.

[0129] Please refer to Figure 4 , Figure 4 A schematic diagram of a knowledge graph construction device provided in this application, the device comprising:

[0130] The subtext set acquisition module 401 is used to acquire a subtext set for constructing a knowledge graph in a specified domain.

[0131] The target category acquisition module 402 is used to acquire the target text category corresponding to each subtext in the subtext set based on a pre-built mapping relationship; the mapping relationship is the correspondence between subtexts and text categories.

[0132] The target prompt word determination module 403 is used to determine the target prompt word project corresponding to the target text category from the prompt word project set constructed according to the target text category.

[0133] The triple extraction module 404 is used to extract triples from subtexts based on target prompt word engineering by specifying a large model.

[0134] Graph construction module 405 is used to construct knowledge graphs based on triples.

[0135] For a detailed description of the knowledge graph construction apparatus provided in this application, please refer to the embodiments of the knowledge graph construction method described above; further details will not be repeated here.

[0136] As an optional embodiment, the device further includes:

[0137] The text acquisition module is used to acquire the raw text for constructing the knowledge graph;

[0138] The initial classification module is used to determine the initial text categories included in the original text by specifying a classification model;

[0139] The text segmentation module is used to divide the original text into sub-texts according to the initial text category, thus obtaining a set of sub-texts.

[0140] The matching value determination module is used to determine the matching value between the subtext and the corresponding initial text category; the matching value is used to characterize the confidence that the subtext belongs to the corresponding initial text category;

[0141] The first mapping module is used to extract the first subtext whose matching value is greater than the preset value, and add the correspondence between the first subtext and the initial text category corresponding to the first subtext to the mapping relationship;

[0142] The second mapping module is used to extract the second sub-text whose matching value is not greater than a preset value, obtain the new text category of the second sub-text, and add the correspondence between the second sub-text and the new text category corresponding to the second sub-text to the mapping relationship.

[0143] As an optional implementation, the constraints in the prompt word engineering include:

[0144] Extract keywords from subtext;

[0145] From the set of predefined ontologies constructed based on the target text category, determine the target predefined ontology corresponding to the subtext;

[0146] When the keyword belongs to the target predefined ontology, a triple is generated based on the target predefined ontology;

[0147] When the keyword does not belong to the target predefined ontology, a custom ontology is generated based on the keyword, and triples are generated based on the custom ontology.

[0148] As an optional implementation, a predefined ontology set is constructed based on the target text category, including:

[0149] Based on the target text category corresponding to each subtext, construct each predefined ontology and add each predefined ontology to the predefined ontology set;

[0150] After generating a custom ontology based on keywords, obtain the verification results; the verification results include the pass result used to characterize the custom ontology passing manual verification;

[0151] When the verification result is successful, the custom ontology is added to the predefined ontology collection.

[0152] As an optional embodiment, the device further includes:

[0153] The scoring module is used to score the current triples by a validation model after extracting triples from the subtext using a specified large model based on the target prompt word engineering, and obtain a quality score. The quality score is used to characterize the confidence of the triples; the quality score is positively correlated with the confidence.

[0154] The first verification module is used to recognize the current triplet as a triplet when the quality score is greater than the first threshold.

[0155] The second verification module is used to obtain the corrected triplet for the current triplet when the quality score is greater than the second threshold and less than or equal to the first threshold, and to use the corrected triplet as the current triplet, and to enter the step of scoring the current triplet through the verification model to obtain the quality score; the second threshold is less than the first threshold.

[0156] The third verification module is used to remove the current triplet when the quality score is less than or equal to the second threshold.

[0157] As an optional embodiment, the device further includes:

[0158] The Low-Rank Matrix Addition Module is used to add a low-rank matrix to a specified layer in a specified large model after the current triplet is used as a triplet.

[0159] The training sample generation module is used to combine triples and their corresponding subtexts to form training samples;

[0160] The training module is used to fine-tune a specified large model using training samples to adjust the parameters of the low-rank matrix.

[0161] As an optional embodiment, the device further includes:

[0162] The object recognition module is used to identify the source object in the triples after extracting triples from the subtext using a specified large model based on the target prompt word engineering; the source object includes at least one of proper nouns and factual knowledge;

[0163] The traceability information acquisition module is used to obtain traceability information associated with the object to be traced from a specified knowledge base in a specified domain.

[0164] The feature extraction module is used to extract triplet features from source information; triplet features include at least one of entity, relation, and attribute.

[0165] The source tracing supplement module is used to generate source tracing triples associated with the object to be traced based on the triple elements, and add the source tracing triples to the triples corresponding to the subtext.

[0166] Please refer to Figure 5 , Figure 5 This application provides a schematic diagram of the structure of an electronic device, which includes:

[0167] Memory 501 is used to store computer programs;

[0168] The processor 502 is configured to implement the steps of any of the above-described knowledge graph construction methods when executing the computer program.

[0169] For a detailed description of the electronic device provided in this application, please refer to the embodiments of the knowledge graph construction method described above; this application will not repeat the details here.

[0170] This application also provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the above-described knowledge graph construction methods.

[0171] The aforementioned storage media include all forms of non-volatile memory, media, and memory devices, such as semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD-ROMs and DVD-ROMs. Processors and memory may be supplemented by or integrated into dedicated logic circuitry.

[0172] For a detailed description of the storage medium provided in this application, please refer to the embodiments of the knowledge graph construction method described above; this application will not repeat the details here.

[0173] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.

[0174] Similarly, although the operations are depicted in a specific order in the accompanying drawings, this should not be construed as requiring these operations to be performed in the specific order shown or sequentially, or requiring all illustrated operations to be performed to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. Furthermore, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.

Claims

1. A method for constructing a knowledge graph, characterized in that, The method includes: Obtain the original text used to construct the knowledge graph; By specifying a classification model, the initial text categories included in the original text are determined; The original text is divided into sub-texts according to the initial text category to obtain a set of sub-texts; Retrieve a sub-text set used to construct a knowledge graph for a specified domain; Based on a pre-constructed mapping relationship, the target text category corresponding to each subtext in the subtext set is obtained; the mapping relationship is the correspondence between subtexts and text categories. From the set of prompt word projects constructed based on the target text category, determine the target prompt word project corresponding to the target text category; Based on the target prompt word engineering, triples are extracted from the subtext by specifying a large model; Based on the triples, the knowledge graph is constructed; The constraints in the prompt word project include: Extract keywords from the subtext; determine the target predefined ontology corresponding to the subtext from the predefined ontology set constructed according to the target text category; when the keyword belongs to the target predefined ontology, generate a triple based on the target predefined ontology; when the keyword does not belong to the target predefined ontology, generate a custom ontology based on the keyword, and generate a triple based on the custom ontology.

2. The method for constructing a knowledge graph as described in claim 1, characterized in that, Pre-build mapping relationships, including: Determine the matching value between the subtext and the corresponding initial text category; the matching value is used to characterize the confidence that the subtext belongs to the corresponding initial text category; Extract the first subtext whose matching value is greater than a preset value, and add the correspondence between the first subtext and the initial text category corresponding to the first subtext to the mapping relationship; Extract the second sub-text whose matching value is not greater than the preset value, obtain the new text category of the second sub-text, and add the correspondence between the second sub-text and the new text category corresponding to the second sub-text to the mapping relationship.

3. The knowledge graph construction method as described in claim 1, characterized in that, The step of constructing a predefined ontology set based on the target text category includes: Based on the target text categories corresponding to each of the sub-texts, each predefined ontology is constructed and added to the predefined ontology set; After generating the custom ontology based on the keywords, a verification result is obtained; the verification result includes a pass result indicating that the custom ontology has passed manual verification. When the verification result is a pass result, the custom ontology is added to the predefined ontology set.

4. The method for constructing a knowledge graph as described in claim 1, characterized in that, After extracting triples from the subtext using a specified large model based on the target prompt word engineering, the method further includes: The current triples are scored using a validation model to obtain a quality score; the quality score is used to characterize the confidence level of the triples; the quality score is positively correlated with the confidence level. When the quality score is greater than the first threshold, the current triplet is taken as the triplet; When the quality score is greater than the second threshold and less than or equal to the first threshold, a corrected triplet is obtained for the current triplet, and the corrected triplet is used as the current triplet. The process then proceeds to the step of scoring the current triplet using a validation model to obtain a quality score; the second threshold is less than the first threshold. When the quality score is less than or equal to the second threshold, the current triplet is removed.

5. The method for constructing a knowledge graph as described in claim 4, characterized in that, After using the current triplet as the triplet, the method further includes: Add a low-rank matrix to a specified layer in the specified large model; The triplet and its corresponding subtext are used to form a training sample; The specified large model is fine-tuned using the training samples to adjust the parameters of the low-rank matrix.

6. The method for constructing a knowledge graph as described in claim 1, characterized in that, After extracting triples from the subtext using a specified large model based on the target prompt word engineering, the method further includes: Identify the source object in the triple; the source object includes at least one of proper nouns and factual knowledge; Obtain tracing information associated with the object to be traced from a specified knowledge base in the specified domain; Extract triplet elements from the source information; the triplet elements include at least one of entity, relation, and attribute. Based on the triplet elements, a tracing triplet associated with the object to be traced is generated, and the tracing triplet is added to the triplet corresponding to the subtext.

7. A knowledge graph construction apparatus, characterized in that, The device includes: The text acquisition module is used to acquire the original text used to construct the knowledge graph; The initial classification module is used to determine the initial text categories included in the original text by specifying a classification model; The text segmentation module is used to divide the original text into sub-texts according to the initial text category, thereby obtaining a set of sub-texts; The subtext set acquisition module is used to acquire a subtext set for constructing a knowledge graph in a specified domain. The target category acquisition module is used to acquire the target text category corresponding to each subtext in the subtext set based on a pre-built mapping relationship; the mapping relationship is the correspondence between subtexts and text categories; The target prompt word determination module is used to determine the target prompt word project corresponding to the target text category from the prompt word project set constructed according to the target text category; The triplet extraction module is used to extract triplets from the subtext based on the target prompt word project and by specifying a large model. The knowledge graph construction module is used to construct the knowledge graph based on the triples. The constraints in the prompt word project include: Extract keywords from the subtext; determine the target predefined ontology corresponding to the subtext from the predefined ontology set constructed according to the target text category; when the keyword belongs to the target predefined ontology, generate a triple based on the target predefined ontology; when the keyword does not belong to the target predefined ontology, generate a custom ontology based on the keyword, and generate a triple based on the custom ontology.

8. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the knowledge graph construction method as described in any one of claims 1 to 6.

9. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the knowledge graph construction method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Knowledge graph construction method and device and medium

    CN120104608A