Large language model multi-agent based federated learning method for sharded blockchain
By using a multi-agent system driven by a large language model, dynamic sharding scheduling, and intelligent routing mechanisms, the efficiency and performance bottlenecks of blockchain sharding under heterogeneous data and device conditions are solved, achieving load balancing and accurate acquisition of high-value knowledge, thereby improving the overall efficiency and model performance of federated learning.
Patent Information
- Application Number
- CN202512000065.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-12-29
AI Technical Summary
Traditional centralized federated learning has the risk of single point of failure and is difficult to cope with the high heterogeneity and non-independent and identically distributed characteristics of terminal device data. Blockchain sharding is inefficient in large-scale client scenarios, and device heterogeneity leads to synchronization blocking within shards and uneven load between shards, affecting model convergence and generalization.
A multi-agent system based on a large language model is adopted, including a sharding scheduling agent, a sharding knowledge state agent, and a global knowledge routing agent. Through dynamic sharding scheduling, knowledge distillation, and intelligent routing, the sharding structure and knowledge sharing are optimized, thereby achieving load balancing and cross-sharding acquisition of high-value knowledge.
It significantly improves the synchronization efficiency and system throughput of federated learning, alleviates the synchronization blocking and uneven load caused by heterogeneous devices, and ensures the efficiency advantages and model performance of the sharded architecture.
Smart Images

