Big-model multi-client collaborative positioning knowledge editing method based on federal learning

By optimizing the hidden state of the Transformer layer and server-side re-editing using the FedLEKE method, redundant computation and leakage risks in multi-client scenarios are resolved, improving knowledge editing efficiency and model performance.

CN120996149APending Publication Date: 2025-11-21CHONGQING UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510763101.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-09
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

In multi-client scenarios, existing LEKE methods suffer from redundant computation, leakage risks, and insufficient cross-client efficiency, making them difficult to adapt to knowledge editing tasks, especially impacting model performance in federated learning frameworks.

Method used

The FedLEKE method is adopted. By constructing the FedLEKE task, the hidden state of the Transformer layer is optimized to generate intermediate knowledge vectors. Cosine similarity retrieval and re-editing are performed on the server to reduce redundant calculations and data leakage.

Benefits of technology

It enables efficient collaboration among multiple clients, maintains performance in over 96% of non-federated scenarios, and improves knowledge editing efficiency and model stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120996149A_ABST
    Figure CN120996149A_ABST
Patent Text Reader

Abstract

The invention discloses a large-model multi-client collaborative positioning knowledge editing method based on federated learning. The method comprises the following steps: 1) constructing an LLM model; 2) constructing a FedLEKE task; (3) executing a FedLEKE task, optimizing the hidden state of a Transform layer so as to finely adjust the weight of a feed-forward network in the LLM model, and updating the LLM model; 4) each client generates an intermediate knowledge vector and uploads the intermediate knowledge vector to the server; 5) in a predefined time slot ti belongs to T, the server distributes the stored MKVs to each client; and 6) each client dynamically retrieves related intermediate knowledge vectors in the server based on cosine similarity, re-edits the knowledge vectors, and locates and modifies related parameters in the LLM model according to the re-edited knowledge vectors. According to the invention, more than 96% of performance of non-federated LEKE is reserved, and the performance of the non-federated LEKE is obviously twice better than that of a base line based on FedAvg.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the intersection of machine learning and natural language processing, specifically a large-scale, multi-client collaborative method for knowledge editing based on federated learning. Background Technology

[0002] In recent years, Large Language Models (LLMs) have demonstrated significant advantages in natural language processing tasks due to their powerful text understanding and generation capabilities. However, directly retraining the entire LLM model to update knowledge suffers from high computational costs and resource consumption. To address this, the Locate-then-Edit Knowledge (LEKE) method directly locates and modifies parameters in the model associated with specific knowledge, avoiding the cost of full model training. It has achieved significant results in single-user scenarios, such as alleviating model illusion and improving fact recall.

[0003] However, as Figure 1 As shown, existing LEKE methods are all based on the single-client assumption, which has significant limitations in real multi-client scenarios (such as hospitals, financial institutions and other decentralized organizations collaboratively updating knowledge): (1) Redundant computation problem: When multiple clients independently update overlapping knowledge, intermediate knowledge vectors (Mediator Knowledge Vectors, MKVs) need to be repeatedly calculated, resulting in a waste of computational resources; (2) Leakage risk: Traditional methods rely on data sharing, but the transmission of sensitive information (such as medical records) in multi-client scenarios may violate protection requirements; (3) Insufficient efficiency across clients: Existing federated learning frameworks (such as FedAvg) directly aggregate model parameters, which is difficult to adapt to knowledge editing tasks, resulting in a significant drop in editing performance (for example, experiments show that variant models based on FedAvg (such as MEMITAvg and PMETAvg) retain less than 50% of the performance in non-federated scenarios).

[0004] The direct application of federated learning in knowledge editing tasks still faces challenges: knowledge editing requires dynamic location and modification of specific parameters, while the global parameter averaging strategy of federated learning will destroy the fine-grained features of local knowledge updates on the client; heterogeneity of data distribution among clients (Non-IID) leads to low efficiency in knowledge vector selection and reuse, affecting model stability. Summary of the Invention

[0005] The purpose of this invention is to provide a method for collaborative localization and knowledge editing of large-scale models based on federated learning, comprising the following steps:

[0006] 1) Constructing an LLM model

[0007] 2) Construct a FedLEKE task with the goal of editing the internal parameters of the LLM and inserting fact data ε for all clients;

[0008] 3) Perform the FedLEKE task to optimize the hidden states of the Transformer layer, thereby fine-tuning the weights of the feedforward network in the LLM model and updating the LLM model;

