Power demand prediction and knowledge retrieval method and device based on NLP

Through the NLP-based method, a power demand prediction model library and power knowledge database are built, user input statements are analyzed and corresponding models or functions are automatically called, which solves the problem of lack of synergy and intelligent interaction of power demand prediction and knowledge retrieval in the existing technology, and achieves high-precision prediction and retrieval effects.

CN119940661AActive Publication Date: 2025-05-06国网福建省电力有限公司营销服务中心 +1
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202510422850.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2025-05-06
Estimated Expiration
2045-04-07

AI Technical Summary

Technical Problem

The existing technology lacks synergistic and intelligent interaction capabilities in power demand forecasting and power knowledge retrieval, and it is difficult to effectively integrate multi-dimensional data, resulting in insufficient prediction accuracy and retrieval accuracy.

Method used

Using NLP-based method, by obtaining power demand data and knowledge data, a power demand prediction model library and power knowledge database are built, and user input statements are analyzed using the Transformer model and intention classifier, and corresponding prediction models or search functions are automatically called to realize the synergization of power demand prediction and knowledge retrieval.

Benefits of technology

The accuracy of power demand forecasting, the accuracy and intelligence level of power knowledge retrieval have been improved, the coordination of functions has been achieved, and the intelligent interaction capabilities of the power system have been enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119940661A_ABST
    Figure CN119940661A_ABST
Patent Text Reader

Abstract

The invention relates to an NLP-based power demand prediction and knowledge retrieval method and device, and belongs to the technical field of power system and energy informationization, and the method comprises the following steps: constructing a power demand prediction model library through obtaining power demand data, and supporting power demand prediction of different time scales; and obtaining power knowledge data to construct a power knowledge database. The system receives a user input statement, identifies a user demand through an intention classifier, and if the user demand is query electric power knowledge, generates a query statement by using an SQL generation model and returns a query result in combination with a retrieval enhancement technology; and if demand prediction is carried out, determining a prediction time scale through a hybrid expert model and calling a corresponding model to generate a power demand prediction result. According to the invention, two independent tasks are integrated, so that the intelligent level of the power system is improved, and a user can obtain information and carry out demand prediction more conveniently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and device for predicting power demand and knowledge retrieval based on NLP, and belongs to the technical field of power system and energy informationization. Background Art

[0002] With the rapid development of energy informatization and smart grids, power demand forecasting and power knowledge retrieval play a vital role in power system planning, operational decision-making and user services. Power demand forecasting needs to comprehensively consider multi-dimensional factors such as historical power consumption data, economic indicators, and meteorological conditions, while power knowledge retrieval involves the rapid and accurate extraction of massive unstructured data such as policy documents, technical specifications, and historical reports. Currently, these two tasks are usually completed by independent systems, lacking coordination and intelligent interaction capabilities.

[0003] Traditional statistical methods and some machine learning methods are inadequate in modeling the complex time-varying characteristics of power data, especially in responding to nonlinear and highly volatile load data. This results in low accuracy of prediction models when faced with emergencies or rapidly changing periods. Existing models usually fail to effectively integrate multi-dimensional data (such as external variables such as temperature, economic indicators, holidays, etc.) and lack the ability to dynamically respond to changes in these external factors.

[0004] Prior art, such as the Chinese patent application with publication number "CN118673041A", discloses a method and device for searching a table of a power business database, including the following steps: constructing a power field dictionary and a knowledge graph of a power business database table based on the collected power field data; parsing a search keyword list based on the power field dictionary and the natural language input by the user, searching the power business database based on the search model and the search keyword list to obtain a sample of the recalled data table; predicting the sample of the recalled data table based on the prediction model to obtain the SQL element and user intention of the power business database corresponding to the natural language input by the user; generating an SQL query statement based on the SQL element, user intention, natural language input by the user, and the knowledge graph of the power business database table, and searching based on the SQL query statement. However, the above patent mainly uses text data in the power field to construct a dictionary and a knowledge graph, and lacks the comprehensive use of multi-dimensional data such as historical electricity consumption data, economic indicators, and meteorological conditions. These multi-dimensional data are crucial to improving the accuracy of retrieval and prediction. Although the above patent realizes the conversion from natural language to SQL query statements, it still needs to be improved in terms of intelligent interaction. For example, there is no mention of how to automatically adjust the search strategy according to the user's intention or provide personalized search results. The proposed power business database table search method and device are relatively independent and lack effective integration with other power system components (such as power demand forecasting system, user service system, etc.). This may lead to information island phenomenon and reduce the operating efficiency of the entire power system. Summary of the invention