Figure CN121413712B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of computers, and particularly relates to a large language model multi-agent sharded blockchain federated learning method. BACKGROUND
[0002] In a scenario with extremely high data security and privacy requirements (such as a medical Internet of Things), federated learning can enable collaborative training under privacy protection. However, traditional centralized federated learning has a single point of failure risk and is difficult to cope with the highly heterogeneous and non-independent and identically distributed characteristics of terminal device data, affecting model convergence and generalization. Therefore, the prior art combines knowledge distillation and a blockchain to build a decentralized knowledge sharing layer by sharing lightweight knowledge representations. However, in a large-scale client scenario, the blockchain efficiency decreases due to saturated transaction throughput. Although the introduction of blockchain sharding can improve parallel processing capability, it faces challenges in a heterogeneous federated environment: on the one hand, device heterogeneity causes synchronization blocking within a shard and uneven load between shards, resulting in resource waste and performance bottlenecks; on the other hand, shard isolation limits cross-shard knowledge acquisition, affecting model individualization gain and generalization ability, while full cross-shard synchronization brings high communication overhead. Therefore, intelligent shard scheduling and cross-shard knowledge routing mechanisms are needed to balance efficiency and knowledge sharing.
[0003] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the application, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0004] To solve or at least alleviate one or more of the above problems, a large language model multi-agent sharded blockchain federated learning method is provided, which can deeply integrate the complex reasoning capability of a large language model and the autonomous collaboration mechanism of three multi-agent systems, namely a shard scheduling agent, a shard knowledge state agent, and a global knowledge routing agent, in a decentralized and sharded federated learning architecture. The mechanism dynamically optimizes the underlying shard structure and intelligently routes high-value knowledge in an intelligent manner, thereby significantly improving the overall efficiency and model performance of the system under heterogeneous data and heterogeneous device conditions.
[0005] To achieve the above purpose, according to a first aspect of the present application, a large language model multi-agent sharded blockchain federated learning method is provided, comprising the following steps:
[0006] S1, client initialization:
[0007] Each client loads a local private data set and initializes a local model, and submits client profile data;
[0008] S2, dynamic shard scheduling and distribution:
[0009] The sharding scheduling agent performs the following three-stage scheduling based on the client portrait data:
[0010] The first stage: using a large language model to predict the expected synchronization time of each client, and dividing the clients into performance-homogeneous initial shards according to the expected synchronization time; the second stage: evaluating the load of each shard, using the planning ability of the large language model, and realizing load balancing between shards by minimizing client migration to determine the final shard allocation; the third stage: for newly added nodes, predicting the performance of the newly added nodes and using the large language model to make decisions to find the insertion point with matching performance and minimum load in the existing shard to realize smooth integration;
[0011] S3, local knowledge generation and chaining:
[0012] Each client trains a model based on a local data set, extracts distilled knowledge fragments through knowledge distillation, and submits the knowledge fragments to the blockchain network for storage;
[0013] S4, agent collaboration routing and knowledge acquisition:
[0014] The shard knowledge state agent collects client model performance data, identifies the knowledge short board of each client model using a large language model, and generates a knowledge request proposal; the global knowledge routing agent receives the proposal, uses a large language model to match the teacher shard with the highest knowledge contribution value in the global knowledge index, and guides the client to acquire the corresponding knowledge fragments across shards;
[0015] S5, knowledge fusion and model updating:
[0016] The client fuses the acquired knowledge fragments with local knowledge and updates the local model;
[0017] S6, repeat S3 to S5 until the model converges or reaches the preset number of iterations.
[0018] After adopting the above technical solutions, the present application has the following beneficial effects compared with the prior art:
[0019] The application uses a large language model to predict client performance and perform dynamic homogeneous sharding and load balancing optimization through a sharding scheduling agent, significantly alleviating the problems of intra-shard synchronization blocking and inter-shard load imbalance caused by device heterogeneity, and improving the synchronization efficiency of federated learning and the overall throughput of the system. At the same time, the application designs a large language model driven multi-agent collaborative routing mechanism, in which the shard knowledge state agent accurately diagnoses the knowledge gap of the client, and the global knowledge routing agent realizes the directional cross-shard routing of high-value knowledge according to the knowledge contribution value index. This mechanism supports clients to acquire external knowledge on demand and accurately, breaks the knowledge isolation, avoids the high communication overhead brought by full synchronization, and guarantees the efficiency advantage of the sharding architecture.
[0020] The specific embodiments of the application will be further described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF DRAWINGS
[0021] The accompanying drawings, which are part of the present application, serve to provide a further understanding of the present application, and the illustrative embodiments of the present application and their descriptions serve to explain the present application, but do not constitute an improper limitation on the present application. Obviously, the drawings described below are only some embodiments, and other drawings can be obtained from these drawings by those of ordinary skill in the art without creating creative labor.
[0022] In the drawings:
[0023] Figure 1 An architecture schematic diagram of the federated learning method based on the large language model multi-agent and knowledge distillation in the specific embodiment of the present application;
[0024] Figure 2 A flowchart of the sharding blockchain federated learning method based on the large language model multi-agent system in the specific embodiment of the present application;
[0025] Figure 3 A flowchart of dynamic sharding scheduling and distribution of the sharding scheduling agent in the specific embodiment of the present application;
[0026] Figure 4 A flowchart of local model training, knowledge distillation and knowledge chaining in the specific embodiment of the present application;
[0027] Figure 5 A flowchart of agent collaborative routing and knowledge acquisition in the specific embodiment of the present application;
[0028] Figure 6 A flowchart of knowledge fusion and student model updating in the specific embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments will be described clearly and completely below with reference to the drawings in the embodiments of the present application. The following embodiments are used to explain the present application but not to limit the scope of the present application.
[0030] Referring to Figure 1 and Figure 2 The present application provides a large language model multi-agent based sharded blockchain federated learning method, comprising the following steps:
[0031] S1, client initialization:
[0032] Each client loads a local private data set and initializes a local model, and submits client portrait data;
[0033] S2, dynamic sharding scheduling and distribution:
[0034] The sharding scheduling agent performs the following three-stage scheduling based on the client portrait data:
[0035] The first stage: using a large language model to predict the task synchronization time of each client, and dividing the clients into performance-homogeneous initial shards accordingly; the second stage: evaluating the load of each shard, using the planning ability of the large language model, achieving load balancing between shards by minimizing client migration, and determining the final shard distribution; the third stage: for newly added nodes, predicting their performance and using the large language model to make decisions to find a performance-matched and load-minimized insertion point in the existing shards, and realize smooth integration;
[0036] S3, local knowledge generation and chaining:
[0037] Each client trains a model based on a local data set, extracts distilled knowledge fragments through knowledge distillation, and submits the knowledge fragments to a blockchain network for notarization;
[0038] S4, agent collaboration routing and knowledge acquisition:
[0039] The shard knowledge state agent collects client model performance data, uses a large language model to identify the knowledge short board of each client model, and generates a knowledge request proposal; the global knowledge routing agent receives the proposal, uses a large language model to match the teacher shard with the highest knowledge contribution value in the global knowledge index, and guides the client to acquire the corresponding knowledge fragments across shards;
[0040] S5, knowledge fusion and model updating:
[0041] The client fuses the acquired knowledge fragments with local knowledge and updates the local model;
[0042] S6, repeat S3 to S5 until the model converges or reaches a preset number of iterations.
[0043] It should be noted that the execution subject of the large language model multi-agent sharded blockchain federated learning in this embodiment is a large language model multi-agent sharded blockchain federated learning system, which can be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. Illustratively, the mobile electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted electronic device, a wearable device, etc., and the non-mobile electronic device can be a server and a personal computer, etc., which are not limited in the present application. The following takes the server as an example to describe the large language model multi-agent sharded blockchain federated learning in this embodiment.
[0044] In addition, the terms "first" and "second" are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined as "first" and "second" can explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise specifically limited.
[0045] In some embodiments, S1, client initialization: each client loads the local private data set and initializes the local model, and submits the client portrait data.
[0046] Illustratively, the client portrait data includes hardware configuration data from the client, network heterogeneity parameters, and historical task time data extracted from the client's task log and the transaction metadata of the blockchain.
[0047] The client portrait data is collected in real time or periodically by various tools. The collection tools include: system information acquisition tools deployed locally by the client, which collect hardware configuration data such as CPU / GPU model, core number, memory capacity, etc. static or semi-static information by querying the client operating system (such as WMI or / proc interface of Unix-like system) or the API of hardware driver; periodic network performance detection module acquires network heterogeneity parameters such as real-time bandwidth, data transmission delay, network jitter, etc. dynamic parameters by performing periodic, lightweight network detection operations (such as sending small data packets, executing PING or delay measurement scripts based on UDP); in addition, there are historical task time data extracted from the client's task log and the transaction metadata of the blockchain, such as local training time consumption, knowledge chaining time consumption, etc. time sequence features.
[0048] In some embodiments, S2, dynamic sharding scheduling and allocation: the sharding scheduling agent performs the following three-stage scheduling based on the client profiling data: first stage: efficiency prediction and initial sharding; second stage: load balancing and final sharding; third stage: dynamic incremental addition.
[0049] The sharding scheduling agent uses a large language model as the core of the prediction inference engine. The operation of the sharding scheduling agent relies on accurate client profiling data.
[0050] The sharding scheduling agent is the key to solving the problem of synchronization blocking within shards and uneven load between shards caused by client device computing heterogeneity and network heterogeneity.
[0051] The sharding scheduling agent dynamic sharding scheduling and allocation aims to optimize the sharding structure by utilizing the inference capabilities of large language models through three-stage scheduling to effectively address client heterogeneity issues.
[0052] For example, see Figure 3 , the sharding scheduling agent dynamic sharding includes the following steps:
[0053] Step 1: Efficiency prediction and initial sharding. The sharding scheduling agent uses a large language model to predict the expected synchronization time required by each client to complete the current task. After obtaining the expected synchronization time of all clients, the sharding scheduling agent analyzes the predicted expected synchronization time and directly performs intelligent classification using the complex inference capabilities of the large language model, dividing the clients into initial shards with similar performance to ensure homogeneity within the shards.
[0054] The sharding scheduling agent accurately predicts the expected synchronization time required by each client to complete the current task based on client profiling data. The prediction process can be represented as:
[0055] ;
[0056] Where, represents hardware configuration data, represents network heterogeneity parameters, represents historical task time data, i.e., the prediction function driven by the large language model, and the clients are preliminarily grouped based on the similarity of .
[0057] The preliminary grouping is performed by the sharding scheduling agent, aiming to divide the client set into initial shards . This process is a grouping operation based on expected synchronization time , ensuring the homogeneity of client performance within the shards. This process can be represented as:
[0058] ;
[0059] The goal of this grouping operation is to minimize the variance or maximum difference of the expected synchronization time of each client within a shard , thus satisfying the performance homogeneity constraint:
[0060] ;
[0061] where, is the mean of the expected synchronization time of all clients within a shard , and sM is the number of initial shards. By minimizing the performance difference within a shard, the performance homogeneity within a shard is ensured, significantly alleviating the synchronization blocking problem caused by device heterogeneity.
[0062] Step 2: Load balancing and final shard. The shard scheduling agent defines the total load of a shard , which is mainly evaluated based on the number of clients within the shard and the total expected synchronization time of the clients.
[0063] Specifically, the shard scheduling agent defines the total load of each shard as the total transaction frequency of the shard expected in a round of federated training (i.e., the on-chain rate of knowledge fragments). According to the principle that the expected synchronization time is inversely proportional to the transaction frequency, the total load is quantitatively evaluated by the sum of the inverses of the expected synchronization times of all clients within the shard:
[0064] ;
[0065] where, represents the average knowledge contribution frequency of the client . The larger the value, the greater the total amount of knowledge fragment transactions that need to be processed by the shard in unit time, and the higher the total load of the system it bears.
[0066] The shard scheduling agent then uses the planning and reasoning capabilities of large language models to make global optimization decisions, identify and execute the minimum set of client migration operations, ensure balanced allocation of total load, and determine the final shard allocation scheme.
[0067] Specifically, the global optimization decision is modeled as a multi-objective optimization problem, aiming to achieve balanced allocation of workloads between shards while ensuring the stability of scheduling. The main goal of the global optimization decision is to achieve balanced allocation of total load, i.e., to minimize the variance of the final shard load :
[0068] ;
[0069] wherein, is the final shard allocation scheme.
[0070] Meanwhile, the operation set of migrating clients is minimized as a key constraint condition The constraint ensures load balancing by making a minimum adjustment to the initial homogenization grouping result, thereby ensuring the scheduling stability of the shard structure and effectively inheriting the performance homogenization advantage established in Step 1.
[0071] Step 3: Dynamic incremental addition. When a new node requests to join, the new node is understood as a client device newly joining the federated learning task, such as a wearable device in the medical Internet, and the shard scheduling agent predicts the expected synchronization time of the new node and uses the decision support capability of the large language model to find the optimal insertion point in the existing shard that meets the performance matching and load minimization standards, realizing the smooth integration of the new node.
[0072] Specifically, the shard scheduling agent performs a search process based on a constrained optimization model to determine the optimal insertion point in the existing final shard allocation scheme . This process minimizes the absolute difference between the predicted synchronization time of the new node and the average expected synchronization time of the clients in the target shard, ensuring that the new node can inherit the performance homogenization advantage of the shard to the greatest extent after joining. On this basis, the shard scheduling agent imposes a load threshold constraint, i.e., the new total load of the target shard after the new node joins must not exceed the pre-set maximum load threshold . Finally, the shard scheduling agent selects the shard with the smallest absolute difference in expected synchronization time from the set of all feasible shards that meet the load threshold constraint as the optimal insertion point.
[0073] In some embodiments, S3, local model training, knowledge distillation, and knowledge on-chain include the following steps: Step 1: perform local model training; Step 2: perform proxy dataset inference operations; Step 3: extract model prediction soft labels; Step 4: perform standardization processing; Step 5: package distillation knowledge fragments; Step 6: submit knowledge fragments to the blockchain network; Step 7: write to the blockchain ledger.
[0074] Local model training, knowledge distillation, and knowledge on-chain aim to extract high-value knowledge using local models and achieve decentralized contribution of knowledge through blockchain.
[0075] For examples, please refer toFigure 4 The local model training, knowledge distillation, and knowledge chaining include the following steps:
[0076] Step 1: Perform local model training. The client performs iterative training on the local model (teacher model) based on local private data, so that it fully fits the local data distribution characteristics;
[0077] Step 2: Perform proxy dataset inference operation. After training, the client uses its trained teacher model to infer each sample in the proxy dataset issued by the system, and generates the original prediction result of the output layer;
[0078] Step 3: Extract model prediction soft label. The client takes the original prediction vector (Logits) of the teacher model output layer as the initial knowledge representation;
[0079] Step 4: Perform standardization processing. The client performs statistical standardization processing on Logits, calculates the mean and standard deviation, and eliminates the difference between model outputs to make them have uniform distribution characteristics in numerical scale;
[0080] Step 5: Package distillation knowledge fragments. The client packages the standardized soft label and metadata (such as client identifier Client_ID, communication round round_ID, timestamp information timestamp, etc.) into structured distillation knowledge fragments;
[0081] Step 6: Submit knowledge fragments to the blockchain network. The client broadcasts the constructed distillation knowledge fragments as transaction records to the sharded blockchain network, ready for the consensus process;
[0082] Step 7: Write to the blockchain ledger. After the transaction is verified by the consensus nodes of the blockchain network, it is packaged into a new block and permanently written into the blockchain ledger, realizing the non-tamperable storage and decentralized sharing of knowledge objects.
[0083] In some embodiments, S4, agent collaboration routing and knowledge acquisition includes the following steps: Step 1: state data collection and demand analysis; Step 2: knowledge request proposal generation; Step 3: value matching and routing decision; Step 4: guidance and knowledge acquisition.
[0084] Agent collaboration routing and knowledge acquisition aims to achieve high-value knowledge directional routing and acquisition driven by demand through agent collaboration.
[0085] For example, see Figure 5 Agent collaboration routing and knowledge acquisition includes the following steps:
[0086] Step 1: State data collection and demand analysis. The fragmented knowledge state agent starts, continuously collects the category-level model performance data of the client (such as prediction loss and accuracy), and uses large language model reasoning to diagnose the model, accurately identifying the client's knowledge gaps or scarce categories.
[0087] The fragmented knowledge state agent and the global knowledge routing agent work together to solve the cross-fragment knowledge isolation problem caused by fragmentation, and achieve demand-driven, value-matched, and directional routing of knowledge through intelligent means.
[0088] The fragmented knowledge state agent is deployed on the coordination node of each fragment, and its core responsibility is state perception and demand analysis. The fragmented knowledge state agent continuously collects fine-grained model performance data through the local learning monitoring module. The local learning monitoring module is integrated into the local training loop of the client, used to intercept and separate the loss calculation and accuracy rate of the model, so as to obtain fine-grained model performance data, including category-level loss function, category-level accuracy and convergence curve, etc.
[0089] Specifically, the fragmented knowledge state agent first performs data aggregation and summarization to construct the input of the large language model: the category-level model performance data of all clients in the fragment is weighted and averaged or statistically aggregated, so as to calculate the aggregated performance data in the fragment, that is, the average performance indicators (such as average accuracy) of the fragment as a whole in each category; at the same time, the fragmented knowledge state agent calculates the knowledge contribution frequency of a specific category by tracking the knowledge distillation transaction record (that is, the submission frequency of the knowledge fragment); finally, based on the knowledge soft label, the knowledge confidence of a specific category is obtained .
[0090] Subsequently, the fragmented knowledge state agent first analyzes the aggregated performance data in the fragment, and if the performance indicators of the fragment as a whole in a certain category are significantly lower than the global or preset baseline level, it is judged that there is a general knowledge gap in the fragment. Or the fragmented knowledge state agent evaluates the knowledge scarcity of a category in the fragment in combination with the calculated knowledge contribution frequency and knowledge confidence , if the contribution frequency is extremely rare and the corresponding average knowledge confidence is low, it is confirmed that is a scarce category in the fragment.
[0091] Step 2: Knowledge request proposal generation. The fragmented knowledge state agent generates a structured knowledge request proposal based on the short board identification result, clearly stating the category of the required knowledge and the expected gain.
[0092] The fragmented knowledge-state agent leverages the contextual understanding and inductive reasoning capabilities of a large language model to perform in-depth analysis of metrics, accurately identifying the current client model's position within a specific category. Knowledge gaps or scarce categories that urgently need external gains.
[0093] After identifying the category After meeting the requirements, the fragmented knowledge state agent determines the knowledge contribution frequency. and knowledge confidence Quantify the intensity of local client demand for this category. . The calculation reflects the client's demand for external knowledge, and its formula is abstracted as follows:
[0094] ;
[0095] in, It is a demand intensity quantification function driven by a large language model. It transforms shortcomings and scarcity into numerical values based on model performance and existing knowledge contribution / confidence indicators. value.
[0096] Ultimately, the fragmented knowledge state agent categorizes knowledge. and its corresponding local client demand intensity Encapsulate into a knowledge request proposal Submit to the global knowledge routing agent.
[0097] Step 3: Value Matching and Routing Decision. The global knowledge routing agent receives knowledge request proposals. By leveraging the decision support capabilities of large language models, the system searches for the most highly relevant terms in the global knowledge index. The optimal teacher allocation.
[0098] Specifically, the global knowledge routing agent acts as the global decision center, continuously evaluating and maintaining a global knowledge index containing knowledge contribution information from all fragments. This index records the knowledge contribution value of each fragment in different categories of knowledge. Knowledge contributes value It is an aggregated indicator calculated based on multiple knowledge quality and adoption metrics.
[0099] The input to the decision-making process is: a structured knowledge request proposal from Step 2. (From this, we can identify the knowledge categories that students urgently need for different areas of study) ) and all potential teacher fragments in the global knowledge index On The output of the process is: a knowledge transaction value score calculated for all potential teachers.
[0100] The global knowledge routing agent inputs these data into a large language model, which performs value matching, i.e., utilizes the knowledge contribution value stored in the index As a matching index, all the owning categories of the potential teacher shards of knowledge are sorted, and the shard with the highest knowledge contribution value is finally selected As the teacher shard, this optimal selection process can be represented by the following formula:
[0101] ;
[0102] Wherein, represents all the owning categories of the potential teacher shards of knowledge. The agent then prepares for cross-shard knowledge interaction according to the identification and routing information of .
[0103] Step 4: Guidance and knowledge acquisition. The global knowledge routing agent issues a collaborative guidance to guide the student client S to obtain the required high-value distilled knowledge fragments from the specified teacher shard through the cross-shard communication mechanism based on the Hyperledger Fabric blockchain architecture.
[0104] In this federated blockchain architecture, each knowledge shard is a logically isolated unit implemented through the channel (Channel) mechanism of Fabric. The channel isolates data, participants, and business logic (i.e., chaincode / smart contract). After determining in Step 3, the global knowledge routing agent immediately issues a collaborative guidance instruction to the target student client S, which encapsulates the key information required for knowledge acquisition to start a cross-shard atomic transaction, which is formally represented as follows:
[0105] ;
[0106] Wherein, S is the student client identification, refers to the selected teacher shard, is the knowledge category that the student client needs to acquire, is the shard channel identification where is located, is the cross-shard atomic transaction ID The service logic (chaincode) that processes knowledge requests on the channel. This cross-shard communication mechanism uses the InvokeChaincode API provided by Fabric to make cross-channel calls, ensuring atomicity and state isolation in knowledge transmission. The specific implementation is as follows: the shard where the student client S is located initiates a synchronous call to the shard (channel ) where the chaincode is located, requesting the chaincode to return high-value distilled knowledge fragments . This cross-shard knowledge acquisition process can be abstractly represented as:
[0107] ;
[0108] This formula indicates that S atomically executes transactions and obtains knowledge fragments by invoking the chaincode of in the Fabric network.
[0109] The global knowledge routing agent serves as the global decision center, responsible for global indexing, value matching, and directional routing. The global knowledge routing agent continuously evaluates and maintains a global knowledge index containing information on all shard knowledge contributions. The global knowledge index records the knowledge contribution values of each shard's knowledge in different categories . The knowledge contribution value is an aggregate index based on the freshness of knowledge, the category knowledge confidence , and the frequency of knowledge fragments being adopted by other clients . The calculation method of knowledge contribution value can be represented as:
[0110] ;
[0111] where is the preset or dynamically adjusted weight;
[0112] After receiving the request from the shard knowledge state agent, the global knowledge routing agent uses the decision support and planning capabilities of the large language model to perform value matching in the global knowledge index, and directionally identifies the optimal teacher shard with the highest knowledge contribution value in the requested category. Subsequently, the global knowledge routing agent issues a collaborative guide to guide the client to obtain high-value knowledge with minimal cross-shard communication overhead, achieving efficient utilization of knowledge.
[0113] In some embodiments, S5, knowledge fusion and student model updating, comprises the following steps: Step 1: setting dynamic fusion weight; Step 2: constructing fusion loss function; Step 3: performing distillation learning and model updating.
[0114] Knowledge fusion and student model updating is the final link of knowledge integration.
[0115] See Figure 6 , knowledge fusion and student model updating comprises the following steps:
[0116] Step 1: setting dynamic fusion weight. The client calculates the dynamic fusion weight according to the knowledge contribution value of the obtained knowledge fragment and the local demand, which is used to quantify the adoption strength of the client to the external knowledge fragment . The calculation formula is:
[0117] ;
[0118] Wherein, is the knowledge contribution value of the external knowledge fragment , is the demand intensity of the client locally to the knowledge category , is the set of all external knowledge fragments selected in this round;
[0119] Step 2: constructing fusion loss function. The client constructs a mixed loss function which combines the local cross-entropy loss and the external knowledge weighted KL divergence loss . Each part in the distillation term is adjusted by its dynamic fusion weight to contribute;
[0120] Step 3: performing distillation learning and model updating. The client uses the mixed loss function to optimize and update the parameters of the student model (the local model of the client itself which is performing model updating), to achieve the selective and effective absorption of external knowledge, and significantly improve the individualization and generalization ability of the model.
[0121] For example, the client then constructs a mixed loss function which combines the local cross-entropy loss and the external knowledge weighted KL divergence loss :
[0122] ;
[0123] Wherein, and are soft label probability distributions of student model and external knowledge fragment respectively and are adjustment parameters of loss terms.
[0124] In some embodiments, S6, iteration and termination, comprises the following steps: Step 1: judging whether the termination condition is met; Step 2: repeating the next round of federated training process: if not terminated, returning to S3 to start the next round of federated training process, repeating the training, knowledge contribution, evaluation and fusion; Step 3: saving the model state and exiting.
[0125] S6, iteration and termination, controls the cycle and end of the entire federated learning process.
[0126] Exemplarily, the process control comprises the following steps:
[0127] Step 1: judging whether the termination condition is met. The client judges whether the termination condition is met according to the number of training rounds, the change trend of the loss function or the local strategy;
[0128] Step 2: repeating the next round of federated training process. If the termination condition is not met, the process will return to S3 to start the next round of federated training process, and the client will repeat the training, knowledge contribution, evaluation and fusion;
[0129] Step 3: saving the model state and exiting. If the termination condition is met, the client will save the final student model state and exit the current federated learning process.
[0130] The above is only a preferred embodiment of the present application, and does not limit the present application in any form. Although the present application has been disclosed as above, it is not intended to limit the present application. Any person skilled in the art can make some changes or modifications to the above-mentioned technical content without departing from the scope of the present application, and the equivalent embodiments of the equivalent changes are equivalent. The embodiments in the above examples can be further combined or replaced, but any simple modification, equivalent change and modification of the above examples according to the technical essence of the present application are still within the scope of the present application.
Claims
1. A sharded blockchain federated learning method based on a large language model and multiple agents, characterized in that, Includes the following steps: S1. Client initialization: Each client loads its local private dataset and initializes its local model, then submits its client profile data. S2. Dynamic Fragmentation Scheduling and Allocation: Based on the client profile data, the sharded scheduling agent performs the following three-stage scheduling: Phase 1: Use a large language model to predict the expected synchronization time of each client, and divide the clients into initial shards with homogeneous performance based on the expected synchronization time; Phase 2: Assess the load of each shard, leverage the planning capabilities of the large language model, achieve load balancing between shards by minimizing client migration, and determine the final shard allocation; The third stage: For newly added nodes, predict the performance of the newly added nodes and use a large language model to make decisions, find the insertion point with matching performance and minimum load in the existing shards, and achieve smooth integration; S3, Local Knowledge Generation and On-Chain: Each client trains a model based on its local dataset, extracts distilled knowledge fragments through knowledge distillation, and submits the knowledge fragments to the blockchain network for storage. S4. Agent Cooperative Routing and Knowledge Acquisition: The fragmented knowledge state agent collects performance data from client models, uses a large language model to identify knowledge gaps in each client model, and generates knowledge request proposals. The global knowledge routing agent receives the proposal, uses a large language model to match the teacher fragment with the highest knowledge contribution value in the global knowledge index, and guides the client to obtain the corresponding knowledge fragment across fragments; S5. Knowledge Integration and Model Update: The client integrates the acquired knowledge fragments with local knowledge to update the local model; S6. Repeat steps S3 to S5 until the model converges or the preset number of iterations is reached.
2. The method according to claim 1, characterized in that, The client profile data includes hardware configuration data, network heterogeneity parameters, and historical task time data extracted from the client's task logs and blockchain transaction metadata.
3. The method according to claim 2, characterized in that, The first stage includes efficiency prediction and initial sharding: The sharding scheduling agent uses a large language model to predict the expected synchronization time required for each client to complete the current round of tasks. After obtaining the expected synchronization time of all clients, the sharding scheduling agent analyzes the predicted expected synchronization time using the large language model and directly performs intelligent classification to divide the clients into initial shards with similar performance, ensuring that the performance within each shard is homogeneous.
4. The method according to any one of claims 2 or 3, characterized in that, The segmented scheduling agent predicts the expected synchronization time required for each client to complete its current task based on client profile data. The prediction process is represented as follows: ; in, This represents the expected synchronization time required for the i-th client to complete this round of tasks. This indicates hardware configuration data. Represents network heterogeneity parameters. This represents historical task time data. The prediction function driven by the large language model, and based on... The similarity of the data will be used to initially segment the client.
5. The method according to claim 3, characterized in that, The second phase includes load balancing and final sharding: The sharding scheduling agent defines the total load of the shard, which is evaluated based on the number of clients within the shard and the sum of the expected synchronization times of all clients. The sharding scheduling agent utilizes the planning and reasoning capabilities of a large language model to make global optimization decisions, identify and execute the minimum set of operations for client migration, ensure a balanced distribution of the total shard load, and determine the final shard allocation.
6. The method according to claim 3, characterized in that, The third phase includes dynamic incremental addition: When a new node requests to join, the sharding scheduling agent predicts the expected synchronization time of the new node and uses the decision support capability of the large language model to find the optimal insertion point in the existing shards that simultaneously meets the performance matching and load minimization criteria, thereby achieving the smooth integration of the new node.
7. The method according to claim 1, characterized in that, Agent cooperative routing and knowledge acquisition include the following steps: State data collection and demand analysis: The fragmented knowledge state intelligent agent is launched to continuously collect the client's category-level model performance data, and uses the large language model to reason and diagnose the model to accurately identify the client's knowledge gaps or scarce categories. Knowledge Request Proposal Generation: Based on the weakness identification results, the fragmented knowledge state agent generates structured knowledge request proposals that clearly specify the category of required knowledge and the expected gain. Value matching and routing decision: The global knowledge routing agent receives requests and uses the value matching algorithm of the large language model to find the optimal teacher slice with the highest knowledge contribution value in the global knowledge index; Guidance and Knowledge Acquisition: The global knowledge routing agent issues collaborative guidance, directing clients to acquire the required high-value distilled knowledge fragments through cross-shard communication protocols.
8. The method according to claim 1, characterized in that, Local model training, knowledge distillation, and knowledge uploading to the blockchain include the following steps: Perform local model training: The client performs iterative training on the local model, i.e. the teacher model, based on local private data, so that it fully fits the distribution characteristics of the local data; Perform inference operations on the proxy dataset: After training, the client uses its trained teacher model to infer each sample in the proxy dataset uniformly distributed by the system, and generates the original prediction results of the output layer. Extracting model prediction soft labels: The client uses the original prediction vectors from the teacher model's output layer as the initial knowledge representation; Standardization process: The client performs statistical standardization on the original prediction vector, calculates the mean and standard deviation, eliminates differences in model output, and makes it have uniform distribution characteristics on a numerical scale; Encapsulating distillation knowledge fragments: The client encapsulates the standardized soft tags and metadata together into structured distillation knowledge fragments; Submitting knowledge fragments to the blockchain network: The client broadcasts the constructed distilled knowledge fragments as transaction records to the sharded blockchain network, preparing to enter the consensus process; Write to the blockchain ledger: After a transaction is verified by the consensus nodes of the blockchain network, it is packaged into a new block and permanently written into the blockchain ledger, realizing the immutable storage and decentralized sharing of knowledge objects.
9. The method according to claim 1, characterized in that, Knowledge integration and student model updating include the following steps: Setting dynamic fusion weights: The client calculates dynamic fusion weights based on the knowledge contribution value of the acquired knowledge fragments and local needs. Used to quantify the client's understanding of external knowledge fragments The adoption strength is expressed as: ; in, External knowledge fragments The value of knowledge contribution, It is the client's local knowledge category The intensity of demand, It is the collection of all external knowledge fragments selected in this round; Constructing the fusion loss function: The client constructs the hybrid loss function. Hybrid loss function Combined with local cross-entropy loss External knowledge-weighted KL divergence loss Each part of the distillation term is composed of its dynamic fusion weights. Adjusting contribution level; Performing distillation learning and model updates: Client usage The parameters of the student model are optimized and updated to enable selective and effective absorption of external knowledge.
10. The method according to claim 1, characterized in that, Process control includes the following steps: The client determines whether the termination condition is met based on the number of training rounds, the trend of the loss function, or the local policy. If the termination condition is not met, it returns to S3 to start the next round of federated training. The client repeats S3-S5. If the termination conditions are met, the client will save the final student model state and exit the current federated learning process.
Citation Information
Patent Citations
Personalized federated learning method with efficient communication and privacy protection
CN112668726A
Federal learning optimization method based on block chain fragmentation
CN120409622A