A method and system for power forecasting artificial intelligence agent based on large language model

Through the power prediction artificial intelligence agent method based on large language model, the problem of complex data preprocessing in the existing technology is solved, and accurate power prediction for multiple categories and regions is achieved, and efficiency and accuracy are improved. .

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

Patent Information

Application Number
CN202411199516.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2024-11-05
Estimated Expiration
2044-08-29

AI Technical Summary

Technical Problem

The existing power forecasting methods require professionals to preprocess and analyze data, which cannot meet the needs of all-round, multi-category, and regions, and cannot process natural language input.

Method used

Using the power prediction artificial intelligence agent method based on large language model, multiple subtasks are constructed and different tools and algorithms are called through user input reading modules, prompt word construction modules, task decomposition and planning modules, tool selection modules and code generation modules. , generate the final power prediction result.

Benefits of technology

It realizes the accuracy of power prediction for different categories and regions, improves work efficiency and results accuracy, can process natural language input, and automatically completes the power prediction process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118709870B_ABST
    Figure CN118709870B_ABST
Patent Text Reader

Abstract

The present invention relates to an artificial intelligence agent method and system for power prediction based on a large language model, and the specific steps include: constructing an artificial intelligence agent prediction model based on a large language model, including a user input reading module, a prompt word construction module, a plurality of large language models, a task decomposition and planning module, a tool selection module and a code generation module; using the user input reading module to read the power prediction problem raised by the target user and translate it into the format required by the large language model, and using the prompt word construction module to construct prompt words for guiding the work of the large language model; then inputting the power prediction problem and the prompt words into a pre-trained first large language model; using the first large language model to perform integrity verification on the input power prediction problem, and further guiding the target user to complete the power prediction problem based on the integrity judgment result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electricity forecasting, and in particular to an artificial intelligence agent method and system for electricity forecasting based on a large language model. Background Art

[0002] In the power industry, many artificial intelligence technologies have been proposed for power forecasting, but the current power forecasting methods have the following problems:

[0003] 1. Professionals are required to complete data preprocessing and data analysis operations. The existing electricity forecasting methods only accept strict data input. The original electricity data comes from the electricity meters of each household, and it can only be converted into daily electricity data after calculation and processing. Different data preprocessing is required for different electricity forecasting categories and regions, including aggregation and summation, data cleaning, etc. All of these tasks need to be completed in advance by professional technicians, and then organized into standard data sets before they can be provided to existing artificial intelligence models for training. When using the trained model for prediction, processed standard data is also required.

[0004] 2. It cannot meet the needs of all-round, multi-category, and multi-regional electricity forecasting. Existing AI electricity forecasting models are trained based on one or several processed standard data sets. These models can only be applied to electricity forecasting tasks within a specific range and constraints, and their performance is poor in scenarios where the training data has not been seen. For example, the model trained using residential electricity consumption data performs poorly in the industrial electricity consumption forecasting scenario.

[0005] 3. Unable to process natural language. A truly intelligent system should be able to process the power forecasting needs input by users using natural language, but the existing power forecasting methods do not have the ability to process natural language and can only accept data in a fixed format.

[0006] In the prior art CN115470970A, a method and system for predicting electricity consumption based on a prophet-LightGBM combined model is disclosed, which summarizes and classifies daily electricity consumption data of users in different regions into a data set, and pre-processes the data set; divides historical electricity consumption data into a training set and a test set according to prediction requirements; uses a combined model of Prophet and lightGBM to predict electricity consumption, first uses the Prophet model to extract time series features from the electricity time series, constructs a new data set, and then uses the gradient boosting LightGBM algorithm to predict electricity consumption for the new data set; and evaluates the prediction accuracy of the model through daily prediction error and monthly prediction error.

[0007] In the prior art, it is proposed to use a combination model of Prophet and lightGBM to predict electricity consumption for users in different regions. This method can only guarantee the accuracy of electricity consumption prediction for users in different regions, but cannot distinguish the accuracy of electricity consumption for different categories of people. Its scope of use is limited. At the same time, the model also has restrictions on the format of input data, and manual preprocessing steps are required in advance, so its scope of application is limited. For different electricity consumption prediction problems, the existing methods cannot realize automatic control of the entire process of electricity consumption prediction results based on the natural language input by the user. Summary of the invention

[0008] In order to solve the above problems existing in the prior art, the present invention proposes an artificial intelligence agent method and system for electricity prediction based on a large language model.

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

[0010] On the one hand, the present invention proposes an artificial intelligence agent method for power forecasting based on a large language model, and the specific steps include:

[0011] Build an AI agent prediction model based on a large language model, including a user input reading module, a prompt word building module, several large language models, a task decomposition and planning module, a tool selection module, and a code generation module;

