Lightweight large language model fine-tuning method for power grid field

By performing lightweight large language model inference at the power grid edge nodes and coordinating fine-tuning at the central nodes, the problem of limited edge computing resources is solved, enabling efficient, real-time, and flexible model fine-tuning for power grid tasks, thus improving computational efficiency and adaptability.

CN121094054BActive Publication Date: 2026-02-17JIANGSU ELECTRIC POWER INFORMATION TECH

Patent Information

Application Number
CN202511640488.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-11
Publication Date
2026-02-17
Estimated Expiration
2045-11-11

AI Technical Summary

Technical Problem

In existing technologies, edge computing nodes in the power grid field have limited resources, making it difficult to effectively perform dynamic fine-tuning of large language models, which cannot meet the requirements of real-time tasks. Furthermore, existing fine-tuning methods cannot flexibly adapt to the complex and ever-changing task requirements in the power grid.

Method used

By performing lightweight large language model inference at edge nodes, acquiring runtime status data and uploading it to the central node, selecting a matching fine-tuning model version, generating a fine-tuning strategy, and performing incremental training and LoRA technology optimization, training efficiency and resource utilization are ensured.

Benefits of technology

It enables real-time inference tasks at edge nodes and dynamic model fine-tuning at central nodes, improving computational efficiency and resource utilization, ensuring low-latency response and efficient resource allocation for power grid tasks, and exhibiting strong adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121094054B_ABST
    Figure CN121094054B_ABST
Patent Text Reader

Abstract

The present application relates to the field of large model fine-tuning, and specifically relates to a lightweight large language model fine-tuning method for the power grid field. The specific method of the present application comprises: obtaining local power grid data at the edge node and performing inference through a lightweight large language model to obtain operating state data; uploading the operating state data to the center node and selecting a matched fine-tuning model version from the lightweight model version library to generate a fine-tuning strategy, ensuring efficient screening of training samples and reasonable allocation of computing resources. Through incremental training and LoRA technology, the fine-tuning process is optimized, significantly improving training efficiency and reducing computational overhead. This method can ensure the real-time performance of the power grid task while fully utilizing the limited computing resources of the edge node, achieving efficient fine-tuning of lightweight large language models in the power grid field and improving the performance of the model in tasks such as monitoring, fault diagnosis and operation optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of large model fine-tuning, and specifically to a lightweight large language model fine-tuning method for the power grid field. Background Technology

[0002] Traditional power grid monitoring and data analysis systems typically rely on centralized computing and processing methods. This approach often encounters computing power bottlenecks when faced with large amounts of real-time data and complex models. Especially in edge computing environments, the massive amounts of data generated by power grid equipment and sensors are difficult to process in real time, leading to data processing delays and wasted computing resources.

[0003] In the power grid sector, applications based on large language models are gradually developing, especially in areas such as power grid monitoring, fault diagnosis, and operation optimization. However, traditional large language models typically require substantial computing resources and storage space, which is often impractical for resource-constrained edge nodes.

[0004] To address this issue, lightweight large language models have been proposed and optimized for edge computing environments. These lightweight large language models, by reducing the number of parameters and computational complexity, are adapted to the computing capabilities of edge nodes in the power grid, enabling rapid data inference and processing without relying on the powerful computing resources of the cloud.

[0005] However, while lightweight large language models have application potential in power grid scenarios, how to effectively dynamically adjust and fine-tune these models according to the different task requirements of edge nodes remains a pressing technical challenge. Most existing fine-tuning methods rely on fixed computing resources and datasets, making efficient adaptive training for real-time changing task requirements in the power grid impossible. Especially in edge computing environments, a mature solution is still lacking for how to flexibly adjust based on the computing resources, data characteristics, and model complexity of edge nodes.

[0006] Based on this, the present invention proposes a lightweight large language model fine-tuning method based on the collaborative work of edge nodes and central nodes. Summary of the Invention

[0007] The technical problem this invention aims to solve is to address the shortcomings of existing technologies by providing a lightweight large language model fine-tuning method for the power grid field. This method obtains local power grid data at edge nodes and performs inference using a lightweight large language model to obtain operational status data. The operational status data is then uploaded to a central node, where a matching fine-tuning model version is selected from a lightweight model version library to generate a fine-tuning strategy, ensuring efficient selection of training samples and rational allocation of computing resources. Incremental training and LoRA technology optimize the fine-tuning process, significantly improving training efficiency and reducing computational overhead. This method can fully utilize the limited computing resources of edge nodes while ensuring the real-time performance of power grid tasks, achieving efficient fine-tuning of lightweight large language models in the power grid field and improving model performance in tasks such as monitoring, fault diagnosis, and operational optimization.

[0008] To achieve the above objectives, the present invention provides the following technical solution:

[0009] A lightweight large language model fine-tuning method for the power grid domain is applied to edge nodes and central nodes in the power grid domain. The edge nodes are used to deploy the lightweight large language model, and the central nodes include computing resources and a lightweight model version library. The lightweight model version library stores the pre-trained weights corresponding to the lightweight model. The fine-tuning method is characterized by comprising:

[0010] Local data from edge nodes is acquired, and inference is performed using the lightweight large language model to obtain the running status data of the lightweight large language model.

[0011] The running status data is uploaded to the central node, a matching fine-tuning model version is selected from the lightweight model version library, and a fine-tuning strategy for the lightweight large language model is generated. The fine-tuning strategy includes sample selection logic and computing power allocation logic.

[0012] According to the sample selection logic of the fine-tuning strategy, the lightweight large language model selects training samples to be fine-tuned from the local data of the edge nodes.

[0013] Based on the computing power allocation logic of the fine-tuning strategy and the pre-trained weights corresponding to the fine-tuning model version, incremental training is performed using the fine-tuning training samples to obtain the fine-tuning training weights.

[0014] The fine-tuned training weights are distributed to the edge nodes to fine-tune the lightweight large language model.

[0015] The process of acquiring local data from edge nodes and performing inference through the lightweight large language model to obtain the runtime status data of the lightweight large language model includes:

[0016] Collect real-time data from edge nodes in power grid monitoring, fault diagnosis, and operation optimization scenarios;

[0017] The real-time data is preprocessed and then input into the lightweight large language model for inference and prediction.

[0018] Record the accuracy, response latency, memory usage, and CPU utilization during the inference and prediction process to generate runtime status data.

[0019] The step of uploading the running status data to the central node, selecting a matching fine-tuning model version from the lightweight model version library, and generating a fine-tuning strategy for the lightweight large language model includes:

[0020] The operation status data is uploaded to the central node, and features are extracted from the operation status data to generate a status feature vector;

[0021] The similarity between the state feature vector and each fine-tuning model version in the lightweight model version library is calculated based on the K-nearest neighbor algorithm, and the fine-tuning model version with the highest similarity is selected.

[0022] Based on the computing power constraints of edge nodes and the complexity of the fine-tuning model version, a fine-tuning strategy including sample selection logic and computing power allocation logic is generated.

[0023] The process involves calculating the feature similarity between the state feature vector and each fine-tuning model version in the lightweight model version library based on the K-nearest neighbor algorithm, and selecting the fine-tuning model version with the highest similarity, including:

[0024] Obtain the historical running state feature vectors corresponding to each fine-tuned model version from the lightweight model version library;

[0025] Calculate the Euclidean distance between the state feature vector and each historical running state feature vector to generate a distance sequence;

[0026] Based on the distance sequence, select the K fine-tuning model versions with the smallest distances as candidate versions;

[0027] Based on the weighted average algorithm, the weighted similarity scores of K candidate versions are calculated, and the fine-tuned model version with the highest score is selected.

[0028] The weighted average algorithm is used to calculate the weighted similarity scores of K candidate versions, and the version of the model with the highest score is selected for fine-tuning, including:

[0029] Calculate the performance weight of each candidate version based on the historical fine-tuning effects of the K candidate versions;

[0030] The distance sequence is normalized to obtain normalized distance scores;

[0031] Based on the performance weights and normalized distance scores, the weighted similarity score of each candidate version is calculated;