[0005] In order to solve the above problems existing in the prior art, the present invention proposes a method and device for power demand forecasting and knowledge retrieval based on NLP.

[0006] The technical solution of the present invention is as follows: On the one hand, the present invention provides a method for power demand forecasting and knowledge retrieval based on NLP, comprising the following steps: Obtain electricity demand data, and build an electricity demand forecasting model library based on the electricity demand data to forecast electricity demand at different time scales; Acquire power knowledge data, and build a power knowledge database based on the power knowledge data; Obtaining a user input sentence, taking the user input sentence as the input of the Transformer model, outputting a context vector, and using an intent classifier to analyze the context vector to obtain an intent analysis result; the intent analysis result includes a query behavior of a power knowledge database and a prediction behavior of a power demand prediction model library; Constructing an SQL generation model and a hybrid expert model. If the intention analysis result is a query behavior of the electric power knowledge database, the user input statement is used as the input of the SQL generation model, and the corresponding SQL statement is output; Use the SQL statement to query the power knowledge database to obtain an initial query result, use the retrieval enhancement technology to query the power knowledge database based on the user input statement to obtain a power knowledge prediction result, and splice the initial query result and the power knowledge prediction result as the power knowledge database query result; If the intention analysis result is a prediction behavior of the power demand prediction model library, the user input statement is used as the input of the hybrid expert model, the time scale to be predicted by the user is output, and the power demand prediction model library is called to select a single model corresponding to the time scale for prediction, so as to obtain the power demand prediction result; The power demand forecast result or the power knowledge database query result is returned to the user. As a preferred implementation, the user input sentence is used as the input of the hybrid expert model, and the time scale to be predicted by the user is output. The specific steps are: Let the number of expert models be , the mixed expert model is expressed in the formula: ; In the formula, represents the time scale to be predicted by the hybrid expert model output user, Indicates The weight of the expert model, Indicates The expert model outputs the time scale that the user wants to predict. Represents a user input statement; The weight of the expert model is obtained through a gated neural network and is expressed as: ; In the formula, represents the weight matrix, represents the bias term; Objective Function of Gated Neural Network It is expressed as: ; In the formula, represents the expectation operator, express The data distribution, represents the parameters of the gated neural network, represents the optimal weight allocation strategy, represents the probability that the gated neural network generates the optimal weight allocation strategy, represents the reward value of the optimal weight allocation strategy of the gated neural network, represents log probability; Output the time scale to be predicted by the user based on the hybrid expert model , call the single model corresponding to the time scale in the electricity demand forecasting model library for forecasting.

[0007] As a preferred implementation, the power demand data is obtained, and a power demand forecasting model library is constructed based on the power demand data to forecast power demand at different time scales. The specific steps are as follows: The power demand data includes historical power consumption, real-time power consumption and power distribution; The time scales include ultra-short term, short term and medium to long term; Construct an ultra-short-term forecasting model, expressed as follows: ; In the formula, Indicated in The prediction results at the moment, represents the long short-term memory network function, express The electricity demand data at the moment, Indicates the time offset; Construct a short-term forecast model, expressed as: ; In the formula, represents the white noise error term, represents the lag operator, represents the length of the seasonal cycle, represents seasonal differences, represents the parameters of the non-seasonal autoregressive part, represents the parameter of the non-seasonal moving average part; Construct a medium- and long-term forecasting model. The specific steps are as follows: Obtain economic, policy and meteorological data to construct an impact set, fuse the impact set with the input data to obtain a data set, select the Transformer model as the base of the medium- and long-term forecast model, and use the data set to train the medium- and long-term forecast model; The loss function of the medium- and long-term prediction model is the mean square error function, which is expressed as follows: ; In the formula, Indicated in The loss value at the moment, Indicates the maximum time offset, Indicated in The predicted value at time, Indicated in The true value of the moment; A power demand prediction model library is constructed based on the ultra-short-term prediction model, the short-term prediction model and the medium- and long-term prediction model.