[0009] 4) Each client generates an intermediate knowledge vector and uploads it to the server;

[0010] 5) In the predefined time slot t i ∈T, the server distributes the stored MKVs to each client; i = 1,...,m, m is the total number of time slots;

[0011] 6) Each client dynamically retrieves relevant intermediate knowledge vectors from the server based on cosine similarity, re-edits the knowledge vectors, and locates and modifies the association parameters in the LLM model based on the re-edited knowledge vectors.

[0012] Furthermore, the LLM model This is an autoregressive model, including a decoder;

[0013] The LLM model encodes the input sequence x into a sequence x1,...,x1 consisting of z labels. z It is then processed by the L-layer Transformer decoder.

[0014] Furthermore, the LLM model is as follows:

[0015] Prerequisites: An autoregressive LLM model with only a decoder is denoted as... It encodes the input sequence x into a sequence of z tags x1,...,x z And it is processed through the L-layer Transformer decoder. Next marker x z+1 The probability calculation formula is:

[0016]

[0017] Among them: W E Let γ be the embedding matrix, and γ be the layer normalization operation; and Let represent the hidden states of the multi-head self-attention network and the feedforward network in layer L, respectively; For the next marker x z+1 The probability of; This is the hidden state of layer L-1;

[0018] The hidden state of the j-th marker in layer l and hidden state As shown below:

[0019]

[0020] in: and σ represents the output weights of MHSA and FFN in the l-th layer, respectively; σ is the nonlinear activation function. For weights.

[0021] Furthermore, for client c, the FedLEKE task is as follows:

[0022]

[0023] in, Let these represent the key and value sets of client c at time t in the l-th layer, respectively, representing the sets of keys and values ​​related to the encoded subject knowledge. This indicates that n pieces of knowledge need to be retained; This indicates that u pieces of knowledge need to be modified, which is much larger than n. These are the original weights;

[0024] Incremental weight As shown below:

[0025]

[0026] in: Represents the target knowledge value Original knowledge of the client-side C model The residuals between; It is the set of memorized keys estimated through sampling; λ is a hyperparameter used to balance the degree of model modification and retention. It is a key-value pair.

[0027] Furthermore, step 3) involves fine-tuning the weights of the feedforward network in the LLM model, including:

[0028] 3.1) The first key layer of knowledge editing in the computing client and the last key layer The set of layers that need to be modified;

[0029] 3.2) For each edit tuple (s) on client c ci ,r ci ,o ci )∈ε c Calculate z ci Replace hidden state Right now:

[0030]

[0031] Where x ci ⊕p(s ci ,r ci ) indicates that the random prefix x ci Combine with templated hints to enhance generalization across contexts; This indicates that by replacing the hidden state of the last layer... For z ci To modify the execution process of the Transformer; residual o ci Represents an object; Represents probability;

[0032] 3.3) Based on the MEMIT algorithm, the incremental weights are... Distribute the weights across the L-th layer MLP to achieve fine-tuning.

[0033] Furthermore, in step 4), each client runs the Edit algorithm locally to generate intermediate knowledge vectors; the Edit algorithm is the LEKE method.

[0034] Furthermore, in step 4), each client generates the following intermediate knowledge vector:

[0035]

[0036] In the formula, z is the first-level key; ci The optimized hidden state residual; Indicates the key generation function; x ij For a random prefix, s ci The main editing element; γ is the layer normalization, σ is the activation function; (s ci ,r ci ,o ci )∈ε c .

[0037] Furthermore, in step 6), the relevant intermediate knowledge vectors retrieved by each client from the server satisfy the following conditions:

[0038]

[0039] In the formula, α is the similarity threshold; len (similarity) represents all knowledge tuples within the current time slot of the client. The total number; ∑(similarity>α) is the number of MKVs in the client that meet the threshold.

[0040] The technical effectiveness of this invention is undeniable. This invention proposes a Federated Location Knowledge Editing (FedLEKE) task, which achieves efficient multi-client collaboration through a two-stage framework (FedEdit): (1) Local editing stage: The client generates MKVs using the LEKE algorithm and only uploads the vectors to the server, avoiding leakage of the original data; (2) Re-editing stage: The client dynamically retrieves relevant MKVs in the server based on cosine similarity, triggering conditional re-editing to reduce redundant computation. Experiments show that FedEdit can retain more than 96% of the performance in non-federated scenarios on GPT-J (6B) and GPT-NeoX (20B) models.

