User-level power prediction method and system based on knowledge graph retrieval enhanced generation

Through the enhanced generation method of knowledge graph retrieval, combining large language model and embedded layer neural network, integrating user attributes and timing characteristics, the problems of insufficient natural language data processing and data scale limitations in the existing technology are solved, and user-level power prediction is realized Accuracy and flexibility.

CN118709871BActive Publication Date: 2024-11-12国网福建省电力有限公司营销服务中心 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411204067.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-11-12
Estimated Expiration
2044-08-30

AI Technical Summary

Technical Problem

The existing user-level power prediction system cannot effectively utilize natural language data, resulting in insufficient mining of users' personalized power demands, inflexible data scale, and complex database processing introduces artificial errors, which cannot accurately reflect users' fine power demands.

Method used

Using a search enhancement generation method based on knowledge graph, the user's personalized attribute characteristics and timing characteristics are extracted through a large language model and an embedded layer neural network, the user's personalized attribute characteristics and timing characteristics are fused to generate comprehensive features, and input the LSTM model for power prediction.

Benefits of technology

It realizes accurate prediction of users' personalized electricity needs, provides high-dimensional and high-throughput power analysis, reduces artificial errors, and improves the accuracy and flexibility of prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118709871B_ABST
    Figure CN118709871B_ABST
Patent Text Reader

Abstract

The present invention relates to a user-level electricity prediction method and system based on knowledge graph retrieval enhanced generation, and the specific steps include: collecting and preprocessing the electricity attribute data of a number of users, constructing a vector database and a hierarchical knowledge graph database based on the preprocessed electricity attribute data; inputting the electricity attribute data of a number of personalized users into a pre-trained large language model, classifying users with similar electricity attribute data into similar users, generating natural language question texts based on the electricity attribute data of the users, querying the electricity consumption levels of various users in the vector database and the hierarchical knowledge graph database, and generating personalized user attribute features for various users respectively; acquiring electricity time series data according to electricity consumption records based on the electricity consumption habits of various users within a preset time range, and then extracting time series features using an embedded layer neural network; fusing the personalized user attribute features of various users with the time series features by vector splicing to obtain comprehensive features.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of large language models and retrieval enhancement technology, and specifically to a user-level power prediction method and system based on knowledge graph retrieval enhancement generation. Background Art

[0002] At present, the user-level artificial intelligence power forecasting system uses complex spatiotemporal data for regression forecasting. However, in the face of the diverse and personalized needs of users, it is difficult to meet the personalized power forecasting of users by relying solely on spatiotemporal power series data. Specifically, there are the following problems:

[0003] The data type is single and the mining of user personality characteristics is insufficient. Existing deep learning algorithms such as LSTM and graph neural networks are good at processing numerical data due to their algorithmic characteristics, and their processing capabilities for natural language data (such as occupation and address) are insufficient. However, data containing user personalized information is often natural language data, which makes it impossible for existing methods to mine users' personalized electricity needs through rich natural language data.

[0004] Due to the limitation of data scale, power data prediction often relies on the user's spatiotemporal series data. In specific operations, data of different scales such as year, month, and day are input into the system to obtain prediction results. However, the traditional scale of year, month, and day is often not flexible enough. If the scale is too small, it will introduce noise caused by accidental actions (such as short-term travel), and if the scale is too large, it will not reflect the user's detailed needs. Relatively speaking, the power consumption impact caused by the user's inherent attributes is often more stable and easy to capture when it changes. Therefore, how to make good use of time series data and user attribute characteristics is the key to solving user personalized prediction.

[0005] The database is complex and requires professionals to perform various processing and calculations. The existing power system database is very large and is usually maintained and processed by professionals, which leads to the introduction of human errors and interference factors in data analysis. Accurate and automated data processing is the basis for subsequent prediction tasks.