[0032] The candidate version with the highest weighted similarity score is selected as the fine-tuned model version for matching.

[0033] The fine-tuning strategy, which generates a sample selection logic and a computing power allocation logic based on the computing power constraints of the edge nodes and the complexity of the fine-tuning model version, includes:

[0034] Obtain the computing resource parameters and network bandwidth parameters of the edge nodes, and calculate the total available computing power resources;

[0035] Based on the parameter size and training complexity of the fine-tuning model version, calculate the computational power requirement for fine-tuning training;

[0036] Based on the ratio of the total available computing resources to the computing power requirement, determine the sample screening threshold and batch size;

[0037] Sample filtering logic is generated based on the sample filtering threshold, and computing power allocation logic is generated based on the batch size.

[0038] According to the sample selection logic, the lightweight large language model selects training samples to be fine-tuned from the local data of edge nodes, including:

[0039] The local data from the edge nodes is input into the lightweight large language model to calculate the prediction confidence for each data sample.

[0040] Based on the sample screening threshold in the sample screening logic, samples with a prediction confidence level higher than the sample screening threshold are marked.

[0041] Extract feature vectors from the labeled samples and calculate the similarity matrix between the samples;

[0042] Cluster analysis is performed on the labeled samples based on the similarity matrix. An equal number of samples are selected from each cluster as fine-tuning training samples, and the fine-tuning training samples are uploaded to the central node.

[0043] Based on the computing power allocation logic and the pre-trained weights corresponding to the fine-tuned model version, incremental training is performed using the fine-tuned training samples to obtain the fine-tuned training weights, including:

[0044] The training batch size and learning rate scheduling strategy are determined based on the computing power allocation logic.

[0045] Load the pre-trained weights corresponding to the fine-tuned model version and freeze the parameters of the pre-trained model;

[0046] Based on the LoRA method, low-rank decomposition matrices are inserted into the key layers of the pre-trained model;

[0047] The fine-tuned training samples are processed in batches according to the training batch size, and only the low-rank decomposition matrix is ​​trained and updated.

[0048] By calculating gradients and optimizing parameters, the output of the low-rank decomposition matrix is ​​added to the output of the original weight matrix to obtain the fine-tuned training weights.

[0049] The LoRA-based method, which inserts low-rank decomposition matrices into the key layers of the pre-trained model, includes:

[0050] Identify the attention layer and feedforward network layer in the pre-trained model, and designate the attention layer and feedforward network layer as key layers;

[0051] A low-rank decomposition matrix is ​​inserted in parallel next to the weight matrix of the key layer. The low-rank decomposition matrix includes a lower projection matrix A and an upper projection matrix B.

[0052] Set the rank parameter r of the low-rank decomposition matrix, where r is less than the rank of the weight matrix of the key layer;

[0053] The lower projection matrix A is initialized to a Gaussian random distribution, and the upper projection matrix B is initialized to a zero matrix to ensure that the LoRA adapter output is zero at the beginning of training.

[0054] The step of distributing the fine-tuned training weights to edge nodes to fine-tune the lightweight large language model includes:

[0055] The fine-tuned model weight parameters are compressed and encoded to generate a weight parameter compressed package;

[0056] The weight parameter compressed package is transmitted from the central node to the corresponding edge node using a secure communication protocol;

[0057] The edge node receives the weight parameter compressed package, decompresses it, and verifies its integrity.

[0058] After passing the integrity verification, the original weight parameters of the lightweight large language model currently deployed on the edge node are replaced with the fine-tuned model weight parameters to complete the fine-tuning of the lightweight large language model.

[0059] Compared with the prior art, the beneficial effects of the present invention are:

[0060] 1. This invention combines a collaborative mechanism between edge nodes and central nodes, enabling edge nodes to independently complete real-time inference tasks, while the central node is responsible for dynamically adjusting the model's fine-tuning process. This distributed architecture not only improves the model's computational efficiency but also ensures low-latency response and efficient resource utilization in power grid scenarios.

[0061] 2. This invention uses computing power allocation logic to dynamically adjust the sample screening threshold and batch size based on the computing resource constraints of edge nodes and the complexity of fine-tuning the model. This allows for flexible allocation according to the specific real-time operation of the power grid, ensuring optimal utilization of computing resources and improving training efficiency and model adaptability. Attached Figure Description

[0062] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0063] Figure 1 This is a schematic diagram illustrating an exemplary application scenario of an embodiment of this application;

[0064] Figure 2 This is a flowchart illustrating the lightweight large language model fine-tuning method for the power grid field according to an embodiment of this application;

[0065] Figure 3 This is a schematic diagram illustrating the lightweight model version matching in an embodiment of this application. Detailed Implementation

[0066] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0067] Please see Figure 1 This application embodiment demonstrates a lightweight large language model collaborative fine-tuning architecture for central and edge nodes in the power grid field. The architecture includes multiple edge nodes and one central node, wherein:

[0068] like Figure 1 As shown, the edge nodes are equipped with lightweight large language models to receive and process local real-time power grid data, such as monitoring data, fault alarm information, and operation optimization parameters. Each edge node not only performs inference tasks but also has an operation status acquisition module to generate operation status data containing indicators such as accuracy, response latency, and resource consumption, and uploads this data to the central node through a secure communication channel.

[0069] The central node includes a computing resource pool, a lightweight model version library, and a fine-tuning control module. The computing resource pool consists of multiple high-performance training servers, supporting distributed incremental training. The lightweight model version library stores pre-trained model versions of different scales and suitable scenarios, serving as the basis for fine-tuning. The fine-tuning control module is responsible for comparing the running status data uploaded by edge nodes with the performance benchmark of the version library, dynamically selecting the model version with the highest matching degree, and generating corresponding fine-tuning strategies.

[0070] like Figure 1 Further, it is shown that the fine-tuning strategy mainly includes sample selection logic and computing power allocation logic: the sample selection logic is used to guide edge nodes to upload representative and high-value training samples; the computing power allocation logic is used to determine the computing power scheduling scheme within the central node, such as training batch size, parallelism and time slice allocation.

[0071] In one implementation example, the central node employs LoRA fine-tuning technology during incremental training, updating only key layers of the pre-trained model to reduce computational consumption and improve training efficiency. After training, the generated fine-tuning weights are compressed and encrypted, then distributed to each edge node via a secure channel. The edge nodes decompress and replace the weights, enabling rapid iterative optimization of the lightweight large language model. Through the collaborative mechanism between edge nodes and the central node, this solution decouples the functions of edge node inference and central node training in power grid scenarios. This ensures low-latency processing of local real-time tasks while improving the overall system's model adaptability and iterative efficiency, making it suitable for complex application scenarios such as power grid monitoring, fault diagnosis, and operation scheduling.

[0072] Please see Figure 2 The flowchart of the lightweight large language model fine-tuning method for the power grid field provided in this application embodiment is shown below, and the specific steps are as follows:

[0073] S1: Obtain local data from edge nodes, perform inference through the lightweight large language model, and obtain the running status data of the lightweight large language model;

[0074] In this embodiment, the local data mainly includes real-time information collected by the power grid edge devices during actual operation, such as voltage, current, and power factor of distribution terminals, monitoring logs of substations, and alarm data and historical operating condition data generated during power grid dispatching. At the edge node, the local data first undergoes preprocessing, including missing value imputation, anomaly detection, and normalization. After preprocessing, the edge node inputs the local data into the lightweight large language model for inference, obtaining prediction results related to the power grid operation scenario, such as load trend prediction, equipment health assessment, or potential fault risk warnings. During inference, the system simultaneously records multi-dimensional state parameters of the model operation, including the accuracy of the inference results, average response latency, memory usage, CPU utilization, and energy consumption level. Finally, the edge node generates complete operating status data based on the above process. This operating status data not only reflects the model's predictive performance in power grid task scenarios but also includes resource consumption and system load, providing a basis for the central node's model version matching and fine-tuning strategy formulation.

