Electric power knowledge graph construction method based on large language model
Based on the method of large language models, extract and filter data from the power scenario, use the pre -training model and the information library of the power field for the extraction and correction of the ternary group information, and establish a high accuracy and high association power knowledge map. The problem of insufficient accuracy of traditional power data processing methods in complex environments has been solved, and the systematic and intelligent application of power data is realized.
Patent Information
- Application Number
- CN202411712763.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-01-24
AI Technical Summary
Traditional power data processing methods have poor accuracy in complex environments, and it is difficult to effectively apply the alignment method of attributes, resulting in poor accuracy of information processing.
Using a method based on a large language model, obtain the initial document data from the power scene, obtain the target power document data after filtering, use the pre -training large language model to extract the initial three yuan group information, and match the related information of the related information in the information library in the field of power field , Data correction processing of the initial three yuan group information, and finally establish an electricity knowledge map.
Improve the accuracy and efficiency of power information processing, enhance the correlation between data correlation and background information through a structured extraction and combined with the field of knowledge bases, and solve the insufficient accuracy of traditional methods in complex environments in complex environments. The problem realizes the systematic organization and intelligent application of data in the field of power.
Smart Images

Figure CN119357408A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, apparatus, computer equipment, computer-readable storage medium and computer program product for constructing an electric power knowledge graph based on a large language model. Background Art
[0002] With the development of power systems and the increasing complexity of power communication networks, operation and maintenance personnel face challenges in processing large amounts of heterogeneous data. These data usually exist in multiple formats such as text, tables and PDF, including equipment operation records, maintenance manuals and fault reports.
[0003] Traditional methods mainly rely on knowledge search technology, but their effectiveness is limited in the complex environment of power communication networks, making it difficult to effectively apply attribute alignment methods, resulting in poor accuracy in information processing. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment, computer-readable storage medium and computer program product for constructing an electric power knowledge graph based on a large language model, which can improve the accuracy of electric power information processing, in response to the above-mentioned technical problems.
[0005] In a first aspect, the present application provides a method for constructing an electric power knowledge graph based on a large language model, comprising:
[0006] Acquire initial document data from the power scenario, and filter the initial document data to obtain target power document data;
[0007] Using a pre-trained large language model, extracting initial triple information from the target power document data;
[0008] According to the target power document data, matching related information from a preset power field information library;
[0009] According to the association information, data correction processing is performed on the initial triple information to obtain target triple information;
[0010] An electric power knowledge graph is established based on the target triplet information.
[0011] In one embodiment, filtering the initial document data to obtain target power document data includes:
[0012] Using a pre-trained machine learning model, the initial document data is classified and processed to obtain power-related document data and non-power-related document data;
[0013] The power-related document data is used as the target power document data.
[0014] In one embodiment, matching the associated information from a preset power field information library according to the target power document data includes:
[0015] Using a natural language processing model, the target power document data is processed into text blocks to obtain target text blocks;
[0016] Vectorizing the target text block to obtain a corresponding text vector;
[0017] According to the text vector, information with the highest correlation with the text vector is matched from the preset power field information library as the associated information.
[0018] In one embodiment, performing data correction processing on the initial triple information according to the association information to obtain target triple information includes:
[0019] According to the association information, disambiguation processing is performed on the entities and entity relationships in the initial triple information to obtain processed triple information;
[0020] According to the association information, the entity attribute information in the processed triple information is reviewed and processed to obtain the target triple information.
[0021] In one embodiment, the pre-trained large language model is used to extract initial triple information from the target power document data, including:
[0022] Generate extracted interaction information according to a preset extraction interaction template;
[0023] The extracted interaction information and the target power document data are input into the pre-trained large language model to obtain initial triplet information returned by the pre-trained large language model.
[0024] In one embodiment, the pre-trained large language model is obtained by:
[0025] Inputting the preset generated interactive information into a general large language model to obtain a triple extraction training sample set returned by the general large language model;
[0026] A training sample set is extracted according to the triples, and the general large language model is trained to obtain the pre-trained large language model for extracting triple information.
[0027] In a second aspect, the present application also provides a device for constructing an electric power knowledge graph based on a large language model, comprising:
[0028] A data acquisition module, used to acquire initial document data from the power scene, and filter the initial document data to obtain target power document data;
[0029] An information extraction module, used to extract initial triple information from the target power document data using a pre-trained large language model;
[0030] An information matching module, used to match related information from a preset power field information library according to the target power document data;
[0031] A data correction module, used for performing data correction processing on the initial triple information according to the association information to obtain target triple information;
[0032] The graph establishment module is used to establish an electric power knowledge graph based on the target triplet information.
[0033] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0034] Acquire initial document data from the power scenario, and filter the initial document data to obtain target power document data;
[0035] Using a pre-trained large language model, extracting initial triple information from the target power document data;
[0036] According to the target power document data, matching related information from a preset power field information library;
[0037] According to the association information, data correction processing is performed on the initial triple information to obtain target triple information;
[0038] An electric power knowledge graph is established based on the target triplet information.
[0039] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:
[0040] Acquire initial document data from the power scenario, and filter the initial document data to obtain target power document data;
[0041] Using a pre-trained large language model, extracting initial triple information from the target power document data;
[0042] According to the target power document data, matching related information from a preset power field information library;
[0043] According to the association information, data correction processing is performed on the initial triple information to obtain target triple information;
[0044] An electric power knowledge graph is established based on the target triplet information.
[0045] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0046] Acquire initial document data from the power scenario, and filter the initial document data to obtain target power document data;
[0047] Using a pre-trained large language model, extracting initial triple information from the target power document data;
[0048] According to the target power document data, matching related information from a preset power field information library;
[0049] According to the association information, data correction processing is performed on the initial triple information to obtain target triple information;
[0050] An electric power knowledge graph is established based on the target triplet information.
[0051] The above-mentioned method, device, computer equipment, computer-readable storage medium and computer program product for constructing an electric power knowledge graph based on a large language model first obtain initial document data from the electric power scene, and filter the initial document data to obtain target electric power document data. By filtering the initial document data, redundant, noisy or incomplete data can be effectively removed to ensure that the data processed subsequently has high quality, reduce the interference of irrelevant information, and lay the foundation for more accurate knowledge graph construction; then, a pre-trained large language model is used to extract initial triple information from the target electric power document data. Extracting initial triple information from the filtered electric power document can convert unstructured electric power field text into structured data form, so that the implicit knowledge in the electric power data can be displayed and organized, which is convenient for subsequent processing and knowledge graph construction; then, according to the target electric power document data, a preset electric power field information database is used to match the target electric power document data. The associated information is matched, and by matching in the preset power field information database, it can provide richer background information for the initial triples, improve the relevance of the information, and ensure that the extracted triples can better reflect the real relationship in the power system; next, according to the associated information, the initial triple information is corrected to obtain the target triple information, and the initial triple is disambiguated, verified and corrected by the associated information, which can effectively correct errors, eliminate ambiguity, and supplement missing information, ensuring the accuracy and completeness of the triple information, and further improving the quality of nodes and relationships in the knowledge graph; finally, according to the target triple information, the power knowledge graph is established. Based on the corrected target triple information, a power knowledge graph with high accuracy and high relevance can be constructed. The graph can systematically display various entities and their relationships in the power system, improve the readability and availability of the data, and provide a basis for intelligent power management. In the above method, by filtering the initial document data in the power field, extracting triples, matching associated information and correcting data, an accurate and high-quality power knowledge graph is constructed, which improves the accuracy and efficiency of power data processing. By extracting triple information in a structured way and combining it with the domain knowledge base, the relevance of data and the completeness of background information are enhanced. Ultimately, the problem of poor accuracy of traditional power data processing methods in complex environments is effectively solved, and the systematic organization and intelligent application of data in the power field are realized, providing strong support for the operation, maintenance and management of power systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0053] FIG1 is a schematic diagram of a flow chart of a method for constructing an electric power knowledge graph based on a large language model in one embodiment;
[0054] FIG2 is a schematic diagram of a flow chart of a method for constructing an electric power knowledge graph based on a large language model in another embodiment;
[0055] FIG3 is a schematic diagram of a model structure for classifying initial document data in one embodiment;
[0056] FIG4 is a schematic diagram of fine-tuning a general large language model in one embodiment;
[0057] FIG5 is a structural block diagram of a device for constructing a power knowledge graph based on a large language model in one embodiment;
[0058] FIG. 6 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0060] In one embodiment, as shown in FIG1 , a method for constructing an electric power knowledge graph based on a large language model is provided. This embodiment uses the method applied to a terminal as an example. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be, but is not limited to, various personal computers, laptops, smart phones, and tablet computers. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. In this embodiment, the method includes the following steps:
[0061] Step S101: acquiring initial document data from a power scenario, and filtering the initial document data to obtain target power document data.
[0062] Among them, initial document data refers to various types of original data collected from power system-related scenarios, including but not limited to equipment operation records, maintenance manuals, fault reports, real-time monitoring data, etc. These data usually exist in the form of text, tables, PDFs or databases, reflecting the operating status, fault information and related operation records in the power system, etc. The target power document data is a data set obtained by filtering, cleaning and screening the initial document data to ensure that it has high-quality characteristics related to the construction of the power knowledge graph.
[0063] Exemplarily, the terminal can automatically obtain the required initial document data by connecting to the operation and maintenance platform or database interface of the power system. First, the terminal collects raw data from multiple power scenarios, which may include multi-source data such as records of daily operation and maintenance systems, historical fault data, and real-time monitoring information of sensors. Then, the terminal performs preliminary cleaning and filtering on these raw data to filter out redundant information, low-quality data, or noise data that is not related to the construction of the power knowledge graph. This filtering process can be performed using machine learning models or natural language processing technology. The terminal excludes incomplete, duplicate, or irrelevant documents by analyzing the semantics, format, and structure of the data, thereby retaining high-quality target document data related to the power field, which is convenient for subsequent triple extraction and knowledge graph construction.
[0064] Step S102: using a pre-trained large language model to extract initial triple information from the target power document data.
[0065] The initial triple information refers to the basic structured knowledge unit extracted from the target power document data, which includes at least two forms: one is entity-relationship-entity, which is used to represent the relationship between two entities in the power system, such as "transformer A-connection-circuit breaker B"; the other is entity-attribute-attribute value, which is used to describe the specific attributes of an entity and its corresponding value, such as "transformer A-power-500 kilowatts". These triple information are the basis for building the power knowledge graph. By capturing the relationship and attribute information between entities, it can provide support for subsequent data query and reasoning.
[0066] Exemplarily, the terminal automatically extracts initial triple information from the target power document data by calling a pre-trained large language model. First, the terminal preprocesses the target document data, including text segmentation, named entity recognition, part-of-speech tagging and other steps, so as to identify relevant entities and attributes in the power field. Next, the terminal analyzes the semantic structure in the document through the model and extracts two types of triples: for entity-relationship-entity, the terminal identifies entities such as equipment and components in the document and extracts the association relationship between them; for entity-attribute-attribute value, the terminal identifies entities (such as equipment) and their corresponding attributes (such as voltage, power) and attribute values. Through these operations, the terminal generates structured initial triple information to ensure that each triple accurately reflects the entities and their mutual relationships or attribute characteristics in the power system, thereby providing basic data for the subsequent knowledge graph construction.
[0067] Step S103, matching related information from a preset power field information library according to the target power document data.
[0068] Among them, the preset power field information database refers to a database containing a large amount of professional knowledge in the power field, covering information such as power equipment, operating procedures, fault handling methods, technical specifications, etc., which can provide relevant background support for the content in the power document. Associated information refers to knowledge items related to entities, relationships or attributes in the target power document data matched from the information database, which are used to supplement and verify the initial triple information.
[0069] Exemplarily, the terminal automatically matches relevant background information from a preset power field information base by analyzing the entities and relationships in the target power document data. The terminal first generates a query request based on the entities, relationships and attributes extracted from the target document data to query the relevant entries of these elements in the power field information base. For example, the terminal can use keyword matching, semantic similarity calculation or knowledge base retrieval tools to match the equipment in the document (such as "transformer A") with the existing equipment entries in the information base to find detailed information about equipment characteristics, operating standards or fault types. During the matching process, the terminal can combine semantic analysis to identify key terms in the power document data and use natural language processing technology for context understanding to ensure that the matched information is highly relevant to the content in the power document. These matched related information may include equipment operating parameters, fault handling specifications, or common equipment interaction relationships in historical data. Through this process, the terminal can provide professional field background knowledge for the initial triple information, further enhance the accuracy and completeness of the triple, and provide support for subsequent correction and verification.
[0070] Step S104: performing data correction processing on the initial triple information according to the associated information to obtain target triple information.
[0071] Among them, data correction processing refers to disambiguating, verifying, supplementing and optimizing the initial triple information based on the associated information matched from the preset power field information library to improve the accuracy, completeness and consistency of the triple. The target triple information is a high-quality triple after correction processing, which can accurately reflect the entities, relationships or attributes in the power system and meet the specifications and requirements of the professional field.
[0072] Exemplarily, the terminal performs multiple levels of correction processing on the initial triple according to the matched association information. First, the terminal performs entity disambiguation, that is, eliminates the ambiguity of entities with the same name or similar entities through association information to ensure that each entity points to a unique power device or system component. For example, "transformer A" mentioned in a document may appear in multiple documents. By combining the association information, the terminal can determine which type or location of the transformer is. Next, the terminal performs relationship verification to review the entity-relationship-entity structure in the initial triple to ensure that these relationships are reasonable in the power field. For example, if the initial triple represents "transformer A-connection-circuit breaker B", the terminal verifies whether the connection relationship complies with the actual operating procedures in the power system through the technical specifications in the association information library, and if not, it is corrected or deleted. In addition, the terminal will perform attribute supplementation, that is, supplement the entities or attributes in the initial triple according to the association information. For example, if an entity lacks specific parameters (such as "voltage level" or "operating status"), the terminal can find and complete these missing attribute values from the association information library. Finally, the terminal performs consistency checks to ensure that the corrected target triple information is consistent with the professional knowledge in the power field in terms of structure and semantics. For example, if the relationship or attribute of the initial triple does not match the conventional knowledge in the associated information base, the terminal will correct these inconsistencies to ensure the accuracy and consistency of the triple. Through these corrections, the target triple information generated by the terminal will be more complete and accurate, providing high-quality basic data for the subsequent knowledge graph construction.
[0073] Step S105: Establish an electric power knowledge graph based on the target triple information.
[0074] Among them, the power knowledge graph refers to presenting the entities and their relationships or attributes in the power system in a structured way in the form of a graph, forming a network that can intuitively display and store knowledge in the power field. The nodes in the graph represent the key entities in the power system (such as equipment and components), and the edges represent the relationships between entities (such as connections and dependencies) or attribute values (such as power and status). The target triple information is a high-quality triple that has been corrected and processed, and constitutes the basic unit in the knowledge graph.
[0075] Exemplarily, the terminal performs construction or update of the knowledge graph based on the target triple information. First, if it is the first construction, the terminal adds the entity of each triple as a node to the knowledge graph, and the relationship as the edge connecting the nodes. For example, for the target triple "transformer A-connection-circuit breaker B", the terminal will create a "transformer A" node and a "circuit breaker B" node in the graph, and associate them through the "connection" relationship. For triples in the form of entity-attribute-attribute value, the terminal will attach the attribute value (such as "500 kilowatts") as additional information of the node to the corresponding entity (such as "transformer A") to make the graph more complete.
[0076] If the graph already exists, the terminal can update the existing graph based on the target triple information. The update process includes: Adding new nodes and relationships: When the entity or relationship in the target triple information is not in the existing knowledge graph, the terminal adds it to the graph as a new node or new edge. For example, if a new device or connection relationship is identified, the terminal will expand the corresponding entity and relationship based on the original graph. Correcting and updating existing node information: When the target triple provides updated information of an existing entity, the terminal will update the existing node. For example, if the power of "Transformer A" in the existing graph is 300 kilowatts, and the new target triple information shows that its power has become 500 kilowatts, the terminal will modify the attribute to ensure the accuracy of the graph data. Removing outdated or invalid information: The terminal can identify and remove outdated or invalid nodes or relationships through the target triple information to ensure that the data in the knowledge graph remains up-to-date and valid.
[0077] Ultimately, by building or updating the power knowledge graph, the terminal can systematically present the complex entity relationships in the power system, and reflect the dynamic changes of equipment status, fault information, maintenance records, etc. in real time, supporting more efficient query, analysis and reasoning. This not only improves the accuracy and real-time performance of the knowledge graph, but also helps operation and maintenance personnel better understand the operation of the power system and promote intelligent and data-driven management of the decision-making process.
[0078] In the above-mentioned method for constructing an electric power knowledge graph based on a large language model, first, initial document data is obtained from the electric power scene, and the initial document data is filtered to obtain target electric power document data. By filtering the initial document data, redundant, noisy or incomplete data can be effectively removed, ensuring that the data processed subsequently has high quality, reducing the interference of irrelevant information, and laying the foundation for more accurate knowledge graph construction; then, a pre-trained large language model is used to extract initial triple information from the target electric power document data. Extracting initial triple information from the filtered electric power document can convert unstructured electric power field text into structured data form, so that the implicit knowledge in the electric power data can be displayed and organized, which is convenient for subsequent processing and knowledge graph construction; then, according to the target electric power document data, related information is matched from the preset electric power field information library, and the information is matched in the preset Matching in the electric power field information database can provide richer background information for the initial triples, improve the relevance of information, and ensure that the extracted triples can better reflect the real relationship in the power system; next, according to the associated information, the initial triple information is corrected to obtain the target triple information. The initial triple is disambiguated, verified and corrected through the associated information, which can effectively correct errors, eliminate ambiguity, and supplement missing information, ensuring the accuracy and completeness of the triple information, and further improving the quality of nodes and relationships in the knowledge graph; finally, according to the target triple information, an electric power knowledge graph is established. Based on the corrected target triple information, an electric power knowledge graph with high accuracy and high relevance can be constructed. The graph can systematically display various entities and their relationships in the power system, improve the readability and availability of data, and provide a basis for intelligent power management. In the above method, by filtering the initial document data in the electric power field, extracting triples, matching associated information and correcting data, an accurate and high-quality electric power knowledge graph is constructed, which improves the accuracy and efficiency of electric power data processing. By extracting triple information in a structured way and combining it with the domain knowledge base, the relevance of data and the completeness of background information are enhanced. Ultimately, the problem of poor accuracy of traditional power data processing methods in complex environments is effectively solved, and the systematic organization and intelligent application of data in the power field are realized, providing strong support for the operation, maintenance and management of power systems.
[0079] In an exemplary embodiment, the above-mentioned step S101 filters the initial document data to obtain target power document data, and also includes: using a pre-trained machine learning model to classify the initial document data to obtain power-related document data and non-power-related document data; and using the power-related document data as the target power document data.
[0080] Exemplarily, the terminal first preprocesses the initial document data, including removing files with irregular formats, correcting spelling errors, and standardizing terminology. Next, natural language processing technology is used to perform word segmentation, part-of-speech tagging, and entity recognition on the document to extract key information. These features are then input into a trained machine learning model that has been trained with data sets related to the power sector and is able to identify and distinguish between power-related documents and non-power-related documents. By using a classification algorithm (such as a support vector machine, random forest, or deep learning model), the terminal classifies the documents and retains all document data marked as "power-related" to form the target power document data.
[0081] In this embodiment, by using a pre-trained machine learning model to classify the initial document data, the efficiency and accuracy of data filtering are significantly improved, ensuring the high relevance and quality of the target power document data, laying a good foundation for subsequent triple extraction and knowledge graph construction, and improving the overall effect of power knowledge management.
[0082] In an exemplary embodiment, the above-mentioned step S103 matches related information from a preset power field information library based on the target power document data, and also includes: using a natural language processing model to perform text block processing on the target power document data to obtain a target text block; vectorizing the target text block to obtain a corresponding text vector; and based on the text vector, matching the information with the highest correlation with the text vector from the preset power field information library as related information.
[0083] The target text block refers to dividing the target power document data into several smaller text segments with semantic independence and integrity for subsequent analysis and processing. The text vector converts the text block into a numerical representation through vectorization processing, which is convenient for computers to perform similarity measurement and information retrieval.
[0084] Exemplarily, the terminal segments the target document data according to specific semantic or structural features, such as by paragraphs, sentences, or specific keywords, to ensure that each text block contains complete information. Next, the terminal vectorizes these target text blocks and converts each text block into a corresponding text vector using a pre-trained model such as Word2Vec, GloVe, or BERT. These vectors represent the semantic features of the text block, allowing it to be compared with the content in the information library. The terminal can then identify the most relevant entries by calculating the similarity between the text vector and the vector of each entry in the information library (for example, using cosine similarity or Euclidean distance).
[0085] In this embodiment, by performing text segmentation and vectorization processing on the target power document data, the retrieval accuracy and efficiency of related information can be effectively improved, which not only enhances the relevance of information matching, but also provides richer and more professional support for subsequent data correction and knowledge graph construction.
[0086] In an exemplary embodiment, the above-mentioned step S104 performs data correction processing on the initial triple information according to the associated information to obtain the target triple information, and also includes: according to the associated information, disambiguating the entities and entity relationships in the initial triple information to obtain the processed triple information; according to the associated information, reviewing the entity attribute information in the processed triple information to obtain the target triple information.
[0087] Exemplarily, the terminal uses the matched associated information to identify and eliminate the ambiguity of entities with the same name. For example, for "transformer" that appears in multiple contexts, the terminal will determine the specific device referred to in combination with the associated information, thereby generating disambiguated triple information. This process can be achieved by comparing contexts, attributes and historical data to ensure the accuracy of the disambiguation results. Next, the terminal reviews the entity attribute information in the processed triple information based on the associated information, rather than directly modifying it. The terminal verifies the attributes of each entity (such as power, voltage, type, etc.) to ensure that they meet the professional knowledge and specifications in the power field. In this process, if an attribute is found to be inconsistent with the associated information, the terminal will mark the triple and notify the user for manual review. For example, if the transformer power marked in the triple is "300 kilowatts", but the associated information indicates that its actual power should be "500 kilowatts", the terminal marks the information as requiring confirmation, and the user can make a decision based on the actual situation. The terminal finally obtains the target triplet information, which is processed through disambiguation and review to ensure its accuracy and completeness without interfering with the validity of the fault report, thus providing a solid foundation for the subsequent knowledge graph construction.
[0088] In this embodiment, by disambiguating and reviewing the initial triplet information, the quality and credibility of the triplet are significantly improved, ensuring the accuracy of each node and relationship in the knowledge graph, which helps to improve the overall effect of power knowledge management while maintaining the reliability of fault information and user trust in the data.
[0089] In an exemplary embodiment, the above-mentioned step S102 uses a pre-trained large language model to extract initial triplet information from the target power document data, and also includes: generating extracted interaction information according to a preset extraction interaction template; inputting the extracted interaction information and the target power document data into the pre-trained large language model to obtain the initial triplet information returned by the pre-trained large language model.
[0090] Extracting interactive information refers to the specific words and instructions used when interacting with the pre-trained large language model, as well as the requirements for the format of the returned information. This interactive information can include questions about specific issues in the power sector, such as "Please extract all triples related to equipment failures in the document", and clarify the format of the model's return information, such as requiring it to be presented in the form of "entity-relationship-entity" or "entity-attribute-attribute value".
[0091] Exemplarily, the terminal inputs the relevant content in the target document into the pre-trained large language model, while attaching a series of interactive words and format requirements. For example, the terminal can instruct the model: "Please extract the voltage and power parameters of the transformer and return the results in the form of triples." These instructions help the model focus on specific content and output it in the expected format. The terminal extracts the interactive information and the target power document data and inputs them into the large language model together. The model generates initial triple information based on the input content and interactive instructions. The returned triple may be presented in the format of "Transformer A-Fault-May 1, 2023" or "Transformer A-Power-500 kW".
[0092] In this embodiment, by effectively interacting with the pre-trained large language model and clarifying the format requirements of the returned information, the initial triple information in the target power document can be efficiently extracted, which simplifies the complexity of information extraction, improves the efficiency of data processing, and provides a reliable foundation for the subsequent knowledge graph construction.
[0093] In an exemplary embodiment, the above-mentioned pre-trained large language model can be obtained in the following manner: input the preset generated interaction information into the general large language model to obtain the triple extraction training sample set returned by the general large language model; according to the triple extraction training sample set, the general large language model is trained to obtain a pre-trained large language model for extracting triple information.
[0094] Among them, the general large language model refers to a natural language processing model that is pre-trained on a wide range of text corpora, which has rich language understanding and generation capabilities, but may lack expertise in specific fields. Therefore, in order to make the model perform better in data extraction tasks in the power field, it needs to be trained specifically.
[0095] Exemplarily, the terminal first inputs the preset generated interaction information into the general large language model to guide the model to generate relevant triple extraction training sample sets. The preset generated interaction information may include specific questions and format requirements for the power field, such as: "Please extract the connection relationship between devices" or "Identify the entities and attributes of the fault description." The output generated by the model based on this information will constitute a triple extraction training sample set, where each sample includes the initial text and the corresponding triple annotation. Next, the terminal fine-tunes the general large language model based on the generated triple extraction training sample set. During the training process, the model will learn how to generate accurate triple information based on the input power field text. Through continuous iteration and optimization, the model is able to more accurately extract entities, relationships, and attributes in specific fields.
[0096] In this embodiment, by combining the generated interactive information with a general large language model, a pre-trained large language model specifically used for extracting triplet information can be effectively constructed, thereby improving the performance of the model in data processing tasks in the power field and ensuring the accuracy and reliability of subsequent triplet extraction.
[0097] In another exemplary embodiment, as shown in FIG2 , the present application provides a method for constructing an electric power knowledge graph based on a large language model, the method comprising:
[0098] Step S201, obtaining initial document data from the power scene.
[0099] Step S202: using a pre-trained machine learning model to classify the initial document data to obtain power-related document data and non-power-related document data.
[0100] Step S203: taking the power-related document data as the target power document data.
[0101] Step S204: generating extracted interaction information according to a preset extraction interaction template.
[0102] Step S205 , extracting the interaction information and the target power document data, and inputting them into the pre-trained large language model to obtain the initial triplet information returned by the pre-trained large language model.
[0103] Step S206: using a natural language processing model, performing text block processing on the target power document data to obtain target text blocks.
[0104] Step S207, vectorizing the target text block to obtain a corresponding text vector.
[0105] Step S208: According to the text vector, information with the highest correlation with the text vector is matched from a preset power field information library as associated information.
[0106] Step S209 , disambiguating the entities and entity relationships in the initial triple information according to the association information to obtain processed triple information.
[0107] Step S210: review and process the entity attribute information in the processed triple information according to the association information to obtain the target triple information.
[0108] Step S211, establishing an electric power knowledge graph based on the target triple information.
[0109] For example, due to the lack of corresponding knowledge of the large model for problems in a specific field, hallucinations may occur during entity extraction. By using information classification and filtering processing, the possibility of large language models generating false information can be reduced, thereby improving the accuracy of knowledge graph construction. For example, assuming that the set of all documents is S, the set of documents that can be better understood by the large model in the field of electric power is R, and the set of documents that can better complete the entity recognition task is N. Obviously, S>R>N. After fine-tuning the large model and matching the related information, R will approach N; using the information filtering module, S will approach R; ensuring that the documents entering the triple extraction are all texts related to the electric power field, reducing the impact of text noise on subsequent entity recognition effects.
[0110] For the obtained initial document data, the transformer-based bidirectional encoding representation model (Bert) as shown in FIG3 may be used to perform information classification and filtering.
[0111] The training process of the transformer-based bidirectional encoding representation model (Bert) can be: input the training data into the Bert model, obtain the corresponding vectorized representation after embedding (vectorization), and connect a fully connected layer after the Bert model to further classify the intermediate vector H output of the Bert model into 0 or 1, 0 means that electricity is not relevant, and 1 means that electricity is relevant. After training, the parameters of the fully connected layer will be changed. The goal of the training process is to maximize the logarithmic probability corresponding to the output label. The formula of the training process is summarized as follows:
[0112]
[0113] Among them, softmax is the normalized exponential function, L is the label of the prediction result, H is the intermediate vector output by the Bert model, and W is the parameter matrix of this task.
[0114] The model after training should have the minimum loss, which can be summarized as follows using the calculation formula of the fully connected layer FC:
[0115]
[0116] In the actual operation process, the label with the highest probability is selected as the classification result, that is, one of power-related and power-irrelevant.
[0117] The pre-trained large language model can be trained in the following ways:
[0118] First, we obtain a fine-tuning sample dataset by asking questions to the general large language model. An example question is: "Please refer to {information extraction example} to generate a fine-tuning sample dataset for triple information extraction."
[0119] Then, the fine-tuning sample dataset is used to fine-tune the general large language model. Specifically, the low-rank matrix fine-tuning (LoRA, Low-Rank Adaptation) method can be used as shown in Figure 4. The fine-tuning formula for weight update through low-rank decomposition can be summarized as follows:
[0120]
[0121] in, represents the pre-trained weight matrix, r represents the rank of the LoRA module, A and B are updateable training parameters, .
[0122] The preset extraction interaction template in step S204 may be:
[0123] "Now that you are an expert in the field of electricity, extract the content of this text fragment: {user-entered question} into knowledge graph triples and entity alignment triples. The format should follow the format of <entity, attribute, attribute value> or <entity, relationship, entity>. Please return the answer in the following format:
[0124] {"sentence":s1,
[0125] "kq":{
[0126] "relation":r1,
[0127] "entity i":e1,
[0128] "entity_j":e2}}
[0129] {"sentence":s2,
[0130] "kg":{
[0131] "attribute":a,
[0132] "entity":e,
[0133] "attribute value":y"}}"
[0134] The “question input by the user” may be “detailed information about transformer A” or “the connection object of transformer A” and the like.
[0135] In step S206 to step S208, a langchain+LLM (LangChain is a framework for building language model-based applications, and LLM is a large language model) can be used. The loader module of langchain is used to load the target power document data. The target power document data is segmented by using the RecursiveCharacterTextSplitter tool in the TextSplitter module, and the size of the largest block into which the text should be segmented is specified by using the chunk_size parameter. Further, the text block to be processed is vectorized. After obtaining the professional knowledge vector library object, the retriever Retriever class can be used to retrieve and return highly relevant content from the document based on the input query question; wherein, search_type is specified as querySmilarity, and the parameter k is specified to define how many documents are returned. Further, after obtaining the Retriever class, the document is retrieved to generate an answer, and the map re-rank file chain mode is used to give an initial prompt to each file. In addition to completing a task, the degree of certainty of the answer is scored, and the answer with the highest score will be returned.
[0136] In step S209 to step S210, a large language model may be used to perform disambiguation and review processing on the initial triple information. Specifically, the following interaction template may be used:
[0137] "Now that you are an expert in the field of electricity, please refer to the following expertise: {Expertise text},
[0138] Check the following triples for errors and perform entity disambiguation.
[0139] Entity disambiguation is divided into two steps. The first step is to disambiguate before entity recognition and relationship recognition. The second step is to use relationship dictionaries and topic dictionaries for matching and disambiguation.
[0140] Disambiguate the results of entity recognition, relationship recognition, and attribute extraction.
[0141] 1. Promotion based on relationships is wrong.
[0142] 2. The entity correspondence is incorrect.
[0143] 3. Problems such as incorrect attribute values.
[0144] If there is no problem, please return "True";
[0145] If there is a problem, please return "False" and follow it with the reason for the error, in the same format as the correct expression.
[0146] The results of entity recognition and relationship extraction are reviewed and disambiguated, and the results of attribute extraction are disambiguated. Entity disambiguation mainly solves the phenomenon of polysemy and monosemy in natural language.
[0147] Finally, for the target triplet information that has been disambiguated and reviewed, the knowledge graph nodes of the target network are matched and connected according to the dependency relationship between entities to construct the target power knowledge graph, and the original power knowledge graph can also be updated. In addition, the preset power field information library can be updated from time to time, and the corpus can be recognized with new dictionaries and models to achieve cyclic iterative updates and knowledge graph construction.
[0148] In this embodiment, by filtering the initial document data in the power field, extracting triples, matching related information and correcting data, an accurate and high-quality power knowledge graph is constructed, which improves the accuracy and efficiency of power data processing. By extracting triple information in a structured manner and combining it with the domain knowledge base, the relevance of the data and the completeness of the background information are enhanced. Ultimately, the problem of poor accuracy of traditional power data processing methods in complex environments is effectively solved, and the systematic organization and intelligent application of data in the power field are realized, providing strong support for the operation, maintenance and management of the power system.
[0149] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0150] Based on the same inventive concept, the embodiment of the present application also provides a device for constructing a power knowledge graph based on a large language model for implementing the above-mentioned method for constructing a power knowledge graph based on a large language model. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more embodiments of the power knowledge graph construction device based on a large language model provided below can be referred to the limitations of the power knowledge graph construction method based on a large language model above, and will not be repeated here.
[0151] In an exemplary embodiment, as shown in FIG5 , a device for constructing a power knowledge graph based on a large language model is provided, comprising: a data acquisition module 501, an information extraction module 502, an information matching module 503, a data correction module 504 and a graph establishment module 505, wherein:
[0152] The data acquisition module 501 is used to acquire initial document data from the power scene, and filter the initial document data to obtain target power document data;
[0153] The information extraction module 502 is used to extract initial triple information from the target power document data using a pre-trained large language model;
[0154] The information matching module 503 is used to match the relevant information from the preset power field information library according to the target power document data;
[0155] The data correction module 504 is used to perform data correction processing on the initial triple information according to the associated information to obtain the target triple information;
[0156] The graph building module 505 is used to build an electric power knowledge graph based on the target triple information.
[0157] In one of the embodiments, the data acquisition module 501 is also used to classify the initial document data using a pre-trained machine learning model to obtain power-related document data and non-power-related document data; and use the power-related document data as target power document data.
[0158] In one of the embodiments, the above-mentioned information matching module 503 is also used to use a natural language processing model to perform text block processing on the target power document data to obtain a target text block; vectorize the target text block to obtain a corresponding text vector; and according to the text vector, match the information with the highest correlation with the text vector from a preset power field information library as related information.
[0159] In one of the embodiments, the above-mentioned data correction module 504 is also used to disambiguate the entities and entity relationships in the initial triple information based on the associated information to obtain the processed triple information; and to review the entity attribute information in the processed triple information based on the associated information to obtain the target triple information.
[0160] In one of the embodiments, the information extraction module 502 is further used to generate extracted interaction information according to a preset extraction interaction template; the extracted interaction information and target power document data are input into a pre-trained large language model to obtain the initial triplet information returned by the pre-trained large language model.
[0161] In one of the embodiments, the above-mentioned power knowledge graph construction device based on the large language model is also used to input the preset generated interactive information into the general large language model to obtain the triple extraction training sample set returned by the general large language model; according to the triple extraction training sample set, the general large language model is trained to obtain a pre-trained large language model for extracting triple information.
[0162] Each module in the above-mentioned power knowledge graph construction device based on a large language model can be implemented in whole or in part by software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each of the above modules.
[0163] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG6. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a method for constructing an electric power knowledge graph based on a large language model is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0164] Those skilled in the art will understand that the structure shown in FIG. 6 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0165] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0166] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0167] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0168] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0169] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0170] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0171] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for constructing an electric power knowledge graph based on a large language model, characterized in that: The method comprises: Acquire initial document data from the power scenario, and filter the initial document data to obtain target power document data; Using a pre-trained large language model, extracting initial triple information from the target power document data; According to the target power document data, matching related information from a preset power field information library; According to the association information, data correction processing is performed on the initial triple information to obtain target triple information; An electric power knowledge graph is established based on the target triplet information.
2. The method according to claim 1, characterized in that The filtering process of the initial document data to obtain target power document data includes: Using a pre-trained machine learning model, the initial document data is classified and processed to obtain power-related document data and non-power-related document data; The power-related document data is used as the target power document data.
3. The method according to claim 1, characterized in that The matching of related information from a preset power field information library according to the target power document data includes: Using a natural language processing model, the target power document data is processed into text blocks to obtain target text blocks; Vectorizing the target text block to obtain a corresponding text vector; According to the text vector, information with the highest correlation with the text vector is matched from the preset power field information library as the associated information.
4. The method according to claim 1, characterized in that: The step of performing data correction processing on the initial triple information according to the association information to obtain target triple information includes: According to the association information, disambiguation processing is performed on the entities and entity relationships in the initial triple information to obtain processed triple information; According to the association information, the entity attribute information in the processed triple information is reviewed and processed to obtain the target triple information.
5. The method according to any one of claims 1 to 4, characterized in that: The pre-trained large language model is used to extract initial triple information from the target power document data, including: Generate extracted interaction information according to a preset extraction interaction template; The extracted interaction information and the target power document data are input into the pre-trained large language model to obtain initial triplet information returned by the pre-trained large language model.
6. The method according to claim 5, characterized in that The pre-trained large language model is obtained in the following way: Inputting the preset generated interactive information into a general large language model to obtain a triple extraction training sample set returned by the general large language model; A training sample set is extracted according to the triples, and the general large language model is trained to obtain the pre-trained large language model for extracting triple information.
7. A device for constructing an electric power knowledge graph based on a large language model, characterized in that: The device comprises: A data acquisition module, used to acquire initial document data from the power scene, and filter the initial document data to obtain target power document data; An information extraction module, used to extract initial triple information from the target power document data using a pre-trained large language model; An information matching module, used to match related information from a preset power field information library according to the target power document data; A data correction module, used for performing data correction processing on the initial triple information according to the association information to obtain target triple information; The graph establishment module is used to establish an electric power knowledge graph based on the target triplet information.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Archive knowledge editing and research method, system and equipment and storage medium
CN119623604A
Document information extraction processing method and device based on power lexical element structure
CN119646116A
Knowledge graph construction method and device and medium
CN120104608A
Power operation and maintenance knowledge graph generation method based on large model and graph neural network
CN120542538A
Document element rapid extraction system based on pre-training large model
CN121189458A