[0012] The user input reading module is used to read the power prediction question raised by the target user and translate it into the format required by the large language model. At the same time, the prompt word construction module is used to construct the prompt words to guide the work of the large language model. Then, the power prediction question and the prompt words are input into the pre-trained first large language model.

[0013] The first language model is used to perform integrity check on the input power forecast question, and based on the integrity judgment result, the target user is further guided to complete the power forecast question;

[0014] In the task decomposition and planning module, multiple subtasks are constructed according to the complete power forecasting problem, and different tools are called in the tool selection module according to the requirements of each subtask;

[0015] When the existing tools cannot meet the requirements of the target task, a code generation large language model and a code checking large language model are constructed through the code generation module. The code generation large language model is responsible for generating the target code, and the generated target code is input into the code checking large language model for code checking until the target code meets the preset accuracy based on the target subtask. The target code is used as a calling tool to solve the target subtask.

[0016] When all subtasks are completed, the results of each subtask, the question text entered by the user, and the historical records are re-entered into the first language model to generate the final power prediction result.

[0017] As a preferred implementation, the prompt words used to guide the large language model using the prompt word construction module include system introduction, tool introduction, task instructions, dialogue history, and optimization prompts. The prompt words are specifically:

[0018] Model introduction: define the role played by the AI ​​agent and the functions it has;

[0019] Tool introduction: Existing algorithms or applications are integrated into the entire large language model and provide services in the form of API interfaces;

[0020] Task instructions: used to indicate which subtasks need to be built for the large language model, as well as the tools to be called to complete each subtask;

[0021] Dialogue history: The question text, prompt words, algorithm models or applications called, and output prediction results are constructed into new prompt words and added to the large language model;

[0022] Optimization tips: Add several limited prompt words to improve the understanding ability of large language models.

[0023] As a preferred implementation, the tools called in the step of calling different tools in the tool selection module according to the requirements of each subtask include a database and an electric quantity prediction algorithm / model.

[0024] As a preferred implementation, the subtasks in the step of constructing multiple subtasks according to the complete power forecasting problem in the task decomposition and planning module include data preprocessing, data analysis, power forecasting and result visualization;

[0025] The data preprocessing steps are specifically as follows:

[0026] According to the requirements of the subtask, query and obtain relevant electrical meter reading data from the relevant database;

[0027] Analyze and organize the acquired electrical meter reading data according to the requirements of the subtasks;

[0028] The sorted electrical meter numerical data is cleaned, and outlier smoothing and missing value filling are completed.

[0029] As a preferred implementation, the steps of calling different tools in the tool selection module according to the requirements of each subtask are specifically as follows:

[0030] Call the existing algorithm model, call external software or code snippets to complete specified functions in the form of API interfaces, and include the name of the calling tool, input parameters and output in the output of the large language model; if it includes the call of multiple tools, give priority to confirming the calling order and dependencies between multiple tools.

[0031] On the other hand, the present invention proposes an artificial intelligence agent system for power prediction based on a large language model, comprising:

[0032] Model building module, which builds an AI agent prediction model based on a large language model, including a user input reading module, a prompt word building module, several large language models, a task decomposition and planning module, a tool selection module, and a code generation module;

[0033] The user input reading and prompt word building module uses the user input reading module to read the power prediction question raised by the target user and translate it into the format required by the large language model. At the same time, the prompt word building module is used to build prompt words to guide the work of the large language model; the power prediction question and prompt words are then input into the pre-trained first large language model;

[0034] The first language model module uses the first language model to perform integrity check on the input power forecast question, and further guides the target user to complete the power forecast question based on the integrity judgment result;

[0035] Task decomposition and tool calling module: In the task decomposition and planning module, multiple subtasks are constructed according to the complete power forecasting problem, and different tools are called in the tool selection module according to the requirements of each subtask;

[0036] Code generation module: When the existing tools cannot meet the requirements of the target task, the code generation module constructs a code generation language model and a code checking language model respectively. The code generation language model is responsible for generating the target code, and the generated target code is input into the code checking language model for code checking until the target code meets the preset accuracy based on the target subtask. The target code is used as a tool to solve the target subtask.

[0037] The power prediction module, when all subtasks are completed, re-enters the results of each subtask, the question text entered by the user, and the historical records into the first language model to generate the final power prediction result.

[0038] As a preferred implementation, the prompt words used to guide the large language model using the prompt word construction module include system introduction, tool introduction, task instructions, dialogue history, and optimization prompts. The prompt words are specifically:

[0039] Model introduction: define the role played by the AI ​​agent and the functions it has;

[0040] Tool introduction: Existing algorithms or applications are integrated into the entire large language model and provide services in the form of API interfaces;