[0006] In the prior art CN116760033B, a real-time electricity demand forecasting system based on artificial intelligence discloses a data acquisition module for real-time collection of electricity supply and demand data; a data preprocessing module for cleaning the collected electricity supply and demand data; a data forecasting cloud platform module for building a data forecasting model based on historical electricity demand data, weather data and industry data, and making real-time forecasts of electricity demand; a model optimization and adjustment module for improving and optimizing the data forecasting model; and a security reinforcement module for improving the robustness and security of the system.

[0007] In the existing technology, only the impact of historical electricity demand data and external data such as environmental data and industry data on electricity demand is considered, but the impact of various user behavior habits on electricity demand is not considered from the user side, resulting in inaccurate electricity consumption forecast results. Summary of the invention

[0008] In order to solve the above problems existing in the prior art, the present invention proposes a user-level power prediction method and system based on knowledge graph retrieval enhanced generation.

[0009] The technical solution of the present invention is as follows:

[0010] On the one hand, the present invention proposes a user-level power prediction method based on knowledge graph retrieval enhanced generation, and the specific steps include:

[0011] Collect and preprocess the power attribute data of several users, and build a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data;

[0012] The power attribute data of several personalized users are input into the pre-trained large language model, and users with similar power attribute data are divided into similar users. Natural language question texts are generated based on the power attribute data of users, and the power consumption levels of various users are queried in the vector database and the hierarchical knowledge graph database to generate personalized user attribute features for each type of user.

[0013] Obtain power time series data based on the power consumption records of various users within a preset time range, and then use the embedded layer neural network to extract time series features; merge the personalized user attribute features of various users with the time series features through vector splicing to obtain comprehensive features;

[0014] The comprehensive features are input into the pre-trained LSTM prediction model to obtain the final power prediction results that take into account the user's power usage habits and user attributes.

[0015] As a preferred implementation, the collecting of several user power attribute data and preprocessing is specifically as follows:

[0016] The tabular structure data in each user profile is extracted in the form of bigrams, wherein the bigrams include user attributes and their corresponding values; and then the pre-trained large language model and prompt engineering are used to unify multiple bigrams of the user into a natural language description text block.

[0017] As a preferred implementation, the steps of constructing a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data are specifically as follows:

[0018] Based on the natural language description text blocks of each user, vector data is established through LangChain's local deployment library;

[0019] The user's natural language description text block in the vector database is called and input into the pre-trained large language model to extract each name entity and the relationship entity between each name entity, build a ternary relationship pair between every two name entities, and generate a preliminary knowledge graph; with each element entity node in the knowledge graph as the center, extract all its link point pairs, and input all link point pairs into the large language model to generate an element entity summary of the element entity and attach it to the description information of each node; then the nodes on the preliminary knowledge graph are clustered through the Leiden algorithm to generate a hierarchical community structure, and complete the construction of the hierarchical knowledge graph database;

[0020] The hierarchical community structure includes a root-level community, a low-level community, a middle-level community and a high-level community.

[0021] As a preferred implementation, the steps of generating a natural language question text based on the user's power attribute data, querying the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generating personalized user attribute features for each type of user are specifically as follows:

[0022] Based on the natural language question text, query in the vector database. The specific formula is as follows:

[0023]

[0024] In the formula, Indicates the return text. represents text concatenation, Q represents natural language question text, Before The maximum value, represents the similarity function, Represents a data block;

[0025] Then query in the hierarchical knowledge graph database. The specific formula is as follows:

[0026]

[0027] In the formula, Represents the electricity consumption characteristics of various users in hierarchical knowledge graph data query, Indicates the community summary, Representing different levels of community;

[0028] The query results of the two databases are concatenated and returned to the large language model as a reference to generate the corresponding natural language answer. The concatenation formula is as follows:

[0029]

[0030] In the formula, T represents the text concatenation result of the user attribute features queried from two databases;

[0031] Finally, the Word2Vec technology is used to transform the answer into a vectorized embedding form as a personalized user attribute feature. The specific formula is as follows:

[0032]

[0033] In the formula, Represents personalized user attribute characteristics.

[0034] As a preferred implementation, the steps of fusing the personalized user attribute features of various users with the time series features by vector concatenation to obtain the comprehensive features are as follows:

[0035]

[0036] In the formula, It represents the time series features obtained after the power time series data is processed by the embedding layer neural network.

[0037] On the other hand, the present invention proposes a user-level power prediction system based on knowledge graph retrieval and enhanced generation, comprising:

[0038] The database construction module collects and preprocesses the power attribute data of several users, and constructs a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data;

[0039] The personalized user attribute feature extraction module inputs the power attribute data of several personalized users into the pre-trained large language model, classifies users with similar power attribute data into similar users, generates natural language question text based on the user's power attribute data, queries the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generates personalized user attribute features for each type of user;

[0040] The comprehensive feature splicing module obtains power time series data based on the power consumption records of various users based on their power consumption habits within a preset time range, and then uses the embedded layer neural network to extract time series features; the personalized user attribute features of various users are integrated with the time series features through vector splicing to obtain comprehensive features;

[0041] The electricity consumption prediction module inputs the comprehensive features into the pre-trained LSTM prediction model to obtain the final electricity prediction results that take into account the user's electricity consumption habits and user attributes.

[0042] As a preferred implementation, the collecting of several user power attribute data and preprocessing is specifically as follows:

[0043] The tabular structure data in each user profile is extracted in the form of bigrams, wherein the bigrams include user attributes and their corresponding values; and then the pre-trained large language model and prompt engineering are used to unify multiple bigrams of the user into a natural language description text block.

[0044] As a preferred implementation, the steps of constructing a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data are specifically as follows:

[0045] Based on the natural language description text blocks of each user, vector data is established through LangChain's local deployment library;

[0046] The user's natural language description text block in the vector database is called and input into the pre-trained large language model to extract each name entity and the relationship entity between each name entity, build a ternary relationship pair between every two name entities, and generate a preliminary knowledge graph; with each element entity node in the knowledge graph as the center, extract all its link point pairs, and input all link point pairs into the large language model to generate an element entity summary of the element entity and attach it to the description information of each node; then the nodes on the preliminary knowledge graph are clustered through the Leiden algorithm to generate a hierarchical community structure, and complete the construction of the hierarchical knowledge graph database;

[0047] The hierarchical community structure includes a root-level community, a low-level community, a middle-level community and a high-level community.

[0048] As a preferred implementation, the steps of generating a natural language question text based on the user's power attribute data, querying the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generating personalized user attribute features for each type of user are specifically as follows:

[0049] Based on the natural language question text, query in the vector database. The specific formula is as follows:

[0050]

[0051] In the formula, Indicates the return text. represents text concatenation, Q represents natural language question text, Before The maximum value, represents the similarity function, Represents a data block;

[0052] Then query in the hierarchical knowledge graph database. The specific formula is as follows:

[0053]

[0054] In the formula, Represents the electricity consumption characteristics of various users in hierarchical knowledge graph data query, Indicates the community summary, Representing different levels of community;

[0055] The query results of the two databases are concatenated and returned to the large language model as a reference to generate the corresponding natural language answer. The concatenation formula is as follows:

[0056]

[0057] In the formula, T represents the text concatenation result of the user attribute features queried from two databases;

[0058] Finally, the Word2Vec technology is used to transform the answer into a vectorized embedding form as a personalized user attribute feature. The specific formula is as follows:

[0059]

[0060] In the formula, Represents personalized user attribute characteristics.

[0061] As a preferred implementation, the steps of fusing the personalized user attribute features of various users with the time series features by vector splicing to obtain the comprehensive features are specifically as follows:

[0062]

[0063] In the formula, It represents the time series features obtained after the power time series data is processed by the embedding layer neural network.

[0064] The present invention has the following beneficial effects:

