Language model knowledge updating method and device, equipment, storage medium and program product

By locating and adjusting the target neurons in the large language model and generating the corresponding loss function, efficient and accurate knowledge updating is achieved, solving the problem of low knowledge updating efficiency in large language models and saving the cost of retraining.

CN122154896APending Publication Date: 2026-06-05TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2024-12-05
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

In existing technologies, large language models have low knowledge update efficiency and high retraining costs, resulting in low efficiency.

Method used

By acquiring the first training sample with changed labels and the second training sample without changes, the target neuron is located, and new knowledge introduction loss, old knowledge forgetting loss and other knowledge maintenance loss are generated. The parameters of the target neuron are adjusted until the convergence condition is met, thus realizing knowledge update.

Benefits of technology

It improves the efficiency and accuracy of knowledge updates, avoids retraining the entire model, saves time and money, and ensures that old knowledge in the model is replaced with new knowledge without affecting other knowledge.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122154896A_ABST
    Figure CN122154896A_ABST
Patent Text Reader

Abstract

The application relates to a language model knowledge updating method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: locating a target neuron for a first training sample from a pre-trained language model; inputting a second training sample into the pre-trained language model to obtain a corresponding first prediction label; inputting the first training sample and the second training sample into a language model in an iteration process to obtain a prediction label corresponding to the first training sample and a second prediction label corresponding to the second training sample; generating a new knowledge introduction loss based on the prediction label corresponding to the first training sample and a training label, generating an old knowledge forgetting loss based on the prediction label and a historical training label, and generating an other knowledge maintenance loss based on the first prediction label and the second prediction label; and adjusting neuron parameters of the target neuron based on the losses until a convergence condition is met, so that a target language model is obtained. In this way, the knowledge updating efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, storage medium, and computer program product for updating language model knowledge. Background Technology

[0002] With the development of artificial intelligence technology, various models have emerged, including the Large Language Model (LLM). The Large Language Model is a deep learning model trained using large amounts of text data, and it can handle a variety of natural language tasks.

[0003] After a large language model has been trained, if the training data used to train the model is updated, the model needs to be updated to learn new knowledge. Currently, the usual method for updating the knowledge of a large language model is to retrain it. However, retraining the model is costly and inefficient. Summary of the Invention

[0004] Therefore, it is necessary to provide a language model knowledge updating method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the efficiency of knowledge updating in order to address the above-mentioned technical problems.

[0005] This application provides a method for updating language model knowledge, including:

[0006] Obtain the first training sample whose label has changed, the second training sample whose label has not changed, and the historical training label and current training label corresponding to the first training sample;

[0007] Based on the first training sample and the historical training labels corresponding to the first training sample, the target neuron is located from the pre-trained language model;

[0008] The second training sample is input into the pre-trained language model to obtain the first predicted label corresponding to the second training sample; the first training sample and the second training sample are input into the language model in the iterative process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample.

[0009] Based on the predicted label and the current training label corresponding to the first training sample, a new knowledge introduction loss is generated; based on the predicted label and the historical training label corresponding to the first training sample, an old knowledge forgetting loss is generated; and based on the first and second predicted labels corresponding to the second training sample, other knowledge maintenance losses are generated.

[0010] Based on the new knowledge introduction loss, the old knowledge forgetting loss, and the other knowledge maintenance loss, the neuron parameters of the target neuron in the language model during the iteration process are adjusted until the convergence condition is met, and the updated target language model is obtained.

[0011] This application also provides a language model knowledge updating device, including:

[0012] The training data acquisition module is used to acquire a first training sample whose label has changed, a second training sample whose label has not changed, and the historical training label and current training label corresponding to the first training sample;

[0013] The neuron localization module is used to locate the target neuron from the pre-trained language model based on the first training sample and the historical training labels corresponding to the first training sample.

[0014] The model processing module is used to input the second training sample into the pre-trained language model to obtain the first predicted label corresponding to the second training sample; and to input the first training sample and the second training sample into the language model during the iterative process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample.

[0015] The loss generation module is used to generate a new knowledge introduction loss based on the predicted label and the current training label corresponding to the first training sample, generate an old knowledge forgetting loss based on the predicted label and the historical training label corresponding to the first training sample, and generate other knowledge maintenance loss based on the first and second predicted labels corresponding to the second training sample.

[0016] The model editing module is used to adjust the neuron parameters of the target neuron in the language model during the iterative process based on the new knowledge introduction loss, the old knowledge forgetting loss, and the other knowledge maintenance loss, until the convergence condition is met, so as to obtain the target language model after knowledge update.

[0017] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps described in the language model knowledge update method above.

[0018] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps described in the language model knowledge update method above.

[0019] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps described in the language model knowledge update method above.

[0020] The aforementioned language model knowledge update method, apparatus, computer device, storage medium, and computer program product acquire a first training sample with changed labels, a second training sample with unchanged labels, and the historical and current training labels corresponding to the first training sample; based on the first training sample and the historical training labels corresponding to the first training sample, locate the target neuron from the pre-trained language model; input the second training sample into the pre-trained language model to obtain the first predicted label corresponding to the second training sample; input the first and second training samples into the language model during the iteration process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample; based on the predicted label corresponding to the first training sample and the current training label, generate a new knowledge introduction loss; based on the predicted label corresponding to the first training sample and the historical training label, generate an old knowledge forgetting loss; and based on the first and second predicted labels corresponding to the second training sample, generate other knowledge maintenance losses; based on the new knowledge introduction loss, the old knowledge forgetting loss, and other knowledge maintenance losses, adjust the neuron parameters of the target neuron in the language model during the iteration process until the convergence condition is met, and obtain the knowledge-updated target language model. In this way, when the training labels of the first training sample are updated, the target neuron storing relevant knowledge of the first training sample is located in the language model. This target neuron is then fine-tuned so that it can store new knowledge related to the first training sample, allowing the model to use this new knowledge for data processing. Fine-tuning the target neuron instead of retraining the language model effectively improves the model's knowledge update efficiency. The current training label corresponding to the first training sample contains new knowledge. Based on the predicted label of the first training sample and the current training label, a new knowledge introduction loss is generated, which helps the model remember new knowledge. The historical training labels corresponding to the first training sample contain old knowledge. Based on the predicted label of the first training sample and the historical training labels, an old knowledge forgetting loss is generated, which helps the model forget old knowledge. By remembering new knowledge and forgetting old knowledge, knowledge replacement can be effectively achieved, thereby improving the model's knowledge update accuracy. The old knowledge forgetting loss also helps align the localization and fine-tuning stages, as the localization of the target neuron is based on old knowledge, and the old knowledge forgetting loss is also based on old knowledge. Based on the first and second predicted labels corresponding to the second training samples, other knowledge maintenance losses are generated. These losses help avoid affecting other knowledge in the model when fine-tuning the target neuron. By adjusting the neuron parameters of the target neuron in the language model based on the new knowledge introduction loss, old knowledge forgetting loss, and other knowledge maintenance losses, the old knowledge in the model can be effectively replaced with new knowledge without affecting other knowledge in the model, thus ensuring the accuracy of knowledge updates. Attached Figure Description

[0021] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a diagram illustrating the application environment of a language model knowledge update method in one embodiment.

[0023] Figure 2 This is a flowchart illustrating a language model knowledge update method in one embodiment;

[0024] Figure 3 This is a schematic diagram illustrating the location of the target neuron in one embodiment;

[0025] Figure 4 A flowchart illustrating the process of generating new knowledge and introducing loss and forgetting old knowledge in one embodiment;

[0026] Figure 5 This is a schematic diagram illustrating the data augmentation of prior knowledge in one embodiment;

[0027] Figure 6 This is a schematic diagram illustrating the use of new and old knowledge in model knowledge updates in one embodiment.

[0028] Figure 7 This is a schematic diagram of the process of updating knowledge in a model in one embodiment;

[0029] Figure 8 This is a schematic diagram illustrating knowledge updates for a chatbot in one embodiment;

[0030] Figure 9 This is a schematic diagram of a chatbot answering questions in one embodiment;

[0031] Figure 10 This is a structural block diagram of a language model knowledge update device in one embodiment;

[0032] Figure 11 This is an internal structural diagram of a computer device in one embodiment;

[0033] Figure 12 This is a diagram of the internal structure of a computer device in another embodiment. Detailed Implementation

[0034] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0035] The language model knowledge update method provided in this application can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be set up independently, integrated into server 104, or placed in the cloud or on other devices. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.

[0036] It is understood that both the terminal and the server can be used independently to execute the language model knowledge update method provided in the embodiments of this application. The terminal and the server can also be used collaboratively to execute the language model knowledge update method provided in the embodiments of this application.