[0041] Task instructions: used to indicate which subtasks need to be built for the large language model, as well as the tools to be called to complete each subtask;

[0042] Dialogue history: The question text, prompt words, algorithm models or applications called, and output prediction results are constructed into new prompt words and added to the large language model;

[0043] Optimization tips: Add several limited prompt words to improve the understanding ability of large language models.

[0044] As a preferred implementation, the tools called in the step of calling different tools in the tool selection module according to the requirements of each subtask include a database and an electric quantity prediction algorithm / model.

[0045] As a preferred implementation, the subtasks in the step of constructing multiple subtasks according to the complete power forecasting problem in the task decomposition and planning module include data preprocessing, data analysis, power forecasting and result visualization;

[0046] The data preprocessing steps are specifically as follows:

[0047] According to the requirements of the subtask, query and obtain relevant electrical meter reading data from the relevant database;

[0048] Analyze and organize the acquired electrical meter reading data according to the requirements of the subtasks;

[0049] The sorted electrical meter numerical data is cleaned, and outlier smoothing and missing value filling are completed.

[0050] As a preferred implementation, the steps of calling different tools in the tool selection module according to the requirements of each subtask are specifically as follows:

[0051] Call the existing algorithm model, call external software or code snippets to complete specified functions in the form of API interfaces, and include the name of the calling tool, input parameters and output in the output of the large language model; if it includes the call of multiple tools, give priority to confirming the calling order and dependencies between multiple tools.

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

[0053] 1. The present invention adopts an artificial intelligence agent to read the natural language text of the user input of the power prediction question, and then converts the natural language question text into the input format required by the corresponding large language model, which solves the problem that the current large language model cannot read multiple input formats.

[0054] 2. The present invention solves the problem of electricity forecasting in different categories, different regions or multiple regions by calling various electricity forecasting algorithms or models, thereby ensuring the accuracy of electricity forecasting.

[0055] 3. The present invention decomposes and constructs multiple subtasks to solve the task according to the target problem, and solves the problems raised by each subtask by calling different algorithms or databases, thereby improving work efficiency and accuracy of results. Finally, all results are comprehensively fed back to the large language model for the final prediction of the target power prediction problem, and the prediction result is more accurate.

[0056] 4. The present invention utilizes the code generation function of the large language model to automatically generate the tools required to complete the corresponding problems of the subtasks, and generates code checkers to check the generated code by constructing prompt words to ensure the practicality of the generated code. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 It is a schematic diagram of the process of the present invention;

[0058] Figure 2 Schematic diagram of the architecture of the artificial intelligence agent prediction model. DETAILED DESCRIPTION

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

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

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

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

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

[0064] Embodiment 1:

[0065] See also Figure 1 , an artificial intelligence agent method for power prediction based on a large language model, the specific steps include:

[0066] Build an AI agent prediction model based on a large language model, including a user input reading module, a prompt word building module, several large language models, a task decomposition and planning module, a tool selection module, and a code generation module;

[0067] In this embodiment, the architecture of the artificial intelligence agent prediction model is as follows Figure 2 shown.

[0068] The user input reading module is used to read the power prediction question raised by the target user and translate it into the format required by the large language model. At the same time, the prompt word construction module is used to construct the prompt words to guide the work of the large language model. Then, the power prediction question and the prompt words are input into the pre-trained first large language model.

[0069] In this embodiment, the artificial intelligence agent first reads the natural language input by the user. The natural language is questions related to power forecast and power data raised by the user, including predicting power information of different regions, industries, types, times, and locations; querying the aggregated power in different regions, categories, and time periods; calculating the year-on-year growth of predicted power; calculating the pull on total power sales; sorting the output results; querying meteorological power in different regions and different times and its year-on-year growth; querying background event records in different time periods; querying information such as temperature and holidays; generating visualization results such as charts.

[0070] The first language model is used to perform integrity check on the input power forecast question, and based on the integrity judgment result, the target user is further guided to complete the power forecast question;

[0071] In this embodiment, the information input by the user may be missing and cannot support the planning and execution of the task process. At this time, the large language model recognizes it based on its powerful text understanding ability. For example, the user inputs "Please predict the total electricity consumption of residents in a certain place". At this time, the user's input is missing time information. The large language model will output "Please predict the electricity consumption for which time period", and then the user further enters "the next week". The large language model has the ability to check the integrity of information and guide users to supplement missing information through multiple rounds of dialogue.

[0072] In the task decomposition and planning module, multiple subtasks are constructed according to the complete power forecasting problem, and different tools are called in the tool selection module according to the requirements of each subtask;