[0065] 1. Aiming at the current demand for personalized electricity consumption services in the electricity market, the present invention uses cutting-edge knowledge graph retrieval enhancement generation algorithm to establish a user-level power and electricity analysis method. By establishing a model that accurately depicts user-level electricity consumption behavior, the high-dimensionality and high-throughput challenges of user-level data are addressed.

[0066] 2. The present invention deeply explores the attribute factors and behavioral logic of users, accurately predicts the electricity demand of various types of electricity users, and provides personalized electricity services for users. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] Figure 1 It is a schematic diagram of the method flow of the present invention;

[0068] Figure 2 It is a structural topology diagram based on the method flow of the present invention;

[0069] Figure 3 Figure 2 is a flow chart of the Leiden algorithm. DETAILED DESCRIPTION

[0070] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0071] It should be understood that the step numbers used in this document are only for convenience of description and are not intended to limit the order in which the steps are executed.

[0072] It should be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0073] The terms “include” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0074] The term "and / or" means and includes any and all possible combinations of one or more of the associated listed items.

[0075] Embodiment 1:

[0076] See also Figure 1 , a user-level power prediction method based on knowledge graph retrieval and enhanced generation, the specific steps include:

[0077] Collect and preprocess the power attribute data of several users, and build a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data;

[0078] In this embodiment, the user's power attribute data is collected based on the user profile, and the data in the table is extracted in the form of two tuples, that is, (attribute, value), and stored in units of users. Then, using the large model and prompt engineering, multiple two tuples of the same user are processed into natural language descriptions. The extracted natural language description result is as follows: XXX is a male high school teacher who lives at No. XX, XXX Road, and belongs to the X-voltage resident in the urban residents' daily electricity consumption...

[0079] The power attribute data of several personalized users are input into the pre-trained large language model, and users with similar power attribute data are divided into similar users. Natural language question texts are generated based on the power attribute data of users, and the power consumption levels of various users are queried in the vector database and the hierarchical knowledge graph database to generate personalized user attribute features for each type of user.

[0080] In this embodiment, for each user, their power attribute data, namely attribute characteristics (age, occupation, gender, address, etc.) are input into the big model, and the big model generates a natural language question text.

[0081] Obtain power time series data based on the power consumption records of various users within a preset time range, and then use the embedded layer neural network to extract time series features; merge the personalized user attribute features of various users with the time series features through vector splicing to obtain comprehensive features;

[0082] In this embodiment, the historical electricity consumption records in each user's profile are extracted first, and then the electricity consumption records within a preset time range are extracted according to the needs. The time series characteristics of the user's short-term and long-term behaviors can be respectively represented according to the preset time length;

[0083] The comprehensive features are input into the pre-trained LSTM prediction model to obtain the final power prediction results that take into account the user's power usage habits and user attributes.

[0084] In this embodiment, the LSTM prediction model is a special recurrent neural network architecture, which is designed to solve the gradient vanishing or gradient exploding problems encountered by traditional RNN when processing long sequence data. This patent inputs the embedded comprehensive features into LSTM, thereby learning the user's behavior while fully combining the user's attribute information, and predicting the user's personalized electricity consumption.

[0085] The LSTM algorithm process is as follows:

[0086] Step 1: Forget gate calculation.

[0087]

[0088] in, It is The forget gate output of time steps, is the hidden state at the previous time step, is the input of the current time step, and are the weight and bias of the forget gate.

[0089] Step2: Input gate calculation.

[0090]

[0091]

[0092] in, is the output of the input gate, is a candidate cell state, is the input gate weight matrix, is the input gate bias term, is the cell state weight matrix, is the cell state bias term.

[0093] Step3: Update cell status.

[0094]

[0095] in, is the cell state at the current time step, is the cell state at the previous time step.

[0096] Step4: Output gate calculation.

[0097]

[0098] in, is the output gate weight matrix, is the output gate bias term.