[0008] As a preferred embodiment, the method further includes multi-model prediction of a power demand prediction model library; If there are special prediction scenarios when the electricity demand prediction model library predicts, the single model prediction is replaced by the multi-model prediction of the electricity demand prediction model library. The specific steps are as follows: The special forecast scenarios include holidays and extreme weather; The multi-model prediction is expressed in the formula: ; In the formula, represents the electricity demand predicted by multiple models, represents the multi-model prediction weight, It indicates the power demand forecast result of the ultra-short-term forecast model, the short-term forecast model or the medium- and long-term forecast model.

[0009] As a preferred implementation, a user input sentence is obtained, the user input sentence is used as the input of the Transformer model, a context vector is output, and the context vector is analyzed using an intent classifier to obtain an intent analysis result. The specific steps are as follows: Let the intention set be expressed as: ; In the formula, Intent Collection The first intent tag in Indicates the number of intent labels; Get the user input sentence, and map the words in the user input sentence into word vectors through word embedding technology, which can be expressed as follows: ; ; In the formula, Represents a user input statement, Indicates the number of words in the user input sentence, represents the word embedding technology function, Indicates the first words, Indicates word vectors; The word vector is used as the input of the Transformer model, and the context vector is output, which can be expressed as: ; In the formula, represents the context vector, Represents the Transformer model function; The context vector is used as the input of the intent classifier and the intent analysis label is output, which can be expressed as: ; In the formula, Indicates the intent analysis tag, represents the intent classifier function; Compare the intent analysis label with the intent labels in the intent set, and take the consistent intent labels as the intent analysis results.

[0010] As a preferred implementation, the steps of acquiring power knowledge data and constructing a power knowledge database based on the power knowledge data are as follows: The electric power knowledge data includes unstructured text data and structured text data; The unstructured text data includes electricity policy documents, business norms and management systems of enterprises, historical electricity demand analysis reports, statistical yearbooks and expert literature; The structured text data includes electricity consumption history data and market economic indicators; The power knowledge data is stored in the database, and the entities of the power knowledge data are extracted through named entity recognition technology to construct a knowledge graph, which can be expressed as follows: ; In the formula, represents the knowledge graph, Represents a collection of entities, Represents a set of relations, Indicates Entities and Entities relationship; Among them, the entities in the knowledge graph are aligned by calculating the cosine similarity of the entities, which can be expressed as: ; In the formula, express and The cosine similarity of Representing Entities The vector of Representing Entities The vector of represents the calculation of the inner product, Indicates the calculated modulus length; An electric power knowledge database is constructed based on the knowledge graph and database.

[0011] As a preferred implementation, the user input statement is used as the input of the SQL generation model, and the corresponding SQL statement is output. The SQL generation model is expressed as: ; In the formula, Represents the SQL generation model, Indicates the length of the user input sentence. Indicates The smallest grammatical unit, Represents a user input statement, represents the probability of the smallest grammatical unit appearing in the user input sentence, Indicates that the index value is less than The smallest grammatical unit of The minimum grammatical unit includes keywords, identifiers, literals, operators and comments.

[0012] As a preferred implementation, the method further includes optimizing the SQL generation model through supervised fine-tuning, which is expressed as: ; ; In the formula, represents the SQL syntax constraint loss term, represents the supervised fine-tuning loss term, represents the scaling parameter of the loss term, represents the loss function of the SQL generation model, represents the minimization loss function, represents the sum of the SQL syntax constraint loss term and the supervised fine-tuning loss term, Indicates User input statements, Indicates The expected output of a SQL statement.

[0013] As a preferred implementation, based on the user input statement, the power knowledge database is queried using the search enhancement technology to obtain the power knowledge prediction result; Through the retrieval enhancement technology, the knowledge graph in the power knowledge database with the same entity relationship as the user input sentence is queried as the power knowledge prediction result, which can be expressed as: ; In the formula, represents the prediction result of power knowledge, Represents a user input statement, represents the retrieval enhancement technique function, Represents the same statement as the user input Knowledge graphs with the same entity relationships.