[0075] S2: Upload the running status data to the central node, select a matching fine-tuning model version from the lightweight model version library, and generate a fine-tuning strategy for the lightweight large language model. The fine-tuning strategy includes sample selection logic and computing power allocation logic.

[0076] In this embodiment, edge nodes continuously monitor the power grid's operational status and collect real-time inference result data. This inference result data includes, but is not limited to, metrics such as real-time inference accuracy, response latency, memory usage, and CPU utilization during power grid monitoring, fault diagnosis, and operational optimization. After this data is uploaded to the central node, the central node performs further analysis based on the characteristics of the operational status data to select the most suitable fine-tuning model version.

[0077] Specifically, the central node extracts features from the received operational status data to form a state feature vector. Next, the K-nearest neighbor algorithm is used to compare the historical state feature vectors of each fine-tuned model version stored in the lightweight model version library, thereby calculating the similarity between the state feature vector and the models in the library, and selecting the fine-tuned model version with the highest similarity as the candidate version.

[0078] Furthermore, after selecting a suitable fine-tuning model version, the central node formulates a fine-tuning strategy, including sample selection logic and computing power allocation logic, based on the computing resource limitations of the edge nodes and the model complexity. This fine-tuning strategy first calculates the required computing power and bandwidth based on the edge nodes' computing resources (such as processing power and bandwidth) and the training requirements of the fine-tuned model, thereby generating the sample selection threshold and batch size. Based on this, the sample selection logic selects suitable training samples according to the set thresholds, while the computing power allocation logic dynamically adjusts the load of each task during training according to the actual resource availability, in order to optimize training efficiency and ensure the stability of the fine-tuning process.

[0079] S3: According to the sample selection logic of the fine-tuning strategy, the lightweight large language model selects training samples to be fine-tuned from the local data of the edge nodes.

[0080] In this embodiment, edge nodes input local data collected in real-time monitoring, fault diagnosis, and operational optimization scenarios into a lightweight large language model. The model's reasoning capabilities are then used to evaluate the quality and importance of the data samples. The model calculates the prediction confidence score for each data sample and identifies samples with prediction confidence scores below a preset threshold. This helps exclude predictions made by the model under conditions of high uncertainty, thereby avoiding the introduction of samples with large errors into the fine-tuning process.

[0081] Specifically, firstly, the prediction confidence of data samples is quantified, and preliminary screening is conducted by combining the business importance of the samples with their historical data performance. Then, feature vectors are extracted from the labeled samples, and a similarity matrix is ​​calculated between these samples to identify groups of samples with similar characteristics. Based on the similarity matrix, clustering analysis is used to select an equal number of samples from each cluster as fine-tuning training samples, ensuring that the selected samples effectively represent the operational status and task characteristics of edge nodes in different scenarios.

[0082] Based on the results of cluster analysis, an equal number of samples are selected from each cluster as the final fine-tuning training samples to ensure the balance of the training data and enhance the model's generalization ability to different types of samples. The selected fine-tuning training samples will then be uploaded to the central node for further incremental training and fine-tuning.

[0083] This embodiment improves the quality and relevance of fine-tuning training data by introducing sample selection logic, ensuring training efficiency and high-efficiency training results during model fine-tuning. Through cluster analysis and similarity calculation, it avoids wasting computational resources due to data redundancy, while enabling the fine-tuning process to better adapt to the specific task requirements of the power grid field.

[0084] S4: Based on the computing power allocation logic of the fine-tuning strategy and the pre-trained weights corresponding to the fine-tuning model version, incremental training is performed using the fine-tuning training samples to obtain the fine-tuning training weights.

[0085] In this embodiment, the fine-tuning process employs incremental training, combining computational power allocation logic with pre-trained weights corresponding to the fine-tuned model version to optimize fine-tuning efficiency. First, the selected fine-tuning training samples are input into the training system, and then training resources are rationally allocated according to the established computational power allocation logic.

[0086] The computing power allocation logic considers the resource status of edge and central nodes, and dynamically adjusts the allocation ratio of computing resources based on the priority of fine-tuning tasks, ensuring that the training process is both efficient and does not excessively consume system resources. This allocation logic typically includes setting the training batch size, configuring the parallel computing degree, and allocating the training time window, thereby ensuring optimal resource utilization.

[0087] The core of incremental training is to perform local fine-tuning of the pre-trained weights based on the fine-tuned model version, by precisely calculating the network layer parameters that need to be adjusted. In traditional deep learning models, fine-tuning usually involves training the entire network. However, in this embodiment, an incremental training method based on LoRA (Low-Rank Adaptation) is adopted, which only fine-tunes the key top-level parameters in the network, while keeping the parameters of other bottom feature extraction layers unchanged. This significantly reduces the amount of computation required for training and improves training efficiency.

[0088] Furthermore, to address the specific task requirements of the power grid sector, incremental training goes beyond simply updating model parameters. It involves analyzing operational data to identify performance bottlenecks in specific tasks (such as fault diagnosis and load forecasting), thereby prioritizing optimization of network layers that significantly impact these tasks. This approach allows the model to maintain high performance while ensuring rapid convergence.

[0089] In this embodiment, by using reasonable computing power allocation and incremental training strategies, resource consumption and training efficiency can be effectively balanced, enabling the fine-tuning process to adapt to the real-time requirements of the power grid scenario and maintain good model performance even when edge node resources are limited.

[0090] S5: Distribute the fine-tuned training weights to the edge nodes to fine-tune the lightweight large language model.

[0091] In this embodiment, once the fine-tuned training weights are generated and fused by the central node, they will be distributed to the edge nodes via a secure communication protocol to complete the fine-tuning operation. Specifically, the fine-tuned training weights are compressed and encoded into a weight parameter compressed package. This process not only helps reduce the volume of data transmission but also ensures data security, preventing possible tampering or leakage during transmission.

[0092] Once the compressed data packet is generated, the central node sends it to the target edge node through a highly secure communication channel. To ensure reliable communication, data encryption and authentication mechanisms are employed throughout the data transmission process to prevent data loss or interference during transmission.

[0093] Upon receiving the compressed weight parameter package, the edge node first performs an integrity check to ensure that the data has not been tampered with or lost during transmission. If the check passes, the edge node decompresses the weight parameters and replaces the original weights in the currently deployed lightweight large language model with the new fine-tuned training weights. This process requires that the edge node system's resources and computing power are sufficient to handle the decompression and loading operations, and is typically completed within a predetermined computation window.

[0094] Through this process, edge nodes will acquire new fine-tuned model weights, thereby improving the model's performance in specific tasks within the power grid domain. For example, the model can make more accurate decisions in tasks such as fault diagnosis, load forecasting, and equipment monitoring, thereby improving power grid stability and optimizing operational efficiency.

[0095] In the power grid sector, while traditional large-scale language models have achieved success in many applications, efficient model fine-tuning at edge nodes remains a technical challenge due to limitations in edge computing resources. Existing technologies such as distributed computing and remote inference are widely used, but they still face problems such as insufficient computing power and untimely model updates when handling tasks like power grid monitoring and fault diagnosis. Traditional model fine-tuning methods typically rely on substantial computing resources and involve complex update processes, making them ill-suited to the dynamic and complex environment of the power grid.

[0096] This invention addresses the limited resources of edge computing devices in the power grid sector by proposing a lightweight large language model fine-tuning method. By constructing a two-layer structure based on edge nodes and a central node, a lightweight large language model is deployed at the edge nodes. Through inference and analysis of local data, operational status data is uploaded to the central node, allowing for the selection of an appropriate model version for fine-tuning. This method not only improves the efficiency of edge computing but also ensures that the model can be dynamically fine-tuned based on real-time data, thereby enhancing the intelligence level of the power grid.

[0097] For example, edge nodes perform inference on local data using a lightweight large language model, obtain runtime status data, and upload it to the central node. The central node determines the actual performance of the edge node's lightweight large language model based on the runtime status data. For instance, if the current edge node's lightweight large language model is a multimodal model, but the local data is mainly single-modal, then during model inference, the lightweight large language model processes single-modal data as if it were multimodal data, leading to excessive consumption of computing resources. Therefore, the central node needs to fine-tune the current edge node's lightweight large language model, reverting from the original multimodal model to a single-modal model to reduce the number of model parameters and improve the utilization rate of computing resources.