[0041] This invention utilizes the FedEdit framework to improve the efficiency of multi-client editing of related knowledge, and effectively selects intermediate knowledge vectors from the server through re-editing conditions. Attached Figure Description

[0042] Figure 1 The diagram shows the MEMIT algorithm of the traditional LEKE method;

[0043] Figure 2 Here is a flowchart of the FedEdit framework;

[0044] Figure 3 This is the overall flowchart of the present invention. Detailed Implementation

[0045] The present invention will be further described below with reference to embodiments, but it should not be construed that the scope of the present invention is limited to the following embodiments. Various substitutions and modifications made based on ordinary technical knowledge and common practices in the art without departing from the above-described technical concept of the present invention should be included within the scope of protection of the present invention.

[0046] Example 1:

[0047] See Figures 2-3 A collaborative knowledge editing method for large-scale models based on federated learning, comprising the following steps:

[0048] 1) Construct an LLM model for performing text processing tasks. Text processing tasks include text entity recognition, feature extraction, text generation, text classification, and sentiment analysis. Examples include generating news summaries and classifying news based on user-inputted news content, and analyzing user sentiment towards products based on user-inputted text.

[0049] 2) Construct a FedLEKE task with the goal of editing the internal parameters of the LLM and inserting fact data ε for all clients;

[0050] 3) Perform the FedLEKE task to optimize the hidden states of the Transformer layer, thereby fine-tuning the weights of the feedforward network in the LLM model and updating the LLM model;

[0051] 4) Each client generates an intermediate knowledge vector and uploads it to the server;

[0052] 5) In the predefined time slot t i ∈T, the server distributes the stored MKVs to each client; i = 1,...,m, m is the total number of time slots;

[0053] 6) Each client dynamically retrieves relevant intermediate knowledge vectors from the server based on cosine similarity, re-edits the knowledge vectors, and locates and modifies the association parameters in the LLM model based on the re-edited knowledge vectors.

[0054] This embodiment is used to update the knowledge in a large-scale language model, and then use the updated large-scale language model to perform user-submitted tasks, such as text generation, content summarization, and dialogue. (Knowledge updating)

[0055] The LLM model This is an autoregressive model, including a decoder;

[0056] The LLM model encodes the input sequence x into a sequence x1,...,x1 consisting of z labels. z It is then processed by the L-layer Transformer decoder.

[0057] The LLM model is shown below:

[0058] Prerequisites: An autoregressive LLM model with only a decoder is denoted as... It encodes the input sequence x into a sequence of z tags x1,...,x z And it is processed through the L-layer Transformer decoder. Next marker x z+1 The probability calculation formula is:

[0059]

[0060] Among them: W E Let γ be the embedding matrix, and γ be the layer normalization operation; and Let represent the hidden states of the multi-head self-attention network and the feedforward network in layer L, respectively; For the next marker x z+1 The probability of; This is the hidden state of layer L-1;

[0061] The hidden state of the j-th marker in layer l and hidden state As shown below:

[0062]

[0063] in: and σ represents the output weights of MHSA and FFN in the l-th layer, respectively; σ is the nonlinear activation function. For weights.

[0064] For client c, the FedLEKE task is as follows:

[0065]

[0066] in, Let these represent the key and value sets of client c at time t in the l-th layer, respectively, representing the sets of keys and values ​​related to the encoded subject knowledge. This indicates that n pieces of knowledge need to be retained; This indicates that u pieces of knowledge need to be modified, which is much larger than n. These are the original weights;

[0067] Incremental weight As shown below:

[0068]

[0069] in: Represents the target knowledge value Original knowledge of the client-side C model The residuals between; It is the set of memorized keys estimated through sampling; λ is a hyperparameter used to balance the degree of model modification and retention. It is a key-value pair.

[0070] Step 3), the steps for fine-tuning the weights of the feedforward network in the LLM model include:

[0071] 3.1) The first key layer of knowledge editing in the computing client and the last key layer The set of layers that need to be modified;

[0072] 3.2) For each edit tuple (s) on client c ci ,r ci ,o ci )∈ε c Calculate z ci Replace hidden state Right now:

[0073]