[0073] In this embodiment, if a tool needs to be called in a subtask, including an existing algorithm, software provided in the form of an API interface, a code snippet that completes a specific function, etc., the output of the large language model includes the name of the tool, input parameters, and output. If it includes calls to multiple tools, the order of calls and dependencies between them are included. For example, GMAN: Community power forecasting model, input parameters: X: historical power data, W: historical weather data, output: Y: predicted power data. According to the tool call defined in the format of the large language model, the artificial intelligence agent uses the reflection mechanism of Python code to call and execute the tool to obtain the output.

[0074] When the existing tools cannot meet the requirements of the target task, a code generation large language model and a code checking large language model are constructed through the code generation module. The code generation large language model is responsible for generating the target code, and the generated target code is input into the code checking large language model for code checking until the target code meets the preset accuracy based on the target subtask. The target code is used as a calling tool to solve the target subtask.

[0075] In this embodiment, if a certain function needs to be completed in a subtask and there is no corresponding tool in the system, it is implemented by generating code. Specifically, at this time, two different APIs and prompts are used to let the big prediction model play the role of code generator and code checker respectively. For example, the prompt of the code generator is "You are a data visualization expert. You are proficient in visual drawing of matplotlib and pyplot. You are good at generating and improving data visualization code through iteration. There is a DataFrame X. You need to find the mean and sum of each column and add the result to the last two rows"; the prompt of the code checker is "You are a data visualization expert. You are proficient in visual drawing of matplotlib and pyplot. You are good at checking and finding errors in the code. There is a code snippet. The function of this code is to find the mean and sum of each column of a DataFrame X and add the result to the last two rows. You need to check and point out whether there are errors in this code".

[0076] The AI ​​agent can set a hyperparameter E. In each round, the generator generates code first, and then the checker checks the code and gives feedback. This iteration stops when the checker cannot find any errors or the number of iterations reaches E. Through the mutual iteration between the generator and the checker, high-quality and reliable code snippets are provided to the AI ​​agent, and the AI ​​agent executes this code snippet to complete the subtask.

[0077] When all subtasks are completed, the results of each subtask, the question text entered by the user, and the historical records are re-entered into the first language model to generate the final power prediction result.

[0078] As a preferred implementation of this embodiment, the prompt words used to guide the large language model work by using the prompt word construction module include system introduction, tool introduction, task instructions, dialogue history, and optimization prompts. The prompt words are specifically:

[0079] Model introduction: define the role played by the AI ​​agent and the functions it has;

[0080] Tool introduction: Existing algorithms or applications are integrated into the entire large language model and provide services in the form of API interfaces;

[0081] Task instructions: used to indicate which subtasks need to be built for the large language model, as well as the tools to be called to complete each subtask;

[0082] Dialogue history: The question text, prompt words, algorithm models or applications called, and output prediction results are constructed into new prompt words and added to the large language model;

[0083] Optimization tips: Add several limited prompt words to improve the understanding ability of large language models.

[0084] In this embodiment, the specific content of each prompt word is as follows:

[0085] System introduction: The system introduction includes a description of the entire AI agent system, the role of the large language model in the system, and its functions. For example, "This is an AI agent system for power prediction. You play the role of an AI agent in the system. You need to determine the task objectives based on the natural language input by the user and the prompts we provide you, decompose the task into multiple subtasks, and call external tools or generate code to gradually complete these subtasks."

[0086] Tool introduction: A tool refers to an existing algorithm or application that is integrated into the entire system and provides services in the form of an API interface, such as an electricity prediction algorithm, a program that reads data from a database, a visualization program that generates charts, etc. The tool introduction includes the tool's name, function, input parameters, output, call priority, etc. For example, the tool description can be "Name: Community electricity consumption prediction method A based on graph multi-head attention mechanism, function: predict the electricity consumption of the next week based on the electricity consumption data of the community in the past month, input parameters: historical electricity consumption data X, weather data W, output: predicted electricity consumption Y, call priority: 0".

[0087] Task instructions: Task instructions are used to prompt the large language model what tasks need to be done and how to complete these tasks. For example, "First, you need to check the integrity of the user's input to see if the information provided by the user meets your task planning requirements. If there is missing information, you need to prompt the user to complete it. Secondly, you need to deconstruct the task objectives and plan them into multiple subtasks. For example, for the power forecasting task, you can deconstruct it into three subtasks: data preprocessing, data analysis, and power forecasting; for the power query task, you can deconstruct it into two subtasks: data preprocessing and data query; for tasks that require visualization of results, you need to add additional subtasks for result visualization. When executing these subtasks, you can generate call information for external tools based on the tool description information. For requirements that cannot be met by existing tools, you can give a request to generate code."

[0088] Dialogue history: During multiple rounds of dialogue between users and the agent system, the dialogue history of previous rounds (including user input, prompt words, intermediate results of tool calls or code generation, output of the AI ​​agent, and other information) is added to the prompt words of the current round, so that the large language model has memory capabilities.