[0037] For example, the server acquires a first training sample with changed labels, a second training sample with unchanged labels, and the historical and current training labels corresponding to the first training sample. Based on this data, it fine-tunes the language model to obtain the target language model. The server locates the target neuron in the pre-trained language model based on the first training sample and its corresponding historical training labels. The server inputs the second training sample into the pre-trained language model to obtain the first predicted label corresponding to the second training sample; it then inputs both the first and second training samples into the language model during the iteration process to obtain the predicted labels corresponding to the first and second training samples. Based on the predicted labels corresponding to the first training sample and the current training label, the server generates a new knowledge introduction loss, an old knowledge forgetting loss, and other knowledge maintenance losses. Based on the new knowledge introduction loss, old knowledge forgetting loss, and other knowledge maintenance losses, the server adjusts the neuron parameters of the target neuron in the language model during the iteration process until the convergence condition is met, resulting in the updated target language model.

[0038] The server can store the target language model locally or send it to other devices for storage. The terminal can then use the target language model to process natural language tasks.

[0039] In one embodiment, such as Figure 2 As shown, a method for updating language model knowledge is provided. Taking the application of this method to a computer device as an example, the computer device can be a terminal or a server. It can be understood that this method can be executed independently by the terminal or server, or it can be implemented through interaction between the terminal and the server. Specifically:

[0040] Step S202: Obtain the first training sample whose label has changed, the second training sample whose label has not changed, and the historical training label and current training label corresponding to the first training sample.

[0041] Here, the first training sample refers to the training sample whose training label has changed, and the second training label refers to the training sample whose training label has not changed. The historical training label corresponding to the first training sample refers to the old training label of the first training sample, which contains old knowledge. The current training label corresponding to the first training sample refers to the new training label corresponding to the first training sample, which contains new knowledge.

[0042] It's understandable that many factors can lead to errors in the knowledge stored in a model, such as incorrect data labeling or data noise; ambiguous wording; and limited model learning ability. Therefore, when errors are found in the model's stored knowledge, a first training sample, its corresponding historical training labels, and current training labels can be generated based on the erroneous knowledge and the corrected knowledge. The first training sample and relevant labels are then used to correct the erroneous knowledge in the model. Furthermore, much knowledge is dynamically updated. For example, the answer to the question "What is the fastest computer's running speed?" varies from year to year. Therefore, when updating knowledge, a first training sample, its corresponding historical training labels, and current training labels can be generated based on the knowledge before and after the update. The first training sample and relevant labels allow the model to learn new knowledge.

[0043] For example, suppose the first training sample represents "what is the fastest computer running speed". If last year's answer was speed A and this year's answer is speed B, then the historical training label corresponding to the first training sample is speed A, and the current training label corresponding to the first training sample is speed B.

[0044] Specifically, the computer device can obtain a first training sample, the historical training label corresponding to the first training sample, and the current training label locally or from other devices, obtain a second training sample, and fine-tune the language model based on the first training sample, the relevant training label of the first training sample, and the second training sample, so that the language model can replace the old knowledge stored related to the first training sample with new knowledge, and obtain the target language model after knowledge update.

[0045] Step S204: Based on the first training sample and the historical training labels corresponding to the first training sample, locate the target neuron from the pre-trained language model.

[0046] A language model is an artificial intelligence model used to process natural language tasks. A pre-trained language model refers to a language model that has undergone pre-training. Pre-trained language models store a large amount of knowledge. In essence, a language model is pre-trained using a large amount of text data. After pre-training, if knowledge updates are detected, the pre-trained language model is used as the language model requiring knowledge updates. First training samples and their relevant labels are determined, and second training samples are determined. Based on the first and second training samples, the language model requiring knowledge updates is fine-tuned to obtain the target language model. If knowledge updates are detected again, the previously fine-tuned target language model is used as the language model requiring knowledge updates. First training samples and their relevant labels are determined, and second training samples are determined. Based on the first and second training samples, the language model requiring knowledge updates is fine-tuned to obtain a new target language model.

[0047] A language model comprises a large number of neurons, which are the computational units within the model. A target neuron is a neuron in the language model that stores knowledge about the first training sample; it plays a crucial role in the model's output data based on the first training sample. It can be understood that there can be at least one target neuron.

[0048] Specifically, to introduce new knowledge related to the first training sample into the model, the computer device first locates the target neuron and then modifies it in a targeted manner. The computer device can locate the target neuron from a pre-trained language model based on the first training sample and its corresponding historical training labels. Alternatively, attribution learning can be used to locate the target neuron. This involves inputting the first training sample into the language model to obtain a correct output, or inputting the first training sample with added noise to obtain an incorrect output. The relevant representations of neurons at the same location are then replaced with neuron representations from the normal inference stage. If the output data of the language model that was previously interfered with becomes the correct output, then the target neuron has been located.

[0049] Step S206: Input the second training sample into the pre-trained language model to obtain the first predicted label corresponding to the second training sample.

[0050] Step S208: Input the first training sample and the second training sample into the language model during the iteration process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample.

[0051] It's understandable that a pre-trained language model is one that requires knowledge updates. To achieve these updates, the language model needs to be trained iteratively multiple times. The language model in each iteration refers to the model that needs adjustment during the iterative training process. In each iteration, the first and second training samples are input into the language model to be adjusted, resulting in predicted labels for the first and second training samples. The loss is then calculated to fine-tune the language model for the next iteration. In the first iteration, the pre-trained language model is the language model to be adjusted. In any subsequent iteration, the language model to be adjusted is the one adjusted in the previous iteration.

[0052] Specifically, during the first training iteration, the computer inputs the second training sample into the pre-trained language model to obtain the first predicted label corresponding to the second training sample. This second predicted label is the same as the first predicted label for the second training sample. The first training sample is then input into the pre-trained language model again to obtain its corresponding predicted label. The model loss is calculated using each predicted label and each training label. Based on this model loss, the pre-trained language model is fine-tuned to obtain the language model that needs adjustment for the second training iteration. During the second training iteration, if the same second training sample is used, it is not necessary to repeatedly input it into the pre-trained language model; the first predicted label can be obtained directly. However, if a new second training sample is used in the second training iteration, the computer needs to input the new second training sample into the pre-trained language model to obtain the new first predicted label. In the second iteration of training, the computer still needs to input the first and second training samples into the language model that needs to be adjusted in this iteration, to obtain the predicted labels corresponding to the first and second training samples. The model loss is calculated using the latest predicted labels and training labels, and the language model that needs to be adjusted in this iteration is fine-tuned based on the model loss, resulting in the language model that needs to be adjusted in the third iteration. This process is repeated multiple times until the convergence condition is met, resulting in the updated target language model.

[0053] It is understandable that in order to achieve knowledge updates, the language model needs to be trained iteratively multiple times. During the knowledge update process, since the pre-trained model is the language model before the knowledge update, the first predicted label corresponding to the same second training sample is fixed. However, since the language model is constantly fine-tuned during the iteration process, the second predicted label corresponding to the same second training sample changes with the iterative training of the language model.

[0054] Step S210: Based on the predicted label corresponding to the first training sample and the current training label, generate a new knowledge introduction loss; based on the predicted label corresponding to the first training sample and the historical training label, generate an old knowledge forgetting loss; and based on the first predicted label and the second predicted label corresponding to the second training sample, generate other knowledge maintenance losses.

[0055] Specifically, the current training label corresponding to the first training sample contains new knowledge. The computer device can generate a new knowledge introduction loss based on the predicted label corresponding to the first training sample and the current training label. This new knowledge introduction loss is used to make the predicted label increasingly closer to the current training label, thereby introducing new knowledge into the language model. For example, a new knowledge introduction loss can be generated based on the label difference between the predicted label corresponding to the first training sample and the current training label; the smaller the label difference, the smaller the new knowledge introduction loss. The historical training labels corresponding to the first training sample contain old knowledge. The computer device can generate an old knowledge forgetting loss based on the predicted label corresponding to the first training sample and the historical training labels. This old knowledge forgetting loss is used to make the predicted label increasingly distant from the historical training labels, thereby allowing the language model to forget old knowledge. For example, an old knowledge forgetting loss can be generated based on the label difference between the predicted label corresponding to the first training sample and the historical training labels; the larger the label difference, the smaller the old knowledge forgetting loss.

[0056] It's understandable that to achieve knowledge updates, the language model needs multiple fine-tunings. Before the first fine-tuning, the first and second predicted labels are the same. As the language model is fine-tuned, the second predicted label changes accordingly. The first training sample is the training sample whose training label has changed; the first training sample and related labels represent the new knowledge that needs to be learned. The second training sample is the training label whose training label has not changed; the second training label represents other knowledge. The computer can generate an "other knowledge maintenance loss" based on the first and second predicted labels corresponding to the second training sample. This loss prevents the first and second predicted labels from drifting further apart, thus avoiding the influence of other knowledge on the language model during editing. For example, the other knowledge maintenance loss is generated based on the label difference between the first and second predicted labels corresponding to the second training sample; the smaller the label difference, the smaller the other knowledge maintenance loss. It can be understood that the other knowledge maintenance loss ensures the similarity of behavior between the old and new models by minimizing the difference between the output distribution of the optimized model and the original model, thereby maintaining the model's stability.

