A method and device for power demand forecasting and knowledge retrieval based on NLP

By integrating power demand forecasting and knowledge retrieval based on NLP methods and dynamically scheduling multiple forecasting models and query technologies, the problems of coordination and intelligent interaction of existing systems are solved, and the forecasting accuracy and information retrieval efficiency of the power system are improved.

CN119940661BActive Publication Date: 2025-09-16国网福建省电力有限公司营销服务中心 +1
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing power demand forecasting and power knowledge retrieval systems lack collaboration and intelligent interaction capabilities. Traditional methods are not flexible enough when processing multi-dimensional data, resulting in low prediction accuracy and serious information island phenomenon.

Method used

An NLP-based method is used to integrate power demand forecasting and knowledge retrieval. The user intention is understood through the Transformer model and intent classifier. A hybrid expert model and SQL generation model are combined to dynamically schedule multiple forecasting models, build a power knowledge database and use retrieval enhancement technology for query.

Benefits of technology

It realizes the intelligent coordination of power systems, improves the prediction accuracy and information retrieval accuracy, meets the electricity demand at different time scales, and supports flexible human-computer interaction and personalized query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119940661B_ABST
    Figure CN119940661B_ABST
Patent Text Reader

Abstract

The present invention relates to a method and device for electricity demand forecasting and knowledge retrieval based on NLP, belonging to the field of power system and energy information technology, and includes the following steps: constructing an electricity demand forecasting model library by acquiring electricity demand data to support electricity demand forecasting at different time scales; and acquiring electricity knowledge data to construct an electricity knowledge database. The system receives user input statements and identifies user needs through an intent classifier. If the query is for electricity knowledge, the SQL generation model is used to generate a query statement and the query results are returned in combination with retrieval enhancement technology. If the query is for demand forecasting, the prediction time scale is determined through a hybrid expert model and the corresponding model is called to generate the electricity demand forecast result. The present invention integrates two independent tasks, improves the intelligence level of the power system, and enables users to obtain information and perform demand forecasting 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 power demand forecasting and knowledge retrieval based on NLP, and belongs to the technical field of power system and energy informatization. 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 requires comprehensive consideration of multiple factors, including historical electricity consumption data, economic indicators, and meteorological conditions. Power knowledge retrieval, on the other hand, involves the rapid and accurate extraction of massive amounts of unstructured data, including policy documents, technical specifications, and historical reports. Currently, these two tasks are typically performed by independent systems, lacking collaborative and intelligent interaction capabilities.

[0003] Traditional statistical methods and some machine learning approaches are inadequate for modeling the complex, time-varying characteristics of power data, particularly nonlinear and highly volatile load data. This results in lower accuracy for forecasting models during unexpected events or during rapidly changing periods. Existing models often fail to effectively integrate multi-dimensional data (such as external variables like temperature, economic indicators, and holidays), lacking 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 apparatus for searching electric power business database tables. The method comprises the following steps: constructing an electric power domain dictionary and an electric power business database table knowledge graph based on collected electric power data; parsing the electric power domain dictionary and user-input natural language to obtain a list of search keywords; searching the electric power business database based on the search model and the list of search keywords to obtain sample recall data tables; predicting the sample recall data tables based on a prediction model to obtain the SQL elements and user intent corresponding to the user-input natural language in the electric power business database; generating an SQL query statement based on the SQL elements, user intent, user-input natural language, and the electric power business database table knowledge graph; and performing a search based on the SQL query statement. However, the aforementioned patent primarily utilizes text data from the electric power domain to construct the dictionary and knowledge graph, lacking the comprehensive utilization of multi-dimensional data such as historical electricity consumption data, economic indicators, and meteorological conditions. This multi-dimensional data is crucial for improving search accuracy and prediction precision. While the aforementioned patent achieves the conversion of natural language into SQL query statements, it still needs improvement in intelligent interaction. For example, there is no mention of how to automatically adjust search strategies based on user intent 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 the power demand forecasting system and user service system). This can lead to information silos and reduce the operational 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 solutions of the present invention are as follows:

[0007] In one aspect, the present invention provides a method for power demand forecasting and knowledge retrieval based on NLP, comprising the following steps:

[0008] Obtain electricity demand data and build an electricity demand forecasting model library based on the electricity demand data to predict electricity demand at different time scales;

[0009] Acquire power knowledge data and build a power knowledge database based on the power knowledge data;