[0099] Step5: Update the hidden status.

[0100]

[0101] in, is the hidden state at the current time step.

[0102] Based on the above steps, the structural topology diagram of the power prediction method is as follows: Figure 2 shown.

[0103] As a preferred implementation of this embodiment, the collection of several user power attribute data and preprocessing are specifically as follows:

[0104] The tabular structure data in each user profile is extracted in the form of bigrams, wherein the bigrams include user attributes and their corresponding values; and then the pre-trained large language model and prompt engineering are used to unify multiple bigrams of the user into a natural language description text block.

[0105] As a preferred implementation of this embodiment, the steps of constructing a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data are specifically as follows:

[0106] Based on the natural language description text blocks of each user, vector data is established through LangChain's local deployment library;

[0107] The user's natural language description text block in the vector database is called and input into the pre-trained large language model to extract each name entity and the relationship entity between each name entity, build a ternary relationship pair between every two name entities, and generate a preliminary knowledge graph; with each element entity node in the knowledge graph as the center, extract all its link point pairs, and input all link point pairs into the large language model to generate an element entity summary of the element entity and attach it to the description information of each node; then the nodes on the preliminary knowledge graph are clustered through the Leiden algorithm to generate a hierarchical community structure, and complete the construction of the hierarchical knowledge graph database;

[0108] The hierarchical community structure includes a root-level community, a low-level community, a middle-level community and a high-level community.

[0109] In this embodiment, the Leiden algorithm is a graph theory algorithm for community detection. It is based on the modular optimization of the graph, and its purpose is to divide the nodes in the network into communities composed of closely connected nodes, while the connections between these communities are relatively sparse. Before the Leiden algorithm is executed, the quality function needs to be defined first, and the Constant Potts Model is usually used to determine the quality function:

[0110]

[0111] in Representing the community The number of sides, Representing the community For the preliminary knowledge graph, the Leiden algorithm is used iteratively to discover communities, and the intermediate results of the iterative process are regarded as communities at different levels, namely, root-level communities, low-level communities, middle-level communities, and high-level communities.

[0112] Leiden algorithm process:

[0113] Input: knowledge graph G=(V,E), where V is the point set and E is the edge set;

[0114] Output: Hierarchical knowledge graph G'.

[0115] Step 1: Local movement of nodes. First, assign each node in the graph G to an independent community, then randomly traverse each node in the form of a queue, try to add the current node to other partitions that can increase the quality function H, and finally move the current node to the partition that can maximize H, and add neighboring nodes that are not in the queue to the queue. Repeat this process until the quality function cannot be increased, and save the partition result at this time as P.

[0116] Step 2: Partition refinement. For each community in P, reassign each node to an independent community, and traverse the well-connected internal nodes, adding them to the well-connected internal community C with probability P:

[0117]

[0118] in Responsible for controlling the degree of randomization to obtain the refined partition Prefine.

[0119] Step 3: Network aggregation based on refined partitions. Aggregate the graph based on the refined partitions, retain the non-refined graph P, and use the community relationship of the non-refined partitions as the starting point for the next iteration. The graph G becomes G' after this round of iteration.

[0120] Repeat Step 1-3 until the mass function cannot be increased.

[0121] The flowchart of Leiden algorithm is as follows Figure 3 shown.

[0122] As a preferred implementation of this embodiment, the steps of generating a natural language question text based on the user's power attribute data, querying the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generating personalized user attribute features for each type of user are specifically as follows:

[0123] Based on the natural language question text, query in the vector database. The specific formula is as follows:

[0124]

[0125] In the formula, Indicates the return text. represents text concatenation, Q represents natural language question text, Before The maximum value, represents the similarity function, Represents a data block;

[0126] Then query in the hierarchical knowledge graph database. The specific formula is as follows:

[0127]

[0128] In the formula, Represents the electricity consumption characteristics of various users in hierarchical knowledge graph data query, Indicates the community summary, Representing different levels of community;