[0014] On the other hand, the present invention further provides an electronic device having a computer program stored thereon, wherein when the computer program is executed by a processor, the NLP-based power demand forecasting and knowledge retrieval method as described in any embodiment of the present invention is implemented.

[0015] The present invention has the following beneficial effects: 1. The present invention integrates two independent tasks, power demand forecasting and power knowledge retrieval, into one system, achieving functional synergy. This greatly improves the intelligence level of the power system, allowing users to more conveniently obtain the required information and conduct power demand forecasting.

[0016] 2. The present invention improves the accuracy of the prediction model by building a power demand prediction model library, comprehensively considering multi-dimensional factors such as historical power consumption data, economic indicators, and meteorological conditions. Corresponding prediction models are built for power demand at different time scales, such as ultra-short-term (minute to hour level), short-term (day to week level), and medium- and long-term (month to year level), to meet the needs of different application scenarios.

[0017] 3. The present invention can process unstructured text data including electricity policy documents, enterprise business specifications, etc., extract entities and construct knowledge graphs through named entity recognition technology, thereby improving the efficiency and accuracy of information retrieval. By integrating the initial query results and user input statements, the final power knowledge database query results are obtained using retrieval enhancement technology, further improving the accuracy and relevance of the retrieval.

[0018] 4. The present invention uses the Transformer model and intent classifier to analyze user input sentences, understand user intent, and automatically call the corresponding prediction model or retrieval function, thus realizing intelligent human-computer interaction. The hybrid expert model is used to analyze the time scale that the user needs to predict, and the most appropriate prediction model is automatically selected for prediction, thus improving the intelligence level of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 The present invention is a flowchart for implementing the method. DETAILED DESCRIPTION

[0020] 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.

[0021] 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.

[0022] 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.

[0023] 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.

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

[0025] Embodiment 1: In this embodiment , Represents a general index.

[0026] See also Figure 1 The present invention provides a method for predicting power demand and knowledge retrieval based on NLP, comprising the following steps: Obtain electricity demand data, and build an electricity demand forecasting model library based on the electricity demand data to forecast electricity demand at different time scales; Acquire power knowledge data, and build a power knowledge database based on the power knowledge data; Obtaining a user input sentence, taking the user input sentence as the input of the Transformer model, outputting a context vector, and using an intent classifier to analyze the context vector to obtain an intent analysis result; the intent analysis result includes a query behavior of a power knowledge database and a prediction behavior of a power demand prediction model library; Constructing an SQL generation model and a hybrid expert model. If the intention analysis result is a query behavior of the electric power knowledge database, the user input statement is used as the input of the SQL generation model, and the corresponding SQL statement is output; Use the SQL statement to query the power knowledge database to obtain an initial query result, use the retrieval enhancement technology to query the power knowledge database based on the user input statement to obtain a power knowledge prediction result, and splice the initial query result and the power knowledge prediction result as the power knowledge database query result; If the intention analysis result is a prediction behavior of the power demand prediction model library, the user input statement is used as the input of the hybrid expert model, the time scale to be predicted by the user is output, and the power demand prediction model library is called to select a single model corresponding to the time scale for prediction, so as to obtain the power demand prediction result; The power demand forecast result or the power knowledge database query result is returned to the user. The core idea of ​​the hybrid expert model is to combine multiple prediction sub-models (i.e., expert models) and dynamically determine the weights of each expert model through a gated neural network to cope with diverse needs under different time scales, power consumption patterns, and prediction scenarios.

[0027] As a preferred implementation, the user input sentence is used as the input of the hybrid expert model, and the time scale to be predicted by the user is output. The specific steps are: Let the number of expert models be , the mixed expert model is expressed in the formula: ; In the formula, represents the time scale to be predicted by the hybrid expert model output user, Indicates The weight of the expert model, Indicates The expert model outputs the time scale that the user wants to predict. Represents a user input statement; The weight of the expert model is obtained through a gated neural network and is expressed as: ; In the formula, represents the weight matrix, represents the bias term, Represents the activation function ; Objective Function of Gated Neural Network It is expressed as: ; In the formula, represents the expectation operator, express The data distribution, Represents the parameters of the gated neural network, including the weight matrix and bias term, represents the optimal weight allocation strategy, represents the probability that the gated neural network generates the optimal weight allocation strategy, represents the reward value of the optimal weight allocation strategy of the gated neural network, represents log probability; Output the time scale to be predicted by the user based on the hybrid expert model , call the single model corresponding to the time scale in the electricity demand forecasting model library for forecasting.