[0098] Specifically, the fine-tuning method of this application includes the following steps: First, edge nodes perform data inference using a lightweight large language model to obtain operational status data; then, the central node selects the optimal fine-tuning model based on this data and generates a fine-tuning strategy, including sample selection logic and computing power allocation logic; next, edge nodes select suitable training samples for fine-tuning according to the sample selection logic; finally, the central node optimizes the fine-tuned model through incremental training and distributes the fine-tuned weight parameters to the edge nodes to complete the model update and improvement. The advantage of the fine-tuning method of this application is that it can not only fully utilize limited computing resources while ensuring the requirements of power grid tasks, but also make the fine-tuning process more efficient through incremental training. In addition, the collaborative work of edge nodes and central nodes further optimizes the accuracy of computing power allocation and sample selection, enabling the model to more accurately adapt to various complex tasks in the power grid field.

[0099] The specific steps of S2 are as follows:

[0100] S2.1: Upload the running status data to the central node, extract features from the running status data, and generate a status feature vector;

[0101] In this embodiment, the operational status data collected on the edge nodes first needs to be uploaded to the central node. The operational status data contains information across multiple dimensions, such as model inference accuracy, response latency, memory usage, and CPU utilization. After uploading the operational status data, the central node performs feature extraction on the data for further analysis and processing. The feature extraction process involves identifying key features related to model performance and resource consumption from the raw operational status data. For example, it might extract computational intensity information during model computation from CPU utilization, or extract the model's real-time performance in the edge node environment from response latency.

[0102] S2.2: Calculate the feature similarity between the state feature vector and each fine-tuning model version in the lightweight model version library based on the K-nearest neighbor algorithm, and select the fine-tuning model version with the highest similarity.

[0103] In this embodiment, the first step is to calculate the similarity between the state feature vector uploaded to the central node and the features of each fine-tuned model version in the lightweight model version library. To this end, this embodiment employs the K-nearest neighbor algorithm, which selects the most suitable fine-tuned model version by calculating the similarity between the state feature vector and the historical running state feature vectors of each fine-tuned model version.

[0104] Specifically, the central node first retrieves the historical running state feature vectors corresponding to all fine-tuned model versions from the lightweight model version library. The historical running state feature vectors for each fine-tuned model version are extracted from data collected during multiple runs in the early training process, reflecting the performance of different models under different operating environments. Then, a distance sequence is generated by calculating the Euclidean distance or other distance metrics between the state feature vectors and each historical running state feature vector.

[0105] Furthermore, to accurately select the fine-tuning model version best suited to the current edge node state, this embodiment employs the K-nearest neighbor algorithm, selecting the K fine-tuning model versions with the smallest distances as candidate versions. The value of K can be adjusted according to actual needs to balance computational efficiency and selection accuracy. By calculating the comprehensive similarity of these K candidate model versions, the most suitable fine-tuning model version can be selected.

[0106] Furthermore, when calculating the overall similarity, the center node uses a weighted average algorithm, where the weight of each candidate version is set based on factors such as its historical fine-tuning performance, parameter size, and training complexity. This ensures that the selected fine-tuned model version not only most closely resembles the current state feature vector in the feature space but also meets the computing power and resource requirements of the edge nodes.

[0107] Finally, the fine-tuned model version with the highest similarity score is selected as the best candidate model and enters the subsequent fine-tuning strategy generation and training stage to ensure that the fine-tuned model can effectively improve performance and adaptability while meeting the operational requirements of edge nodes.

[0108] Please see Figure 3 The present application provides a schematic diagram of a lightweight model version matching method. The specific steps of S2.2 are as follows:

[0109] S2.2.1: Obtain the historical running state feature vectors corresponding to each fine-tuning model version from the lightweight model version library;

[0110] In this embodiment, in order to accurately select the fine-tuned model version most similar to the current edge node state feature vector, it is first necessary to obtain the historical running state feature vectors corresponding to each fine-tuned model version from the lightweight model version library. These historical running state feature vectors are accumulated during the fine-tuning model training process based on the performance of different running environments and datasets, and they represent the performance characteristics exhibited by each model version during historical operation.

[0111] Specifically, each fine-tuned model version in the lightweight model version library is accompanied by a set of historical operating state feature vectors. These feature vectors record the model's performance in different training cycles and scenarios (such as power grid monitoring and fault diagnosis). This information includes, but is not limited to, the model's response time, accuracy, memory usage, and other resource consumption metrics. Through these historical operating state feature vectors, the central node can evaluate the model's performance in various scenarios, thus providing a basis for selecting the most suitable fine-tuned model version.

[0112] When acquiring these historical operational status feature vectors, the central node can filter out the model version related to the current task and its corresponding historical operational status feature vector from the version repository based on a specific timestamp or version identifier. If the model repository is large, the central node can also classify the historical operational status feature vectors through metadata or tags to facilitate more efficient retrieval and comparison.

[0113] S2.2.2: Calculate the Euclidean distance between the state feature vector and each historical running state feature vector, and generate a distance sequence;

[0114] In this embodiment, to evaluate the similarity between the current state feature vector and the historical running state feature vector, the central node quantifies their differences by calculating the Euclidean distance. Euclidean distance is a commonly used distance metric that measures the straight-line distance between two feature vectors, effectively reflecting their relative positions and similarities in the feature space.

[0115] Specifically, the central node first compares the currently uploaded state feature vector with the historical running state feature vectors of each fine-tuned model version in the lightweight model version library. For each pair of state feature vectors and historical running state feature vectors, the Euclidean distance between them is calculated using the following formula:

[0116]

[0117] in, and The current state feature vector and the historical running state feature vector are respectively in the th... The components of the dimension, The dimension of the feature vector. This represents the Euclidean distance between the two states. The smaller the calculated distance value, the more similar the current state is to the historical state.

[0118] After the calculation is complete, the central node will obtain a sequence of Euclidean distances, which reflects the distance between the current state feature vector and the feature vectors of each historical running state. Using this distance sequence, the central node can identify the historical model version that is closest to the current state, providing a reference for fine-tuning the model selection.

[0119] S2.2.3: Based on the distance sequence, select the K fine-tuning model versions with the smallest distances as candidate versions;

[0120] In this embodiment, the calculated distance sequence provides a quantitative basis for the subsequent selection of fine-tuning model versions. Specifically, the central node selects K fine-tuning model versions with the smallest distances from the calculated Euclidean distance sequence as candidate versions. The smaller the distance, the more similar the current state features are to the historical features of that model version, and the more suitable it may be for fine-tuning the current task.

[0121] Furthermore, to select the K most suitable fine-tuning model versions, the calculated distance sequence first needs to be sorted. By arranging the distances from smallest to largest, the central node can intuitively identify the K model versions that are closest to the current state feature vector. During this process, the value of K can be adjusted according to the system's requirements; generally, choosing a smaller K value can improve the accuracy of selection while reducing computational complexity.

[0122] For example, the choice of K can be flexibly adjusted based on the constraints of computing resources and the complexity of the task. For instance, the value of K can be set to a fixed constant, or dynamically adjusted based on the number of historical models and the distribution of features, to balance the diversity of candidate models and computational efficiency. A larger value of K increases the diversity of candidate versions, covering more possible operating scenarios; while a smaller value of K allows for a more focused approach on the most relevant model versions.

[0123] S2.2.4: Based on the weighted average algorithm, calculate the weighted similarity score of K candidate versions and select the fine-tuned model version with the highest score.

[0124] Specifically, after completing the initial screening of candidate fine-tuning model versions, the central node calculates a weighted similarity score for each candidate model version based on a weighted average algorithm. First, the K candidate versions are obtained by calculating the feature similarity between the current state feature vector and each historical model version. Each candidate version corresponds to a historical running state feature vector, which reflects the performance of each model under different training cycles and operating environments.