[0010] Obtain user input sentences, use the user input sentences as input to the Transformer model, output a context vector, and use the intent classifier to analyze the context vector to obtain intent analysis results; the intent analysis results include query behavior of the power knowledge database and prediction behavior of the power demand prediction model library;

[0011] Constructing an SQL generation model and a hybrid expert model. If the intention analysis result is a query behavior of the power knowledge database, the user input statement is used as the input of the SQL generation model and the corresponding SQL statement is output;

[0012] Using the SQL statement to query the electric power knowledge database to obtain an initial query result, using the search enhancement technology to query the electric power knowledge database based on the user input statement to obtain an electric power knowledge prediction result, and splicing the initial query result and the electric power knowledge prediction result as the electric power knowledge database query result;

[0013] If the intention analysis result is a prediction behavior of the electricity demand prediction model library, the user input sentence is used as the input of the hybrid expert model, the time scale to be predicted by the user is output, and the electricity demand prediction model library is called to select a single model corresponding to the time scale for prediction to obtain the electricity demand prediction result;

[0014] The power demand forecast result or the power knowledge database query result is returned to the user.

[0015] As a preferred embodiment, 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 as follows:

[0016] Let the number of expert models be , the mixed expert model is expressed as:

[0017] ;

[0018] Where, Indicates the time scale to be predicted by the hybrid expert model output user, Indicates the The weight of the expert model, Indicates the The expert model outputs the time scale to be predicted by the user, Represents a user input statement;

[0019] The weight of the expert model is obtained through the gated neural network and is expressed as follows:

[0020] ;

[0021] Where, represents the weight matrix, represents the bias term;

[0022] Objective function of gated neural network It can be expressed as:

[0023] ;

[0024] Where, 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 distribution strategy of the gated neural network, represents the log probability;

[0025] 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 forecast model library for prediction.

[0026] As a preferred embodiment, the steps of obtaining power demand data and constructing a power demand forecasting model library based on the power demand data to forecast power demand at different time scales are as follows:

[0027] The power demand data includes historical power consumption, real-time power consumption and power distribution;

[0028] The time scales include ultra-short term, short term and medium to long term;

[0029] Construct an ultra-short-term forecast model, which is expressed as follows:

[0030] ;

[0031] Where, Indicates The prediction results at the moment, represents the long short-term memory network function, express The electricity demand data at each moment, Indicates the time offset;

[0032] Construct a short-term forecast model, which is expressed as follows:

[0033] ;

[0034] Where, 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, Parameters representing the non-seasonal moving average part;

[0035] The specific steps for building a medium- and long-term forecasting model are as follows:

[0036] Obtain economic, policy, and meteorological data to construct an impact set, fuse the impact set with the input data to obtain a dataset, select the Transformer model as the basis for the medium- and long-term forecast model, and use the dataset to train the medium- and long-term forecast model;

[0037] The loss function of the medium- and long-term prediction model is the mean square error function, which is expressed as follows:

[0038] ;

[0039] Where, Indicates The loss value at the moment, Indicates the maximum time offset, Indicates The predicted value at time, Indicates The true value of the moment;

[0040] A power demand forecast model library is constructed based on the ultra-short-term forecast model, the short-term forecast model and the medium- and long-term forecast model.

[0041] As a preferred embodiment, the method further includes multi-model prediction of the electricity demand prediction model library;

[0042] If there are special prediction scenarios when the electricity demand prediction model library is used for prediction, the single-model prediction is replaced with the multi-model prediction of the electricity demand prediction model library. The specific steps are as follows:

[0043] The special forecast scenarios include holidays and extreme weather;

[0044] The multi-model prediction is expressed in the formula:

[0045] ;

[0046] Where, represents the electricity demand predicted by multiple models, represents the multi-model prediction weight, Indicates the power demand forecast results of the ultra-short-term forecast model, short-term forecast model, or medium- and long-term forecast model.

[0047] 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:

[0048] Let the intention set be expressed as:

[0049] ;

[0050] Where, Intent Set The first intent tag in Indicates the number of intent labels;

[0051] Get the user input sentence and map the words in the user input sentence into word vectors using word embedding technology, which can be expressed as follows:

[0052] ;

[0053] ;

[0054] Where, Represents a user input statement, Indicates the number of words in the user input sentence, Represents word embedding technology function, Indicates the first words, Indicates the word vectors;

[0055] The word vector is used as the input of the Transformer model and the context vector is output, which can be expressed as follows:

[0056] ;

[0057] Where, represents the context vector, Represents the Transformer model function;

[0058] The context vector is used as the input of the intent classifier and the output is the intent analysis label, which can be expressed as follows:

[0059] ;

[0060] Where, Indicates intent analysis tag, represents the intent classifier function;

[0061] Compare the intent analysis label with the intent labels in the intent set, and use the consistent intent labels as the intent analysis results.

[0062] As a preferred embodiment, the steps of acquiring power knowledge data and constructing a power knowledge database based on the power knowledge data are as follows:

[0063] The electric power knowledge data includes unstructured text data and structured text data;

[0064] The unstructured text data includes electricity policy documents, business regulations and management systems of enterprises, historical electricity demand analysis reports, statistical yearbooks and expert literature;

[0065] The structured text data includes electricity consumption history data and market economic indicators;

[0066] 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:

[0067] ;

[0068] Where, represents the knowledge graph, Represents a collection of entities, Represents a set of relations, Indicates the Entities Hedi Entities relationship;

[0069] Among them, the entities in the knowledge graph are aligned by calculating the cosine similarity of the entities, which can be expressed as:

[0070] ;

[0071] Where, express and The cosine similarity of Representing an entity vector, Representing an entity vector, Indicates the calculation of inner product, Indicates the calculated modulus length;

[0072] An electric power knowledge database is constructed based on the knowledge graph and database.

[0073] As a preferred embodiment, 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:

[0074] ;

[0075] Where, Represents the SQL generation model, Indicates the length of the user input sentence, Indicates the The smallest grammatical unit, Represents a user input statement, Indicates 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

[0076] The minimum grammatical unit includes keywords, identifiers, literals, operators and comments.

[0077] As a preferred embodiment, the method further includes optimizing the SQL generation model through supervised fine-tuning, which can be expressed as:

[0078] ;

[0079] ;

[0080] Where, represents the SQL syntax constraint loss term, represents the supervised fine-tuning loss term, represents the scale 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 the User input statement, Indicates the The expected output of a SQL statement.

[0081] As a preferred embodiment, based on the user input statement, the search enhancement technology is used to query the power knowledge database to obtain the power knowledge prediction result;

[0082] The knowledge graph with the same entity relationship as the user input sentence in the power knowledge database is queried by retrieval enhancement technology as the power knowledge prediction result, which can be expressed as:

[0083] ;

[0084] Where, represents the prediction result of electric power knowledge, Represents a user input statement, represents the retrieval enhancement technology function, Represents user input statements Knowledge graphs with the same entity relationships.

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

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

[0087] 1. This invention integrates two independent tasks, power demand forecasting and power knowledge retrieval, into a single system, achieving functional synergy. This significantly improves the intelligence level of the power system, enabling users to more easily obtain the required information and perform power demand forecasting.

[0088] 2. This invention improves the accuracy of the forecast model by building a power demand forecast model library that comprehensively considers multiple factors, including historical power consumption data, economic indicators, and meteorological conditions. It constructs corresponding forecast models for power demand at different time scales, including ultra-short-term (minutes to hours), short-term (days to weeks), and medium- to long-term (months to years), meeting the needs of different application scenarios.

[0089] 3. This invention can process unstructured text data, including electricity policy documents and corporate business specifications. It uses named entity recognition technology to extract entities and construct a knowledge graph, improving the efficiency and accuracy of information retrieval. By integrating initial query results with user input statements and using search enhancement technology to obtain the final power knowledge database query results, it further improves the accuracy and relevance of retrieval.

[0090] 4. This invention uses a Transformer model and intent classifier to analyze user input, understand user intent, and automatically invoke the corresponding prediction model or search function, achieving intelligent human-computer interaction. It also uses a hybrid expert model to analyze the time scale required by the user and automatically select the most appropriate prediction model for prediction, improving the system's intelligence. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0092] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

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

[0094] 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, the singular forms "a", "an" and "the" are intended to include the plural forms unless the context clearly indicates otherwise.

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

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

[0097] Example 1:

[0098] In this embodiment 、 Represents a general index.

[0099] See also Figure 1 The present invention provides a method for power demand forecasting and knowledge retrieval based on NLP, comprising the following steps:

[0100] Obtain electricity demand data and build an electricity demand forecasting model library based on the electricity demand data to predict electricity demand at different time scales;

[0101] Acquire power knowledge data and build a power knowledge database based on the power knowledge data;

[0102] Obtain user input sentences, use the user input sentences as input to the Transformer model, output a context vector, and use the intent classifier to analyze the context vector to obtain intent analysis results; the intent analysis results include query behavior of the power knowledge database and prediction behavior of the power demand prediction model library;