[0028] Dynamic scheduling of expert models is achieved through gated neural networks. As a "scheduler", the gated neural network automatically learns and analyzes the characteristics of the input data, evaluates the characteristic pattern of the current prediction task, and assigns different weights to each expert model.

[0029] The gated neural network and multi-expert model are modularly integrated, and a unified input and output interface is designed to support users to flexibly access various input data, such as historical electricity consumption data, meteorological data, holiday factors, and economic indicators. By setting up a data preprocessing module, multi-source data is cleaned, standardized, and feature extracted. The hybrid expert model has the ability to automatically model and predict. Users do not need to manually select models from the electricity demand prediction model library, but rely on the gated neural network to automatically complete the weight allocation and prediction output of the expert model.

[0030] As a preferred implementation, the power demand data is obtained, and a power demand forecasting model library is constructed based on the power demand data to forecast power demand at different time scales. The specific steps are as follows: The power demand data includes historical power consumption, real-time power consumption and power distribution; The time scales include ultra-short term, short term and medium to long term; The ultra-short term is from minute to hour level, and an ultra-short term prediction model is constructed, which is expressed as follows: ; In the formula, Indicated in The prediction results at the moment, represents the long short-term memory network function, express The electricity demand data at the moment, Indicates the time offset; The short term is from days to weeks, and a short-term prediction model is constructed, which is expressed as follows: ; In the formula, represents the white noise error term, represents the lag operator, represents the length of the seasonal cycle, represents seasonal differences, represents the parameters of the non-seasonal autoregressive part, represents the parameter of the non-seasonal moving average part; The medium and long term refers to the month to grade level. The specific steps for building a medium and long term prediction model are as follows: Obtain economic, policy and meteorological data to construct an impact set, fuse the impact set with the input data to obtain a data set, select the Transformer model as the base of the medium- and long-term forecast model, and use the data set to train the medium- and long-term forecast model; The loss function of the medium- and long-term prediction model is the mean square error function, which is expressed as follows: ; In the formula, Indicated in The loss value at the moment, Indicates the maximum time offset, Indicated in The predicted value at time, Indicated in The true value of the moment; The optimizer of the medium- and long-term prediction model is the Adam optimizer, which is expressed as follows: ; In the formula, Indicated in The learning rate at each moment, Indicated in The parameters updated at all times include the learning rate, the exponential decay rate of the first-order moment estimate, Represents the loss function Parameters The gradient of Indicated in The parameters of the moment, Indicated in The square of the gradient at that moment, represents the smoothing term; A power demand prediction model library is constructed based on the ultra-short-term prediction model, the short-term prediction model and the medium- and long-term prediction model.

[0031] As a preferred embodiment, the method further includes multi-model prediction of a power demand prediction model library; If there are special prediction scenarios when the electricity demand prediction model library predicts, the single model prediction is replaced by the multi-model prediction of the electricity demand prediction model library. The specific steps are as follows: The special forecast scenarios include holidays and extreme weather; The multi-model prediction is expressed in the formula: ; In the formula, represents the electricity demand predicted by multiple models, represents the multi-model prediction weight, It indicates the power demand forecast result of the ultra-short-term forecast model, the short-term forecast model or the medium- and long-term forecast model.

[0032] As a preferred implementation, a user input sentence is obtained, the user input sentence is used as the input of the Transformer model, a context vector is output, and the context vector is analyzed using an intent classifier to obtain an intent analysis result. The specific steps are as follows: Through in-depth communication with business personnel, we sorted out the analysis demand scenarios in their daily work, including specific business tasks such as trend forecasting, anomaly detection, load analysis, extreme weather impact assessment, regional comparative analysis, etc., and broke down the scenarios into a series of standardized intent labels, such as "query electricity demand in the next week", "analyze peak and valley loads in specific time periods", and "obtain electricity consumption trends in a certain area".