[0125] Furthermore, different weights are assigned to each candidate version based on its historical fine-tuning performance and runtime performance. These weights reflect the candidate version's performance in past tasks. Versions with higher weights indicate superior historical performance and stronger adaptability to the current task, thus deserving higher similarity weights. A weighted average is then used to calculate the weighted similarity score for each candidate version, allowing for a comprehensive consideration of feature similarity and performance across different candidate model versions.

[0126] The specific steps of S2.2.4 are as follows:

[0127] S2.2.4.1: Calculate the performance weight of each candidate version based on the historical fine-tuning effects of the K candidate versions;

[0128] Specifically, in order to effectively select the optimal model from multiple candidate versions, it is necessary to consider the performance of each candidate version during the historical fine-tuning process. The performance weight of a candidate version reflects its adaptability and training effect in previous training tasks. The larger the weight, the better the version has performed historically and the more adaptable it may be to the current task.

[0129] Furthermore, to avoid bias from a single metric, weighting coefficients can be assigned to different evaluation metrics, adjusting their influence according to the specific requirements of the task. For example, if the current task prioritizes model training speed, the weight of training convergence speed can be increased accordingly. The core of this calculation process lies in deriving the performance weight of each version based on its historical fine-tuning effects, which is then used in subsequent similarity-weighted calculations to further improve the selection accuracy of the fine-tuned versions.

[0130] S2.2.4.2: Normalize the distance sequence to obtain normalized distance scores;

[0131] Specifically, when selecting candidate versions, the calculated distance sequence reflects the similarity between the current state features and each candidate model version. However, since different state features may differ, the values ​​of these distances may vary significantly, causing some distance values ​​to contribute excessively to the weighted calculation, thus affecting the accuracy of the final version selection. Therefore, these distance values ​​need to be normalized to ensure that the influence of each distance is within the same order of magnitude.

[0132] In this embodiment, to ensure high comparability of the normalized distance scores, a linear normalization method is adopted, which maps the minimum and maximum values ​​in the distance sequence to fixed intervals. By subtracting the minimum value from each distance value and dividing by the difference between the maximum and minimum values, all distance values ​​are compressed into the interval [0,1]. This ensures that the similarity scores between different candidate versions can be compared on a uniform scale.

[0133] S2.2.4.3: Calculate the weighted similarity score for each candidate version based on the performance weights and normalized distance scores;

[0134] Specifically, when calculating the weighted similarity score of candidate model versions, the normalized distance score of each candidate version needs to be combined with its corresponding performance weight for historical fine-tuning. The performance weight reflects the candidate version's performance in historical tasks; versions with higher weights indicate better performance in historical tasks and a relatively stronger ability to adapt to the current task. The normalized distance score quantifies the similarity between the current task features and each candidate version. By combining the performance weight and the normalized distance score, the weighted similarity score of each candidate version can be obtained, ultimately determining the best-matching fine-tuning version.

[0135] S2.2.4.4: Select the candidate version with the highest weighted similarity score as the matching fine-tuning model version.

[0136] Specifically, during the fine-tuning process, the weighted similarity score of the candidate versions reflects their matching degree with the current task requirements and the comprehensive performance of historical fine-tuning. To ensure that the final selected model can achieve the best performance in the current task, the version with the highest weighted similarity score must be selected from all candidate versions as the final matched fine-tuning model version, ensuring the model's adaptability and effectiveness in the task and improving the effect of fine-tuning training.

[0137] S2.3: Based on the computing power constraints of edge nodes and the complexity of the fine-tuning model version, generate a fine-tuning strategy that includes sample selection logic and computing power allocation logic.

[0138] Specifically, to ensure effective model fine-tuning on resource-constrained edge nodes, a reasonable fine-tuning strategy needs to be formulated based on the actual computing power of the edge nodes and the complexity of the fine-tuning model. The core of this fine-tuning strategy is to balance the use of computing resources with the requirements of the fine-tuning task, ensuring that the computing potential is fully utilized without exceeding the processing capacity of the nodes.

[0139] First, it's necessary to obtain the computing resource parameters (such as CPU and GPU performance) and network bandwidth parameters of the edge nodes. These parameters help accurately assess the total available computing power resources of the edge nodes, further determining the computing power and memory resources that can be allocated to the training task during fine-tuning. Second, based on the parameter size and training complexity of the fine-tuned model version, the computing power requirements for fine-tuning should be estimated. Simultaneously, the model size, the number of training iterations, and the computational cost per iteration must be considered. If the fine-tuned model is too complex, it may lead to excessively slow training speeds, or even exceed the computing power capabilities of the edge nodes; therefore, appropriate computing power requirement assessment and matching are necessary.

[0140] Furthermore, a sample selection threshold and batch size are generated. The sample selection threshold is used to filter out training samples that have a significant impact on the fine-tuning effect, avoiding the inclusion of low-quality or irrelevant data in the fine-tuning process. The batch size determines the amount of data loaded during each training session, directly affecting training speed and memory usage. By appropriately setting the sample selection threshold and batch size based on the computing resources of the edge nodes and the needs of the fine-tuning model, the training process can be effectively optimized, avoiding overload.

[0141] The specific steps of S2.3 are as follows:

[0142] S2.3.1: Obtain the computing resource parameters and network bandwidth parameters of the edge nodes, and calculate the total available computing power resources;

[0143] Specifically, edge nodes periodically acquire and report the current status of their computing resources, including the number of CPU cores, clock frequency, GPU model and computing power, memory size, and current load. This information can be obtained in real time through APIs provided by the operating system or dedicated hardware monitoring tools. For GPUs, it is also necessary to pay attention to parameters such as the number of computing units, computing power (e.g., TFLOPS), and memory bandwidth, as these factors directly affect the actual inference capabilities of the lightweight large language models deployed on the edge nodes.

[0144] Furthermore, the network bandwidth parameters of edge nodes also need to be obtained in real time, especially in distributed training environments where data uploads, synchronizations, and gradient updates are all limited by network bandwidth. Network bandwidth parameters can be obtained using network monitoring tools, such as bandwidth testing tools or real-time network traffic monitors, to determine the currently available upload and download bandwidth. For large-scale distributed training, the network bandwidth of edge nodes determines the bottleneck of data transmission, affecting the efficiency of fine-tuning tasks.

[0145] S2.3.2: Based on the parameter size and training complexity of the fine-tuning model version, calculate the computing power requirements for fine-tuning training;

[0146] Specifically, the computational requirements for fine-tuning training depend on the parameter size of the model version being fine-tuned, the complexity of the network structure, and the amount of computation required during training. When assessing computational requirements, the size and structure of the model being fine-tuned must first be considered, including the number of network layers, the number of neurons per layer, the number of parameters, and the model depth. Furthermore, training complexity is not only determined by the parameter size of the model itself but is also closely related to the amount of training data involved in the fine-tuning process, the number of training epochs, the batch size, and the computational cost required for each training sample.

[0147] S2.3.3: Determine the sample screening threshold and batch size based on the ratio of the total available computing resources to the computing power requirement;

[0148] Specifically, based on the ratio of total available computing resources to computing power requirements, the central node determines an appropriate sample selection threshold and batch size. A higher ratio indicates sufficient available computing resources, allowing the central node to allow larger batch sizes, thus improving training efficiency. Simultaneously, the sample selection threshold can be adjusted to select more samples for fine-tuning, further enhancing model performance. However, a lower ratio indicates insufficient available computing resources, causing the central node to reduce batch sizes to avoid exceeding computational resource limits and ensure stable training. At the same time, the sample selection threshold may be increased to restrict the selection to only the most valuable samples, thereby reducing computational burden and maintaining training efficiency and quality.

[0149] S2.3.4: Generate sample screening logic based on the sample screening threshold, and generate computing power allocation logic based on the batch size.