[0103] Constructing an SQL generation model and a hybrid expert model. If the intention analysis result is a query behavior of the power knowledge database, the user input statement is used as the input of the SQL generation model and the corresponding SQL statement is output;

[0104] Using the SQL statement to query the electric power knowledge database to obtain an initial query result, using the search enhancement technology to query the electric power knowledge database based on the user input statement to obtain an electric power knowledge prediction result, and splicing the initial query result and the electric power knowledge prediction result as the electric power knowledge database query result;

[0105] If the intention analysis result is a prediction behavior of the electricity demand prediction model library, the user input sentence is used as the input of the hybrid expert model, the time scale to be predicted by the user is output, and the electricity demand prediction model library is called to select a single model corresponding to the time scale for prediction to obtain the electricity demand prediction result;

[0106] The power demand forecast result or the power knowledge database query result is returned to the user.

[0107] 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 meet diverse needs under different time scales, power consumption patterns, and prediction scenarios.

[0108] As a preferred embodiment, 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 as follows:

[0109] Let the number of expert models be , the mixed expert model is expressed as:

[0110] ;

[0111] Where, Indicates the time scale to be predicted by the hybrid expert model output user, Indicates the The weight of the expert model, Indicates the The expert model outputs the time scale to be predicted by the user, Represents user input statement;

[0112] The weight of the expert model is obtained through the gated neural network and is expressed as follows:

[0113] ;

[0114] Where, represents the weight matrix, represents the bias term, Represents the activation function ;

[0115] Objective function of gated neural network It can be expressed as:

[0116] ;

[0117] Where, 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 distribution strategy of the gated neural network, represents the log probability;

[0118] 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 forecast model library for prediction.

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

[0120] The modular integration of gated neural networks and multiple expert models creates a unified input and output interface, allowing users to flexibly access a variety of input data, such as historical electricity consumption data, meteorological data, holiday factors, and economic indicators. A data preprocessing module cleans, standardizes, and extracts features from multi-source data. The hybrid expert model offers automated modeling and forecasting capabilities. Users no longer need to manually select models from the electricity demand forecasting library. Instead, the gated neural network automatically assigns weights to the expert models and generates forecast outputs.

[0121] As a preferred embodiment, the steps of obtaining power demand data and constructing a power demand forecasting model library based on the power demand data to forecast power demand at different time scales are as follows:

[0122] The power demand data includes historical power consumption, real-time power consumption and power distribution;

[0123] The time scales include ultra-short term, short term and medium to long term;

[0124] The ultra-short term is from minute to hour. The ultra-short term prediction model is constructed and expressed as follows:

[0125] ;

[0126] Where, Indicates The prediction results at the moment, represents the long short-term memory network function, express The electricity demand data at each moment, Indicates the time offset;

[0127] The short term is from days to weeks, and a short-term prediction model is constructed, which is expressed as follows:

[0128] ;

[0129] Where, 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, Parameters representing the non-seasonal moving average part;

[0130] The medium- to long-term range is from month to grade. The specific steps for building a medium- to long-term prediction model are as follows:

[0131] Obtain economic, policy, and meteorological data to construct an impact set, fuse the impact set with the input data to obtain a dataset, select the Transformer model as the basis for the medium- and long-term forecast model, and use the dataset to train the medium- and long-term forecast model;

[0132] The loss function of the medium- and long-term prediction model is the mean square error function, which is expressed as follows:

[0133] ;

[0134] Where, Indicates The loss value at the moment, Indicates the maximum time offset, Indicates The predicted value at time, Indicates The true value of the moment;

[0135] The optimizer of the medium- and long-term forecast model is the Adam optimizer, which is expressed as follows:

[0136] ;

[0137] Where, Indicates The learning rate at each moment, Indicates 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, Indicates The parameters of the moment, Indicates The square of the gradient at that moment, represents the smoothing term;

[0138] A power demand forecast model library is constructed based on the ultra-short-term forecast model, the short-term forecast model and the medium- and long-term forecast model.

[0139] As a preferred embodiment, the method further includes multi-model prediction of the electricity demand prediction model library;

[0140] If there are special prediction scenarios when the electricity demand prediction model library is used for prediction, the single-model prediction is replaced with the multi-model prediction of the electricity demand prediction model library. The specific steps are as follows:

[0141] The special forecast scenarios include holidays and extreme weather;

[0142] The multi-model prediction is expressed in the formula:

[0143] ;