[0057] Step S212: Based on the loss of introducing new knowledge, the loss of forgetting old knowledge, and the loss of maintaining other knowledge, the neuron parameters of the target neuron in the language model during the iteration process are adjusted until the convergence condition is met, and the target language model after knowledge update is obtained.

[0058] The convergence condition is the criterion used to determine whether the model has converged. Convergence conditions include, but are not limited to, at least one of the following: model loss is greater than a preset loss value, the number of model iterations is greater than a preset number of iterations, or the rate of change of model loss is less than a preset rate of change. The target language model refers to the language model that has completed knowledge updates.

[0059] Specifically, after calculating the losses from new knowledge acquisition, forgetting old knowledge, and other knowledge maintenance, the computer device can derive the total model loss based on these losses. This total model loss is then backpropagated to adjust the neuron parameters of the target neuron in the language model during the iterative process. For example, the total model loss can be obtained by adding the losses from new knowledge acquisition, forgetting old knowledge, and other knowledge maintenance; the average of these losses can be used as the total model loss; or a weighted sum can be calculated to obtain the total model loss; and so on. Iterative training is used to iteratively adjust the neuron parameters of the target neuron until a convergence condition is met, resulting in the updated target language model. For example, the convergence condition might include a model iteration count greater than a preset iteration count. If the preset iteration count is 10, then the language model obtained by adjusting the neuron parameters of the target neuron in the 11th iteration is taken as the target language model.

[0060] Understandably, in traditional techniques, updating knowledge in a language model requires retraining the model and adjusting all its parameters, resulting in excessive time and financial costs. However, the method in this application first locates the target neurons related to new knowledge, then performs small-batch iterative knowledge updates on these neurons—essentially fine-tuning them—allowing the model to learn new knowledge and achieving rapid model editing (i.e., knowledge updating), thus improving the efficiency of model editing (i.e., knowledge updating efficiency). Furthermore, the model loss includes not only new knowledge introduction loss and other knowledge maintenance losses, but also old knowledge forgetting loss. The new knowledge introduction loss enables the model to output new knowledge when faced with specific inputs, the old knowledge forgetting loss enables the model to forget old knowledge when faced with specific inputs, and other knowledge maintenance losses enable the model to maintain its original output when faced with other inputs. However, in the localization phase, the target neuron is located using existing knowledge, while in the fine-tuning phase, the loss for introducing new knowledge is calculated based on the new knowledge. This inconsistency between the two phases leads to a problem of inconsistent targets. Therefore, to improve the accuracy of model editing (i.e., knowledge update accuracy), this application's method further introduces an existing knowledge forgetting loss. This loss, calculated based on existing knowledge, helps align the localization and fine-tuning phases, resulting in better model editing performance. Thus, by forgetting existing knowledge, introducing new knowledge, and maintaining other knowledge unchanged, this application's method ensures that the model accurately replaces existing knowledge with new knowledge without affecting other knowledge, thereby improving the accuracy of model editing.

[0061] In one embodiment, the convergence difficulty of the convergence condition is determined based on the data complexity of the first training sample. Convergence difficulty is positively correlated with data complexity; the more complex the first training sample, the higher the convergence difficulty. For example, the first training sample can be converted into a question input to a language model, and the language model outputs the answer to the question. The longer the question, the higher the data complexity of the first training sample. Another example is that the convergence condition includes a preset number of iterations; the larger the preset number of iterations, the higher the convergence difficulty. In this way, different first training samples correspond to different convergence conditions, achieving personalized convergence and further ensuring the accuracy of model editing.

[0062] In one embodiment, the first training sample is the training sample whose label changes during the current time period, and the second training sample is the training sample whose label does not change during the current time period. It can be understood that the language model can be periodically updated, allowing it to learn the latest knowledge. For example, the language model can be updated quarterly, with the current time period referring to the current quarter. The first training sample and its training label are determined based on the updated knowledge during the current time period, and the second training sample is determined based on the unchanged knowledge during the current time period. Alternatively, the language model can be updated according to user needs. For example, if a user triggers a knowledge update task for the model, the current time period is determined based on the task trigger time, the first training sample and its training label are determined based on the newly added knowledge during the current time period, and the second training sample is determined based on the unchanged knowledge during the current time period.

[0063] It's understandable that if there are multiple first training samples, meaning multiple new knowledge points, the language model can learn each new knowledge point sequentially. For example, if there are three first training samples, namely first training sample A, first training sample B, and first training sample C, then firstly, the target neuron 'a' corresponding to first training sample A is located in the language model, and fine-tuned through iterative training. Next, the target neuron 'b' corresponding to first training sample B is located in the language model, and fine-tuned through iterative training. Finally, the target neuron 'c' corresponding to first training sample C is located in the language model, and fine-tuned through iterative training.

[0064] It is understood that "multiple" in this application refers to at least two.

[0065] In the aforementioned language model knowledge update method, when the training label of the first training sample is updated, the target neuron storing relevant knowledge of the first training sample is located in the language model. This target neuron is then fine-tuned so that it can store new knowledge related to the first training sample, enabling the model to use this new knowledge for data processing. Fine-tuning the target neuron instead of retraining the language model effectively improves the model's knowledge update efficiency. The current training label corresponding to the first training sample contains new knowledge. Based on the predicted label of the first training sample and the current training label, a new knowledge introduction loss is generated, which helps the model remember new knowledge. Similarly, the historical training label corresponding to the first training sample contains old knowledge. Based on the predicted label of the first training sample and the historical training label, an old knowledge forgetting loss is generated, which helps the model forget old knowledge. By combining remembering new knowledge with forgetting old knowledge, knowledge replacement can be effectively achieved, thereby improving the model's knowledge update accuracy. The old knowledge forgetting loss also helps align the localization and fine-tuning stages, as the localization of the target neuron is based on old knowledge, and the old knowledge forgetting loss is also based on old knowledge. Based on the first and second predicted labels corresponding to the second training samples, other knowledge maintenance losses are generated. These losses help avoid affecting other knowledge in the model when fine-tuning the target neuron. By adjusting the neuron parameters of the target neuron in the language model based on the new knowledge introduction loss, old knowledge forgetting loss, and other knowledge maintenance losses, the old knowledge in the model can be effectively replaced with new knowledge without affecting other knowledge in the model, thus ensuring the accuracy of knowledge updates.

[0066] In one embodiment, locating the target neuron from the pre-trained language model based on the first training sample and the corresponding historical training labels includes:

[0067] Input the first training sample into the pre-trained language model to obtain the first neuron features output by each of the multiple neurons in the pre-trained language model, as well as the first predicted label corresponding to the first training sample.

[0068] Noise is added to the first training sample, and the first training sample with added noise is input into the pre-trained language model to obtain the second neuron features output by each of the multiple neurons in the pre-trained language model and the second predicted label corresponding to the first training sample.

[0069] Based on the sequential replacement of the corresponding second neuron features with multiple first neuron features, and the model inference continues after the replacement, the neuron that converts the second predicted label into the first predicted label is taken as the target neuron.

[0070] The first neuron feature is the feature vector output by the neurons in the language model when the input data is unnoised data. The second neuron feature is the feature vector output by the neurons in the language model when the input data is noisy data. The first training sample is input into the pre-trained language model to obtain the first predicted label corresponding to the first training sample; the first training sample with added noise is input into the pre-trained language model to obtain the second predicted label corresponding to the first training sample.

[0071] Specifically, attribution learning can be used to locate the target neuron. The computer device can input a first training sample into a pre-trained language model to obtain the first neuron features output by each neuron in the pre-trained language model, as well as the first predicted label corresponding to the first training sample. That is, the first training sample is input into the model, and the model outputs the correct label through inference. The computer device can also add noise to the first training sample and input the noisy first training sample into the pre-trained language model to obtain the second neuron features output by each neuron in the pre-trained language model, as well as the second predicted label corresponding to the first training sample. For example, the first training sample needs to be converted into a feature vector and input into the model. Gaussian noise is added to the feature vector, and the noisy feature vector is input into the model. Of course, other types of noise can also be added. That is, the noisy first training sample is input into the model, and the model outputs the incorrect label through inference. The computer device sequentially replaces the corresponding second neuron features based on the multiple first neuron features, and continues model inference after the replacement, identifying the neuron that converts the second predicted label into the first predicted label as the target neuron. In other words, the neuronal representations (i.e., neuronal features) of the normal inference stage of the input data are used to replace the neuronal representations of neurons at the same position in the inference stage where the input data is disturbed. The output of the model after the replacement is observed, and the neuron that makes the output of the model change from the wrong label to the normal label is taken as the target neuron.