[0150] In this embodiment, the sample selection logic is dynamically adjusted based on the sample selection threshold and fine-tuning objectives. First, the edge nodes select local data based on the sample selection threshold received from the central node. The sample selection threshold is determined by the specific requirements of the analysis task, the quality of the data, and the prediction confidence of the model, ensuring that the selected samples have high quality and representativeness. Specifically, the edge nodes calculate the prediction confidence of each data sample, marking samples with prediction confidence higher than the sample selection threshold as valid samples, and then performing further feature extraction and analysis.

[0151] Furthermore, in fine-tuning training, the calculation of computing power allocation logic is based on the computing power resources of the central node. The central node possesses powerful computing capabilities and typically has multiple high-performance computing servers to support distributed training. In this step, the central node first obtains the currently available computing power resources, such as the number of computing nodes, GPU / CPU performance, memory, and network bandwidth, and calculates the total available computing power resources.

[0152] The specific steps for S3 are as follows:

[0153] S3.1: Input the local data of the edge nodes into the lightweight large language model and calculate the prediction confidence of each data sample;

[0154] Specifically, in order to effectively identify suitable data samples for fine-tuning from the massive local data collected from edge nodes, the local data first needs to be input into the lightweight large language model for inference processing to obtain the prediction result for each data sample. The prediction result corresponds to the classification or regression output of the data sample, while the prediction confidence is a measure reflecting the reliability of the prediction result of the data sample. By calculating the prediction confidence, the degree of fit of each data sample under the current lightweight large language model can be quantified.

[0155] S3.2: Based on the sample screening threshold in the sample screening logic, mark the samples whose prediction confidence is higher than the sample screening threshold;

[0156] In this embodiment, the core purpose of the sample selection logic is to evaluate the local data collected from edge nodes and select the most valuable samples for fine-tuning training. First, the prediction confidence of each data sample is an important indicator of the reliability of its prediction result, typically calculated using the probability value output by the model or some form of confidence score. When the prediction confidence of a sample is higher than the set sample selection threshold, it indicates that the prediction result of that sample has high reliability in the model and is suitable for fine-tuning training.

[0157] S3.3: Extract feature vectors from the labeled samples and calculate the similarity matrix between samples;

[0158] Specifically, in this embodiment, the first step is to extract feature vectors from the labeled samples. These feature vectors represent the samples in the feature space and effectively capture the key information of the samples. During feature extraction, each sample is typically encoded using an input layer neural network model or a pre-trained feature extractor, transforming the sample into a high-dimensional feature vector. This feature vector contains feature information about the sample across multiple dimensions, such as data category information, numerical features, and text features. Depending on the application scenario, the extracted features may include numerical values, word vectors of text, or pixel features in an image.

[0159] S3.4: Perform cluster analysis on the labeled samples based on the similarity matrix, select an equal number of samples from each cluster as fine-tuning training samples, and upload the fine-tuning training samples to the central node.

[0160] Specifically, the purpose of cluster analysis is to ensure the representativeness of the fine-tuned training samples, avoiding the selection of highly repetitive or redundant samples, thereby improving training effectiveness and optimizing the utilization of computational resources. Samples in each cluster have similar characteristics and potential patterns. By uniformly selecting an equal number of samples from each cluster, the diversity and comprehensiveness of each cluster can be guaranteed, avoiding over-representation of one type of sample and ensuring that the training data can cover the model's performance in various scenarios.

[0161] The specific steps for S4 are as follows:

[0162] S4.1: Determine the training batch size and learning rate scheduling strategy based on the computing power allocation logic;

[0163] In this embodiment, the selection of training batch size needs to comprehensively consider the processing power, memory capacity, and computing resources of the edge nodes. For example, when the computing resources of the edge nodes are relatively scarce, a smaller batch size can reduce the burden on memory and processor, avoiding resource overload. When computing resources are abundant, the batch size can be appropriately increased to improve training efficiency and reduce the time cost of each training round.

[0164] Furthermore, the learning rate scheduling strategy dynamically adjusts the learning rate based on performance during training. The initial learning rate is typically set conservatively to avoid overfitting the model in the early stages of training. During training, as the model gradually converges, the learning rate is gradually reduced to improve training stability and prevent overfitting. For example, a learning rate warm-up and gradual decay strategy can be used, where the learning rate gradually increases in the early stages of training and then gradually decreases in the later stages. This strategy effectively avoids instability caused by an excessively large learning rate during training.

[0165] S4.2: Load the pre-trained weights corresponding to the fine-tuned model version and freeze the parameters of the pre-trained model;

[0166] Specifically, during fine-tuning, the first step is to load the pre-trained weights corresponding to the version of the model being fine-tuned. Pre-trained weights are typically model parameters trained on large datasets; these weights have been optimized on large-scale training data and can capture general features. Since the goal of fine-tuning is to adaptively optimize an existing pre-trained model for a specific task, loading pre-trained weights can significantly reduce the time and computational resources required to train from scratch.

[0167] After loading the pre-trained weights, the next crucial step is to freeze the model's parameters. Freezing refers to fixing some or most of the parameters in the pre-trained model during fine-tuning, typically the lower layers (such as feature extraction layers). The purpose of this is to prevent changes to these trained weights during fine-tuning, preserving the general features they have learned on large-scale datasets and avoiding over-tuning that could cause the model to lose its generality.

[0168] Specifically, the basic feature extraction layer in the model is typically frozen. This layer is responsible for capturing basic features of data such as images and text, including information such as edges, shapes, and words. The focus of updates is then placed on the higher-level task-related layers of the model. These layers are responsible for performing higher-level reasoning and decision-making on the input data, thereby fine-tuning the model to adapt to specific tasks (such as power grid monitoring and fault diagnosis).

[0169] S4.3: Based on the LoRA method, insert low-rank decomposition matrices into the key layers of the pre-trained model;

[0170] Specifically, in this step, the LoRA method is employed. This method optimizes the fine-tuning process by inserting low-rank factorization matrices into the key layers of the pre-trained model. The core idea of ​​LoRA is to reduce the number of parameter updates, thereby reducing computational overhead, and to fine-tune only the key parts of the model without requiring a complete retraining of the entire model. This method is particularly suitable for scenarios with limited computational resources and can significantly improve training efficiency.

[0171] In this embodiment, the key layers of the pre-trained model include attention layers and feedforward network layers, which play a crucial role in the model's inference process. First, identifying and locating these key layers is a prerequisite for LoRA adapter insertion. Typically, attention layers and feedforward network layers are responsible for processing the complex interactive features of the model input. In most pre-trained language models, these layers have a large number of parameters and significantly impact overall performance; therefore, they are the focus of fine-tuning.

[0172] Furthermore, low-rank decomposition matrices are inserted in parallel alongside the weight matrices of these key layers. These low-rank decomposition matrices consist of a lower projection matrix A and an upper projection matrix B, with the ranks of matrices A and B typically set to a relatively small value, much smaller than the dimension of the original weight matrices. The advantage of this approach is that it captures task-relevant high-order features in the key layers without significantly increasing computational complexity.

[0173] The specific steps of S4.3 are as follows:

[0174] S4.3.1: Identify the attention layer and feedforward network layer in the pre-trained model, and designate the attention layer and feedforward network layer as key layers;

[0175] Specifically, in applying the LoRA method, the first step is to identify and determine the key layers in the pre-trained model. Pre-trained models typically contain multiple layers, some of which are crucial to the model's performance and functionality, particularly those involved in the model's core computations.

[0176] In pre-trained models, attention layers are typically used to capture the relationships and dependencies between input data. These layers can dynamically adjust computational weights based on the interactions between different parts of the input data, thereby improving the model's performance in tasks such as natural language processing and image analysis. Therefore, attention layers usually have high parameter complexity and play a crucial role in model inference.

[0177] Feedforward layers, typically located within each encoder and decoder block of models like the Transformer, are responsible for processing and transforming the output of the attention layer. The role of feedforward layers is to perform non-linear mapping of information, thereby enhancing the model's expressive power. These layers usually consist of a set of fully connected layers, capable of extracting higher-level features and playing a crucial role in the model's performance.