[0033] Let the intention set be expressed as: ; In the formula, Intent Collection The first intent tag in Indicates the number of intent labels; Get the user input sentence, and map the words in the user input sentence into word vectors through word embedding technology, which can be expressed as follows: ; ; In the formula, Represents a user input statement, Indicates the number of words in the user input sentence, represents the word embedding technology function, Indicates the first words, Indicates word vectors; The word vector is used as the input of the Transformer model, and the context vector is output, which can be expressed as: ; In the formula, represents the context vector, Represents the Transformer model function; The context vector is used as the input of the intent classifier and the intent analysis label is output, which can be expressed as: ; In the formula, Indicates the intent analysis tag, represents the intent classifier function; Compare the intent analysis label with the intent labels in the intent set, and take the consistent intent labels as the intent analysis results.

[0034] As a preferred implementation, the steps of acquiring power knowledge data and constructing a power knowledge database based on the power knowledge data are as follows: The power knowledge data includes unstructured text data and structured text data, and the data scattered in different sources are collected and integrated by using automated crawling tools, OCR text recognition technology and enterprise data interface; The unstructured text data includes electricity policy documents issued by the government, business norms and management systems of enterprises, historical electricity demand analysis reports, statistical yearbooks and expert literature; The structured text data includes electricity consumption history data and market economic indicators; The power knowledge data is stored in the database, and the entities of the power knowledge data are extracted through named entity recognition technology to construct a knowledge graph, which can be expressed as follows: ; In the formula, represents the knowledge graph, Represents a collection of entities, Represents a set of relations, Indicates Entities and Entities relationship, , Represents an index; Among them, the entities in the knowledge graph are aligned by calculating the cosine similarity of the entities, which can be expressed as: ; In the formula, express and The cosine similarity of Representing Entities The vector of Representing Entities The vector of represents the calculation of the inner product, Indicates the calculated modulus length; An electric power knowledge database is constructed based on the knowledge graph and database.

[0035] As a preferred implementation, the user input statement is used as the input of the SQL generation model, and the corresponding SQL statement is output. The SQL generation model is expressed as: ; In the formula, Represents the SQL generation model, Indicates the length of the user input sentence. Indicates The smallest grammatical unit, Represents a user input statement, Indicates the probability of the smallest grammatical unit appearing in the user input sentence; The minimum grammatical unit includes keywords, identifiers, literals, operators and comments.

[0036] In order to further improve the performance and robustness of the SQL generation model, reinforcement learning with human feedback (RLHF) is used for optimization. By introducing a reward mechanism, the SQL generation model can self-correct according to the execution results of the generated SQL query statements. For example, when the SQL query execution fails, the SQL generation model adjusts according to the execution error information to optimize the generation of subsequent queries.

[0037] As a preferred implementation, the method further includes optimizing the SQL generation model through supervised fine-tuning, which is expressed as: ; ; In the formula, represents the SQL syntax constraint loss term, represents the supervised fine-tuning loss term, represents the scaling parameter of the loss term, represents the loss function of the SQL generation model, represents the minimization loss function, represents the sum of the SQL syntax constraint loss term and the supervised fine-tuning loss term, Indicates User input statements, Indicates The expected output of a SQL statement is preset.

[0038] As a preferred implementation, based on the user input statement, the power knowledge database is queried using the search enhancement technology to obtain the power knowledge prediction result; Through the retrieval enhancement technology, the knowledge graph in the power knowledge database with the same entity relationship as the user input sentence is queried as the power knowledge prediction result, which can be expressed as: ; In the formula, represents the prediction result of power knowledge, Represents a user input statement, represents the retrieval enhancement technique function, Represents the same statement as the user input Knowledge graphs with the same entity relationships.

[0039] Embodiment 2: This embodiment provides an electronic device having a computer program stored thereon, wherein when the computer program is executed by a processor, the NLP-based power demand prediction and knowledge retrieval method as described in any embodiment of the present invention is implemented.

[0040] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.

[0041] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0042] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0043] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk, and other media that can store program codes.