[0072] In a specific application, refer to Figure 3The language model includes neurons, attention layers, and a multilayer perceptron (MLP). When a first training sample without added noise is input into the language model, the model infers and outputs the correct answer. When a first training sample with added noise is input into the language model, the model infers and outputs an incorrect answer. It can be understood that the correct answer refers to the correct answer before the knowledge was updated, and the incorrect answer refers to the incorrect answer before the knowledge was updated. If replacing the correct neuron representation on the left with the neuron representation on the right results in the previously incorrect output on the right becoming the correct output, then this neuron plays a crucial role in the model's output, indicating that this neuron stores relevant knowledge from the first training sample, and this neuron is then selected as the target neuron.

[0073] In one embodiment, when there are multiple first training samples, i.e., when multiple pieces of knowledge need to be updated, if the overlap rate between the target neurons corresponding to different first training samples is greater than the overlap rate threshold, the neuron parameters of different knowledge can be adjusted synchronously to further improve the knowledge update efficiency. For multiple first training samples with an overlap rate greater than the overlap rate threshold between target neurons, a new knowledge introduction loss is generated based on the predicted labels and current training labels corresponding to each of the multiple first training samples. An old knowledge forgetting loss is generated based on the predicted labels and historical training labels corresponding to each of the multiple first training samples. Other knowledge maintenance losses are generated based on the first and second predicted labels corresponding to the second training samples. Based on the new knowledge introduction loss, old knowledge forgetting loss, and other knowledge maintenance losses, the neuron parameters of the target neurons corresponding to the multiple first training samples in the language model during the iteration process are adjusted until the convergence condition is met, and the updated target language model is obtained.

[0074] In the above embodiments, the neuronal representations of neurons in the reasoning stage where the input data is normal are used to replace the neuronal representations of neurons in the same position in the reasoning stage where the input data is disturbed. The output of the model after the replacement is observed. The neurons that make the output of the model change from the wrong label to the normal label are used as target neurons, which can accurately locate neurons that store old knowledge.

[0075] In one embodiment, reference Figure 4 Based on the predicted label corresponding to the first training sample and the current training label, a new knowledge introduction loss is generated, and based on the predicted label corresponding to the first training sample and the historical training label, an old knowledge forgetting loss is generated, including:

[0076] Step S402: Obtain the predicted probability corresponding to the current training label from the predicted label corresponding to the first training sample as the first probability, and generate a new knowledge introduction loss based on the first probability; the new knowledge introduction loss is negatively correlated with the first probability.

[0077] Step S404: Obtain the predicted probability corresponding to the historical training label from the predicted label corresponding to the first training sample as the second probability, and generate the old knowledge forgetting loss based on the second probability; the old knowledge forgetting loss is positively correlated with the second probability.

[0078] Specifically, the training samples are input into the language model to obtain the predicted labels corresponding to the training samples. The predicted labels corresponding to the training samples include the predicted probabilities of multiple words or characters as the model's output data.

[0079] When generating a new knowledge introduction loss based on the predicted label of the first training sample and the current training label, the computer device can obtain the predicted probability corresponding to the current training label from the predicted label of the first training sample as the first probability. For example, taking the current training label as "Zhang San", the computer device obtains the predicted probability corresponding to "Zhang" and the predicted probability corresponding to "San" from the predicted labels of the first training sample, and obtains the first probability based on the predicted probabilities of "Zhang" and "San". Furthermore, the computer device can generate a new knowledge introduction loss based on the first probability, and the new knowledge introduction loss is negatively correlated with the first probability; that is, the larger the first probability, the smaller the new knowledge introduction loss. The new knowledge introduction loss ensures the accuracy of knowledge updates by maximizing the probability of the latest correct answer.

[0080] Similarly, when generating the old knowledge forgetting loss based on the predicted labels and historical training labels corresponding to the first training sample, the computer device can obtain the predicted probabilities corresponding to the historical training labels from the predicted labels corresponding to the first training sample as the second probability. The old knowledge forgetting loss is generated based on the second probability, and the old knowledge forgetting loss is positively correlated with the second probability; that is, the smaller the second probability, the smaller the loss from introducing new knowledge. The old knowledge forgetting loss ensures the accuracy of knowledge updates by minimizing the probability of the latest incorrect answer.

[0081] In the above embodiments, the predicted probability corresponding to the current training label is obtained from the predicted labels corresponding to the first training sample as a first probability. A new knowledge introduction loss is generated based on the first probability, which ensures the accuracy of knowledge updates by maximizing the probability of the latest correct answer. The predicted probability corresponding to the historical training labels is obtained from the predicted labels corresponding to the first training sample as a second probability, which is used to generate an old knowledge forgetting loss. The old knowledge forgetting loss ensures the accuracy of knowledge updates by minimizing the probability of the latest incorrect answer.

[0082] In one embodiment, based on a second probability, a loss for forgetting old knowledge is generated, including:

[0083] Based on the second probability, a first forgetting loss is generated; the first forgetting loss is positively correlated with the second probability.

[0084] A second forgetting loss is generated based on the probability difference between the first and second probabilities; the second forgetting loss is negatively correlated with the probability difference.

[0085] The loss of old knowledge is obtained based on at least one of the first forgetting loss and the second forgetting loss.

[0086] Specifically, the loss from forgetting old knowledge can be calculated in several ways. The computer device can generate a first forgetting loss based on a second probability. For example, substituting the second probability into a custom logarithmic loss function yields the first forgetting loss. The first forgetting loss is positively correlated with the second probability; that is, the smaller the second probability, the smaller the first forgetting loss. Since the model training objective is to minimize this loss, such a first forgetting loss helps to reduce the probability of the model outputting an incorrect answer. The computer device can also generate a second forgetting loss based on the probability difference between the first and second probabilities. For example, calculating the difference between the first and second probabilities yields the second forgetting loss. The second forgetting loss is negatively correlated with the probability difference; that is, the larger the probability difference, the smaller the second forgetting loss. Since the model training objective is to minimize this loss, such a first forgetting loss helps to reduce the probability of the model outputting an incorrect answer compared to the probability of outputting a correct answer. Finally, the computer device can obtain the loss from forgetting old knowledge based on at least one of the first and second forgetting losses. For example, the first forgetting loss can be used as the loss from forgetting old knowledge; the second forgetting loss can be used as the loss from forgetting old knowledge; the sum of the first and second forgetting losses can be used as the loss from forgetting old knowledge; and so on.

[0087] In the above embodiments, a first forgetting loss is generated based on a second probability, and a second forgetting loss is generated based on the probability difference between the first and second probabilities. The first forgetting loss and the second forgetting loss are different forms of forgetting loss. The old knowledge forgetting loss is obtained based on at least one of the first forgetting loss and the second forgetting loss, which helps to improve the flexibility and diversity of the old knowledge forgetting loss.

[0088] In one embodiment, based on the predicted labels corresponding to the first training sample and the historical training labels, an old knowledge forgetting loss is generated, including:

[0089] Data augmentation is performed on the first training sample and historical training labels to obtain multiple reference training samples and training labels corresponding to the multiple reference training samples respectively.

[0090] Multiple reference training samples are input into the language model during the iterative process to obtain the predicted labels corresponding to the multiple reference training samples respectively.

[0091] Based on the predicted label and historical training label corresponding to the first training sample, and the predicted label and training label corresponding to multiple reference training samples, an old knowledge forgetting loss is generated.

[0092] Data augmentation is used to increase the diversity of training data. By augmenting the first training sample and historical training labels, more similar training samples and labels can be obtained. The reference training sample is a training sample similar to the first training sample, and the training label corresponding to the reference training sample is a training label similar to the historical training label corresponding to the first training sample.

[0093] Specifically, to enhance the robustness of the model, data augmentation can be performed on the existing knowledge. The computer device can augment the first training sample and historical training labels to obtain multiple reference training samples and their corresponding training labels. The reference training samples are those with the same meaning as the first training sample but expressed differently, and their corresponding training labels are those with the same meaning as the historical training labels corresponding to the first training sample but expressed differently, or, conversely, those are the same as the historical training labels corresponding to the first training sample. The computer device can then input the first training sample and the multiple reference training samples into the language model during the iterative process. The model processes the input data to obtain the predicted label for the first training sample and the predicted labels for each of the multiple reference training samples. Finally, the computer device can generate an old knowledge forgetting loss based on the predicted label and historical training label for the first training sample, and the predicted and training labels for each of the multiple reference training samples. For example, from the predicted labels corresponding to the first training sample, the predicted probability corresponding to its historical training labels is obtained as the second probability, and from the predicted labels corresponding to the reference training sample, the predicted probability corresponding to its training labels is obtained as the second probability. Based on each second probability, the old knowledge forgetting loss is generated.

[0094] In the above embodiments, data augmentation can enrich the amount of training data representing old knowledge. Generating old knowledge forgetting loss based on multiple training data can improve the accuracy of old knowledge forgetting loss, thereby helping to improve the robustness of the model.

[0095] In one embodiment, data augmentation is performed on the first training sample and historical training labels to obtain multiple reference training samples and training labels corresponding to the multiple reference training samples, including:

[0096] Based on the first training sample and historical training labels, old knowledge statements are obtained;