[0178] S4.3.2: Insert a low-rank decomposition matrix in parallel next to the weight matrix of the key layer. The low-rank decomposition matrix includes a lower projection matrix A and an upper projection matrix B.

[0179] Specifically, in the LoRA method, to efficiently fine-tune the key layers of the pre-trained model, low-rank decomposition matrices need to be inserted next to the weight matrices of these layers. The construction of the low-rank decomposition matrix consists of two parts: a lower projection matrix A and an upper projection matrix B. By dividing it into two parts, the LoRA method can insert new information adapted to the task without changing the original weights of the pre-trained model, reducing computational complexity and accelerating training.

[0180] First, the purpose of the downprojection matrix A is to map the input data to a low-dimensional space. This matrix transforms the input data from a high-dimensional space into a low-rank space by projecting it, reducing information complexity while preserving important task-relevant features. The dimension of matrix A is typically smaller than that of the original weight matrix, ensuring reduced computational overhead. Specifically, the dimension of the downprojection matrix A is usually set to a low-rank value r, which is much smaller than the dimension of the original weight matrix, thus effectively reducing the number of parameters.

[0181] Next, the upprojection matrix B is responsible for remapping the information in the low-rank space to the high-dimensional space, thus combining it with the original weight matrix. The role of matrix B is to recover the high-dimensional representation of the information, enabling it to be effectively integrated with the original weights of the model. In this way, the LoRA method can adjust and adapt the pre-trained model within a specific layer with relatively low computational overhead, without requiring a comprehensive update of the entire weight matrix.

[0182] S4.3.3: Set the rank parameter r of the low-rank decomposition matrix, where r is much smaller than the dimension of the original weight matrix;

[0183] Specifically, in the LoRA method, the computational complexity and fine-tuning efficiency can be effectively controlled and improved by setting the rank parameter *r* of the low-rank decomposition matrix. The low-rank decomposition matrix consists of a lower projection matrix A and an upper projection matrix B, and their rank parameter *r* is a key factor determining the difference in dimensionality between them and the original weight matrix. When setting *r*, it is typically set to be much smaller than the dimension of the original weight matrix, allowing the low-rank decomposition matrix to capture important features in key layers during fine-tuning, while avoiding a complete update of the entire model's weights, thereby reducing computational cost and storage requirements.

[0184] Furthermore, the rank parameter r refers to the number of dimensions retained in the low-rank portions of the projection matrices A and B. In the LoRA method, the original weight matrix typically has a high dimension. Therefore, by setting the rank parameter r to be much smaller than the dimension of the original weight matrix, the number of parameters in the insertion matrix can be effectively reduced. Because r is small, the number of parameters in the low-rank decomposition matrix is ​​significantly reduced, greatly decreasing computational overhead while maintaining sufficient expressive power for effective fine-tuning of the pre-trained model.

[0185] S4.3.4: Initialize the lower projection matrix A to a Gaussian random distribution and initialize the upper projection matrix B to a zero matrix to ensure that the LoRA adapter output is zero at the beginning of training.

[0186] Specifically, in the LoRA method, initializing projection matrices A and B is a crucial step to ensure the smooth progress of fine-tuning. To guarantee the stability and effectiveness of training, matrices A and B are specially initialized so that the output of the LoRA adapter is zero at the beginning of training, thereby avoiding excessive perturbation to the model at the start of training.

[0187] Furthermore, the lower projection matrix A is initialized using a Gaussian random distribution, ensuring that the parameters of matrix A have a certain degree of randomness at the start of training, thus providing diversity and flexibility for the fine-tuning process. Through Gaussian random distribution initialization, each element of matrix A is randomly generated according to a standard normal distribution, ensuring that matrix A has reasonable initial values. The upper projection matrix B is initialized to a zero matrix, ensuring that all values ​​of matrix B are zero in the early stages of training. Therefore, the output of the LoRA adapter is also zero, ensuring that the model's behavior relies entirely on the pre-trained weights in the early stages of training, avoiding unnecessary impact on the model initially. As training progresses, matrices A and B gradually learn task-related features, and the zero initialization of the upper projection matrix B ensures that the model's dependence on the original weights remains unchanged in the initial stage, allowing for a smoother learning of new knowledge during fine-tuning.

[0188] S4.4: The fine-tuned training samples are processed in batches according to the training batch size, and only the low-rank decomposition matrix is ​​trained and updated.

[0189] Specifically, during fine-tuning, training samples are processed in batches according to the set batch size. This step aims to ensure efficient use of computational resources during training while avoiding excessively large batches that could lead to memory overflow or excessive consumption of computational resources. By batch processing the fine-tuned training samples, training stability can be improved, the convergence process accelerated, and the training process made more efficient.

[0190] S4.5: By calculating gradients and optimizing parameters, the output of the low-rank decomposition matrix is ​​added to the output of the original weight matrix to obtain the fine-tuned training weights.

[0191] Specifically, during fine-tuning, to improve training efficiency and make rational use of computing resources, the training batch size must first be determined based on the requirements of the training task and the computing resources of the edge nodes. The training batch size is the number of data samples processed each time during fine-tuning. Batch sizes that are too large may lead to excessive memory consumption, while batch sizes that are too small may result in low training efficiency. Therefore, this embodiment ensures an optimal balance between computing resources and time in fine-tuning training by using a reasonable batch size.

[0192] After batching the training samples according to batch size, only the low-rank factorization matrix is ​​updated within each batch. The low-rank factorization matrix is ​​inserted into the attention layer and feedforward network layer of the pre-trained model using the LoRA (Low-Rank Adaptation) method. These matrices are much smaller than the weight matrix of the original model. Therefore, during fine-tuning, only these matrices need to be updated, rather than updating the parameters of the entire pre-trained model. This significantly reduces the computational cost of training, especially on computationally limited edge nodes, effectively improving training efficiency and reducing resource consumption.

[0193] The specific steps for S5 are as follows:

[0194] S5.1: Compress and encode the fine-tuned model weight parameters to generate a compressed weight parameter package;

[0195] Specifically, after the fine-tuning process is complete, the generated model weights need to be compressed and encoded to reduce the amount of data during transmission, improve transmission efficiency, and reduce storage consumption. Since the fine-tuned model weights typically have a large parameter scale, especially in edge computing environments, transmitting and storing large amounts of weight data can lead to excessive consumption of bandwidth and storage resources.

[0196] In this embodiment, an efficient compression algorithm is used to encode the fine-tuned weight parameters. The compression encoding process not only includes lossless data compression to ensure that the compressed data can be transmitted and recovered without losing information, but may also include strategies based on redundant information removal, such as sparsification and quantization of the weight matrix. This can significantly reduce the storage space of the weight data, making the compressed file smaller and more suitable for transmission in a network environment.

[0197] S5.2: Transmit the weight parameter compressed package from the central node to the corresponding edge node through a secure communication protocol;

[0198] Specifically, after the fine-tuned model weights are compressed into a weight parameter compressed package, to ensure the security and integrity of the model weights during transmission, this compressed package must be transmitted from the central node to the corresponding edge nodes via a secure communication protocol. Since edge nodes are typically distributed in different geographical locations and may face risks such as network latency, bandwidth limitations, and data leakage when performing real-time inference tasks, it is crucial to adopt a highly secure data transmission protocol.

[0199] S5.3: Receive the weight parameter compressed package at the edge node, and perform decompression and integrity verification;

[0200] Specifically, after an edge node successfully receives the compressed package transmitted via a secure communication protocol from the central node, it first needs to decompress the received data to restore the fine-tuned model weight parameters. This ensures that the edge node can obtain complete weight data and prepares for subsequent model updates. Since the compressed package contains the fine-tuned model weights, the edge node will restore these weight parameters during decompression for subsequent model updates.

[0201] Furthermore, before decompression, an integrity check is performed. The purpose of this check is to ensure that the data has not been tampered with or corrupted during transmission. This is typically done through checksums, hash values, or digital signatures to ensure the compressed package maintains consistency and accuracy during transmission. If incomplete or tampered data is found during the check, the edge node will issue a warning and interrupt the decompression process, requiring the correct weight parameter file to be retrieved from the central node.

