Large language model knowledge editing method and system
Through scoring and clustering techniques, the key neurons in the large language model are accurately positioned, combined with the two-stage gradient update method, the shortcomings in the knowledge editing method of the large language model in terms of accuracy, efficiency and adaptability are solved, and efficient and accurate knowledge editing is achieved.
Patent Information
- Application Number
- CN202510386461.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-03-31
AI Technical Summary
The current knowledge editing method of large language models has great room for improvement in accuracy, efficiency and adaptability, especially when dealing with dynamic knowledge updates and personalized knowledge adjustments.
By scoring the importance of model neurons, selecting the key set of neurons involved in knowledge editing, and clustering of the edited knowledge. Then, the sample closest to the cluster center is used as the anchor sample, and all instances within the cluster share an update vector based on the anchor sample for the first phase update, and additional personalization is made to each instance for the second phase update.
The precise positioning of target knowledge is achieved, the accuracy and efficiency of knowledge editing is improved, the calculation overhead is reduced, and the stability and robustness of the model are ensured.
Smart Images

Figure CN119886073A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and more specifically to a large language model knowledge editing method and system. Background Art
[0002] In recent years, large language models (LLMs) have made significant progress in the field of natural language processing. These models are trained on large-scale Internet data, and are not only able to generate high-quality text, but also store and retrieve a large amount of factual knowledge. However, the dynamic and accuracy issues of these knowledge bases have brought great challenges to the practical application of large language models. The knowledge in LLMs usually comes from static training corpora, which may contain outdated, inaccurate or even contradictory information, causing the model to provide wrong or irrelevant answers when reasoning. For example, a model may incorrectly answer who is the current legal representative of a company, or provide outdated medical guidelines.
[0003] The traditional solution is to retrain the entire large model, which requires recollecting and cleaning massive amounts of data and consumes huge computing resources. For large language models with billions or even hundreds of billions of parameters (such as GPT-3, Llama, etc.), the computational cost of retraining is often unbearable. In addition, retraining may also destroy useful knowledge stored in the model, resulting in a decline in the overall performance of the model.
[0004] In order to avoid the high cost of retraining, a variety of knowledge editing methods have been proposed in recent years. These methods aim to modify specific knowledge by locally updating model parameters while maintaining the integrity of other knowledge. These methods can be roughly divided into the following categories: (1) Fine-tuning-based methods: Fine-tuning methods directly train specific layers or all parameters of the model to update the target knowledge. This type of method is simple and intuitive, but its limitation is that the update range is too large, which may introduce knowledge forgetting problems, and the computational cost is still high. (2) Memory module-based methods: Some studies introduce external memory modules (such as SERAC) for explicit storage and retrieval of new knowledge. Although this method avoids modifying the internal parameters of the model, it relies on the implementation of external memory, resulting in slow retrieval speed and difficulty in handling the deep correlation of knowledge during model reasoning. (3) Local parameter update-based methods: In recent years, some "locate-and-edit" methods have become popular, such as ROME and MEMIT. These methods locate the key layers or neurons that store specific knowledge by analyzing the parameter distribution of large language models and perform targeted updates. However, they have two major limitations. One is the limitation of the fixed layer assumption: the existing methods determine a fixed set of key layers after model training, but different knowledge may be stored in different locations in the large model. The fixed layer assumption cannot adapt to the diversity of storage modes, resulting in insufficient editing accuracy. The second point is the high computational overhead: for large-scale knowledge updates, existing methods often need to update the parameters of the knowledge one by one, and the gradient calculation process is inefficient, especially in scenarios where tens of thousands of knowledge need to be updated, the time cost is extremely high.
[0005] In summary, the current knowledge editing methods for large language models still have much room for improvement in terms of accuracy, efficiency, and adaptability. Summary of the invention
[0006] In this embodiment, a large language model knowledge editing method, system, electronic device and storage medium are provided to solve the problems of poor accuracy, efficiency and adaptability of current large language model knowledge editing methods.
[0007] In a first aspect, an embodiment of the present invention provides a large language model knowledge editing method, the large language model knowledge editing method comprising: Score the importance of the model neurons and get the score value of each neuron; Calculate the contribution value based on the score, and select the key neuron set participating in knowledge editing according to the pre-set contribution threshold; Select key neurons to cluster the knowledge to be edited; The sample closest to the cluster center is taken as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample for the first stage update. Additional personalized adjustments are made to each instance for the second stage update.
[0008] In an optional embodiment, the importance of the model neurons is scored to obtain a score value for each neuron, including: The score value of each neuron is calculated by any one of the activation value score, weight importance score and residual sensitivity score.
[0009] In an optional embodiment, the contribution value is calculated based on the score, and a key neuron set participating in knowledge editing is selected according to a preset contribution threshold, including: The neuron sets are sorted by cumulative contribution values to determine the neuron sets that meet a specific contribution threshold.
[0010] In an optional embodiment, key neurons are selected to cluster the knowledge to be edited, including: Represent each knowledge instance and its associated neuron set as a key-value pair; Using Jaccard similarity as a metric, the similarity between the neuron ensembles of two knowledge instances is calculated; According to Jaccard similarity, similar knowledge instances are aggregated into the same cluster.
[0011] In an optional embodiment, the sample closest to the cluster center is used as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample to perform the first stage update, including: Determine the cluster center; In each cluster, the Jaccard distance between each sample and the cluster center is calculated, and the sample closest to the cluster center is selected as the anchor sample; All instances within a cluster share the same update vector calculated based on the anchor sample to minimize the average loss between the anchor sample and its target output; The computed shared update vector is applied to all instances within the cluster.
[0012] In an optional embodiment, additional personalized adjustments are made to each instance for the second stage update, including: For each instance in the cluster, additional personalized adjustments are made based on its shared update to minimize the instance-specific adjustment of the residual error after the shared update. The shared update vector from the first stage is added to the personalized adjustment vector from the second stage to form the complete gradient descent update vector.
[0013] In an optional embodiment, the optimization objective of minimizing the instance-specific adjustment term of the shared updated residual error is: ; In the formula, Indicates that for the sample The optimal personalized adjustment amount, Represents the samples calculated at layer L The hidden representation of represents a single instance input within a cluster, Representation instance The target output, Representation instance Personalized gradient adjustment variables.
[0014] Compared with the prior art, the large language model knowledge editing method of the present invention has the following beneficial effects: This method achieves precise positioning of target knowledge by introducing interpretability-based key neuron identification, thereby providing higher accuracy and efficiency when performing knowledge editing in large language models. Secondly, through the combination of knowledge clustering and two-stage gradient update, the computational overhead in the editing process is effectively reduced while ensuring the stability and robustness of the model. In addition, this method theoretically reveals the deep connection between interpretability analysis and neural network knowledge storage distribution, providing a new technical perspective for understanding model editing tasks. Empirical evaluation shows that this method significantly outperforms existing methods in knowledge editing tasks on multiple public datasets, fully demonstrating strong practical application potential and wide applicability. In general, this method provides an efficient, accurate and robust solution for knowledge editing tasks in large language models, which helps promote the application and development of large language models in dynamic knowledge updating and personalized knowledge adjustment.
[0015] In a second aspect, an embodiment of the present invention provides a large language model knowledge editing system, including: The scoring module is used to score the importance of the model neurons and obtain the score value of each neuron; A dynamic neuron selection module is used to calculate the contribution value based on the score and select the key neuron set participating in knowledge editing according to the preset contribution threshold; The knowledge clustering module is used to select key neurons and cluster the knowledge to be edited; A two-stage gradient update module is used to take the sample closest to the cluster center as the anchor sample. All instances in the cluster share an update vector based on the anchor sample for the first stage update, and additional personalized adjustments are made to each instance for the second stage update.
[0016] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor, a communication interface, a memory and a bus, wherein the processor, the communication interface and the memory communicate with each other through the bus, and the processor can call logical instructions in the memory to execute the steps of the method provided in the first aspect.
[0017] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the large language model knowledge editing method as described in the first aspect.
[0018] Compared with the prior art, the beneficial effects of the large language model knowledge editing system, electronic device and storage medium of the present invention are the same as those of the large language model knowledge editing method described in the first aspect, so they will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 Flow chart of a large language model knowledge editing method according to an embodiment of the present invention; Figure 2 It is a framework diagram of a large language model knowledge editing method according to an embodiment of the present invention; Figure 3 Schematic diagram of the process framework of the large language model knowledge editing method in an embodiment of the present invention; Figure 4 It is a structural block diagram of a large language model knowledge editing system in an embodiment of the present invention; Figure 5 1 is a structural block diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0022] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.
[0023] In an embodiment of the present invention, a large language model knowledge editing method (TripleE Edit) is provided. Figure 1 is a flow chart of the large language model knowledge editing method of the present invention, such as Figure 1 and Figure 2 As shown, the process includes the following steps: S100, scoring the importance of the model neurons to obtain a score value for each neuron; Specifically, the importance of the model neurons is scored to obtain the score value of each neuron, including: The score value of each neuron is calculated by any one of the activation value score, weight importance score and residual sensitivity score.
[0024] Activation score: By calculating the strength of the neuron's activation of the input knowledge, the importance of the neuron in knowledge storage is evaluated. The formula is: in, Representing neurons On input The activation value on .
[0025] Weight importance scoring: By analyzing the weight connection strength between neurons, the neurons that play a dominant role in information transmission are identified. The scoring formula is: in, Representing neurons and The connection weight between .
[0026] Residual sensitivity score: Evaluate the influence of each neuron in knowledge storage by analyzing the contribution of residual flow to model output. The formula is as follows: in, Presentation Layer Mesoneuron The activation value of For neurons The output weight of .
[0027] S200, calculating the contribution value based on the score, and selecting the key neuron set participating in knowledge editing according to a preset contribution threshold; Specifically, the contribution value is calculated based on the score, and the key neuron set participating in knowledge editing is selected according to the preset contribution threshold, including: The neuron sets are sorted by cumulative contribution values to determine the neuron sets that meet a specific contribution threshold.
[0028] It should be noted that this method uses a dynamic selection mechanism to adaptively select the most relevant neuron set in different knowledge editing tasks. The specific steps are as follows: select any of the three methods mentioned above, calculate the score value of each neuron, and sort them according to the score to determine the neuron set used for the knowledge editing task. Sort by the cumulative contribution value to determine the neurons that meet the specific contribution threshold. I , the formula is: ; in, For the The score of a neuron, is the contribution threshold. For batch editing scenarios, this method aggregates the neuron scores of all tasks and uniformly identifies the neuron set that contributes the most to multiple tasks, further optimizing the editing efficiency.
[0029] Through the above-mentioned dynamic selection mechanism, this method can accurately identify the target neurons while minimizing the interference with other knowledge. Compared with the previous mainstream method of selecting a few layers of coarse-grained methods, this method directly selects from the neuron accuracy. After selecting one of the AC, WE, and RE methods to perform the task, the different adaptability of each method to the environment settings and input attributes can be deduced based on the different performances. This shows that this method has implanted explainability into the step of selecting specific neurons, and can trace back to find out which neurons are key to specific attributes, so as to select effective neurons to proceed to the next editing task.
[0030] S300, select key neurons and cluster the knowledge to be edited; After identifying the target neurons, this method efficiently edits the model by optimizing the designed parameter update mechanism. The core goal is to reduce the gradient calculation overhead through batch optimization techniques while ensuring the efficiency and stability of editing. Different types of knowledge may correspond to different neuron distributions. This method (TripleE Edit) uses a clustering algorithm to group the knowledge to be edited and integrate the update operations of similar knowledge together to achieve batch updates. The main goal of knowledge clustering is to group knowledge with similar attributes into the same cluster according to the characteristics of different knowledge instances to reduce possible conflicts during knowledge editing.
[0031] Specifically, key neurons are selected to cluster the knowledge to be edited, including: Represent each knowledge instance and its associated neuron set as a key-value pair; Using Jaccard similarity as a metric, the similarity between the neuron ensembles of two knowledge instances is calculated; According to Jaccard similarity, similar knowledge instances are aggregated into the same cluster.
[0032] For example, first, for each knowledge instance The corresponding neuron set is represented as a key-value pair. This representation can reflect the association between the knowledge instance and the storage location in the model. Jaccard similarity is then used as a similarity measurement method between knowledge instances to calculate the difference in the proportion of the intersection and union of the neuron sets of two knowledge instances. The specific formula is: ; in, and Represents knowledge instance and The corresponding set of neurons then aggregates similar knowledge instances into the same cluster.
[0033] The optimization goal of clustering is to minimize the Jaccard distance between the data point and its corresponding cluster center. The formula is as follows: ; in, Indicates clusters, is the center point of the cluster. For each cluster, select the sample closest to the cluster center as the anchor sample.
[0034] This anchor sample is regarded as the knowledge instance that best represents the cluster. Finally, the clustering results divide the knowledge instances into multiple small batches, and each batch is finely edited according to its specific attributes, so as to achieve higher targeting and efficiency in knowledge editing. Through the above steps, knowledge clustering ensures that the knowledge instances in each cluster have high internal similarity and provides a basis for grouping optimization in subsequent editing tasks using large models.
[0035] S400, taking the sample closest to the cluster center as the anchor sample, all instances in the cluster share an update vector based on the anchor sample for the first stage update, and performing additional personalized adjustments on each instance for the second stage update.
[0036] This step is a two-stage gradient update, which aims to improve the computational efficiency in the sequential batch editing process. By dividing the gradient optimization process of each cluster into two stages - a sharing stage and a personalized fine-tuning stage, it maximizes the utilization of shared information while retaining the unique adjustments of each instance.
[0037] Specifically, the sample closest to the cluster center is used as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample for the first stage update, including: Determine the cluster center; In each cluster, the Jaccard distance between each sample and the cluster center is calculated, and the sample closest to the cluster center is selected as the anchor sample; All instances within a cluster share the same update vector calculated based on the anchor sample to minimize the average loss between the anchor sample and its target output; The computed shared update vector is applied to all instances within the cluster.
[0038] For example, first cluster the anchor samples Based on the gradient of , 4 rounds of unified updates are performed (a total of 5 rounds of updates in the whole process). All instances in the cluster share this update vector , because the anchor sample is regarded as the representative of the cluster and can capture the core features of the cluster. With its target output The average loss of , calculate the shared update vector , the formula is: ; In the formula, represents the calculated shared update vector, represents the adjustment or gradient update variable used for optimization, P G represents the probability output of a probability distribution or model G under specific circumstances, represents the hidden representation of the anchor sample calculated on layer L.
[0039] The updates at this stage capture the common patterns within the clusters, lay the foundation for subsequent personalized updates, and reduce the burden of repeated calculations within the clusters.
[0040] Furthermore, additional personalized adjustments are made to each instance for the second phase of updating, including: For each instance in the cluster, additional personalized adjustments are made based on its shared update to minimize the instance-specific adjustment of the residual error after the shared update. The shared update vector from the first stage is added to the personalized adjustment vector from the second stage to form the complete gradient descent update vector.
[0041] For example, the second stage performs additional personalized adjustments for instances within each cluster to account for subtle differences between instances. Perform 1 round of fine-tuning on top of the shared update. The optimization goal is to minimize the instance-specific adjustment of the residual error after the shared update , the formula is: ; In the formula, Indicates that for the sample The optimal personalized adjustment amount, Represents the samples calculated at layer L The hidden representation of represents a single instance input within a cluster, Representation instance The target output, Representation instance Personalized gradient adjustment variables.
[0042] This fine-tunes the details of each instance, ensuring that the model can adapt to the unique characteristics of each instance. Finally, the two-stage vector is added together to get the complete gradient descent update vector: ; The first stage uses shared updates to reduce most of the repeated calculations and avoid the high computational cost of traditional instance-by-instance update methods. The personalized fine-tuning in the second stage ensures that the uniqueness of each instance is preserved and the personalized features are not lost due to shared updates. This method focuses on the identified important neurons, avoids global modifications to the parameters of the entire model, and reduces potential damage to the stability and integrity of the model. Through the two-stage gradient update method, this method achieves efficient and accurate model editing, which is particularly suitable for large-scale editing scenarios. While significantly reducing the computational overhead, it ensures the high quality of knowledge editing and the stability of the model.
[0043] This method achieves efficient and accurate knowledge editing of large language models. Experiments show that this method improves editing efficiency by more than several times, while significantly reducing the risk of model performance degradation, providing an efficient and practical solution for dynamic knowledge updating of large models.
[0044] Specifically, Figure 3 As shown, Figure 3 A schematic diagram of the two-stage specific process of optimization from the mechanism of grouping similar knowledge using clustering algorithm and performing batch optimization to the two-step gradient descent method is shown.
[0045] Clustering phase: In this phase, all knowledge instances to be edited are grouped by calculating the similarity between their feature representations, and clustering algorithms (such as K-means) are used to cluster similar knowledge instances together. Batch optimization phase: Once the knowledge is grouped, all instances in the same cluster will share an update vector. In this way, repeated calculations between different instances are reduced, significantly improving computational efficiency. Shared update phase: All knowledge instances in a cluster share a unified update vector. By performing gradient updates on the central samples in the cluster (usually samples representing the characteristics of the class), the common characteristics of the knowledge in the cluster can be captured. This process usually performs multiple rounds of gradient descent. Personalized fine-tuning phase: After the shared update, each knowledge instance in the cluster is fine-tuned individually to ensure that their specific features are further optimized. The update of each instance is based on the shared update vector, and usually fewer rounds of gradient descent are performed. Fine-tuning at this stage ensures that the personalized differences of each instance are preserved while avoiding over-adjustment. Through this two-stage optimization process, TripleE Edit can not only efficiently perform large-scale knowledge updates, but also ensure that the personalized features of each instance are carefully adjusted, maintaining the consistency of the model in multiple tasks.
[0046] The TripleE Edit proposed in the present invention has significant advantages and positive effects. First, TripleE Edit achieves precise positioning of target knowledge by introducing interpretability-based key neuron identification, thereby providing higher accuracy and efficiency when performing knowledge editing in large language models. Secondly, TripleE Edit effectively reduces the computational overhead in the editing process by combining knowledge clustering and two-stage gradient updating, while ensuring the stability and robustness of the model. In addition, TripleE Edit theoretically reveals the deep connection between interpretability analysis and neural network knowledge storage distribution, providing a new technical perspective for understanding model editing tasks. Empirical evaluations show that TripleE Edit significantly outperforms existing methods in knowledge editing tasks on multiple public datasets, fully demonstrating its strong practical application potential and wide applicability. In general, TripleE Edit provides an efficient, accurate and robust solution for knowledge editing tasks of large language models, which helps promote the application and development of large language models in dynamic knowledge updating and personalized knowledge adjustment.
[0047] In order to verify the effectiveness of the present invention, TripleE Edit was experimentally evaluated on the public datasets Counterfact and ZsRE, and experiments were conducted on different architectures such as GPT-2 XL, GPT-J, and Llama3. The editing quality of the model was evaluated by comparing it with existing editing methods in terms of editing effectiveness (Eff), editing generalization (Gen), editing locality (Spe), language fluency (Flu), and knowledge consistency (Cons). The main results are shown in Table 1: Table 1 Continuous editing experiment results
[0048] TripleE Edit excels in editing effectiveness. Experimental results on the Counterfact dataset show that the editing success rate of TripleE Edit's three neuron selection methods all reached over 95%. In addition, experiments on the ZsRE dataset show that TripleE Edit can quickly adapt to a variety of editing tasks and outperforms the comparison methods in all indicators. Therefore, in the scenario of continuous knowledge editing, our method has more advantages in generalization and stability in various evaluation indicators. The editing speed is significantly improved compared to the current knowledge editing methods; Table 2 Comparison results of continuous editing experiment time
[0049] TripleE Edit significantly reduces computational overhead through knowledge clustering and two-stage gradient updates. Experimental data show (Table 2), for example, in editing tasks using GPT-J, the average editing time of TripleE Edit is only 178 seconds, significantly lower than ROME's 764 seconds and MEMIT's 334 seconds, achieving several times the efficiency improvement. Compared with traditional methods, TripleE Edit can not only complete editing tasks of the same scale in a shorter time, but also ensure the high quality and stability of the editing results. Therefore, TripleE Edit has demonstrated great practical value and efficiency advantages in continuous knowledge editing, and is particularly suitable for scenarios that require rapid updating and processing of large amounts of knowledge.
[0050] The embodiment of the present invention also provides a large language model knowledge editing system, which is used to implement the above method embodiment, and will not be repeated hereafter. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware for predetermined functions. Although the system described in the following embodiments is preferably implemented in software, the implementation of hardware or a combination of software and hardware is also possible and conceivable.
[0051] like Figure 4 As shown, Figure 4 : is a structural block diagram of the large language model knowledge editing system in the present invention, the system includes: A scoring module 101 is used to score the importance of model neurons and obtain a score value for each neuron; A dynamic neuron selection module 102, used to calculate the contribution value based on the score, and select the key neuron set participating in knowledge editing according to a preset contribution threshold; A knowledge clustering module 103 is used to select key neurons and cluster the knowledge to be edited; The two-stage gradient update module 104 is used to use the sample closest to the cluster center as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample for the first stage update, and perform additional personalized adjustments on each instance for the second stage update.
[0052] Figure 5 A structural block diagram of an electronic device provided by an embodiment of the present invention, such as Figure 5As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the following method: Score the importance of the model neurons and get the score value of each neuron; Calculate the contribution value based on the score, and select the key neuron set participating in knowledge editing according to the pre-set contribution threshold; Select key neurons to cluster the knowledge to be edited; The sample closest to the cluster center is taken as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample for the first stage update. Additional personalized adjustments are made to each instance for the second stage update.
[0053] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0054] An embodiment of the present invention further provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method provided in each of the above embodiments is implemented, for example, including: Score the importance of the model neurons and get the score value of each neuron; Calculate the contribution value based on the score, and select the key neuron set participating in knowledge editing according to the pre-set contribution threshold; Select key neurons to cluster the knowledge to be edited; The sample closest to the cluster center is taken as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample for the first stage update. Additional personalized adjustments are made to each instance for the second stage update.
[0055] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.
[0056] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A large language model knowledge editing method, characterized in that: The large language model knowledge editing method comprises: Score the importance of the model neurons and get the score value of each neuron; Calculate the contribution value based on the score, and select the key neuron set participating in knowledge editing according to the pre-set contribution threshold; Select key neurons to cluster the knowledge to be edited; The sample closest to the cluster center is taken as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample for the first stage update. Additional personalized adjustments are made to each instance for the second stage update.
2. The large language model knowledge editing method according to claim 1, characterized in that: Score the importance of the model neurons and get the score value of each neuron, including: The score value of each neuron is calculated by any one of the activation value score, weight importance score and residual sensitivity score.
3. The large language model knowledge editing method according to claim 1, characterized in that: The contribution value is calculated based on the score, and the key neuron set participating in knowledge editing is selected according to the pre-set contribution threshold, including: The neuron sets are sorted by cumulative contribution values to determine the neuron sets that meet a specific contribution threshold.
4. The large language model knowledge editing method according to claim 1, characterized in that: Select key neurons and cluster the knowledge to be edited, including: Represent each knowledge instance and its associated neuron set as a key-value pair; Using Jaccard similarity as a metric, the similarity between the neuron ensembles of two knowledge instances is calculated; According to Jaccard similarity, similar knowledge instances are aggregated into the same cluster.
5. The large language model knowledge editing method according to claim 1, characterized in that: The sample closest to the cluster center is used as the anchor sample, and all instances in the cluster share an update vector based on the anchor sample for the first stage update, including: Determine the cluster center; In each cluster, the Jaccard distance between each sample and the cluster center is calculated, and the sample closest to the cluster center is selected as the anchor sample; All instances within a cluster share the same update vector calculated based on the anchor sample to minimize the average loss between the anchor sample and its target output; The computed shared update vector is applied to all instances within the cluster.
6. The large language model knowledge editing method according to claim 1, characterized in that: Additional personalized adjustments are made to each instance for the second phase of updates, including: For each instance in the cluster, additional personalized adjustments are made based on its shared update to minimize the instance-specific adjustment of the residual error after the shared update. The shared update vector from the first stage is added to the personalized adjustment vector from the second stage to form the complete gradient descent update vector.
7. The large language model knowledge editing method according to claim 6, characterized in that: The optimization objective of the instance-specific adjustment term that minimizes the residual error after the shared update is: ; In the formula, Indicates that for the sample The optimal personalized adjustment amount, Represents the samples calculated at layer L The hidden representation of represents a single instance input within a cluster, Representation instance The target output, Representation instance Personalized gradient adjustment variables.
8. A large language model knowledge editing system, characterized in that: include: The scoring module is used to score the importance of the model neurons and obtain the score value of each neuron; A dynamic neuron selection module is used to calculate the contribution value based on the score and select the key neuron set participating in knowledge editing according to the preset contribution threshold; The knowledge clustering module is used to select key neurons and cluster the knowledge to be edited; A two-stage gradient update module is used to take the sample closest to the cluster center as the anchor sample. All instances in the cluster share an update vector based on the anchor sample for the first stage update, and additional personalized adjustments are made to each instance for the second stage update.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the large language model knowledge editing method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the large language model knowledge editing method as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method for training large language model, storage medium and equipment
CN118297136A
Multi-modal large language model neuron attribution method and related equipment
CN118761476A
Data clustering method, related method, equipment and storage medium
CN119377714A
Neural network critical neuron selection
US20250094801A1
Systems and methods for iterative code generation with large language models and representative sub-modules
US20250103300A1
Cited By
Large language model knowledge editing method based on data enhancement
CN121503602A
A knowledge editing method based on super network parameter generation
CN122528834A
A knowledge editing method based on super network parameter generation
CN122528834B