[0097] The old knowledge statements are reconstructed to obtain the first reference statement. The keywords in the old knowledge statements are replaced with synonyms to obtain the second reference statement. The old knowledge statements are then back-translated to obtain the third reference statement.

[0098] The reference training samples and their corresponding training labels are determined from the first, second, and third reference statements, respectively, resulting in multiple reference training samples and their corresponding training labels.

[0099] This process involves converting the first training sample and historical training labels into statements to express knowledge, resulting in old knowledge statements. For example, the first training sample includes city A and its mayor, and the corresponding historical training label includes citizen a1. The old knowledge statement could be that the mayor of city A is citizen a1.

[0100] Sentence reconstruction refers to rearranging and adjusting existing sentences. For example, reconstructing "The mayor of city A is citizen a1" yields "Citizen a1 is the mayor of city A".

[0101] Keywords in existing knowledge statements refer to important words or phrases within those statements. For example, at least one of the subject, predicate, or object in an existing knowledge statement can be considered a keyword. Synonym substitution refers to replacing keywords in existing knowledge statements with their synonyms. For example, if city A has an alias, then "city A" in the existing knowledge statement can be replaced with its alias.

[0102] Back-translation refers to translating existing knowledge statements into another language and then back into the original language. For example, if the existing knowledge statement is in Chinese, translating it into English and then back into Chinese can yield a new statement that is equivalent to the existing knowledge statement.

[0103] Specifically, data augmentation can be performed in various ways. The computer device can obtain old knowledge statements based on the first training sample and historical training labels. For example, it can determine the subject, predicate, and object from the first training sample and historical training labels, and compose old knowledge statements based on these elements. The computer device can augment the old knowledge statements in various ways to obtain new statements, and generate reference training samples and their training labels based on these new statements. Specifically, the old knowledge statements can be reconstructed to change their structure, resulting in the first reference statement. Alternatively, keywords in the old knowledge statements can be replaced with synonyms to obtain the second reference statement. Finally, the old knowledge statements can be back-translated to obtain the third reference statement. The computer device can then determine reference training samples and their corresponding training labels from the first reference statement, the second reference statement, and the third reference statement, thereby obtaining multiple reference training samples and their corresponding training labels.

[0104] It is understandable that there can be at least one first reference statement, at least one second reference statement, and at least one third reference statement.

[0105] In a specific application, (s, p, o) represents a triple of knowledge, where s represents the subject, p represents the predicate, and o represents the object. These three components define a piece of knowledge. For example, the triple (City A, Mayor, Citizen X) represents the knowledge that the mayor of City A is citizen X. It can be understood that (s, p, o_old) represents old knowledge, and (s, p, o_new) represents new knowledge. (See reference) Figure 5 For (s, p, o_old) old knowledge, the knowledge triples are converted into sentence expressions. Through sentence reconstruction, synonym replacement, and back translation, an expanded old knowledge expression can be obtained. The expanded old knowledge expression is used in model training to fine-tune the neuron parameters of the target neuron, which can effectively improve the robustness of the model.

[0106] In the above embodiments, data expansion through sentence reconstruction, synonym replacement, and back-translation can yield a large amount of training data representing old knowledge, thereby increasing the richness of the training data and helping to improve the accuracy of knowledge updates.

[0107] It's understandable that, besides augmenting existing knowledge with data, data augmentation can also be applied to new knowledge. Specifically, the first training sample and the current training label are augmented to obtain multiple first reference training samples and their corresponding first training labels. Similarly, the first training sample and historical training labels are augmented to obtain multiple second reference training samples and their corresponding second training labels. The first training sample, first reference training sample, and second reference training sample are then input into the model to obtain their respective predicted labels. Based on the predicted labels of the first training samples and the current training label, and the predicted labels of the first reference training samples and their first training labels, a new knowledge introduction loss is generated. Finally, based on the predicted labels of the first training samples and their historical training labels, and the predicted labels and second training labels of the second reference training samples, an existing knowledge forgetting loss is generated.

[0108] In a specific application, the formula for calculating the loss introduced by new knowledge is as follows:

[0109]

[0110] in, Indicating targeting The new knowledge (i.e., the current training label) of the first training sample. Indicates will Substitute p (prompt, model prompt word) to get the data that needs to be input into the model. This typically represents a question that needs to be answered by the model. The question is input into the model, and the model outputs the answer. Indicates will Input Model The model will The probability of outputting the answer. It's understandable that the training goal of the model is to increase the probability of... The probability of outputting the answer. N represents the number of training samples augmented with new knowledge. Let j represent the j-th training sample. The purpose of loss (introduction) is to help the model remember new knowledge.

[0111] In a specific application, the formula for calculating the first forgetting loss is as follows:

[0112]

[0113] Where o represents targeting (i.e., the prior knowledge of the first training sample, i.e., the historical training labels). Indicates will Input Model The model outputs the probability of 'o' as the answer. This can be understood as the training objective of the model being to reduce the probability of outputting 'o' as the answer. M represents the number of data augmentations performed on the first training sample for prior knowledge. Let j represent the j-th training sample. The purpose of loss (forgetting) is to make the model forget old knowledge.

[0114] In a specific application, the formula for calculating the first forgetting loss is as follows:

[0115]

[0116] It's understandable that 'o' represents targeting... (i.e., the prior knowledge of the first training sample, i.e., the historical training labels). Indicates will Input Model The model outputs the probability of 'o' as the answer. This can be understood as the training objective of the model being to reduce the probability of outputting 'o' as the answer. M represents the number of data augmentations performed on the first training sample for prior knowledge. Let j represent the j-th training sample. The purpose of loss (forgetting) is to make the model forget old knowledge.

[0117] In a specific application, the formula for calculating the second forgetting loss is as follows:

[0118]

[0119] in, Indicating targeting (i.e., the new knowledge of the first training sample, i.e., the current training label), o represents the new knowledge for the first training sample. (i.e., the prior knowledge of the first training sample, i.e., the historical training labels). Indicates will Input Model The model will The probability of outputting as an answer. Will Input Model The model outputs the probability of 'o' as the answer. The training objective of the model is to increase the probability of outputting 'o' as the answer compared to... The probability of it being output as an answer is low. The purpose of Loss (forgetting) is to help the model forget old knowledge.

[0120] For example, refer to Figure 6Let (s, p, o_old) represent old knowledge and (s, p, o_new) represent new knowledge. Expanding (s, p, o_new) yields N new knowledge representations. These new knowledge representations are then converted into training samples and training labels. The training samples are input into the model, and the model outputs the predicted labels corresponding to the training samples. The model loss is calculated based on the predicted labels and training labels, yielding the new knowledge introduction loss. Similarly, expanding (s, p, o_old) yields M old knowledge representations. These old knowledge representations are then converted into training samples and training labels. The training samples are input into the model, and the model outputs the predicted labels corresponding to the training samples. The model loss is calculated based on the predicted labels and training labels, yielding the old knowledge forgetting loss.

[0121] In a specific application, the formula for calculating the knowledge maintenance loss is as follows:

[0122]

[0123] Where x represents the second training sample. Indicates model prompt words, This typically represents a question that needs to be answered by the model. The question is input into the model, and the model outputs the answer. Indicates will Input Model ,Model The probability distribution of the output. Indicates will Input model G, output probability distribution of model G. G can be understood as representing a pre-trained language model. This represents the language model during the iterative process. To enable the model to learn new knowledge, it needs to undergo multiple training iterations. It is constantly changing, while G is constant. This refers to calculating the KL divergence. The training goal of the model is to ensure that the output of the modified model is consistent with that of the original model for other knowledge. The role of loss (maintenance) is to ensure that the model does not affect the knowledge representation of other knowledge when updating new knowledge.

[0124] In one embodiment, based on the new knowledge introduction loss, old knowledge forgetting loss, and other knowledge maintenance losses, the neuron parameters of the target neuron in the language model during the iterative process are adjusted until the convergence condition is met, resulting in the knowledge-updated target language model, including:

[0125] Adjust the loss for forgetting old knowledge based on the loss weight for forgetting old knowledge;

[0126] Based on the loss from introducing new knowledge, the loss from maintaining other knowledge, and the adjusted loss from forgetting old knowledge, a comprehensive loss is obtained.

[0127] Based on the comprehensive loss, the neuron parameters of the target neurons in the language model during the iteration process and the loss weights for the loss of old knowledge forgetting are adjusted until the convergence condition is met, and the target language model after knowledge update is obtained.

[0128] The loss weights for the loss due to forgetting old knowledge are used to adjust the weight values ​​of the loss due to forgetting old knowledge. These loss weights are also parameters that the model needs to learn.

[0129] Specifically, the computer device can adjust the loss for forgetting old knowledge based on the loss weights applied to the forgetting of old knowledge. It adds the loss for introducing new knowledge, the loss for maintaining other knowledge, and the adjusted loss for forgetting old knowledge to obtain a comprehensive loss. This comprehensive loss is then backpropagated to adjust relevant parameters. The parameters that need adjustment include the neuron parameters of the target neurons in the language model during the iterative process, as well as the loss weights applied to the forgetting of old knowledge. Iterative training is used to iteratively adjust the neuron parameters of the target neurons and the loss weights applied to the forgetting of old knowledge until the convergence condition is met, resulting in the updated target language model.