[0089] Optimization tips: The large language model itself does not have reliable output capabilities. Some optimized prompt words can be used to improve the reliability of the output. Optimization content, for example, "Please do not forge the name and input and output of the tool, strictly plan and execute subtasks according to the task objectives, abide by existing rules and methods during execution, and avoid reusing the same tool."

[0090] As a preferred implementation manner of this embodiment, the tools called in the step of calling different tools in the tool selection module according to the requirements of each subtask include a database and an electric quantity prediction algorithm / model.

[0091] As a preferred implementation of this embodiment, the subtasks in the step of constructing multiple subtasks according to the complete power forecasting problem in the task decomposition and planning module include data preprocessing, data analysis, power forecasting and result visualization;

[0092] The data preprocessing steps are specifically as follows:

[0093] According to the requirements of the subtask, query and obtain relevant electrical meter reading data from the relevant database;

[0094] Analyze and organize the acquired electrical meter reading data according to the requirements of the subtasks;

[0095] The sorted electrical meter numerical data is cleaned, and outlier smoothing and missing value filling are completed.

[0096] In this embodiment, each subtask is specifically:

[0097] Data preprocessing: (1) refers to querying and obtaining relevant electricity meter numerical data from the database according to the needs of the task, and converting it into daily electricity data after calculation and processing; (2) according to the needs of the task, the data is aggregated and summed into group electricity and other operations; (3) the data is cleaned to complete operations such as outlier smoothing and missing value filling. The source of the data is the electricity meter data of each household.

[0098] Data analysis: Based on the pre-processed data, relevant analysis is performed on the data according to the task objectives, including: (1) querying the total electricity consumption of a certain category in a certain area within a certain time period, calculating the year-on-year growth, and calculating the impact of each category on the total electricity consumption; (2) querying the total electricity consumption of different industries in a certain area within a certain period of time, calculating the year-on-year growth, and calculating the impact on the total electricity consumption; (3) sorting the query results according to requirements; (4) querying the weather in a certain area at a certain time, calculating the basic electricity consumption and meteorological electricity consumption, the year-on-year growth of meteorological electricity consumption, and the impact of electricity consumption. (5) Querying whether an event occurred in a certain area within a certain time period, whether a certain time period is a holiday, etc.

[0099] Electricity forecasting: According to the pre-processed historical electricity data and the related electricity data analysis features, select the appropriate electricity forecasting algorithm / model in combination with the task objectives. For example, the "Community Electricity Forecasting Method with Multi-Head Attention Mechanism" can be used to predict community electricity consumption using weather information, and the "Electricity Forecasting Method Based on Prophet-LightGBM Combined Model" can be used to predict industrial electricity consumption. The historical electricity data and related features are used as input according to the instructions of the electricity forecasting tool to obtain the forecast results.

[0100] Result visualization: For tabular results, you only need to give the table header and the format of each column in the input, and the large language model can output it well. For graphical results, such as bar charts, pie charts, line charts, etc., the AI ​​agent can execute the code of the relevant function, save the image in a certain directory, and inform the user in the output.

[0101] As a preferred implementation of this embodiment, the steps of calling different tools in the tool selection module according to the requirements of each subtask are specifically as follows:

[0102] Call the existing algorithm model, call external software or code snippets to complete specified functions in the form of API interfaces, and include the name of the calling tool, input parameters and output in the output of the large language model; if it includes the call of multiple tools, give priority to confirming the calling order and dependencies between multiple tools.

[0103] Embodiment 2:

[0104] Based on the above-mentioned large language model-based power forecasting artificial intelligence agent method, the following example is used to specifically illustrate the above steps:

[0105] The user inputs natural language to the AI ​​agent prediction model: "Please predict the electricity consumption of XX community in the next week."

[0106] Next, we construct prompt words for the first language model, including:

[0107] System Introduction: This is an AI agent system for power consumption prediction. You play the role of an AI agent in the system. You need to determine the task objectives based on the natural language input by the user and the prompt words we provide you, decompose the task into multiple subtasks, and call external tools or generate code to gradually complete these subtasks.

[0108] Tool Introduction:

[0109] 1. Name: Community electricity consumption prediction method A based on graph multi-head attention mechanism, Function: predict the electricity consumption of the next week based on the electricity consumption data of the community in the past week, Input parameters: historical electricity consumption data X, weather data W, Output: predicted electricity consumption Y, Call priority: 1;

[0110] 2. Name: Single-point electricity consumption prediction algorithm B based on LSTM model, Function: Predict the electricity consumption in the next week based on the electricity consumption in a certain place in the past week, Input parameter: Historical electricity consumption data X, Output: Predicted electricity consumption Y, Call priority: 0; ......