[0044] 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. A method for power demand forecasting and knowledge retrieval based on NLP, characterized in that: The following steps are involved: Obtain power demand data, and build a power demand forecasting model library based on the power demand data to predict power demand at different time scales; obtain power knowledge data, and build a power knowledge database based on the power knowledge data; obtain user input statements, use the user input statements as input to the Transformer model, output context vectors, and use the intent classifier to analyze the context vectors to obtain intent analysis results; the intent analysis results include power knowledge database query behavior and power demand forecasting model library prediction behavior; Constructing an SQL generation model and a hybrid expert model. If the intention analysis result is a query behavior of the electric power knowledge database, the user input statement is used as the input of the SQL generation model, and the corresponding SQL statement is output; Use the SQL statement to query the power knowledge database to obtain an initial query result, use the retrieval enhancement technology to query the power knowledge database based on the user input statement to obtain a power knowledge prediction result, and splice the initial query result and the power knowledge prediction result as the power knowledge database query result; If the intention analysis result is a prediction behavior of the power demand prediction model library, the user input statement is used as the input of the hybrid expert model, the time scale to be predicted by the user is output, and the power demand prediction model library is called to select a single model corresponding to the time scale for prediction, so as to obtain the power demand prediction result; The power demand forecast result or the power knowledge database query result is returned to the user.

2. The NLP-based power demand forecasting and knowledge retrieval method according to claim 1, characterized in that: The user input sentence is used as the input of the hybrid expert model, and the time scale to be predicted by the user is output. The specific steps are: Let the number of expert models be , the mixed expert model is expressed in the formula: ; In the formula, represents the time scale to be predicted by the hybrid expert model output user, Indicates The weight of the expert model, Indicates The expert model outputs the time scale that the user wants to predict. Represents a user input statement; The weight of the expert model is obtained through a gated neural network and is expressed as: ; In the formula, represents the weight matrix, represents the bias term; Objective Function of Gated Neural Network It is expressed as: ; In the formula, represents the expectation operator, express The data distribution, represents the parameters of the gated neural network, represents the optimal weight allocation strategy, represents the probability that the gated neural network generates the optimal weight allocation strategy, represents the reward value of the optimal weight allocation strategy of the gated neural network, represents log probability; Output the time scale to be predicted by the user based on the hybrid expert model , call the single model corresponding to the time scale in the electricity demand forecasting model library for forecasting.

3. The NLP-based power demand forecasting and knowledge retrieval method according to claim 1, characterized in that: The specific steps of obtaining power demand data and constructing a power demand prediction model library based on the power demand data to predict power demand at different time scales are as follows: The power demand data includes historical power consumption, real-time power consumption and power distribution; Construct an ultra-short-term forecasting model, expressed as follows: ; In the formula, Indicated in The prediction results at the moment, represents the long short-term memory network function, express The electricity demand data at the moment, Indicates the time offset; Construct a short-term forecast model, expressed as: ; In the formula, represents the white noise error term, represents the lag operator, represents the length of the seasonal cycle, represents seasonal differences, represents the parameters of the non-seasonal autoregressive part, represents the parameter of the non-seasonal moving average part; Construct a medium- and long-term forecasting model. The specific steps are as follows: Obtain economic, policy and meteorological data to construct an impact set, fuse the impact set with the input data to obtain a data set, select the Transformer model as the base of the medium- and long-term forecast model, and use the data set to train the medium- and long-term forecast model; The loss function of the medium- and long-term prediction model is the mean square error function, which is expressed as follows: ; In the formula, Indicated in The loss value at the moment, Indicates the maximum time offset, Indicated in The predicted value at time, Indicated in The true value of the moment; A power demand prediction model library is constructed based on the ultra-short-term prediction model, the short-term prediction model and the medium- and long-term prediction model.

4. The NLP-based power demand forecasting and knowledge retrieval method according to claim 3 is characterized in that: The method also includes multi-model prediction of the electricity demand prediction model library; If there are special prediction scenarios when the electricity demand prediction model library predicts, the single model prediction is replaced by the multi-model prediction of the electricity demand prediction model library. The specific steps are as follows: The special forecast scenarios include holidays and extreme weather; The multi-model prediction is expressed in the formula: ; In the formula, represents the electricity demand predicted by multiple models, represents the multi-model prediction weight, It indicates the power demand forecast result of the ultra-short-term forecast model, the short-term forecast model or the medium- and long-term forecast model.

