Distributed photovoltaic power generation prediction method and system based on large language model and RAG
By combining large language models and RAG technology, and utilizing Euclidean distance and timestamp semantic alignment mechanisms, the problems of utilizing historical information and cross-modal fusion in photovoltaic power generation forecasting are solved, resulting in more accurate photovoltaic power generation forecasting.
Patent Information
- Application Number
- CN202511641199.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-11
- Publication Date
- 2026-03-20
AI Technical Summary
Existing photovoltaic power generation forecasting methods are insufficient in utilizing historical information, cross-modal information fusion, and reasoning capabilities, making it difficult to achieve accurate forecasts.
A distributed photovoltaic power generation prediction method based on large language model and RAG is adopted. Similar historical data are retrieved by Euclidean distance, and semantic alignment is performed by combining timestamps and descriptive language sequences. The reasoning ability of large language model is used for prediction.
It significantly improves the accuracy and generalization ability of photovoltaic power generation prediction, enabling effective causal analysis and trend judgment in complex scenarios, and enhancing the adaptability and robustness of the model.
Smart Images

Figure CN121707770A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of new energy power generation prediction technology, specifically involving a distributed photovoltaic power generation prediction method and system based on large language models and RAG. Background Technology
[0002] Distributed photovoltaic (PV) power generation has developed rapidly as an important form of clean and renewable energy. However, PV power generation is characterized by significant intermittency, volatility, and uncertainty. Its output is affected by various factors such as weather conditions, sunlight intensity, and seasonal variations, posing a significant challenge to the safe and stable operation of the power grid. Accurate PV power generation forecasting is of great significance for improving grid dispatch efficiency, ensuring power system stability, and promoting the consumption of renewable energy.
[0003] Currently, photovoltaic (PV) power generation forecasting methods are mainly divided into two categories: physical methods and data-driven methods. Physical methods rely on numerical weather prediction and PV system physical models for forecasting; however, their accuracy is limited by weather forecast precision and the difficulty of model parameter calibration. Data-driven methods predict by mining patterns in historical data. In recent years, with the development of deep learning technology, models such as LSTM and Transformer have achieved certain results in time series forecasting tasks. However, these methods still have the following shortcomings: 1) Insufficient utilization of historical information: Traditional deep learning models mainly rely on fixed-length historical input sequences, which makes it difficult to effectively utilize the similar power generation patterns and regular information contained in massive historical data, resulting in limited prediction generalization ability.
[0004] 2) Difficulty in cross-modal information fusion: Photovoltaic forecasting involves multimodal information such as numerical power data, timestamp information, and meteorological parameters. Existing methods lack effective cross-modal fusion mechanisms, making it difficult to fully explore the correlation between different modal data.
[0005] 3) Insufficient reasoning ability: Traditional time series forecasting models are mainly based on statistical learning and pattern recognition, lacking human-like logical reasoning ability, making it difficult to conduct effective causal analysis and trend judgment when facing complex and ever-changing power generation scenarios.
[0006] 4) Inappropriate retrieval strategy: In recent years, retrieval augmentation generation (RAG) technology has achieved remarkable success in the field of natural language processing. However, traditional RAG methods mainly use semantic similarity measures such as cosine similarity, which are not suitable for the precise requirements of numerical similarity in photovoltaic prediction.
[0007] In recent years, large language models, such as GPT and LLaMA, have demonstrated powerful knowledge representation and reasoning capabilities in natural language understanding and generation tasks. Research shows that language models pre-trained on a large scale possess rich world knowledge and logical reasoning abilities, and can be transferred to various downstream tasks through appropriate cue engineering and fine-tuning techniques. However, how to apply the reasoning capabilities of large language models to numerical time series prediction tasks, especially how to bridge the representation gap between numerical data and the semantic space of language, remains a challenging problem that urgently needs to be solved. Summary of the Invention
[0008] In view of the shortcomings of the prior art, the purpose of this invention is to provide a distributed photovoltaic power generation prediction method and system based on large language models and RAG, which solves the problems in the prior art.
[0009] The objective of this invention can be achieved through the following technical solutions: A distributed photovoltaic power generation prediction method based on large language models and RAG includes the following steps: Based on historical photovoltaic power data, a photovoltaic data retrieval pool is constructed, and Euclidean distance is used as a similarity metric. According to a given query sequence, the most relevant photovoltaic sequence and its corresponding prediction target sequence are retrieved from the retrieval pool. The query sequence, the most relevant photovoltaic sequence, and the prediction target sequence corresponding to the most relevant photovoltaic sequence are preprocessed to obtain discrete sharding results, and timestamps are embedded to obtain hidden states combined with timestamp information; the descriptive language sequence in the chain thinking prompt template is preprocessed to obtain an embedding vector; then, the hidden states combined with timestamp information are mapped to the same dimension as the embedding vector through a linear layer, and semantic alignment is achieved by connecting them with the embedding vector to obtain the final embedding. The final embedded state is then incorporated into the pre-trained language model, and the output of the pre-trained language model is mapped to the prediction target space to obtain the final hidden state result.
[0010] Furthermore, the retrieval process for the most relevant photovoltaic sequence includes: Given a length of l The historical sequence is the query sequence in the retrieval task. Q t−l:t Its timestamp is from t−l arrive t From historical photovoltaic power dataset Search timestamp from τ−l arrive τ The most relevant photovoltaic sequence R τ−l:τ : in, Represents historical photovoltaic power data Each sequence in the sequence has the same length as the query sequence. This represents the Euclidean distance metric.
[0011] Furthermore, the preprocessing of the query sequence, the most relevant photovoltaic sequence, and their corresponding prediction target sequence includes: A time series partitioning method is used to convert the continuous photovoltaic sequence into discrete partitions. The partitioning results of the query sequence, the most relevant photovoltaic sequence, and the prediction target sequence are as follows: , , : in, , , These represent the number of segments for the query sequence, the most relevant photovoltaic sequence, and the predicted target sequence, respectively. p The size of the slice is denoted by Patch, which represents the slice processing operation.
[0012] Furthermore, the preprocessing of the descriptive language sequence includes: first, using a pre-trained word segmenter to convert the descriptive language sequence into a tokenized sequence, and then converting the tokenized sequence into an embedding vector through a pre-trained word token embedding layer and a word position embedding layer.
[0013] Furthermore, the expression for inputting the final embedding into the pre-trained language model is: in, For the final embedding, N is the number of Transformer blocks in the pre-trained language model, Attention is the multi-head attention mechanism, FFN represents the feedforward network, and LayerNorm is the layer normalization. This represents the i-th token in the output of the pre-trained language model, and np represents the total number of tokens. To represent the output of the pre-trained language model, by... Obtained by performing average pooling.
[0014] Furthermore, the process of obtaining the final hidden state is as follows: Applying a linear layer to represent the output of the pre-trained language model Mapping to the prediction target space yields the final hidden state result. : in, W o , b o For the learnable parameters of the linear layer, h To predict the length of the target sequence.
[0015] A distributed photovoltaic power generation prediction system based on large language models and RAG includes: The retrieval enhancement generation module: Based on historical photovoltaic power data, a photovoltaic data retrieval pool is constructed, and Euclidean distance is used as a similarity measurement method. According to the given query sequence, the most relevant photovoltaic sequence and its corresponding predicted target sequence are retrieved from the retrieval pool. Semantic alignment module: Preprocesses the query sequence, the most relevant photovoltaic sequence and its corresponding prediction target sequence to obtain discrete sharding results, and embeds timestamps to obtain hidden states combined with timestamp information; preprocesses the descriptive language sequence in the chain thinking prompt template to obtain embedding vectors; then maps the hidden states combined with timestamp information to the same dimension as the embedding vectors through a linear layer, and connects them with the embedding vectors to achieve semantic alignment, and obtains the final embedding; Prediction module: The final embedded input is entered into the pre-trained language model, and the output of the pre-trained language model is mapped to the prediction target space to obtain the final hidden state result.
[0016] A computer storage medium storing a readable program that, when executed, instructs a computing device to perform the distributed photovoltaic power generation prediction method based on the large language model and RAG as described above.
[0017] An electronic device includes: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; The memory is used to store at least one executable instruction that causes the processor to perform operations corresponding to the distributed photovoltaic power generation prediction method based on the large language model and RAG described above.
[0018] A computer program product includes computer instructions that instruct a computing device to perform operations corresponding to the distributed photovoltaic power generation prediction method based on large language models and RAG as described above.
[0019] The beneficial effects of this invention are: 1. This invention utilizes Retrieval Enhanced Generation (RAG) technology to retrieve the most similar historical power generation patterns to the current query scenario from massive historical photovoltaic power data. It fully leverages the periodic patterns and similar characteristics inherent in historical data, overcoming the limitations of traditional deep learning models that rely solely on fixed-length input sequences. Combined with the powerful reasoning capabilities of large language models, it enables effective causal analysis and trend judgment in complex and ever-changing power generation scenarios, significantly improving the accuracy of photovoltaic power generation prediction and the model's generalization ability across different scenarios.
[0020] 2. Considering the numerical sequence characteristics of photovoltaic power generation data, this invention innovatively employs Euclidean distance as a similarity metric, rather than semantic similarity metrics such as cosine similarity commonly used in traditional RAG techniques. Euclidean distance can more accurately measure the differences between numerical time series, ensuring that the retrieved historical sequences highly match the query sequences in terms of power change trends and magnitudes. This provides more valuable reference information for subsequent predictions, effectively improving retrieval quality and prediction accuracy.
[0021] 3. This invention cleverly unifies the representation of numerical photovoltaic power time series data with descriptive language sequences (chain-like thinking prompt templates) through a semantic alignment mechanism. Specifically, a time series slicing processing method is used to convert continuous numerical sequences into discrete slices. After embedding timestamp information, a linear mapping layer maps the hidden states of the numerical sequences to the same semantic space as the language embedding vector, achieving deep integration of numerical data and natural language. This innovative design effectively solves the key technical challenge of applying large language models to numerical time series prediction tasks.
[0022] 4. This invention constructs a complete cross-modal information fusion framework, which can effectively integrate multimodal information such as numerical power data, timestamp information, and descriptive language prompts. By embedding timestamp information into the segmented sequence, key features of the time dimension are preserved; a chain-like thinking prompt template guides the model to perform logical reasoning; and a semantic alignment mechanism achieves a unified representation of different modal data. The deep fusion of multimodal information fully explores the correlation between different modal data, enhancing the model's understanding and prediction capabilities for complex power generation scenarios.
[0023] 5. This invention transfers the powerful reasoning capabilities of large language models to photovoltaic power generation prediction tasks, enabling the model to possess human-like logical reasoning and knowledge representation abilities. Through the multi-head attention mechanism and feedforward network in the pre-trained language model, it can capture the complex interactive relationships between query sequences, retrieved related sequences, and language prompts, performing deep feature extraction and reasoning. Compared to traditional time series prediction models based on statistical learning, this invention demonstrates stronger adaptability and robustness in dealing with complex scenarios such as sudden weather changes and seasonal transitions.
[0024] 6. This invention provides a complete method, system, storage medium, electronic device, and computer program product, exhibiting excellent scalability and practicality. This technical solution is not only applicable to distributed photovoltaic power generation forecasting but can also be extended to other time-series forecasting tasks such as renewable energy power generation forecasting and power load forecasting. By adjusting the retrieval strategy and prompt templates, it can flexibly adapt to different forecasting scenarios and needs, possessing broad application prospects and significant engineering value. It is of great importance for improving grid dispatch efficiency, ensuring stable power system operation, and promoting the consumption of renewable energy. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a flowchart of the distributed photovoltaic power generation prediction method of the present invention; Figure 2 This is a schematic diagram of some prediction results of the prediction model and the comparison model of the present invention in Station 1; Figure 3 This is a schematic diagram showing some of the prediction results of the prediction model and the comparison model of the present invention in Station 2. Detailed Implementation
[0027] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] Example 1 like Figure 1 As shown, the distributed photovoltaic power generation prediction method based on large language models and RAG includes the following steps: S1. Based on historical photovoltaic power data, a photovoltaic data retrieval pool is constructed, and Euclidean distance is used as a similarity measurement method. According to the given query sequence, the most relevant photovoltaic sequence and its corresponding prediction target sequence are retrieved from the retrieval pool. Retrieval Augmentation (RAG) is a mature technique in the field of pre-trained large language models, used to enhance the reasoning ability of large language models. This technique adopts a two-stage processing flow: first, relevant contextual information is retrieved from an external knowledge base, and then the retrieved knowledge is combined with the model's inherent parameters to generate a response, thereby better activating the prior knowledge embedded in the pre-trained large language model.
[0029] Traditional retrieval enhancement generation techniques are mainly designed for text data and natural language processing tasks. They typically use cosine similarity as a similarity metric between different sequences to effectively mine potential semantic information in the database. However, in photovoltaic prediction tasks, the retrieval target is fixed-length and precise photovoltaic power generation numerical data, which clearly prioritizes numerical similarity over semantic similarity.
[0030] S11, Selection and Acquisition of Data Sources The open-source distributed photovoltaic (PV) forecasting dataset from the State Grid Renewable Energy Generation Forecasting Competition was used. This dataset contains historical power data from multiple PV power plants in different geographical regions, covering the period from 2019 to 2020, and has good representativeness and reliability. Considering the availability and completeness of data from different power plants, Station 1, Station 2, Station 5, and Station 6 were selected from the original dataset as experimental datasets. These four power plants are located in different geographical regions, with installed capacities of 50MW, 130MW, 110MW, and 35MW, respectively, which can fully reflect the regional differences and scale diversity of distributed PV systems.
[0031] S12, Search Pool Construction To address the proposed enhanced generation method for scene consistency retrieval, historical photovoltaic power datasets from January 2019 to December 2019 were used. As a retrieval pool, based on a fixed time window length l The sequence is divided into multiple historical photovoltaic power sequence segments of equal length; in this invention, each sequence segment contains 48 consecutive hours ( l =48) photovoltaic power generation data, and also record the corresponding next 24 hours ( h The power generation data (=24) is used as the target sequence.
[0032] To address the specific needs of photovoltaic (PV) forecasting tasks, a scenario consistency retrieval mechanism is constructed, employing Euclidean distance as a similarity metric to identify historical PV power generation patterns. In PV forecasting tasks, historical sequences over a certain time period are typically used to predict future sequences over a different time period. Given a length of... l The historical sequence is the query sequence in the retrieval task. Qt−l:t Its timestamp is from t−l arrive t From historical photovoltaic power dataset Search timestamp from τ−l arrive τ The most relevant photovoltaic sequence R τ−l:τ The retrieval process is implemented as follows: (1) in, Represents historical photovoltaic power data Each sequence in the sequence has the same length as the query sequence. This represents the Euclidean distance metric.
[0033] At the same time, it can The label is recorded as It is from arrive The photovoltaic power generation sequence (predicted target sequence) has a length of h Assuming Able to predict labels for the true To make contributions and provide effective historical references for subsequent prediction processes.
[0034] S2 preprocesses the query sequence, the most relevant photovoltaic sequence, and the prediction target sequence in S1 to obtain discrete sharding results, and embeds timestamps to obtain hidden states combined with timestamp information; preprocesses the descriptive language sequence in the chain-thinking prompt template to obtain an embedding vector; then maps the hidden states combined with timestamp information to the same dimension as the embedding vector, and connects them with the embedding vector to achieve semantic alignment, thus obtaining the final embedding. S21. Multimodal data preprocessing and feature extraction The query sequence obtained during the retrieval enhancement generation process Q t−l:t Most relevant photovoltaic sequence R τ−l:τ and its predicted target sequence R τ+1:τ+h The descriptive language sequences in the chain-like thinking prompt template and the data are subjected to multimodal data preprocessing. For the language sequences, a pre-trained word segmenter is used to convert them into labeled sequences, denoted as T1, T2, T3, and T4, as follows: (2) (3) (4) (5) Then, the tokens are converted into corresponding embedding vectors E1, E2, E3, E4∈R through a pre-trained Word Token Embedding (WTE) layer and a Word Positional Embedding (WPE) layer. n 1,2,3,4 ×dmodel , means as follows: (6) (7) (8) (9) in, Represents a word tag embedding layer. Indicates word position embedding layer, This represents the position encoding function. These represent the lengths of the four language sequences after they have been tokenized. Indicates the dimension of the embedding vector.
[0035] For the retrieved data, a time-series segmentation method is used to convert the continuous photovoltaic sequence into discrete segments (patching) to... Q t−l:t For example, the result obtained after sharding ,in n q For the number of fragments, p The size of the slice, and l=n q × p Similarly, we can obtain R τ−l:τ and R τ+1:τ+h The sharding results are as follows: (10) (11) S22, Construction of Timestamp Semantic Embedding Mechanism Considering that photovoltaic power generation is strongly affected by time-related factors, a detailed timestamp encoding mechanism is implemented, extracting three key time components from each timestamp: the hour t of a day. h ∈(0,23), the number of days in a year t d ∈(0,365) and the number of days in a week t w ∈(0,6); Sine coding is used to preserve the periodicity of temporal features, and the corresponding temporal embedding is calculated: (12) Then, each temporal embedding is concatenated with its corresponding patch embedding to form a comprehensive representation that simultaneously captures both the numerical and temporal features of the data. This process is then applied to all three sequences: , and This allows us to obtain the hidden state by combining timestamp information. .
[0036] S23, Cross-modal semantic alignment mapping To bridge the representation gap between fragmented photovoltaic sequence data and the semantic space of a pre-trained large language model, a linear layer is used to incorporate the hidden states with timestamp information. , , Mapping to descriptive language sequence embedding vectors E 1 , E 2 , E 3 , E 4 The same dimension is represented as : (13) in, and These are the trainable parameters of the linear layer.
[0037] S24. Semantic Alignment Sequence Construction and Fusion Chain-of-Thought (CoT) hints are a widely used technique in the field of pre-trained language models (PLMs). This technique enhances the reasoning ability of pre-trained language models by constructing chains of thought processes. This technique provides a reasonable inspiration for the effective utilization of retrieval results in this invention. Unlike the traditional application of CoT techniques in natural language tasks, the method of this invention adapts the CoT paradigm to numerical time series reasoning.
[0038] Following the order of the chain-thinking prompt template, the descriptive language sequence is embedded. E 1 , E 2 , E 3 , E 4 And embedding photovoltaic sequence patches with timestamp information The connections are made to obtain the final embeddings for the pre-trained language model PLM. : (14) in, It is the length of the final embedded vector. This represents the tensor concatenation operation; S3. The final result obtained in S2 is embedded into the pre-trained language model, and the output of the pre-trained language model is mapped to the prediction target space to obtain the final hidden state result.
[0039] The final embedded part after splicing When input into the pre-trained language model, its expression is: (15) (16) Where N is the number of Transformer blocks in the pre-trained language model, Attention is the multi-head attention mechanism, FFN represents the feedforward network, and LayerNorm is the layer normalization; Then, average pooling is applied to obtain the pooled representation (i.e., the output representation of the pre-trained language model). : (17) in, This represents the i-th token in the output of the pre-trained language model. n p This represents the total number of tokens.
[0040] Finally, the output representation is extracted from the pre-trained language model. A linear layer is then applied to map the hidden state to the prediction target space, thus obtaining the final hidden state result. (18) in, W o , b o For the learnable parameters of the linear layer, h To predict the length of the target sequence.
[0041] Based on a similar inventive concept, embodiments of the present invention also provide a computer storage medium storing a readable program that, when run by a processor, can execute the aforementioned distributed photovoltaic power generation prediction method based on a large language model and RAG.
[0042] Based on a similar inventive concept, this invention provides an electronic device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; The memory is used to store at least one executable instruction, which causes the processor to perform the operation corresponding to the distributed photovoltaic power generation prediction method based on the large language model and RAG described above.
[0043] Based on a similar inventive concept, embodiments of the present invention also provide a computer program product, including computer instructions, which instruct a computing device to perform the operations corresponding to the above-described distributed photovoltaic power generation prediction method based on large language models and RAG.
[0044] Example 2 In this embodiment, the proposed method is compared and verified with existing prediction methods on four real photovoltaic datasets with different geographical locations. The experimental results show that the proposed method achieves the best prediction performance in multi-scenario distributed photovoltaic prediction tasks. Compared with existing technologies, the prediction accuracy is significantly improved, providing effective technical support for stable grid operation and optimized utilization of renewable energy.
[0045] To comprehensively evaluate the performance of the proposed framework, the prediction accuracy was compared with six benchmark models, including LSTM, Transformer, Dlinear, and PatchTST. Furthermore, it was compared with GPT4TS, a time series prediction model based on a pre-trained large model. All experiments were conducted on an NVIDIA RTX4090-24G with a PyTorch environment. To ensure optimal performance for each model, a grid search was performed on the hyperparameter configuration for each model. The batch size for all models was set to 32, and the learning rate was set to 1e-4. The loss function was set to MSELoss, the optimizer was AdamW, and the weight decay was set to 1e-5. The patience value for the early stopping mechanism was set to 10 epochs, and the maximum training epochs were set to 1000. Input length... l Set to 48, output length h The value is set to 24, meaning the model uses photovoltaic data from the past 48 hours as input to predict photovoltaic power generation for the next 24 hours.
[0046] This embodiment uses an open-source dataset for distributed photovoltaic (PV) prediction for validation. The dataset covers data from eight distributed PV power plants in China. Considering the data availability at different sites, Site 1, Site 2, Site 5, and Site 6 were selected as the experimental dataset. These datasets were collected from different regions of China, spanning from 2019 to 2020. For the baseline model, data from January 2019 to June 2020 was used as the training set, and data from July 2020 to December 2020 was used as the test set. For the model proposed in this invention, data from January 2019 to December 2019 was used as the retrieval pool, data from January 2020 to June 2020 was used as the training set, and data from July 2020 to December 2020 was used as the test set. All datasets were strictly divided into training and test sets to ensure fairness in the comparison.
[0047] The metrics are as follows: (19) (20) in, K This represents the total number of samples. This represents the i-th prediction result. This represents the true value corresponding to the i-th prediction result.
[0048] Table 1 provides detailed results comparing the performance of the model of this invention with the benchmark method in four photovoltaic prediction scenarios. Specifically, compared with the best method PatchTST without using a pre-trained model, the model of this invention reduces MAE and RMSE by 10.0% and 3.6% in the four scenarios, respectively, while improving the R² score by 1.8%. Compared with GPT4TS, which also uses a pre-trained GPT model for prediction, the model of this invention reduces MAE and RMSE by 18.0% and 7.14% in the four scenarios, respectively, while improving the R² score by 4.0%. Figure 2 and Figure 3 The prediction results of each model in distributed photovoltaic power station 1 and distributed photovoltaic power station 2 are presented, and the superiority of the proposed method is further demonstrated through visualization.
[0049] Table 1. Comparison of prediction results of the proposed method with those of other methods. The experimental results above fully demonstrate that the distributed photovoltaic power generation prediction method proposed in this invention, based on a large language model and retrieval enhancement, can effectively mine similar power generation patterns in historical data and significantly improve the accuracy of photovoltaic power generation prediction by organically combining a scene consistency retrieval mechanism, cross-modal semantic alignment technology, and chain-like reasoning strategy. Compared with traditional deep learning methods and existing prediction methods based on pre-trained models, the method of this invention achieves optimal prediction performance on multiple real distributed photovoltaic datasets, verifying the effectiveness and superiority of the proposed method and providing an efficient and reliable technical solution for distributed photovoltaic power generation prediction.
[0050] The experimental results above fully demonstrate the advantages of using pre-trained language models combined with RAG technology for distributed photovoltaic prediction tasks. However, whether different pre-trained language model architectures affect the prediction process has not been fully investigated in existing work. Therefore, this invention conducted comparative experiments on pre-trained language models with different infrastructures and parameter scales, selecting four state-of-the-art backbone models: Llama3.2-1B, Llama3.2-3B, Qwen3-1.7B, and Qwen2.5-3B for validation.
[0051] The experimental results are shown in Table 2. It can be observed that although a larger number of parameters in a pre-trained language model generally implies stronger reasoning ability, increasing the number of parameters did not lead to better performance when applying the pre-trained language model to photovoltaic prediction tasks. The GPT-2 backbone model used in this invention exhibited the best prediction accuracy in all prediction scenarios. Among all tested pre-trained language models, the prediction accuracy ranking was: GPT-2 > Llama3.2-1B > Qwen3-1.7B > Llama3.2-3B > Qwen2.5-3B; the experimental results clearly show that fewer parameters resulted in better prediction results. Furthermore, comparative analysis revealed that the Llama architecture exhibited better applicability and compatibility for photovoltaic prediction tasks compared to the Qwen architecture.
[0052] Table 2 Comparison of prediction results of the proposed method with those of other methods Example 3 In this embodiment, a distributed photovoltaic power generation prediction system based on large language models and RAG is proposed, including: The retrieval enhancement generation module constructs a photovoltaic data retrieval pool based on historical photovoltaic power data and uses Euclidean distance as a similarity metric. Based on a given query sequence, it retrieves the most relevant photovoltaic sequence and the predicted target sequence from the retrieval pool. Semantic alignment module: preprocesses the query sequence, the most relevant photovoltaic sequence, and the predicted target sequence to obtain discrete sharding results, and embeds timestamps to obtain hidden states combined with timestamp information; preprocesses the descriptive language sequence in the chain thinking prompt template to obtain an embedding vector; then maps the hidden states combined with timestamp information to the same dimension as the embedding vector, and connects them with the embedding vector to achieve semantic alignment, thus obtaining the final embedding; Prediction module: The final embedded input is entered into the pre-trained language model, and the output of the pre-trained language model is mapped to the prediction target space to obtain the final hidden state result.
[0053] The methods of the present invention can be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as a CD-ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code originally stored on a remote recording medium or a non-transitory machine-readable medium and subsequently stored on a local recording medium, downloaded via a network. Thus, the methods described herein can be processed by software stored on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that the computer, processor, microprocessor controller, or programmable hardware includes storage components (e.g., RAM, ROM, flash memory, etc.) capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the methods described herein. Furthermore, when a general-purpose computer accesses the code used to implement the methods shown herein, the execution of the code transforms the general-purpose computer into a dedicated computer for performing the methods shown herein.
[0054] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.
Claims
1. A distributed photovoltaic power generation prediction method based on large language models and RAG, characterized in that, Includes the following steps: Based on historical photovoltaic power data, a photovoltaic data retrieval pool is constructed, and Euclidean distance is used as a similarity metric. According to a given query sequence, the most relevant photovoltaic sequence and its corresponding prediction target sequence are retrieved from the retrieval pool. The query sequence, the most relevant photovoltaic sequence, and the prediction target sequence corresponding to the most relevant photovoltaic sequence are preprocessed to obtain discrete slicing results, and timestamps are embedded to obtain the hidden state combined with timestamp information. The descriptive language sequence in the chain-thinking prompt template is preprocessed to obtain the embedding vector; then, the hidden state combined with the timestamp information is mapped to the same dimension as the embedding vector through a linear layer, and semantic alignment is achieved by connecting it with the embedding vector to obtain the final embedding. The final embedded state is then incorporated into the pre-trained language model, and the output of the pre-trained language model is mapped to the prediction target space to obtain the final hidden state result.
2. The distributed photovoltaic power generation prediction method based on large language model and RAG according to claim 1, characterized in that, The retrieval process for the most relevant photovoltaic sequence includes: Given a length of l The historical sequence is the query sequence in the retrieval task. Q t−l:t Its timestamp is from t−l arrive t From historical photovoltaic power dataset Search timestamp from τ−l arrive τ The most relevant photovoltaic sequence R τ−l:τ : in, Represents historical photovoltaic power data Each sequence in the sequence has the same length as the query sequence. This represents the Euclidean distance metric.
3. The distributed photovoltaic power generation prediction method based on large language model and RAG according to claim 1, characterized in that, The preprocessing process for the query sequence, the most relevant photovoltaic sequence, and their corresponding prediction target sequence includes: A time series partitioning method is used to convert the continuous photovoltaic sequence into discrete partitions. The partitioning results of the query sequence, the most relevant photovoltaic sequence, and the prediction target sequence are as follows: , , : in, , , These represent the number of segments for the query sequence, the most relevant photovoltaic sequence, and the predicted target sequence, respectively. p The size of the slice is denoted by Patch, which represents the slice processing operation.
4. The distributed photovoltaic power generation prediction method based on large language model and RAG according to claim 1, characterized in that, The preprocessing of the descriptive language sequence includes: first, using a pre-trained word segmenter to convert the descriptive language sequence into a tokenized sequence, and then converting the tokenized sequence into an embedding vector through a pre-trained word token embedding layer and a word position embedding layer.
5. The distributed photovoltaic power generation prediction method based on large language model and RAG according to claim 1, characterized in that, The expression for inputting the final embedding into the pre-trained language model is: in, For the final embedding, N is the number of Transformer blocks in the pre-trained language model, Attention is the multi-head attention mechanism, FFN represents the feedforward network, and LayerNorm is the layer normalization. This represents the i-th token in the output of the pre-trained language model, and np represents the total number of tokens. To represent the output of the pre-trained language model, by... Obtained by performing average pooling.
6. The distributed photovoltaic power generation prediction method based on large language model and RAG according to claim 5, characterized in that, The process of obtaining the final hidden state is as follows: Applying a linear layer to represent the output of the pre-trained language model Mapping to the prediction target space yields the final hidden state result. : in, W o , b o For the learnable parameters of the linear layer, h To predict the length of the target sequence.
7. A distributed photovoltaic power generation prediction system based on large language models and RAG, characterized in that, include: The retrieval enhancement generation module: Based on historical photovoltaic power data, a photovoltaic data retrieval pool is constructed, and Euclidean distance is used as a similarity measurement method. According to the given query sequence, the most relevant photovoltaic sequence and its corresponding predicted target sequence are retrieved from the retrieval pool. Semantic alignment module: preprocesses the query sequence, the most relevant photovoltaic sequence and its corresponding prediction target sequence to obtain discrete sharding results, and embeds timestamps to obtain the hidden state combined with timestamp information; The descriptive language sequence in the chain-thinking prompt template is preprocessed to obtain the embedding vector; then, the hidden state combined with the timestamp information is mapped to the same dimension as the embedding vector through a linear layer, and semantic alignment is achieved by connecting it with the embedding vector to obtain the final embedding. Prediction module: The final embedded input is entered into the pre-trained language model, and the output of the pre-trained language model is mapped to the prediction target space to obtain the final hidden state result.
8. A computer storage medium storing a readable program, characterized in that, When the program runs, it can instruct the computing device to execute the distributed photovoltaic power generation prediction method based on large language models and RAG as described in any one of claims 1-6.
9. An electronic device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform the operation corresponding to the distributed photovoltaic power generation prediction method based on large language model and RAG as described in any one of claims 1-6.
10. A computer program product comprising computer instructions, characterized in that, The computer instructions instruct the computing device to perform the operations corresponding to the distributed photovoltaic power generation prediction method based on large language models and RAG as described in any one of claims 1-6.