[0130] In one embodiment, the loss weights for the loss due to forgetting old knowledge are learnable parameters between 0 and 1. The neuron parameters of the target neuron and the loss weights for the loss due to forgetting old knowledge can be adjusted using a gradient descent algorithm based on the comprehensive loss.

[0131] In the above embodiments, based on the loss weights for the loss due to the forgetting of old knowledge, the loss for introducing new knowledge, the loss for maintaining other knowledge, and the loss for forgetting old knowledge are weighted and fused to obtain a comprehensive loss. The loss weights for the loss due to the forgetting of old knowledge help balance the model's fitting ability and generalization ability. By adjusting the neuron parameters of the target neuron in the language model during the iterative process based on the comprehensive loss, as well as the loss weights for the loss due to the forgetting of old knowledge, the neuron parameters can be optimized by adjusting the loss weights, effectively balancing the model's fitting ability and generalization ability.

[0132] In a specific application, the formula for calculating the overall loss is as follows:

[0133]

[0134] in, This represents the loss weight for the loss due to forgetting old knowledge. It can be... You can set it to a fixed value, such as 0.5. Set to a learnable parameter between 0 and 1.

[0135] In one embodiment, obtaining a first training sample whose label has changed, a second training sample whose label has not changed, and the historical training label and current training label corresponding to the first training sample includes:

[0136] Retrieve the first knowledge triplet whose content has been modified in the current time period and the second knowledge triplet whose content has not been modified.

[0137] The first training sample is obtained based on the unmodified content in the first knowledge triple. For the first knowledge triple, the historical training label corresponding to the first training sample is obtained based on the content before the modification position. The current training label corresponding to the first training sample is obtained based on the content after the modification position.

[0138] The second training sample is obtained based on the second knowledge triplet.

[0139] Here, "current time period" refers to the current time period. It's understandable that some knowledge changes over time. The first training sample is the training sample whose training label changed during the current time period. The historical training label corresponding to the first training sample refers to the training label before the change, and the current training label corresponding to the first training sample refers to the training label after the change. The second training sample is the training sample whose training label did not change during the current time period.

[0140] A knowledge triple is a triple used to define knowledge. For example, (s, p, o) represents a knowledge triple, where s represents the subject, p represents the predicate, and o represents the object. A first knowledge triple is one whose content has been modified in the current time period; that is, a first knowledge triple represents a knowledge triple whose knowledge has been updated. A second knowledge triple is one whose content has not been modified in the current time period; that is, a second knowledge triple represents a knowledge triple whose knowledge has not been updated.

[0141] The content modification position of the first knowledge triple refers to the location within the first knowledge triple where the content is modified. For example, (s, p, o) represents a knowledge triple; if o is modified, then the position of o is the content modification position. It can be understood that the content modification position can be any one of s, p, or o.

[0142] Specifically, the first and second training samples can be determined based on knowledge triples. The computer device can acquire a first knowledge triple whose content has been modified in the current time period, determine the first training sample based on the first knowledge triple, acquire a second knowledge triple whose content has not been modified in the current time period, and determine the second training sample based on the second knowledge triple. For the first knowledge triple, the computer device can obtain the first training sample based on the unmodified content in the first knowledge triple, obtain the historical training label corresponding to the first training sample based on the content before the modification, and obtain the current training label corresponding to the first training sample based on the content after the modification. For example, (s, p, o_old) represents the first knowledge triple before modification, and (s, p, o_new) represents the first knowledge triple after modification. Since 'o' in the knowledge triple has changed, s and p in the knowledge triple constitute the first training sample, o_old serves as the historical training label corresponding to the first training sample, and o_new serves as the current training label corresponding to the first training sample. For the second knowledge triple, the computer device determines the second training sample based on the second knowledge triple, and combines any two elements in the second knowledge triple to form the second training sample.

[0143] In one embodiment, when an update to the knowledge graph is detected, a first knowledge triplet and a second knowledge triplet are determined from the knowledge graph.

[0144] In the above embodiments, the first training sample and the second training sample can be quickly determined based on the knowledge triples. The first training sample and its corresponding historical training label and current training label are determined based on the first knowledge triples whose content has been modified in the current time period. The second training sample is determined based on the second knowledge triples whose content has not been modified in the current time period.

[0145] In one embodiment, inputting a first training sample and a second training sample into a language model during the iterative process to obtain a predicted label corresponding to the first training sample and a second predicted label corresponding to the second training sample includes:

[0146] Obtain the issue template based on the unmodified content;

[0147] Based on the unchanged content, fill in the question template to obtain the training question;

[0148] The training question is input into the language model during the iteration process to obtain the predicted answer corresponding to the training question, and the predicted answer is used as the predicted label corresponding to the first training sample.

[0149] Among them, the question template is a template used to fill in data and generate questions.

[0150] Specifically, language models can be used to handle question-answering tasks. During the fine-tuning phase, questions can be input into the language model, and the language model can output the answer to the question through model reasoning.

[0151] The first training sample is generated based on the unmodified content of the first knowledge triple. The computer device can obtain a matching question template based on the unmodified content, and then fill the question template with the unmodified content to obtain the training question. For example, if the unmodified content includes a subject and a predicate, a question template set for the subject and predicate is obtained; if the unmodified content includes a subject and an object, a question template set for the subject and object is obtained; if the unmodified content includes a predicate and an object, a question template set for the predicate and object is obtained. The computer device can input the training question into the language model during the iterative process to obtain the predicted answer corresponding to the training question, and use the predicted answer as the predicted label corresponding to the first training sample.

[0152] In one embodiment, the first training sample includes the subject and predicate of the first knowledge triple, the historical training label corresponding to the first training sample includes the object before modification in the first knowledge triple, and the current training label corresponding to the first training sample includes the object after modification in the first knowledge triple. Based on the predicate in the first training sample, a question template set for the predicate is obtained, and the subject in the first training sample is filled into the question template to obtain the training question. It can be understood that subjects are highly variable; setting question templates for predicates facilitates the management of question templates.

[0153] It is understandable. Similarly, for the second training sample, a corresponding question template can be obtained. Based on the second training sample, the question template is filled to obtain the training question. The training question is input into the pre-trained language model to obtain the first predicted answer corresponding to the training question. The first predicted answer is used as the first predicted label corresponding to the second training sample. The training question is input into the language model in the iterative process to obtain the second predicted answer corresponding to the training question. The second predicted answer is used as the second predicted label corresponding to the second training sample.

[0154] In the above embodiments, the question template can better guide the model to generate more accurate and relevant outputs. By converting the first training sample into a training question through the question template, and inputting the training question into the model, the model can output more accurate predicted answers.

[0155] In one embodiment, the language model knowledge update method further includes:

[0156] Get the text to be categorized;

[0157] Input the text to be classified into the target language model to obtain the classification result corresponding to the text to be classified.

[0158] Among them, the text to be classified refers to the text that needs to be classified.

[0159] Specifically, a target language model can be used for text classification. A computer device can acquire the text to be classified locally or from other devices, input the text into the target language model, and the target language model will output the classification result corresponding to the text through model inference. For example, a text classification hint template can be obtained, the text to be classified can be input into the text classification hint template to obtain a text classification question, the text classification question can be input into the target language model, and the target language model will output the classification result corresponding to the text to be classified.

[0160] In the above embodiments, the target language model can be used for text classification. The target language model obtained by fine-tuning the target neurons contains new knowledge and can output accurate text classification results.

[0161] In one embodiment, the language model knowledge update method further includes:

[0162] Identify the target problem;

[0163] Input the target question into the target language model to obtain the target answer to the target question.

[0164] The target problem refers to the problem that needs to be solved.

[0165] Specifically, a target language model can be used to handle question-answering tasks. A computer device can obtain a target question locally or from another device, input the target question into the target language model, and the target language model will output the target answer corresponding to the target question through model inference.

[0166] In the above embodiments, the target language model can be used to process question-and-answer tasks. The target language model obtained by fine-tuning the target neurons contains new knowledge and can output accurate question answers.

[0167] In one specific embodiment, the method of this application can be applied to scenarios involving knowledge updates for chatbots within an application. The application can integrate a chatbot implemented based on an LLM (Large Language Model), which is used to understand user input and generate corresponding responses. The chatbot needs to possess accurate knowledge to produce accurate responses, ensuring a good user experience. Since some knowledge changes over time, the method of this application can be used for small-scale, rapid knowledge iteration of the chatbot during knowledge updates.

[0168] refer to Figure 7The application's server can first locate the target neuron in the chatbot based on existing knowledge, and then fine-tune the neuron parameters of the target neuron based on new knowledge, existing knowledge, and other knowledge, thereby achieving the replacement of old and new knowledge in the chatbot.