[0144] Where, represents the electricity demand predicted by multiple models, represents the multi-model prediction weight, Indicates the power demand forecast results of the ultra-short-term forecast model, short-term forecast model, or medium- and long-term forecast model.

[0145] 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:

[0146] 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 tags, such as "query electricity demand in the next week", "analyze peak and valley loads in specific time periods", "obtain electricity consumption trends in a certain area", etc.

[0147] Let the intention set be expressed as:

[0148] ;

[0149] Where, Intent Set The first intent tag in Indicates the number of intent labels;

[0150] Get the user input sentence and map the words in the user input sentence into word vectors using word embedding technology, which can be expressed as follows:

[0151] ;

[0152] ;

[0153] Where, Represents a user input statement, Indicates the number of words in the user input sentence, Represents word embedding technology function, Indicates the first words, Indicates the word vectors;

[0154] The word vector is used as the input of the Transformer model and the context vector is output, which can be expressed as follows:

[0155] ;

[0156] Where, represents the context vector, Represents the Transformer model function;

[0157] The context vector is used as the input of the intent classifier and the output is the intent analysis label, which can be expressed as follows:

[0158] ;

[0159] Where, Indicates intent analysis tag, represents the intent classifier function;

[0160] Compare the intent analysis label with the intent labels in the intent set, and use the consistent intent labels as the intent analysis results.

[0161] As a preferred embodiment, the steps of acquiring power knowledge data and constructing a power knowledge database based on the power knowledge data are as follows:

[0162] The power knowledge data includes unstructured text data and structured text data. Automated crawling tools, OCR text recognition technology, and enterprise data interfaces are used to aggregate and integrate data scattered across different sources.

[0163] The unstructured text data includes government-issued electricity policy documents, business regulations and management systems of enterprises, historical electricity demand analysis reports, statistical yearbooks, and expert literature;

[0164] The structured text data includes electricity consumption history data and market economic indicators;

[0165] 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:

[0166] ;

[0167] Where, represents the knowledge graph, Represents a collection of entities, Represents a set of relations, Indicates the Entities Hedi Entities relationship, 、 Represents an index;

[0168] Among them, the entities in the knowledge graph are aligned by calculating the cosine similarity of the entities, which can be expressed as:

[0169] ;

[0170] Where, express and The cosine similarity of Representing an entity vector, Representing an entity vector, Indicates the calculation of inner product, Indicates the calculated modulus length;

[0171] An electric power knowledge database is constructed based on the knowledge graph and database.

[0172] As a preferred embodiment, 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:

[0173] ;

[0174] Where, Represents the SQL generation model, Indicates the length of the user input sentence, Indicates the The smallest grammatical unit, Represents a user input statement, Indicates the probability of the smallest grammatical unit appearing in the user input sentence;

[0175] The minimum grammatical unit includes keywords, identifiers, literals, operators and comments.

[0176] To further enhance the performance and robustness of the SQL generation model, we employ reinforcement learning with human feedback (RLHF) for optimization. By introducing a reward mechanism, the SQL generation model can self-correct based on the execution results of generated SQL queries. For example, when a SQL query fails, the SQL generation model uses the error information to optimize the generation of subsequent queries.

[0177] As a preferred embodiment, the method further includes optimizing the SQL generation model through supervised fine-tuning, which can be expressed as:

[0178] ;

[0179] ;

[0180] Where, represents the SQL syntax constraint loss term, represents the supervised fine-tuning loss term, represents the scale 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 the User input statement, Indicates the The expected output of a SQL statement is preset.

[0181] As a preferred embodiment, based on the user input statement, the search enhancement technology is used to query the power knowledge database to obtain the power knowledge prediction result;

[0182] The knowledge graph with the same entity relationship as the user input sentence in the power knowledge database is queried by retrieval enhancement technology as the power knowledge prediction result, which can be expressed as:

[0183] ;

[0184] Where, represents the prediction result of electric power knowledge, Represents a user input statement, represents the retrieval enhancement technology function, Represents user input statements Knowledge graphs with the same entity relationships.

[0185] Example 2:

[0186] This embodiment provides an electronic device having a computer program stored thereon. 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.

[0187] In the embodiments of the present application, "at least one" refers to one or more, and "more" 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 represent: 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.

[0188] Those skilled in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented using 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. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0189] Those skilled in the art will 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.

[0190] In the several embodiments provided in this 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 this 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. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of this 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), magnetic disk or optical disk, and other media that can store program code.