[0129] The query results of the two databases are concatenated and returned to the large language model as a reference to generate the corresponding natural language answer. The concatenation formula is as follows:

[0130]

[0131] In the formula, T represents the text concatenation result of the user attribute features queried from two databases;

[0132] Finally, the Word2Vec technology is used to transform the answer into a vectorized embedding form as a personalized user attribute feature. The specific formula is as follows:

[0133]

[0134] In the formula, Represents personalized user attribute characteristics.

[0135] In this embodiment, Word2Vec is a computational model for generating word embeddings, which can map vocabulary to continuous vectors in a vector space. Word2Vec has two main architectures: continuous bag of words and skip model.

[0136] 1. Continuous Bag of Words

[0137] The goal of the continuous bag of words model is to predict words in a given context. Specifically, it uses several surrounding words of a word as input to predict the target word.

[0138] 2. Leapfrog Model

[0139] In contrast to continuous bag of words, the goal of the skip model is to use the target word to predict its context. The skip model usually performs better when dealing with rare words because it directly learns the relationship between the target word and its context.

[0140] Word2Vec algorithm flow:

[0141] Step 1: Initialize word vectors. Randomly initialize a vector for each word in the vocabulary.

[0142] Step 2: Select training samples. For each word, select a context window based on its position in the text and extract training samples from it.

[0143] Step 3: Train the model. For the continuous bag-of-words model, use the weighted sum of the context word vectors to predict the target word. For Skip-gram, use the target word vector to predict the context word.

[0144] Step 4: Optimize. Use gradient descent or other optimization algorithms to adjust the word vectors to minimize the prediction error.

[0145] Step 5: Iteration. Repeat Step 3 and 4 until the model converges.

[0146] As a preferred implementation of this embodiment, the steps of fusing the personalized user attribute features of various users with the time series features by vector splicing to obtain the comprehensive features are specifically as follows:

[0147]

[0148] In the formula, It represents the time series features obtained after the power time series data is processed by the embedding layer neural network.

[0149] Embodiment 2

[0150] A user-level power prediction system based on knowledge graph retrieval and enhanced generation, comprising:

[0151] The database construction module collects and preprocesses the power attribute data of several users, and constructs a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data;

[0152] The personalized user attribute feature extraction module inputs the power attribute data of several personalized users into the pre-trained large language model, classifies users with similar power attribute data into similar users, generates natural language question text based on the user's power attribute data, queries the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generates personalized user attribute features for each type of user;

[0153] The comprehensive feature splicing module obtains power time series data based on the power consumption records of various users based on their power consumption habits within a preset time range, and then uses the embedded layer neural network to extract time series features; the personalized user attribute features of various users are integrated with the time series features through vector splicing to obtain comprehensive features;

[0154] The electricity consumption prediction module inputs the comprehensive features into the pre-trained LSTM prediction model to obtain the final electricity prediction results that take into account the user's electricity consumption habits and user attributes.

[0155] As a preferred implementation of this embodiment, the collection of several user power attribute data and preprocessing are specifically as follows:

[0156] The tabular structure data in each user profile is extracted in the form of bigrams, wherein the bigrams include user attributes and their corresponding values; and then the pre-trained large language model and prompt engineering are used to unify multiple bigrams of the user into a natural language description text block.

[0157] As a preferred implementation of this embodiment, the steps of constructing a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data are specifically as follows:

[0158] Based on the natural language description text blocks of each user, vector data is established through LangChain's local deployment library;

[0159] The user's natural language description text block in the vector database is called and input into the pre-trained large language model to extract each name entity and the relationship entity between each name entity, build a ternary relationship pair between every two name entities, and generate a preliminary knowledge graph; with each element entity node in the knowledge graph as the center, extract all its link point pairs, and input all link point pairs into the large language model to generate an element entity summary of the element entity and attach it to the description information of each node; then the nodes on the preliminary knowledge graph are clustered through the Leiden algorithm to generate a hierarchical community structure, and complete the construction of the hierarchical knowledge graph database;