[0169] If knowledge is updated, the knowledge before the update can be considered old knowledge, and the updated knowledge can be considered new knowledge. The server can create a first training sample and its corresponding historical training labels based on the old knowledge, and create a current training label for the first training sample based on the new knowledge. The server can also create a second training sample based on the unupdated knowledge. The server can input the first training sample into the chatbot to obtain correct output, and input the first training sample with added noise into the chatbot to obtain incorrect output. The server then replaces the neuron representations of neurons at the same position in the inference stage of the input data with the neuron representations of neurons in the inference stage of the input data that have been disturbed, and observes the output of the model after the replacement. The neuron that changes the model's output from incorrect to normal is selected as the target neuron.

[0170] refer to Figure 8 The server inputs the second training sample into the chatbot before knowledge update (i.e., the pre-trained language model) to obtain the first predicted label corresponding to the second training sample. Then, it inputs the first and second training samples into the chatbot during the iteration process (i.e., the language model during the iteration process) to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample. Based on the predicted label corresponding to the first training sample and the current training label, the server generates a new knowledge introduction loss; based on the predicted label corresponding to the first training sample and the historical training label, it generates an old knowledge forgetting loss; and based on the first and second predicted labels corresponding to the second training sample, it generates other knowledge maintenance losses. The server obtains the total loss based on the new knowledge introduction loss, the old knowledge forgetting loss, and the other knowledge maintenance losses. This total loss is backpropagated to adjust the neuron parameters of the target neuron in the chatbot during the iteration process. The neuron parameters of the target neuron are iteratively adjusted through iterative training until the convergence condition is met, resulting in the chatbot after knowledge update.

[0171] In this application's method, knowledge replacement equals removing old knowledge and introducing new knowledge. The new knowledge introduction loss ensures that after knowledge updates, the model's output should reflect the updated knowledge when faced with the same input. For example, before the knowledge update, the fastest computer's speed is speed A; after the update, it's speed B. The new knowledge introduction loss ensures the model outputs speed B when answering "What is the fastest computer's speed?". It can be understood that target neuron localization is based on old knowledge, while the new knowledge introduction loss is based on new knowledge. To align the localization and fine-tuning stages and achieve better model editing results, an old knowledge forgetting loss is introduced. This loss aims to ensure the model forgets old knowledge after updates. Other knowledge maintenance losses ensure that after knowledge updates, the edited model's output should be consistent with the original model's output when faced with different inputs.

[0172] refer to Figure 9 If the fastest computer speed has been updated from speed A to speed B, and the chatbot is not updated with new knowledge, then when asked "What is the fastest computer speed?", the chatbot will still output speed A. However, after updating the chatbot's knowledge using the method described in this application, the chatbot will be able to output the correct answer, speed B.

[0173] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0174] Based on the same inventive concept, this application also provides a language model knowledge updating apparatus for implementing the language model knowledge updating method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more language model knowledge updating apparatus embodiments provided below can be found in the limitations of the language model knowledge updating method described above, and will not be repeated here.

[0175] In one embodiment, such as Figure 10As shown, a language model knowledge update device is provided, including: a training data acquisition module 1002, a neuron localization module 1004, a model processing module 1006, a loss generation module 1008, and a model editing module 1010, wherein:

[0176] The training data acquisition module 1002 is used to acquire the first training sample whose label has changed, the second training sample whose label has not changed, and the historical training label and the current training label corresponding to the first training sample.

[0177] The neuron localization module 1004 is used to locate the target neuron from the pre-trained language model based on the first training sample and the historical training label corresponding to the first training sample.

[0178] The model processing module 1006 is used to input the second training sample into the pre-trained language model to obtain the first predicted label corresponding to the second training sample; and to input the first training sample and the second training sample into the language model during the iteration process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample.

[0179] The loss generation module 1008 is used to generate a new knowledge introduction loss based on the predicted label corresponding to the first training sample and the current training label, to generate an old knowledge forgetting loss based on the predicted label corresponding to the first training sample and the historical training label, and to generate other knowledge maintenance losses based on the first and second predicted labels corresponding to the second training sample.

[0180] The model editing module 1010 is used to adjust the neuron parameters of the target neuron in the language model during the iterative process based on the new knowledge introduction loss, old knowledge forgetting loss and other knowledge maintenance loss, until the convergence condition is met, and the updated target language model is obtained.

[0181] In one embodiment, the neuron localization module 1004 is further configured to:

[0182] Input the first training sample into the pre-trained language model to obtain the first neuron features output by each of the multiple neurons in the pre-trained language model, as well as the first predicted label corresponding to the first training sample.

[0183] Noise is added to the first training sample, and the first training sample with added noise is input into the pre-trained language model to obtain the second neuron features output by each of the multiple neurons in the pre-trained language model and the second predicted label corresponding to the first training sample.

[0184] Based on the sequential replacement of the corresponding second neuron features with multiple first neuron features, and the model inference continues after the replacement, the neuron that converts the second predicted label into the first predicted label is taken as the target neuron.

[0185] In one embodiment, the loss generation module 1008 is further configured to:

[0186] From the predicted labels corresponding to the first training sample, the predicted probability corresponding to the current training label is obtained as the first probability. Based on the first probability, a new knowledge introduction loss is generated; the new knowledge introduction loss is negatively correlated with the first probability.

[0187] From the predicted labels corresponding to the first training sample, the predicted probabilities corresponding to the historical training labels are obtained as the second probability. Based on the second probability, the old knowledge forgetting loss is generated. The old knowledge forgetting loss is positively correlated with the second probability.

[0188] In one embodiment, the loss generation module 1008 is further configured to:

[0189] Based on the second probability, a first forgetting loss is generated; the first forgetting loss is positively correlated with the second probability.

[0190] A second forgetting loss is generated based on the probability difference between the first and second probabilities; the second forgetting loss is negatively correlated with the probability difference.

[0191] The loss of old knowledge is obtained based on at least one of the first forgetting loss and the second forgetting loss.

[0192] In one embodiment, the loss generation module 1008 is further configured to:

[0193] Data augmentation is performed on the first training sample and historical training labels to obtain multiple reference training samples and training labels corresponding to the multiple reference training samples respectively.

[0194] Multiple reference training samples are input into the language model during the iterative process to obtain the predicted labels corresponding to the multiple reference training samples respectively.

[0195] Based on the predicted label and historical training label corresponding to the first training sample, and the predicted label and training label corresponding to multiple reference training samples, an old knowledge forgetting loss is generated.

[0196] In one embodiment, the loss generation module 1008 is further configured to:

[0197] Based on the first training sample and historical training labels, old knowledge statements are obtained;

[0198] The old knowledge statements are reconstructed to obtain the first reference statement. The keywords in the old knowledge statements are replaced with synonyms to obtain the second reference statement. The old knowledge statements are then back-translated to obtain the third reference statement.

[0199] The reference training samples and their corresponding training labels are determined from the first, second, and third reference statements, respectively, resulting in multiple reference training samples and their corresponding training labels.

[0200] In one embodiment, the model editing module 1010 is further configured to:

[0201] Adjust the loss for forgetting old knowledge based on the loss weight for forgetting old knowledge;

[0202] Based on the loss from introducing new knowledge, the loss from maintaining other knowledge, and the adjusted loss from forgetting old knowledge, a comprehensive loss is obtained.

[0203] Based on the comprehensive loss, the neuron parameters of the target neurons in the language model during the iteration process and the loss weights for the loss of old knowledge forgetting are adjusted until the convergence condition is met, and the target language model after knowledge update is obtained.

[0204] In one embodiment, the training data acquisition module 1002 is further configured to:

[0205] Retrieve the first knowledge triplet whose content has been modified in the current time period and the second knowledge triplet whose content has not been modified.

[0206] The first training sample is obtained based on the unmodified content in the first knowledge triple. For the first knowledge triple, the historical training label corresponding to the first training sample is obtained based on the content before the modification position. The current training label corresponding to the first training sample is obtained based on the content after the modification position.

[0207] The second training sample is obtained based on the second knowledge triplet.

[0208] In one embodiment, the model processing module 1006 is further configured to:

[0209] Obtain the issue template based on the unmodified content;

[0210] Based on the unchanged content, fill in the question template to obtain the training question;

[0211] The training question is input into the language model during the iteration process to obtain the predicted answer corresponding to the training question, and the predicted answer is used as the predicted label corresponding to the first training sample.

[0212] In one embodiment, the language model knowledge update device is also used for:

[0213] Get the text to be categorized;

[0214] Input the text to be classified into the target language model to obtain the classification result corresponding to the text to be classified.

[0215] In one embodiment, the language model knowledge update device is also used for:

[0216] Identify the target problem;

[0217] Input the target question into the target language model to obtain the target answer to the target question.