[0074] Where x ci ⊕p(s ci ,r ci ) indicates that the random prefix x ci Combine with templated hints to enhance generalization across contexts; This indicates that by replacing the hidden state of the last layer... For z ci To modify the execution process of the Transformer; residual Equivalent to o ci Represents an object; Represents probability;

[0075] 3.3) Based on the MEMIT algorithm, the incremental weights are... Distribute the weights across the L-th layer MLP to achieve fine-tuning.

[0076] In step 4), each client runs the Edit algorithm locally to generate intermediate knowledge vectors; the Edit algorithm is the LEKE method.

[0077] In step 4), each client generates the following intermediate knowledge vector:

[0078]

[0079] In the formula, z is the first-level key; ci The optimized hidden state residual; Indicates the key generation function; x ij For a random prefix, s ci The main editing element; γ is the layer normalization, σ is the activation function; (s ci ,r ci ,o ci )∈ε c .

[0080] In step 6), the relevant intermediate knowledge vectors retrieved by each client from the server satisfy the following conditions:

[0081]

[0082] In the formula, α is the similarity threshold; len (similarity) represents all knowledge tuples within the current time slot of the client. The total number; ∑(similarity>α) is the number of MKVs in the client that meet the threshold.

[0083] Example 2:

[0084] A collaborative knowledge editing method for large-scale models based on federated learning, comprising the following steps:

[0085] 1) Constructing an LLM model

[0086] 2) Construct a FedLEKE task with the goal of editing the internal parameters of the LLM and inserting fact data ε for all clients;

[0087] 3) Perform the FedLEKE task to optimize the hidden states of the Transformer layer, thereby fine-tuning the weights of the feedforward network in the LLM model and updating the LLM model;

[0088] 4) Each client generates an intermediate knowledge vector and uploads it to the server;

[0089] 5) In the predefined time slot t i ∈T, the server distributes the stored MKVs to each client; i = 1,...,m, m is the total number of time slots;

[0090] 6) Each client dynamically retrieves relevant intermediate knowledge vectors from the server based on cosine similarity, re-edits the knowledge vectors, and locates and modifies the association parameters in the LLM model based on the re-edited knowledge vectors.

[0091] Example 3:

[0092] A method for collaborative localization and knowledge editing of large-scale models based on federated learning, with the same technical content as in Embodiment 2, further comprising the LLM model. This is an autoregressive model, including a decoder;

[0093] The LLM model encodes the input sequence x into a sequence x1,...,x1 consisting of z labels. z It is then processed by the L-layer Transformer decoder.

[0094] Example 4:

[0095] A large-scale, multi-client collaborative knowledge editing method based on federated learning, with technical content identical to any one of embodiments 2-3, further wherein the LLM model is as follows:

[0096] Prerequisites: An autoregressive LLM model with only a decoder is denoted as... It encodes the input sequence x into a sequence of z tags x1,...,x z And it is processed through the L-layer Transformer decoder. Next marker x z+1 The probability calculation formula is:

[0097]

[0098] Among them: W E Let γ be the embedding matrix, and γ be the layer normalization operation; and Let represent the hidden states of the multi-head self-attention network and the feedforward network in layer L, respectively; For the next marker x z+1 The probability of;

[0099] The hidden state of the j-th marker in layer l and hidden state As shown below:

[0100]

[0101] in: and σ represents the output weights of MHSA and FFN in the l-th layer, respectively; σ is the nonlinear activation function.

[0102] Example 5:

[0103] A method for collaborative localization and knowledge editing in a large-scale model based on federated learning, with technical content identical to any one of embodiments 2-4, further wherein, for client c, the FedLEKE task is as follows:

[0104]

[0105] in, Let these represent the key and value sets of client c at time t in the l-th layer, respectively, representing the sets of keys and values ​​related to the encoded subject knowledge. This indicates that n pieces of knowledge need to be retained; This indicates that u pieces of knowledge need to be modified, which is much larger than n. These are the original weights;

[0106] Incremental weight As shown below:

[0107]

[0108] in: Represents the target knowledge value Original knowledge of the client-side C model The residuals between; It is the set of memorized keys estimated through sampling; λ is a hyperparameter used to balance the degree of model modification and retention.

[0109] Example 6:

[0110] A method for collaborative localization and knowledge editing in a large-scale model based on federated learning, with technical content identical to any one of embodiments 2-5, further comprising, in step 3), fine-tuning the weights of the feedforward network in the LLM model, including:

[0111] 3.1) The first key layer of knowledge editing in the computing client and the last key layer The set of layers that need to be modified;

[0112] 3.2) For each edit tuple (s) on client c ci ,r ci ,o ci )∈ε c Calculate z ci Replace hidden state Right now:

[0113]

[0114] Where x ci ⊕p(s ci ,r ci ) indicates that the random prefix x ci Combine with templated hints to enhance generalization across contexts; This indicates that by replacing the hidden state of the last layer... For z ci To modify the execution process of the Transformer; residual

[0115] 3.3) Based on the MEMIT algorithm, the incremental weights are... Distribute the weights across the L-th layer MLP to achieve fine-tuning.

[0116] Example 7:

[0117] A collaborative knowledge editing method for large-scale models based on federated learning is provided. The technical content is the same as any one of embodiments 2-6. Further, in step 4), each client runs the Edit algorithm locally to generate intermediate knowledge vectors; the Edit algorithm is the LEKE method.

[0118] Example 8:

[0119] A collaborative knowledge editing method for large-scale models based on federated learning, with technical content identical to any one of embodiments 2-7, further comprising the following step 4): Each client generates an intermediate knowledge vector as shown below:

[0120]

[0121] In the formula, z is the first-level key; ci The optimized hidden state residual; Indicates the key generation function; x cj For a random prefix, s ci The main editing element; γ is the layer normalization, σ is the activation function; (s ci ,r ci ,o ci )∈ε c .

[0122] Example 9:

[0123] A large-scale, multi-client collaborative knowledge editing method based on federated learning, with technical content identical to any one of embodiments 2-8, further wherein, in step 6), the relevant intermediate knowledge vectors retrieved by each client from the server satisfy the following conditions:

[0124]

[0125] In the formula, α is the similarity threshold; len (similarity) represents all knowledge tuples within the current time slot of the client. The total number; ∑(similarity>α) is the number of MKVs in the client that meet the threshold.

[0126] Example 10:

[0127] A collaborative knowledge editing method for large-scale models based on federated learning, involving multiple clients, comprises the following steps:

[0128] 1) Prerequisites: An autoregressive LLM model with only a decoder is denoted as... It encodes the input sequence x into a sequence of z tags x1,...,x z And it is processed through the L-layer Transformer decoder. Next marker x z+1 The probability calculation formula is:

[0129]

[0130] Among them: W E Let γ be the embedding matrix, and γ be the layer normalization operation; and Let represent the hidden states of the multi-head self-attention (MHSA) and feedforward network (FFN) in layer L, respectively; the j-th labeled state in layer l. and Defined as:

[0131]

[0132] in: and σ represents the output weights of MHSA and FFN in the l-th layer, respectively; σ is the nonlinear activation function.

[0133] 2) FedLEKE Task Construction: Assume that each client c has a fact dataset to be edited in time slot t. FedLEKE's goal is to insert factual data ε from all clients by editing the internal parameters of the LLM. Overall, for each client c, FedLEKE optimizes the objective function across predefined time slots to obtain the objective weights:

[0134]

[0135] in These represent the sets of keys and values ​​that encode the subject-related knowledge of client c at time t in the l-th layer.

[0136] This indicates that n pieces of knowledge need to be retained; This represents u pieces of knowledge that need to be modified, which is much larger than n (i.e., u >> 1). The keys and values ​​are represented in a horizontally stacked matrix: Target weight Original weights with incremental weights The sum of Based on the derivation of the MEMIT method, the expression for the incremental weight is:

[0137]

[0138] in: Represents the target knowledge value (i.e., target knowledge representation) and the original knowledge of the client-side c model The residuals between; It is the set of memorized keys estimated through sampling; λ is a hyperparameter used to balance the degree of model modification and retention.

[0139] 3) LEKE method: such as Figure 1 As shown, MEMIT fine-tunes the FFN weights by optimizing the hidden states of the Transformer layers. Specifically, it computes the first and last key layers of client knowledge editing: in This is the set of layers that need to be modified. For each edit tuple (s) on client c... ci ,r ci ,o ci )∈ε c (Subject s, relation r, object o), perform the following two steps:

[0140] 3.1) Calculate z ci Replace hidden state The goal is to add residuals to the hidden state of the last layer L. The method is to optimize the residual vector δ using gradient descent. ci The formula is:

[0141]

[0142] Where x ci ⊕p(s ci ,r ci ) indicates that the random prefix x ci Combine with templated hints to enhance generalization across contexts; This indicates that by replacing the hidden state of the last layer... For z ci This allows us to modify the execution process of the Transformer.

[0143] 3.2) Propagate incremental weights in layer 1 The method follows the MEMIT algorithm steps, and increments the weights. Distributed into the MLP of layer 1, where

[0144] 4) FedEdit framework:

[0145] 4.1) Local Editing (Step 1): Starting from t=0, each client runs the Edit algorithm locally (which can be any LEKE method, such as MEMIT and PMET). This process generates MKVs.

[0146] 4.2) Upload MKVs (Step 2): Each client uploads the generated MKVs to the server.

[0147] 4.3) Select MKVs (Step 3): In the predefined time slot t i For each time slot in the array ∈T (i = 1, ..., m, where m is the total number of time slots), the server distributes the stored MKVs to each client. The client then selects the MKVs that are beneficial to it based on the re-editing criteria.

[0148] 4.4) Re-editing (Step 4): If the client selects at least one MKV, the Edit algorithm is executed again based on the already edited model (edited_model_c).

[0149] 4.5) To clearly define MKVs and re-editing conditions, the FedEdit framework is summarized as Algorithm 1, which includes the following two main steps:

[0150] 4.5.1) Editing: Within the interval of the time slot set T, each client executes the Edit algorithm (step 1) in parallel and independently. Taking MEMIT as an example, it generates client data records ε. c Relevant parameters: Optimized hidden state residual z ci The key at the first level (L0) Defined as:

[0151]

[0152] in: Indicates the key generation function; x cj For a random prefix, s ci The main editing element is γ; layer normalization is γ, and activation function is σ.

[0153] The MKVs of client c at time t are:

[0154]

[0155] in Generated by the client within the time interval [t-1, t], and (s ci ,r ci ,o ci )∈ε c After the client completes local editing, it will... Upload to the server (Step 2).

[0156] 4.5.2) Re-editing: When the time reaches the predefined time slot t i When ∈T (a total of m time slots), the server will store the global Distribute to each client. Clients filter useful MKVs based on the following "re-edit criteria":

[0157]

[0158] The similarity is determined by traversing the server. With the client local The cosine similarity; α is the similarity threshold (hyperparameter); ∑(similarity>α) is the number of MKVs in the client that meet the threshold; len(similarity) is the total number of knowledge tuples in the current time slot of the client. The total number. If more than half of the knowledge tuples in the client meet the similarity threshold, then the corresponding one is selected. (Step 3). The client executes the Edit algorithm again based on the already edited model (Step 4), until t. i =t m .

[0159] In summary, the steps of this invention are as follows: 1) Constructing the FedLEKE task, including formulating the objective function and defining the objective weights; 2) To efficiently solve the FedLEKE task, we designed the FedEdit framework, specifically: 2.1) Each client executes the LEKE task locally, which generates intermediate knowledge vectors (MKVs) as defined by us; 2.2) Each client uploads the MKVs generated in the previous step to the server; 2.3) When the predetermined time slot arrives, each client selects MKVs highly similar to the currently edited knowledge from the server according to our designed "re-editing conditions"; 2.4) If MKVs were selected in the previous step, the client performs a re-editing process on these MKVs. This invention analyzes the core text of the zsRE dataset and the z... ci The correlation between vectors reveals a strong correlation between them, i.e., z ci Vectors can effectively encode raw knowledge, making them ideal as MKVs. Therefore, this invention defines MKVs and re-editing conditions to further design the FedEdit framework.

[0160] Experimental results on two benchmark datasets, zsRE and COUNTFACT, show that FedEdit retains over 96% of the performance of non-Federated LEKE, while significantly outperforming the FedAvg-based baseline by approximately twice. When performing FedLEKE tasks using the FedEdit framework, MEMIT's performance is more stable than PMET.

Claims