[0160] The hierarchical community structure includes a root-level community, a low-level community, a middle-level community and a high-level community.

[0161] As a preferred implementation of this embodiment, the steps of generating a natural language question text based on the user's power attribute data, querying the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generating personalized user attribute features for each type of user are specifically as follows:

[0162] Based on the natural language question text, query in the vector database. The specific formula is as follows:

[0163]

[0164] In the formula, Indicates the return text. represents text concatenation, Q represents natural language question text, Before The maximum value, represents the similarity function, Represents a data block;

[0165] Then query in the hierarchical knowledge graph database. The specific formula is as follows:

[0166]

[0167] In the formula, Represents the electricity consumption characteristics of various users in hierarchical knowledge graph data query, Indicates the community summary, Representing different levels of community;

[0168] The query results of the two databases are concatenated and returned to the large language model as a reference to generate the corresponding natural language answer. The concatenation formula is as follows:

[0169]

[0170] In the formula, T represents the text concatenation result of the user attribute features queried from two databases;

[0171] Finally, the Word2Vec technology is used to transform the answer into a vectorized embedding form as a personalized user attribute feature. The specific formula is as follows:

[0172]

[0173] In the formula, Represents personalized user attribute characteristics.

[0174] As a preferred implementation of this embodiment, the steps of fusing the personalized user attribute features of various users with the time series features by vector splicing to obtain the comprehensive features are specifically as follows:

[0175]

[0176] In the formula, It represents the time series features obtained after the power time series data is processed by the embedding layer neural network.

[0177] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. User-level power prediction method based on knowledge graph retrieval and enhanced generation, It is characterized in that The specific steps include: Collect and preprocess the power attribute data of several users, and build a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data; The collecting of several user power attribute data and preprocessing is specifically as follows: Extract the table structure data in each user profile in the form of two-tuples, wherein the two-tuples include user attributes and their corresponding values; then use the pre-trained large language model and prompt engineering to generate a natural language description text block from multiple two-tuples of unified users; The steps of constructing a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data are specifically as follows: Based on the natural language description text blocks of each user, vector data is established through LangChain's local deployment library; The user's natural language description text block in the vector database is called and input into the pre-trained large language model to extract each name entity and the relationship entity between each name entity, build a ternary relationship pair between every two name entities, and generate a preliminary knowledge graph; with each element entity node in the knowledge graph as the center, extract all its link point pairs, and input all link point pairs into the large language model to generate an element entity summary of the element entity and attach it to the description information of each node; then the nodes on the preliminary knowledge graph are clustered through the Leiden algorithm to generate a hierarchical community structure, and complete the construction of the hierarchical knowledge graph database; The hierarchical community structure includes a root-level community, a low-level community, an intermediate-level community and a high-level community; The power attribute data of several personalized users are input into the pre-trained large language model, and users with similar power attribute data are divided into similar users. Natural language question texts are generated based on the power attribute data of users, and the power consumption levels of various users are queried in the vector database and the hierarchical knowledge graph database to generate personalized user attribute features for each type of user. The steps of generating a natural language question text based on the user's power attribute data, querying the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generating personalized user attribute features for each type of user are specifically as follows: Based on the natural language question text, query in the vector database. The specific formula is as follows: In the formula, Indicates the return text. represents text concatenation, Q represents natural language question text, Before The maximum value, represents the similarity function, Represents a data block; Then query in the hierarchical knowledge graph database, the specific formula is as follows: In the formula, Represents the electricity consumption characteristics of various users in hierarchical knowledge graph data query, Indicates the community summary, Representing different levels of community; The query results of the two databases are concatenated and returned to the large language model as a reference to generate the corresponding natural language answer. The concatenation formula is as follows: In the formula, T represents the text concatenation result of the user attribute features queried from two databases; Finally, the Word2Vec technology is used to transform the answer into a vectorized embedding form as a personalized user attribute feature. The specific formula is as follows: In the formula, Represents personalized user attribute characteristics; Obtain power time series data based on the power consumption records of various users within a preset time range, and then use the embedded layer neural network to extract time series features; merge the personalized user attribute features of various users with the time series features through vector splicing to obtain comprehensive features; The steps of fusing the personalized user attribute features of various users with the time series features by vector concatenation to obtain comprehensive features are as follows: In the formula, It represents the time series characteristics obtained after the power time series data is processed by the embedding layer neural network; The comprehensive features are input into the pre-trained LSTM prediction model to obtain the final power prediction results that take into account the user's power usage habits and user attributes.