[0218] The aforementioned language model knowledge update device, when the training label of the first training sample is updated, locates the target neuron storing relevant knowledge of the first training sample in the language model, fine-tunes the target neuron so that it can store new knowledge related to the first training sample, and thus the model can use the new knowledge for data processing. By fine-tuning the target neuron instead of retraining the language model, the knowledge update efficiency of the model can be effectively improved. The current training label corresponding to the first training sample contains new knowledge. Based on the predicted label corresponding to the first training sample and the current training label, a new knowledge introduction loss is generated, which helps the model remember new knowledge. The historical training label corresponding to the first training sample contains old knowledge. Based on the predicted label corresponding to the first training sample and the historical training label, an old knowledge forgetting loss is generated, which helps the model forget old knowledge. By remembering new knowledge and forgetting old knowledge, knowledge replacement can be effectively achieved, thereby improving the accuracy of the model's knowledge update. The old knowledge forgetting loss also helps align the localization stage and the fine-tuning stage. The localization of the target neuron is based on old knowledge, and the old knowledge forgetting loss is also based on old knowledge. Based on the first and second predicted labels corresponding to the second training samples, other knowledge maintenance losses are generated. These losses help avoid affecting other knowledge in the model when fine-tuning the target neuron. By adjusting the neuron parameters of the target neuron in the language model based on the new knowledge introduction loss, old knowledge forgetting loss, and other knowledge maintenance losses, the old knowledge in the model can be effectively replaced with new knowledge without affecting other knowledge in the model, thus ensuring the accuracy of knowledge updates.

[0219] Each module in the aforementioned language model knowledge update device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0220] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 11As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data related to a language model knowledge update method. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a language model knowledge update method.

[0221] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 12 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a language model knowledge update method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.

[0222] Those skilled in the art will understand that Figure 11 , Figure 12The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0223] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0224] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0225] In one embodiment, a computer program product is provided, the computer program product including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0226] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0227] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0228] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0229] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for updating knowledge in a language model, characterized in that, The method includes: Obtain the first training sample whose label has changed, the second training sample whose label has not changed, and the historical training label and current training label corresponding to the first training sample; Based on the first training sample and the historical training labels corresponding to the first training sample, the target neuron is located from the pre-trained language model; The second training sample is input into the pre-trained language model to obtain the first predicted label corresponding to the second training sample; The first training sample and the second training sample are input into the language model during the iterative process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample. Based on the predicted label and the current training label corresponding to the first training sample, a new knowledge introduction loss is generated; based on the predicted label and the historical training label corresponding to the first training sample, an old knowledge forgetting loss is generated; and based on the first and second predicted labels corresponding to the second training sample, other knowledge maintenance losses are generated. Based on the new knowledge introduction loss, the old knowledge forgetting loss, and the other knowledge maintenance loss, the neuron parameters of the target neuron in the language model during the iteration process are adjusted until the convergence condition is met, and the updated target language model is obtained.

2. The method according to claim 1, characterized in that, The step of locating the target neuron from the pre-trained language model based on the first training sample and the corresponding historical training labels includes: The first training sample is input into the pre-trained language model to obtain the first neuron features output by each of the multiple neurons in the pre-trained language model, and the first predicted label corresponding to the first training sample. Noise is added to the first training sample, and the first training sample with added noise is input into the pre-trained language model to obtain the second neuron features output by each of the multiple neurons in the pre-trained language model and the second predicted label corresponding to the first training sample. Based on the sequential replacement of the corresponding second neuron features with multiple first neuron features, and the model inference continues after the replacement, the neuron that converts the second predicted label into the first predicted label is taken as the target neuron.

3. The method according to claim 1, characterized in that, The step of generating a new knowledge introduction loss based on the predicted label corresponding to the first training sample and the current training label, and generating an old knowledge forgetting loss based on the predicted label corresponding to the first training sample and the historical training label, includes: From the predicted labels corresponding to the first training sample, the predicted probability corresponding to the current training label is obtained as the first probability. Based on the first probability, a new knowledge introduction loss is generated. The new knowledge introduction loss is negatively correlated with the first probability. From the predicted labels corresponding to the first training sample, the predicted probability corresponding to the historical training label is obtained as the second probability. Based on the second probability, the old knowledge forgetting loss is generated. The old knowledge forgetting loss is positively correlated with the second probability.

4. The method according to claim 3, characterized in that, The generation of old knowledge forgetting loss based on the second probability includes: Based on the second probability, a first forgetting loss is generated; the first forgetting loss is positively correlated with the second probability; A second forgetting loss is generated based on the probability difference between the first probability and the second probability; the second forgetting loss is negatively correlated with the probability difference. The old knowledge forgetting loss is obtained based on at least one of the first forgetting loss and the second forgetting loss.

5. The method according to claim 1, characterized in that, The step of generating old knowledge forgetting loss based on the predicted label and historical training label corresponding to the first training sample includes: The first training sample and the historical training labels are augmented to obtain multiple reference training samples and training labels corresponding to the multiple reference training samples respectively. The multiple reference training samples are input into the language model during the iterative process to obtain the predicted labels corresponding to the multiple reference training samples respectively. Based on the predicted label and historical training label corresponding to the first training sample, and the predicted label and training label corresponding to the multiple reference training samples, an old knowledge forgetting loss is generated.

6. The method according to claim 5, characterized in that, The step of augmenting the first training sample and the historical training labels to obtain multiple reference training samples and training labels corresponding to the multiple reference training samples includes: Based on the first training sample and the historical training labels, old knowledge statements are obtained; The old knowledge statement is reconstructed to obtain the first reference statement. The keywords in the old knowledge statement are replaced with synonyms to obtain the second reference statement. The old knowledge statement is back-translated to obtain the third reference statement. The reference training samples and their corresponding training labels are determined from the first reference statement, the second reference statement, and the third reference statement, respectively, to obtain multiple reference training samples and their corresponding training labels.

7. The method according to claim 1, characterized in that, The process of adjusting the neuron parameters of the target neuron in the language model during the iterative process based on the new knowledge introduction loss, the old knowledge forgetting loss, and the other knowledge maintenance losses until the convergence condition is met, thereby obtaining the knowledge-updated target language model, includes: The loss for forgetting old knowledge is adjusted based on the loss weight for forgetting old knowledge; Based on the loss from introducing new knowledge, the loss from maintaining other knowledge, and the adjusted loss from forgetting old knowledge, a comprehensive loss is obtained. Based on the comprehensive loss, the neuron parameters of the target neuron in the language model during the iteration process and the loss weight for the loss of old knowledge are adjusted until the convergence condition is met, and the target language model after knowledge update is obtained.

8. The method according to claim 1, characterized in that, The acquisition of the first training sample whose label has changed, the second training sample whose label has not changed, and the historical training label and current training label corresponding to the first training sample includes: Retrieve the first knowledge triplet whose content has been modified in the current time period and the second knowledge triplet whose content has not been modified. The first training sample is obtained based on the unmodified content in the first knowledge triple. For the first knowledge triple, the historical training label corresponding to the first training sample is obtained based on the content before the modification position. The current training label corresponding to the first training sample is obtained based on the content after the modification position. Based on the second knowledge triplet, the second training sample is obtained.

9. The method according to claim 8, characterized in that, The step of inputting the first training sample and the second training sample into the language model during the iterative process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample includes: Obtain the issue template based on the aforementioned unmodified content; Based on the unmodified content, the question template is filled in to obtain the training question; The training question is input into the language model during the iteration process to obtain the predicted answer corresponding to the training question, and the predicted answer is used as the predicted label corresponding to the first training sample.

10. The method according to any one of claims 1 to 9, characterized in that, The method further includes: Get the text to be categorized; The text to be classified is input into the target language model to obtain the classification result corresponding to the text to be classified.

11. The method according to any one of claims 1 to 9, characterized in that, The method further includes: Identify the target problem; The target question is input into the target language model to obtain the target answer corresponding to the target question.

12. A language model knowledge updating device, characterized in that, The device includes: The training data acquisition module is used to acquire a first training sample whose label has changed, a second training sample whose label has not changed, and the historical training label and current training label corresponding to the first training sample; The neuron localization module is used to locate the target neuron from the pre-trained language model based on the first training sample and the historical training labels corresponding to the first training sample. The model processing module is used to input the second training sample into the pre-trained language model to obtain the first predicted label corresponding to the second training sample; and to input the first training sample and the second training sample into the language model during the iterative process to obtain the predicted label corresponding to the first training sample and the second predicted label corresponding to the second training sample. The loss generation module is used to generate a new knowledge introduction loss based on the predicted label and the current training label corresponding to the first training sample, generate an old knowledge forgetting loss based on the predicted label and the historical training label corresponding to the first training sample, and generate other knowledge maintenance loss based on the first and second predicted labels corresponding to the second training sample. The model editing module is used to adjust the neuron parameters of the target neuron in the language model during the iterative process based on the new knowledge introduction loss, the old knowledge forgetting loss, and the other knowledge maintenance loss, until the convergence condition is met, so as to obtain the target language model after knowledge update.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 11.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.

15. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 11.