1. A method for collaborative localization and knowledge editing in a large-scale model based on federated learning, characterized in that, Includes the following steps: 1) Constructing an LLM model 2) Construct a FedLEKE task with the goal of editing the internal parameters of the LLM and inserting fact data ε for all clients; 3) Perform the FedLEKE task to optimize the hidden states of the Transformer layer, thereby fine-tuning the weights of the feedforward network in the LLM model and updating the LLM model; 4) Each client generates an intermediate knowledge vector and uploads it to the server; 5) In the predefined time slot t i ∈T, the server distributes the stored MKVs to each client; i = 1,...,m, m is the total number of time slots; 6) Each client dynamically retrieves relevant intermediate knowledge vectors from the server based on cosine similarity, re-edits the knowledge vectors, and locates and modifies the association parameters in the LLM model based on the re-edited knowledge vectors.

2. The method for knowledge editing in a large-scale, multi-client collaborative model based on federated learning according to claim 1, characterized in that, The LLM model This is an autoregressive model, including a decoder; The LLM model encodes the input sequence x into a sequence x1,...,x1 consisting of z labels. z It is then processed by the L-layer Transformer decoder.

3. The method for multi-client collaborative localization and knowledge editing based on federated learning in a large model according to claim 1, characterized in that, The LLM model is shown below: Prerequisites: An autoregressive LLM model with only a decoder is denoted as... It encodes the input sequence x into a sequence of z tags x1,...,x z And processed by the L-layer Transformer decoder; the next marker x z+1 The probability calculation formula is: Among them: W E Let γ be the embedding matrix, and γ be the layer normalization operation; and Let represent the hidden states of the multi-head self-attention network and the feedforward network in layer L, respectively; This is the hidden state of layer L-1; For the next marker x z+1 The probability of; The hidden state of the j-th marker in layer l and hidden state As shown below: in: and σ represents the output weights of MHSA and FFN in the l-th layer, respectively; σ is the nonlinear activation function. For weights.

4. The method for multi-client collaborative localization and knowledge editing based on federated learning in a large model according to claim 1, characterized in that, For client c, the FedLEKE task is as follows: in, Let these represent the key and value sets of client c at time t in the l-th layer, respectively, representing the sets of keys and values ​​related to the encoded subject knowledge. This indicates that n pieces of knowledge need to be retained; This indicates that u pieces of knowledge need to be modified, which is much larger than n. These are the original weights; Incremental weight As shown below: in: Represents the target knowledge value Original knowledge of the client-side C model The residuals between them; C0 is the set of memorized keys estimated through sampling; It is a key-value pair.

5. The method for multi-client collaborative localization and knowledge editing based on federated learning in a large model according to claim 1, characterized in that, Step 3), the steps for fine-tuning the weights of the feedforward network in the LLM model include: 3.1) The first key layer of knowledge editing in the computing client and the last key layer The set of layers that need to be modified; 3.2) For each edit tuple (s) on client c ci ,r ci ,o ci )∈ε c Calculate parameter z ci Replace hidden state Right now: in This indicates that the random prefix x will be used. ci Combined with templated prompts; This indicates that by replacing the hidden state of the last layer... For z ci To modify the execution process of the Transformer; residual o ci Represents an object; Represents probability; 3.3) Based on the MEMIT algorithm, the incremental weights are... Distribute the weights across the L-th layer MLP to achieve fine-tuning.

6. The method for multi-client collaborative localization and knowledge editing based on federated learning in a large model according to claim 1, characterized in that, In step 4), each client runs the Edit algorithm locally to generate intermediate knowledge vectors; the Edit algorithm is the LEKE method.

7. The method for multi-client collaborative localization and knowledge editing based on federated learning in a large model according to claim 6, characterized in that, In step 4), each client generates the following intermediate knowledge vector: In the formula, z is the first-level key; ci The optimized hidden state residual; Indicates the key generation function; x cj For a random prefix, s ci The main editing element; γ is the layer normalization, σ is the activation function; (s ci ,r ci ,o ci )∈ε c .

8. The method for collaborative localization and knowledge editing of a large-scale model based on federated learning according to claim 1, characterized in that, In step 6), the relevant intermediate knowledge vectors retrieved by each client from the server satisfy the following conditions: In the formula, α is the similarity threshold; len (similarity) represents all knowledge tuples within the current time slot of the client. The total number of MKVs; ∑(similarity>α) is the number of MKVs in the client that meet the threshold.

Citation Information

Cited By

  • Cross-domain large model method and system based on federated RAG

    CN121660106A

  • Cross-domain large model method and system based on federated rag

    CN121660106B