5. The NLP-based power demand forecasting and knowledge retrieval method according to claim 1, characterized in that: Obtain the user input sentence, use the user input sentence as the input of the Transformer model, output the context vector, use the intent classifier to analyze the context vector, and obtain the intent analysis result. The specific steps are as follows: Let the intention set be expressed as: ; In the formula, Intent Collection The first intent tag in Indicates the number of intent labels; Get the user input sentence, and map the words in the user input sentence into word vectors through word embedding technology, which can be expressed as follows: ; ; In the formula, Represents a user input statement, Indicates the number of words in the user input sentence, represents the word embedding technology function, Indicates the first words, Indicates word vectors; The word vector is used as the input of the Transformer model, and the context vector is output, which can be expressed as: ; In the formula, represents the context vector, Represents the Transformer model function; The context vector is used as the input of the intent classifier and the intent analysis label is output, which can be expressed as: ; In the formula, Indicates the intent analysis tag, represents the intent classifier function; Compare the intent analysis label with the intent labels in the intent set, and take the consistent intent labels as the intent analysis results.

6. The NLP-based power demand forecasting and knowledge retrieval method according to claim 1, characterized in that: The specific steps of acquiring the power knowledge data and constructing the power knowledge database based on the power knowledge data are as follows: The electric power knowledge data includes unstructured text data and structured text data; The unstructured text data includes electricity policy documents, business norms and management systems of enterprises, historical electricity demand analysis reports, statistical yearbooks and expert literature; The structured text data includes electricity consumption history data and market economic indicators; The power knowledge data is stored in the database, and the entities of the power knowledge data are extracted through named entity recognition technology to construct a knowledge graph, which can be expressed as follows: ; In the formula, represents the knowledge graph, Represents a collection of entities, Represents a set of relations, Indicates Entities and Entities relationship; Among them, the entities in the knowledge graph are aligned by calculating the cosine similarity of the entities, which can be expressed as: ; In the formula, express and The cosine similarity of Representing Entities The vector of Representing Entities The vector of represents the calculation of the inner product, Indicates the calculated modulus length; An electric power knowledge database is constructed based on the knowledge graph and database.

7. The NLP-based power demand forecasting and knowledge retrieval method according to claim 6, characterized in that: The user input statement is used as the input of the SQL generation model, and the corresponding SQL statement is output. The SQL generation model is expressed as follows: ; In the formula, Represents the SQL generation model, Indicates the length of the user input sentence. Indicates The smallest grammatical unit, Represents a user input statement, represents the probability of the smallest grammatical unit appearing in the user input sentence, Indicates that the index value is less than The smallest grammatical unit of The minimum grammatical unit includes keywords, identifiers, literals, operators and comments.

8. The NLP-based power demand forecasting and knowledge retrieval method according to claim 7, characterized in that: The method also includes optimizing the SQL generation model through supervised fine-tuning, which is expressed as: ; ; In the formula, represents the SQL syntax constraint loss term, represents the supervised fine-tuning loss term, represents the scaling parameter of the loss term, represents the loss function of the SQL generation model, represents the minimization loss function, represents the sum of the SQL syntax constraint loss term and the supervised fine-tuning loss term, Indicates User input statements, Indicates The expected output of a SQL statement.

9. The NLP-based power demand forecasting and knowledge retrieval method according to claim 6, characterized in that: Based on the user input sentence, the retrieval enhancement technology is used to query the power knowledge database to obtain the power knowledge prediction result; Through the retrieval enhancement technology, the knowledge graph with the same entity relationship as the user input sentence in the power knowledge database is queried as the power knowledge prediction result, which can be expressed as: ; In the formula, represents the prediction result of power knowledge, Represents a user input statement, represents the retrieval enhancement technology function, Represents the same statement as the user input Knowledge graphs with the same entity relationships.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the NLP-based power demand forecasting and knowledge retrieval method as described in any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

  • Method and device for retrieving power business database table

    CN118673041A

  • Medium-and-long-term power load prediction device

    CN110135634A

  • Power knowledge acquisition method and system combined with plug-in professional knowledge base

    CN118260381A

  • User-level electric quantity prediction method and system based on knowledge graph retrieval enhancement generation

    CN118709871A

  • Intelligent electricity selling settlement management system and method based on predictive analysis

    CN118886552A