[0112] Task instructions: First, you need to check the integrity of the user's input to see if the information provided by the user meets your task planning requirements. If there is missing information, you need to prompt the user to complete it. Secondly, you need to deconstruct the task objectives and plan them into multiple subtasks. For example, for the power forecasting task, you can deconstruct it into three subtasks: data preprocessing, data analysis, and power forecasting; for the power query task, you can deconstruct it into two subtasks: data preprocessing and data query; for tasks that require visualization of results, you need to add additional subtasks for result visualization. When executing these subtasks, you can generate call information for external tools based on the tool description information. For requirements that cannot be met by existing tools, you can make a request to generate code.

[0113] Conversation history:

[0114] User input: Please predict the electricity consumption of XX community in the next week.

[0115] Optimization tips: Please do not forge tool names and inputs and outputs, plan and execute subtasks strictly according to task objectives, abide by existing rules and methods during execution, and avoid reusing the same tools.

[0116] The AI ​​agent prediction model inputs the user input + prompt words into the large language model, and the large language model feeds back the output to the AI ​​agent prediction model:

[0117] The first language model reports that the user input is incomplete and asks a question: "Does the prediction result need to be visualized?"

[0118] The AI ​​agent prediction model outputs the question to the user, and the user inputs: "Please draw a line graph of the predicted electricity consumption."

[0119] The AI ​​agent predicts the model and updates the user input and prompt words:

[0120] User input: Please predict the electricity consumption of XX community in the next week and draw a line graph of the predicted electricity consumption. The artificial intelligence agent inputs the new user input and prompt words into the first language model.

[0121] The first language model deconstructs and plans the task and obtains the output:

[0122] Task objective: Predict the electricity consumption of XX community in the next week and draw a line chart of the predicted electricity consumption;

[0123] Task sub-process:

[0124] Subtask 1: Data preprocessing. (1) Use get_current_time() to get the current time, parameter: None, output: current time t; (2) Use query_from_db(type, time, location) to get the meter reading data in the database, parameter: type query type: meter reading data, time time: from t to the past week, location location: all meters in XX community, output: the reading data of all meters in XX community in the past week original_data; (3) Use daily_calculate(data) to calculate daily electricity data, parameter: original data data: original_data, output: daily electricity data data. (4) Use fill_data(data) to clean the daily electricity data, complete operations such as clothing length smoothing and missing value filling, parameter: data data: data, output: cleaned daily electricity data data. (5) Use get_weather(time, location) to get weather data, parameter: time time: from t to the past week and the next week, location location: XX community, output: weather data weather of XX community in the past week and the next week.

[0125] Subtask 2: Power consumption prediction. (1) Use the community power consumption prediction method A(data, weather) based on the graph multi-head attention mechanism to predict the power consumption in the next week. Parameters: data: power consumption data of the past week, weather: weather data of the past week and the next week, output: power consumption Y in the next week.

[0126] Subtask 3: Result visualization. (1) Draw a line graph for the predicted data Y, with the horizontal axis being time and the vertical axis being the predicted power consumption. There is no tool available, so code needs to be generated.

[0127] The large language model outputs the above task planning to the artificial intelligence agent, which then executes (1), (2), ..., subtask 2, and subtask 3 in subtask 1. Subtask 3 generates the large model through code and checks the interaction of the large model through code, and then executes the code.

[0128] When the AI ​​agent completes all subtasks, it combines the intermediate output of the subtasks with the user input, conversation history and other information and inputs them into the first language model:

[0129] User input: Please predict the electricity consumption of XX community in the next week and draw a line graph of the predicted electricity consumption.

[0130] Conversation History: ...

[0131] Prompt words: ......

[0132] Subtask planning results: ...

[0133] Subtask execution results: ...

[0134] The first language model generates output to the AI ​​agent prediction model:

[0135] According to my prediction results, the electricity consumption of XX community in the next week is:

[0136] Time | Resident A | Resident B | Resident C | ...

[0137] 2024-07-06 | 12 | 11.8 | ...... ......

[0139] The line chart of predicted electricity consumption has been drawn and saved in the figure.png file on the desktop.

[0140] The AI ​​agent prediction model displays the above output to the user, completing the entire conversation process.

[0141] Embodiment three:

[0142] An artificial intelligence agent system for power forecasting based on a large language model, comprising:

[0143] Model building module, which builds an AI agent prediction model based on a large language model, including a user input reading module, a prompt word building module, several large language models, a task decomposition and planning module, a tool selection module, and a code generation module;