[0191] 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's description 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 electricity demand data and build an electricity demand forecasting model library based on the electricity demand data to predict electricity demand at different time scales; Acquire power knowledge data and build a power knowledge database based on the power knowledge data; Obtain user input sentences, use the user input sentences as input to the Transformer model, output context vectors, use the intent classifier to analyze the context vectors, and obtain intent analysis results. The specific steps are as follows: Let the intention set be expressed as: ; Where, Intent Set 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 using word embedding technology, which can be expressed as follows: ; ; Where, Represents a user input statement, Indicates the number of words in the user input sentence, Represents word embedding technology function, Indicates the first words, Indicates the 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 follows: ; Where, represents the context vector, Represents the Transformer model function; The context vector is used as the input of the intent classifier and the output is the intent analysis label, which can be expressed as follows: ; Where, Indicates intent analysis tag, represents the intent classifier function; Comparing the intent analysis label with the intent labels in the intent set, and taking the consistent intent labels as the intent analysis result; the intent analysis result includes the query behavior of the power knowledge database and the prediction behavior of the 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 power knowledge database, the user input statement is used as the input of the SQL generation model and the corresponding SQL statement is output; Using the SQL statement to query the electric power knowledge database to obtain an initial query result, using the search enhancement technology to query the electric power knowledge database based on the user input statement to obtain an electric power knowledge prediction result, and splicing the initial query result and the electric power knowledge prediction result as the electric power knowledge database query result; If the intention analysis result is a prediction behavior of the electricity demand prediction model library, the user input sentence is used as the input of the hybrid expert model, the time scale to be predicted by the user is output, and the electricity demand prediction model library is called to select a single model corresponding to the time scale for prediction to obtain the electricity 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 as follows: Let the number of expert models be , the mixed expert model is expressed as: ; Where, Indicates the time scale to be predicted by the hybrid expert model output user, Indicates the The weight of the expert model, Indicates the The expert model outputs the time scale to be predicted by the user, Represents user input statement; The weight of the expert model is obtained through the gated neural network and is expressed as follows: ; Where, represents the weight matrix, represents the bias term; Objective function of gated neural network It can be expressed as: ; Where, 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 distribution strategy of the gated neural network, represents the 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 forecast model library for prediction.

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 forecasting 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 forecast model, which is expressed as follows: ; Where, Indicates The prediction results at the moment, represents the long short-term memory network function, express The electricity demand data at each moment, Indicates the time offset; Construct a short-term forecast model, which is expressed as follows: ; Where, 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, Parameters representing the non-seasonal moving average part; The specific steps for building a medium- and long-term forecasting 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 dataset, select the Transformer model as the basis for the medium- and long-term forecast model, and use the dataset 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: ; Where, Indicates The loss value at the moment, Indicates the maximum time offset, Indicates The predicted value at time, Indicates The true value of the moment; A power demand forecast model library is constructed based on the ultra-short-term forecast model, the short-term forecast model and the medium- and long-term forecast model.

4. The NLP-based power demand forecasting and knowledge retrieval method according to claim 3 is characterized in that: 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 is used for prediction, the single-model prediction is replaced with 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: ; Where, represents the electricity demand predicted by multiple models, represents the multi-model prediction weight, Indicates the power demand forecast results of the ultra-short-term forecast model, short-term forecast model, or medium- and long-term forecast model.

5. 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 building 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 regulations 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: ; Where, represents the knowledge graph, Represents a collection of entities, Represents a set of relations, Indicates the Entities Hedi 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: ; Where, express and The cosine similarity of Representing an entity vector, Representing an entity vector, Indicates the calculation of inner product, Indicates the calculated modulus length; An electric power knowledge database is constructed based on the knowledge graph and database.

6. The NLP-based power demand forecasting and knowledge retrieval method according to claim 5, 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: ; Where, Represents the SQL generation model, Indicates the length of the user input sentence, Indicates the The smallest grammatical unit, Represents a user input statement, Indicates 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.

7. The NLP-based power demand forecasting and knowledge retrieval method according to claim 6, characterized in that: The method further includes optimizing the SQL generation model through supervised fine-tuning, which can be expressed as: ; ; Where, represents the SQL syntax constraint loss term, represents the supervised fine-tuning loss term, represents the scale 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 the User input statement, Indicates the The expected output of the SQL statement corresponding to the user input statement, Indicates the number of user input sentences.

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

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

Citation Information

Patent Citations

  • Method and device for retrieving power business database table

    CN118673041A

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

    CN118886552A

  • Electric power vector knowledge base enhanced retrieval method and system based on artificial intelligence

    CN118964648A

  • Knowledge service system construction method

    CN119322858A