[0202] S5.4: After passing the integrity check, replace the original weight parameters of the lightweight large language model currently deployed on the edge node with the fine-tuned model weight parameters to complete the fine-tuning of the lightweight large language model.

[0203] Specifically, after model fine-tuning, the weight parameters obtained from the fine-tuning training are encrypted and compressed before being transmitted from the central node to each edge node. To ensure that the data is not tampered with or lost during transmission, the edge nodes first perform integrity verification upon receiving the compressed package. This step uses hash verification or other encryption methods to confirm that the data within the compressed package remains consistent during transmission, ensuring accuracy. After confirming the data is complete and error-free, the edge nodes decompress the compressed package and load the fine-tuned weight parameters. These fine-tuned weights replace the original weight parameters in the currently deployed lightweight large language model. This not only ensures that the model deployed on the edge nodes is updated, but also enables the edge nodes to perform more accurate and efficient inference tasks by replacing the original weights, improving the model's application performance in the power grid field.

[0204] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A lightweight large language model fine-tuning method for the power grid field, applied to edge nodes and center nodes in the power grid field, the edge nodes being used to deploy lightweight large language models, the center nodes including computing power resources and a lightweight model version library, the lightweight model version library storing pre-training weights corresponding to the lightweight models, characterized in that, The fine-tuning method comprises: Obtaining local data of the edge node, inferring through the lightweight large language model to obtain running state data of the lightweight large language model; Uploading the running state data to the center node, selecting a matched fine-tuning model version from the lightweight model version library, and generating a fine-tuning strategy for the lightweight large language model, the fine-tuning strategy comprising sample screening logic and computing power allocation logic; According to the sample screening logic of the fine-tuning strategy, the lightweight large language model is used to screen the fine-tuning training samples from the local data of the edge node; Based on the computing power allocation logic of the fine-tuning strategy and the pre-training weight corresponding to the fine-tuning model version, the fine-tuning training samples are incrementally trained to obtain fine-tuning training weights; The fine-tuning training weights are distributed to the edge node to fine-tune the lightweight large language model; Based on the computing power allocation logic and the pre-training weight corresponding to the fine-tuning model version, the fine-tuning training samples are incrementally trained to obtain fine-tuning training weights, comprising: Determine the training batch size and learning rate scheduling strategy according to the computing power allocation logic; Load the pre-training weight corresponding to the fine-tuning model version, and freeze the parameters of the pre-training model; Based on the LoRA method, insert a low-rank decomposition matrix in the key layer of the pre-training model; The fine-tuning training samples are processed in batches according to the training batch size, and only the low-rank decomposition matrix is trained and updated; Through gradient calculation and parameter optimization, the output of the low-rank decomposition matrix is added to the output of the original weight matrix to obtain fine-tuning training weights.

2. The grid-oriented lightweight large language model fine-tuning method according to claim 1, characterized in that, The obtaining of the local data of the edge node, the inference through the lightweight large language model, and the obtaining of the running state data of the lightweight large language model comprise: Collecting real-time data of the edge node in the scenarios of power grid monitoring, fault diagnosis and operation optimization; After preprocessing, the real-time data is input into the lightweight large language model for inference prediction; Record the accuracy, response delay, memory occupation and CPU utilization in the inference prediction process to generate running state data.

3. The grid-oriented lightweight large language model fine-tuning method according to claim 1, characterized in that, The uploading of the running state data to the center node, the selection of a matched fine-tuning model version from the lightweight model version library, and the generation of a fine-tuning strategy for the lightweight large language model comprise: Upload the running state data to the center node, extract features from the running state data to generate a state feature vector; Based on the K-Nearest Neighbor algorithm, calculate the feature similarity between the state feature vector and each fine-tuning model version in the lightweight model version library, and select the fine-tuning model version with the highest similarity; According to the computing power constraint of the edge node and the complexity of the fine-tuning model version, generate a fine-tuning strategy comprising sample screening logic and computing power allocation logic.

4. The grid-oriented lightweight large language model fine-tuning method according to claim 3, characterized in that, The calculation of the feature similarity between the state feature vector and each fine-tuning model version in the lightweight model version library based on the K-Nearest Neighbor algorithm, and the selection of the fine-tuning model version with the highest similarity comprise: Obtain the historical running state feature vector corresponding to each fine-tuning model version from the lightweight model version library; Calculate the Euclidean distance between the state feature vector and each historical running state feature vector to generate a distance sequence; According to the distance sequence, select K distance minimum fine-tuning model versions as candidate versions; Based on the weighted average algorithm, calculate the weighted similarity score of K candidate versions, and select the fine-tuning model version with the highest score.

5. The grid-oriented lightweight large language model fine-tuning method according to claim 4, characterized in that, The weighted average algorithm is used to calculate the weighted similarity score of K candidate versions, and the fine-tuning model version with the highest score is selected. According to the historical fine-tuning effect of K candidate versions, calculate the performance weight of each candidate version; The distance sequence is normalized to obtain a normalized distance score; Based on the performance weight and the normalized distance score, calculate the weighted similarity score of each candidate version; Select the candidate version with the highest weighted similarity score as the matched fine-tuning model version.

6. The grid-oriented lightweight large language model fine-tuning method according to claim 3, characterized in that, According to the computing power constraints of the edge node and the complexity of the fine-tuning model version, generate a fine-tuning strategy including sample screening logic and computing power allocation logic, including: Obtain the computing resource parameters and network bandwidth parameters of the edge node, and calculate the total amount of available computing resources; Based on the parameter size and training complexity of the fine-tuning model version, calculate the computing power requirement of fine-tuning training; According to the ratio of the total amount of available computing resources and the computing power requirement, determine the sample screening threshold and batch size; Based on the sample screening threshold, generate sample screening logic, and based on the batch size, generate computing power allocation logic.

7. The grid-oriented lightweight large language model fine-tuning method according to claim 1, characterized in that, According to the sample screening logic, screen the fine-tuning training samples from the local data of the edge node through the lightweight large language model, including: Input the local data of the edge node into the lightweight large language model, and calculate the prediction confidence of each data sample; Based on the sample screening threshold in the sample screening logic, mark the samples with prediction confidence higher than the sample screening threshold; Extract the feature vector of the marked samples, and calculate the similarity matrix between the samples; Based on the similarity matrix, perform clustering analysis on the marked samples, select an equal number of samples from each cluster as fine-tuning training samples, and upload the fine-tuning training samples to the center node.

8. The grid-oriented lightweight large language model fine-tuning method according to claim 1, characterized in that, Based on the LoRA method, insert a low-rank decomposition matrix into the key layers of the pre-trained model, including: Identify the attention layers and feedforward network layers in the pre-trained model as key layers; Insert a low-rank decomposition matrix in parallel to the weight matrix of the key layer, the low-rank decomposition matrix includes a lower projection matrix A and an upper projection matrix B; Set the rank parameter r of the low-rank decomposition matrix, where r is less than the rank of the weight matrix of the key layer; Initialize the lower projection matrix A as a Gaussian random distribution, and initialize the upper projection matrix B as a zero matrix.

9. The grid-oriented lightweight large language model fine-tuning method according to claim 1, characterized in that, The fine-tuning training weight is sent to the edge node, and the lightweight large language model is fine-tuned, including: Compress and encode the fine-tuned model weight parameters to generate a weight parameter compression package; Transfer the weight parameter compression package from the center node to the corresponding edge node through a secure communication protocol; Receive the weight parameter compression package at the edge node, perform decompression and integrity verification; After the integrity check, the fine-tuned model weight parameters are used to replace the original weight parameters of the lightweight large language model currently deployed by the edge node, and the fine-tuning of the lightweight large language model is completed.

Citation Information

Patent Citations

  • Battery life self-adaptive calibration method oriented to cloud-edge collaboration

    CN120908672A

  • Federated learning optimizations

    WO2021247448A1

Cited By

  • A green electricity adaptive operation method and system of a containerized mobile computing power node

    CN122247985A