[0144] The user input reading and prompt word building module uses the user input reading module to read the power prediction question raised by the target user and translate it into the format required by the large language model. At the same time, the prompt word building module is used to build prompt words to guide the work of the large language model; the power prediction question and prompt words are then input into the pre-trained first large language model;

[0145] The first language model module uses the first language model to perform integrity check on the input power forecast question, and further guides the target user to complete the power forecast question based on the integrity judgment result;

[0146] Task decomposition and tool calling module: In the task decomposition and planning module, multiple subtasks are constructed according to the complete power forecasting problem, and different tools are called in the tool selection module according to the requirements of each subtask;

[0147] Code generation module: When the existing tools cannot meet the requirements of the target task, the code generation module constructs a code generation language model and a code checking language model respectively. The code generation language model is responsible for generating the target code, and the generated target code is input into the code checking language model for code checking until the target code meets the preset accuracy based on the target subtask. The target code is used as a tool to solve the target subtask.

[0148] The power prediction module, when all subtasks are completed, re-enters the results of each subtask, the question text entered by the user, and the historical records into the first language model to generate the final power prediction result.

[0149] As a preferred implementation of this embodiment, the prompt words used to guide the large language model work by using the prompt word construction module include system introduction, tool introduction, task instructions, dialogue history, and optimization prompts. The prompt words are specifically:

[0150] Model introduction: define the role played by the AI ​​agent and the functions it has;

[0151] Tool introduction: Existing algorithms or applications are integrated into the entire large language model and provide services in the form of API interfaces;

[0152] Task instructions: used to indicate which subtasks need to be built for the large language model, as well as the tools to be called to complete each subtask;

[0153] Dialogue history: The question text, prompt words, algorithm models or applications called, and output prediction results are constructed into new prompt words and added to the large language model;

[0154] Optimization tips: Add several limited prompt words to improve the understanding ability of large language models.

[0155] As a preferred implementation manner of this embodiment, the tools called in the step of calling different tools in the tool selection module according to the requirements of each subtask include a database and an electric quantity prediction algorithm / model.

[0156] As a preferred implementation of this embodiment, the subtasks in the step of constructing multiple subtasks according to the complete power forecasting problem in the task decomposition and planning module include data preprocessing, data analysis, power forecasting and result visualization;

[0157] The data preprocessing steps are specifically as follows:

[0158] According to the requirements of the subtask, query and obtain relevant electrical meter reading data from the relevant database;

[0159] Analyze and organize the acquired electrical meter reading data according to the requirements of the subtasks;

[0160] The sorted electrical meter numerical data is cleaned, and outlier smoothing and missing value filling are completed.

[0161] As a preferred implementation of this embodiment, the steps of calling different tools in the tool selection module according to the requirements of each subtask are specifically as follows:

[0162] Call the existing algorithm model, call external software or code snippets to complete specified functions in the form of API interfaces, and include the name of the calling tool, input parameters and output in the output of the large language model; if it includes the call of multiple tools, give priority to confirming the calling order and dependencies between multiple tools.

[0163] 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. An artificial intelligence agent method for electricity prediction based on a large language model, characterized in that: The specific steps include: Build an AI agent prediction model based on a large language model, including a user input reading module, a prompt word building module, several large language models, a task decomposition and planning module, a tool selection module, and a code generation module; The user input reading module is used to read the power prediction question raised by the target user and translate it into the format required by the large language model. At the same time, the prompt word construction module is used to construct the prompt words to guide the work of the large language model. Then, the power prediction question and the prompt words are input into the pre-trained first large language model. The first language model is used to perform integrity check on the input power forecast question, and based on the integrity judgment result, the target user is further guided to complete the power forecast question; In the task decomposition and planning module, multiple subtasks are constructed according to the complete power forecasting problem, and different tools are called in the tool selection module according to the requirements of each subtask; When the existing tools cannot meet the requirements of the target task, a code generation large language model and a code checking large language model are constructed through the code generation module. The code generation large language model is responsible for generating the target code, and the generated target code is input into the code checking large language model for code checking until the target code meets the preset accuracy based on the target subtask. The target code is used as a calling tool to solve the target subtask. When all subtasks are completed, the results of each subtask, the question text entered by the user, and the historical records are re-entered into the first language model to generate the final power prediction result.

2. According to claim 1, an artificial intelligence agent method for power prediction based on a large language model is characterized in that: The prompt words used to construct the prompt word construction module to guide the work of the large language model include system introduction, tool introduction, task instructions, dialogue history, and optimization prompts. Each prompt word is specifically: Model introduction: define the role played by the AI ​​agent and the functions it has; Tool introduction: Existing algorithms or applications are integrated into the entire large language model and provide services in the form of API interfaces; Task instructions: used to indicate which subtasks need to be built for the large language model, as well as the tools to be called to complete each subtask; Dialogue history: The question text, prompt words, algorithm models or applications called, and output prediction results are constructed into new prompt words and added to the large language model; Optimization tips: Add several limited prompt words to improve the understanding ability of large language models.