2. User-level power prediction system based on knowledge graph retrieval and enhanced generation, It is characterized in that include: The database construction module collects and preprocesses the power attribute data of several users, and constructs a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data; The collecting of several user power attribute data and preprocessing is specifically as follows: Extract the table structure data in each user profile in the form of two-tuples, wherein the two-tuples include user attributes and their corresponding values; then use the pre-trained large language model and prompt engineering to generate a natural language description text block from multiple two-tuples of unified users; The steps of constructing a vector database and a hierarchical knowledge graph database based on the preprocessed power attribute data are specifically as follows: Based on the natural language description text blocks of each user, vector data is established through LangChain's local deployment library; The user's natural language description text block in the vector database is called and input into the pre-trained large language model to extract each name entity and the relationship entity between each name entity, build a ternary relationship pair between every two name entities, and generate a preliminary knowledge graph; with each element entity node in the knowledge graph as the center, extract all its link point pairs, and input all link point pairs into the large language model to generate an element entity summary of the element entity and attach it to the description information of each node; then the nodes on the preliminary knowledge graph are clustered through the Leiden algorithm to generate a hierarchical community structure, and complete the construction of the hierarchical knowledge graph database; The hierarchical community structure includes a root-level community, a low-level community, an intermediate-level community and a high-level community; The personalized user attribute feature extraction module inputs the power attribute data of several personalized users into the pre-trained large language model, classifies users with similar power attribute data into similar users, generates natural language question text based on the user's power attribute data, queries the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generates personalized user attribute features for each type of user; The steps of generating a natural language question text based on the user's power attribute data, querying the power consumption level of each type of user in the vector database and the hierarchical knowledge graph database, and generating personalized user attribute features for each type of user are specifically as follows: Based on the natural language question text, query in the vector database. The specific formula is as follows: In the formula, Indicates the return text. represents text concatenation, Q represents natural language question text, Before The maximum value, represents the similarity function, Represents a data block; Then query in the hierarchical knowledge graph database, the specific formula is as follows: In the formula, Represents the electricity consumption characteristics of various users in hierarchical knowledge graph data query, Indicates the community summary, Representing different levels of community; The query results of the two databases are concatenated and returned to the large language model as a reference to generate the corresponding natural language answer. The concatenation formula is as follows: In the formula, T represents the text concatenation result of the user attribute features queried from two databases; Finally, the Word2Vec technology is used to transform the answer into a vectorized embedding form as a personalized user attribute feature. The specific formula is as follows: In the formula, Represents personalized user attribute characteristics; The comprehensive feature splicing module obtains power time series data based on the power consumption records of various users based on their power consumption habits within a preset time range, and then uses the embedded layer neural network to extract time series features; the personalized user attribute features of various users are integrated with the time series features through vector splicing to obtain comprehensive features; The steps of fusing the personalized user attribute features of various users with the time series features by vector concatenation to obtain comprehensive features are as follows: In the formula, It represents the time series characteristics obtained after the power time series data is processed by the embedding layer neural network; The electricity consumption prediction module inputs the comprehensive features into the pre-trained LSTM prediction model to obtain the final electricity prediction results that take into account the user's electricity consumption habits and user attributes.