3. The method for power prediction artificial intelligence agent based on a large language model according to claim 1 is characterized in that: The tools called in the step of calling different tools in the tool selection module according to the requirements of each subtask include a database and an electric quantity prediction algorithm / model.

4. The method for power prediction artificial intelligence agent based on a large language model according to claim 3 is characterized in that: The subtasks in the step of constructing multiple subtasks according to the complete power forecasting problem in the task decomposition and planning module include data preprocessing, data analysis, power forecasting and result visualization; The data preprocessing steps are specifically as follows: According to the requirements of the subtask, query and obtain relevant electrical meter reading data from the relevant database; Analyze and organize the acquired electrical meter reading data according to the requirements of the subtasks; The sorted electrical meter numerical data is cleaned, and outlier smoothing and missing value filling are completed.

5. The method for power prediction artificial intelligence agent based on a large language model according to claim 1 is characterized in that: The steps of calling different tools in the tool selection module according to the requirements of each subtask are specifically as follows: Call the existing algorithm model, call external software or code snippets to complete specified functions in the form of API interfaces, and include the name of the calling tool, input parameters and output in the output of the large language model; if it includes the call of multiple tools, give priority to confirming the calling order and dependencies between multiple tools.

6. An artificial intelligence agent system for electricity prediction based on a large language model, characterized in that: include: Model building module, which builds an AI agent prediction model based on a large language model, including a user input reading module, a prompt word building module, several large language models, a task decomposition and planning module, a tool selection module, and a code generation module; The user input reading and prompt word building module uses the user input reading module to read the power prediction questions raised by the target user and translate them into the format required by the large language model. At the same time, the prompt word building module is used to build prompt words to guide the work of the large language model. Then input the power prediction question and prompt words into the pre-trained first language model; The first language model module uses the first language model to perform integrity check on the input power forecast question, and further guides the target user to complete the power forecast question based on the integrity judgment result; Task decomposition and tool calling module: In the task decomposition and planning module, multiple subtasks are constructed according to the complete power forecasting problem, and different tools are called in the tool selection module according to the requirements of each subtask; Code generation module: When the existing tools cannot meet the requirements of the target task, the code generation module constructs a code generation language model and a code checking language model respectively. The code generation language model is responsible for generating the target code, and the generated target code is input into the code checking language model for code checking until the target code meets the preset accuracy based on the target subtask. The target code is used as a tool to solve the target subtask. The power prediction module, when all subtasks are completed, re-enters the results of each subtask, the question text entered by the user, and the historical records into the first language model to generate the final power prediction result.

7. The power forecasting artificial intelligence agent system based on a large language model according to claim 6 is characterized in that: The prompt words used to construct the prompt word construction module to guide the work of the large language model include system introduction, tool introduction, task instructions, dialogue history, and optimization prompts. The prompt words are specifically: Model introduction: define the role played by the AI ​​agent and the functions it has; Tool introduction: Existing algorithms or applications are integrated into the entire large language model and provide services in the form of API interfaces; Task instructions: used to indicate which subtasks need to be built for the large language model, as well as the tools to be called to complete each subtask; Dialogue history: The question text, prompt words, algorithm models or applications called, and output prediction results are constructed into new prompt words and added to the large language model; Optimization tips: Add several limited prompt words to improve the understanding ability of large language models.

8. The power forecasting artificial intelligence agent system based on a large language model according to claim 6 is characterized in that: The tools called in the step of calling different tools in the tool selection module according to the requirements of each subtask include a database and an electric quantity prediction algorithm / model.

9. The power forecasting artificial intelligence agent system based on a large language model according to claim 8 is characterized in that: The subtasks in the step of constructing multiple subtasks according to the complete power forecasting problem in the task decomposition and planning module include data preprocessing, data analysis, power forecasting and result visualization; The data preprocessing steps are specifically as follows: According to the requirements of the subtask, query and obtain relevant electrical meter reading data from the relevant database; Analyze and organize the acquired electrical meter reading data according to the requirements of the subtasks; The sorted electrical meter numerical data is cleaned, and outlier smoothing and missing value filling are completed.

10. The power forecasting artificial intelligence agent system based on a large language model according to claim 6, characterized in that: The steps of calling different tools in the tool selection module according to the requirements of each subtask are specifically as follows: Call the existing algorithm model, call external software or code snippets to complete specified functions in the form of API interfaces, and include the name of the calling tool, input parameters and output in the output of the large language model; if it includes the call of multiple tools, give priority to confirming the calling order and dependencies between multiple tools.