Serialization model editing method and device

By using knowledge triple data and structure editing loss functions in large-scale language models for parameter update and alignment learning, the ability degradation caused by serialized editing in the existing technology is solved, and the stability in the editing process of the model is improved. and universality.

CN118917399APending Publication Date: 2024-11-08TAOBAO CHINA SOFTWARE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411055522.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

When the existing technology performs serialization editing of large-scale language models, it is easy to lead to capabilities degradation and forgetting problems, resulting in a decline in the general capabilities of the model, and it is impossible to effectively handle long-sequence knowledge editing and multiple knowledge editing scenarios.

Method used

By obtaining the knowledge triple data to be edited, locate the multi-layer perceptron layer of the large-scale language model, determine the structure edit loss function and update the relevant parameters, save it to the knowledge parameter queue, and update and filter edited according to the semantic similarity Parameters to ensure the alignment of parameters in the global parameter space.

Benefits of technology

It effectively reduces the problem of degradation in the ability of large-scale language models in the editing process, improves the reliability and universality of the model in the serialized editing process, and avoids the occurrence of hallucinations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118917399A_ABST
    Figure CN118917399A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a serialization model editing method and device. In the embodiment of the invention, to-be-edited knowledge triple data is obtained, a multi-layer perceptron layer of a large-scale language model is positioned, and a first parameter and a to-be-edited second parameter are determined; determining a structure editing loss function according to the to-be-edited knowledge triple data, the first parameter and the to-be-edited second parameter; updating a second parameter to be edited according to the structure editing loss function; storing the updated second parameter to be edited in a knowledge parameter queue; updating a plurality of edited second parameters in a knowledge parameter queue according to the updated second parameters to be edited; and updating the multi-layer perceptron layer of the large-scale language model by using the updated to-be-edited second parameters and the plurality of updated edited second parameters. By means of the method, the problem of capability degradation generated in the serialization editing process of a large-scale language model can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and more specifically, to a method and device for editing a serialized model. Background Art

[0002] With the development of science and technology, the application of intelligent question-answering systems is becoming more and more extensive. Specifically, after a user asks a question to the intelligent question-answering system, the intelligent question-answering system will give an answer to the question raised by the user. The above question-answering process can be implemented through large-scale language models LLMs, which have the ability to understand, analyze and generate text; the above LLMs have an important disadvantage, that is, due to their large number of parameters, the computational cost of pre-training is huge. When new knowledge needs to be introduced into the pre-trained LLMs, considering the overhead of computing resources and data resources, training cannot be started from scratch. Therefore, it is necessary to accurately modify specific knowledge parameters in LLMs when introducing new knowledge.

[0003] In the prior art, the serialized model editing SME method is used to edit LLMs, but the above SME method is only applicable to single editing and simple knowledge editing. The above SME method can only process a small amount of data and still faces great challenges for long sequence knowledge editing; and, in scenarios involving sequence editing of multiple pieces of knowledge, only multiple edits can be performed. Multiple edits will cause the general ability of LLMs to degrade during the editing process, resulting in forgetting problems, which will in turn affect other parameters in the LLMs during the editing process, causing the above LLMs to produce hallucinations.

[0004] In summary, how to reduce the ability degradation of LLMs during the editing process is a problem that needs to be solved at present. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and apparatus for serialized model editing, which can reduce the problem of capability degradation of large-scale language models during serialized editing.

[0006] In a first aspect, an embodiment of the present invention provides a method for editing a serialized model, the method comprising:

[0007] Acquire knowledge triple data to be edited, wherein the knowledge triple data to be edited includes a head entity, a relationship, and a tail entity;

[0008] Locate the multi-layer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determine the first parameter of the first layer neuron and the second parameter to be edited of the second layer neuron;

[0009] Determining a structure editing loss function according to the knowledge triplet data to be edited, the first parameter and the second parameter to be edited;

[0010] Update the second parameter to be edited of the second layer of neurons corresponding to the knowledge triplet data to be edited according to the structure editing loss function;

[0011] Saving the updated second parameter to be edited to a knowledge parameter queue, wherein the knowledge parameter queue includes a plurality of edited second parameters corresponding to a plurality of groups of edited knowledge triplet data;

[0012] updating a plurality of edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited;

[0013] The multilayer perceptron layer of the large-scale language model is updated using the updated second parameter to be edited and the updated plurality of edited second parameters.

[0014] Optionally, the method further includes:

[0015] A sequence editing loss function is generated according to the knowledge triplet data to be edited, wherein the sequence editing loss function includes a reliability performance loss function, a general performance loss function and a generalization performance loss function.

[0016] Optionally, generating a sequence editing loss function according to the knowledge triplet data to be edited specifically includes:

[0017] Constructing two-dimensional sample data according to the knowledge triplet data to be edited;

[0018] A sequence editing loss function is generated according to the two-dimensional sample data.

[0019] Optionally, the method further includes:

[0020] The large-scale language model is updated according to the structure editing loss function and the sequence editing loss function.

[0021] Optionally, determining the structure editing loss function according to the knowledge triplet data to be edited, the first parameter and the second parameter to be edited specifically includes:

[0022] Generate a first value according to the head entity in the knowledge triple data to be edited and the first parameter;

[0023] Generating a second value according to the relationship in the knowledge triple data to be edited, wherein the second value is a hidden state representation of the relationship in the large-scale language model;

[0024] Iterate the tail entity in the knowledge triple data to be edited by back propagation to generate a third value;

[0025] The structure editing loss function is generated according to the first value, the second value, the third value and the second parameter to be edited.

[0026] Optionally, the step of saving the updated second parameter to be edited to a knowledge parameter queue specifically includes:

[0027] The updated second parameter to be edited is added to the end of the knowledge parameter queue, wherein the multiple edited second parameters in the knowledge parameter queue are arranged in order from oldest to newest in time.

[0028] Optionally, the method further includes:

[0029] respectively determining semantic similarities between a plurality of edited second parameters in the knowledge parameter queue and the updated second parameter to be edited;

[0030] In response to the semantic similarity being less than a first set threshold, the edited second parameter less than the first set threshold is removed from the knowledge parameter queue to generate a candidate knowledge parameter queue.

[0031] Optionally, updating the multiple edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited specifically includes:

[0032] All edited second parameters in the candidate knowledge parameter queue are updated according to the updated second parameter to be edited.

[0033] Optionally, updating the multiple edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited specifically includes:

[0034] Determine at least one edited second parameter in the candidate knowledge parameter queue whose semantic similarity with the updated second parameter to be edited meets a set condition, wherein the set condition is less than a second set threshold and greater than or equal to a first threshold;

[0035] The at least one edited second parameter is updated according to the updated second parameter to be edited.

[0036] In a second aspect, an embodiment of the present invention provides a device for editing a serialized model, the device comprising:

[0037] An acquisition unit, used for acquiring knowledge triple data to be edited, wherein the knowledge triple data to be edited includes a head entity, a relationship and a tail entity;

[0038] A positioning unit, used for positioning the multi-layer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determining the first parameter of the first layer neuron and the second parameter to be edited of the second layer neuron;

[0039] A determination unit, configured to determine a structure editing loss function according to the knowledge triplet data to be edited, the first parameter and the second parameter to be edited;

[0040] An updating unit, used for updating the second parameter to be edited of the second layer of neurons corresponding to the knowledge triple data to be edited according to the structure editing loss function;

[0041] A saving unit, used for saving the updated second parameter to be edited to a knowledge parameter queue, wherein the knowledge parameter queue includes a plurality of edited second parameters corresponding to a plurality of groups of edited knowledge triplet data;

[0042] The updating unit is further used to update the plurality of edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited;

[0043] The updating unit is further used to update the multi-layer perceptron layer of the large-scale language model using the updated second parameter to be edited and the updated plurality of edited second parameters.

[0044] Optionally, the device further comprises:

[0045] A generating unit is used to generate a sequence editing loss function according to the knowledge triple data to be edited, wherein the sequence editing loss function includes a reliability performance loss function, a general performance loss function and a generalization performance loss function.

[0046] Optionally, the generating unit is specifically used for:

[0047] Constructing two-dimensional sample data according to the knowledge triplet data to be edited;

[0048] A sequence editing loss function is generated according to the two-dimensional sample data.

[0049] Optionally, the updating unit is further used for:

[0050] The large-scale language model is updated according to the structure editing loss function and the sequence editing loss function.

[0051] Optionally, the determining unit is specifically configured to:

[0052] Generate a first value according to the head entity in the knowledge triple data to be edited and the first parameter;

[0053] Generating a second value according to the relationship in the knowledge triple data to be edited, wherein the second value is a hidden state representation of the relationship in the large-scale language model;

[0054] Iterate the tail entity in the knowledge triple data to be edited by back propagation to generate a third value;

[0055] The structure editing loss function is generated according to the first value, the second value, the third value and the second parameter to be edited.

[0056] Optionally, the storage unit is specifically used for:

[0057] The updated second parameter to be edited is added to the end of the knowledge parameter queue, wherein the multiple edited second parameters in the knowledge parameter queue are arranged in order from oldest to newest in time.

[0058] Optionally, the generating unit is further used for:

[0059] respectively determining semantic similarities between a plurality of edited second parameters in the knowledge parameter queue and the updated second parameter to be edited;

[0060] In response to the semantic similarity being less than a first set threshold, the edited second parameter less than the first set threshold is removed from the knowledge parameter queue to generate a candidate knowledge parameter queue.

[0061] Optionally, the updating unit is specifically used for:

[0062] All edited second parameters in the candidate knowledge parameter queue are updated according to the updated second parameter to be edited.

[0063] Optionally, the updating unit is specifically used for:

[0064] Determine at least one edited second parameter in the candidate knowledge parameter queue whose semantic similarity with the updated second parameter to be edited meets a set condition, wherein the set condition is less than a second set threshold and greater than or equal to a first threshold;

[0065] The at least one edited second parameter is updated according to the updated second parameter to be edited.

[0066] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, the memory being used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement a method as described in the first aspect or any possible embodiment of the first aspect.

[0067] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing computer program instructions, which, when executed by a processor, implement a method as described in the first aspect or any possible embodiment of the first aspect.

[0068] In an embodiment of the present invention, by acquiring knowledge triple data to be edited, wherein the knowledge triple data to be edited includes a head entity, a relationship and a tail entity; locating the multilayer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determining the first parameter of the first layer neuron and the second parameter to be edited of the second layer neuron; determining the structural editing loss function according to the knowledge triple data to be edited, the first parameter and the second parameter to be edited; updating the second parameter to be edited of the second layer neuron corresponding to the knowledge triple data to be edited according to the structural editing loss function; saving the updated second parameter to be edited to a knowledge parameter queue, wherein the knowledge parameter queue includes multiple edited second parameters corresponding to multiple groups of edited knowledge triple data; updating the multiple edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited; and updating the multilayer perceptron layer of the large-scale language model with the updated second parameter to be edited and the updated multiple edited second parameters. Through the above method, multiple edited second parameters are aligned according to the updated second parameters to be edited, and then the multi-layer perceptron layer of the large-scale language model is updated. Since the knowledge parameters are modified from the perspective of the global parameter space, the ability degradation problem of the large-scale language model during the editing process can be reduced during the serialized model editing process. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0070] Figure 1 It is a flow chart of a method for model editing in the prior art;

[0071] Figure 2 is a flow chart of a method for model editing in an embodiment of the present invention;

[0072] Figure 3is a flow chart of another method for model editing in an embodiment of the present invention;

[0073] Figure 4 is a flow chart of another model editing method in an embodiment of the present invention;

[0074] Figure 5 It is a general performance schematic diagram of an embodiment of the present invention;

[0075] Figure 6 is a schematic diagram of a device for model editing in an embodiment of the present invention;

[0076] Figure 7 is a schematic diagram of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0077] The present application is described below based on embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, some specific details are described in detail. It is possible for those skilled in the art to fully understand the present application without the description of these details. In order to avoid confusing the essence of the present application, known methods, processes, flows, components and circuits are not described in detail.

[0078] In addition, persons of ordinary skill in the art will appreciate that the drawings provided herein are for illustration purposes and are not necessarily drawn to scale.

[0079] Unless the context clearly requires otherwise, the words "include", "comprising" and similar words throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, the meaning is "including but not limited to".

[0080] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.

[0081] In the prior art, a simple Sequential Model Editing (SME) method, a MEND method, and a ROME method are used to edit large-scale language models (LLMs).

[0082] Specifically, the SME method is only applicable to single editing and simple knowledge editing. The SME method can only process small amounts of data and still faces great challenges in editing long sequences of knowledge. Moreover, in scenarios involving serialized editing of multiple pieces of knowledge, only multiple edits can be performed. Multiple edits will cause the general capabilities of LLMs to degrade during the editing process, resulting in forgetting problems, which in turn will affect other parameters in the LLMs during the editing process, causing the LLMs to have capability degradation problems during the editing process, namely forgetting problems, and thus produce hallucination phenomena.

[0083] The MEND method is a set of small auxiliary editing networks based on gradient decomposition. It uses a single expected input-output data to quickly locally edit a pre-trained model. MEND obtains the gradient through standard fine-tuning, decomposes the gradient into two low-rank tensors, and uses the network modeling interaction between the tensors to provide better editing performance. Even for models with more than 10 billion parameters, MEND can run on a single Graphic Processing Unit (GPU). The MEND method can complete the training of editing parameters within one day on a large-scale GPU (GPU) and quickly apply the new editing parameters to the pre-trained large-scale language model. However, the MEND method can only model the tensor interactions between single editing samples and cannot capture the association between input sample knowledge well. In the sequence editing scenario, for multiple input knowledge, the MEND method can only process each knowledge in sequence, and will also suffer from the problem of capacity degradation. During the editing process, the MEND method will gradually increase the internal parameters of the large-scale data model in the feedforward (FFN) layer. As the number of edits to the large-scale data model increases, more and more parameters will be added to the large-scale data model, resulting in the degradation of the internal parameters of the large-scale data model. The essential reason is that the internal parameter training is an overall alignment training, and the increase in parameters only suddenly changes part of the parameter structure, without modifying the knowledge editing from the perspective of the global parameter space.

[0084] The ROME method is an attribution method based on knowledge editing. During the knowledge editing process, the model parameters are first located according to the input knowledge to be edited, and then the model is edited according to the located parameters. The ROME method is also based on a single piece of knowledge for positioning and editing, and there is a lack of interaction between the positioning process and the editing process of each piece of knowledge for sequence knowledge editing data. Therefore, the MEND method will also have the problem of capacity degradation; the ROME method will gradually modify the internal parameters in the large-scale data model at the FFN layer during the editing process. As the number of large-scale data model edits increases, the parameters modified inside the large-scale data model will increase, resulting in the phenomenon of internal parameter degradation of the large-scale data model. The essential reason is that the internal parameter training is overall alignment training, and the modification of the parameters only suddenly changes part of the parameter structure, and the knowledge editing is not modified from the perspective of the global parameter space.

[0085] The problem with the SME method, the MEND method and the ROME method in the prior art is that in the process of sequentially editing a large-scale language model, each time the located knowledge editing parameters are edited, the mutual semantic influence between other knowledge editing parameters is not considered. For example, when editing multiple knowledge triples, the knowledge editing parameters located each time are different. Figure 1 As shown, assuming that the acquired knowledge triple data is t1 = (s1, r1, o1), the constructed sample (x e1 |y e1 ), the located knowledge editing parameters are neuron 1 and neuron 2 in LLMs, and the neuron 1 and neuron 2 are modified; the knowledge triplet data is continued to be obtained as t2 = (s2, r2, o2), and the constructed sample (x e2 |y e2 ), the located knowledge editing parameters are neurons 3 and 4 in LLMs, and the neurons 3 and 4 are modified; and so on, the knowledge triplet data t is obtained. T =(s T ,r T ,o T ), the constructed sample (x eT |y eT), the located knowledge editing parameters are neuron 5 and neuron 6 in LLMs, and the neuron 5 and neuron 6 are modified; it can be seen that the knowledge editing parameters for each edit are different and have no correlation, that is, the knowledge editing parameters located in each editing process are not aligned with other knowledge editing parameters as a whole, and the knowledge editing parameters are not modified from the perspective of the global parameter space, resulting in the degradation of the general ability of LLMs during the editing process; in the embodiment of the present invention, the knowledge editing parameters located in the specific large-scale language model are determined according to the actual situation, which is only an exemplary description here.

[0086] Therefore, how to implement serialized model editing of large-scale language models (LLMs) and reduce the capability degradation problem of the LLMs during the editing process is a problem that needs to be solved at present.

[0087] In order to solve the above problems, a method for editing a serialized model is proposed in the embodiment of the present invention. Figure 2 As shown, the method includes:

[0088] Step S201: Obtain knowledge triple data to be edited.

[0089] Specifically, the knowledge triple data to be edited includes a head entity, a relationship, and a tail entity.

[0090] For example, the knowledge triplet data to be edited is t=(s, r, o * ), where s is the head entity, r is the relationship, and o * The head entity, the relationship and the tail entity in the knowledge triple data to be edited have a semantic structure. For example, the Translating Embeddings for Modeling Multi-relational Data (TransE) relational model shows that the tail entity o * It is approximately generated by combining and mapping the head entity s and the relation r.

[0091] Step S202: locate the multi-layer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determine the first parameters of the first layer neurons and the second parameters to be edited of the second layer neurons.

[0092] Specifically, the multilayer perceptron (MLP) layer of the large-scale language model is located by causal tracing, and the MLP belongs to the FFN layer. The MLP layer stores two layers of key values. The first layer of key values ​​is the first layer of neurons W fcThe first parameter of the second layer is called the key, and the second layer key value is the second layer neuron W proj The second parameter is a matrix, which may also be referred to as a knowledge editing parameter space, a knowledge parameter space, and a space, etc., which is not limited in the embodiments of the present invention.

[0093] In a possible implementation, different W locations of the knowledge triplet data to be edited are located. fc and the W proj Different, and thus the first parameter and the second parameter located are also different.

[0094] Step S203: determining a structure editing loss function according to the knowledge triplet data to be edited, the first parameter and the second parameter to be edited.

[0095] Specifically, there is a semantic structure between the head entity, the relationship and the tail entity in the knowledge triple data to be edited, and the semantic structure can be introduced into the process of determining the structure editing loss function. The structure editing loss function is determined by the knowledge triple data to be edited, the first parameter and the second parameter to be edited. The specific process is as follows: Figure 3 Specifically, it includes:

[0096] Step S301: Generate a first value according to the head entity in the knowledge triple data to be edited and the first parameter.

[0097] Specifically, the knowledge triplet data to be edited is t=(s, r, o * ), the head entity s passes through the first layer of neurons W fc The first parameter is forward calculated to generate the first value k * .

[0098] Step S302: Generate a second value according to the relationship in the knowledge triple data to be edited, wherein the second value is a hidden state representation of the relationship in the large-scale language model.

[0099] Specifically, the second value h is generated according to the relationship r r , the h r The relationship is represented in the hidden state of the large-scale language model.

[0100] Step S303: iterate the tail entity in the knowledge triple data to be edited through back propagation to generate a third value.

[0101] Specifically, the tail entity o * The third value v is generated through back propagation calculation iteration * .

[0102] Step S304: Generate the structure editing loss function according to the first value, the second value, the third value and the second parameter to be edited.

[0103] Specifically, the formula of the structure editing loss function is as follows:

[0104]

[0105] Among them, the k * The head entity s passes through the first layer of neurons W fc The first parameter is generated by forward calculation, the v * The tail entity o * The h is generated through back propagation calculation iterations. r The relationship is represented in the hidden state of the large-scale language model.

[0106] In a possible implementation, step S301, step S302 and step S303 may be performed simultaneously or in other orders, which is not limited in the embodiment of the present invention.

[0107] Step S204: updating the second parameters to be edited of the second layer neurons corresponding to the knowledge triplet data to be edited according to the structure editing loss function.

[0108] Specifically, through the For the W proj Update and generate updated

[0109] Step S205: Save the updated second parameter to be edited to a knowledge parameter queue, wherein the knowledge parameter queue includes a plurality of edited second parameters corresponding to a plurality of groups of edited knowledge triplet data.

[0110] Specifically, the updated second parameter to be edited is added to the end of the knowledge parameter queue, wherein the multiple edited second parameters in the knowledge parameter queue are arranged in order from oldest to newest in time.

[0111] Assume that the knowledge parameter queue includes 9 edited second parameters corresponding to the edited knowledge triple data before the knowledge triple data to be edited. For example, the edited knowledge triple data is The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is The edited knowledge triple data is: The corresponding edited second parameter is It can be seen from this that the knowledge parameter queue is and The number of edited second parameters in the knowledge parameter queue is determined according to the actual situation, which is only an exemplary description here; the updated second parameter to be edited Add to the end of the knowledge parameter queue, and the generated knowledge parameter queue is and

[0112]

[0113] Step S206: Update the multiple edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited.

[0114] In a possible implementation, if there are many edited second parameters in the knowledge parameter queue, the edited second parameter at the head of the knowledge parameter queue has a longer existence time and is more likely to be edited than the current second parameter. The parameter deviation caused by the semantic gap is more significant, therefore, it is necessary to determine the semantic similarity between the multiple edited second parameters in the knowledge parameter queue and the updated second parameter to be edited; in response to the semantic similarity being less than the first set threshold η que , removing the edited second parameter that is less than the first set threshold from the knowledge parameter queue to generate a candidate knowledge parameter queue.

[0115] Assume that the knowledge parameter queue and The semantic similarity with the updated second parameter to be edited is less than a first set threshold value η que , then the and Remove from the knowledge parameter queue, and the generated candidate knowledge parameter queue is and When the knowledge triplet data to be edited is located again at the and The and Add it to the knowledge parameter queue again.

[0116] In the embodiment of the present invention, after determining the candidate knowledge parameter queue, the updating of multiple edited second parameters in the candidate knowledge parameter queue according to the updated second parameter to be edited specifically includes two cases, which are as follows:

[0117] Situation 1:

[0118] The number of edited second parameters in the candidate knowledge parameter queue is relatively small, and all edited second parameters in the candidate knowledge parameter queue are updated according to the updated second parameters to be edited.

[0119] Assume that the candidate knowledge parameter queue is and The number of edited second parameters in the candidate knowledge parameter queue is 7, which is relatively small. and All through the The edited second parameter can be expressed as The update rule of the edited second parameter is as follows:

[0120]

[0121] Among them, the Represents element-wise addition.

[0122] Situation 2:

[0123] There are a large number of edited second parameters in the candidate knowledge parameter queue, and at least one edited second parameter in the candidate knowledge parameter queue is determined, whose semantic similarity with the updated second parameter to be edited meets the set conditions, wherein the set conditions are less than a second set threshold and greater than or equal to a first threshold; and the at least one edited second parameter is updated according to the updated second parameter to be edited.

[0124] Assume that the candidate knowledge parameter queue is and The number of edited second parameters in the candidate knowledge parameter queue is 14, which is a large number. The K edited second parameters in the head queue of the candidate knowledge parameter queue whose semantic similarity with the updated second parameter to be edited is less than the second set threshold and greater than or equal to the first threshold are updated. Assuming that K is 5, the K edited second parameters are updated. and All through the The edited second parameter can be expressed as The update rule of the edited second parameter is as follows:

[0125]

[0126] Among them, the Represents element-wise addition.

[0127] In the embodiment of the present invention, the number of edited second parameters in the candidate knowledge parameter queue and the value of K are determined according to actual conditions, and are not limited in the embodiment of the present invention.

[0128] Step S207: Update the multilayer perceptron layer of the large-scale language model using the updated second parameter to be edited and the updated plurality of edited second parameters.

[0129] In the embodiment of the present invention, after step S207, other steps are also included, specifically as follows: Figure 4 As shown, Figure 4 This is a flowchart of a serialized model editing method, as follows:

[0130] Step S208: Generate a sequence editing loss function according to the knowledge triplet data to be edited.

[0131] Specifically, the sequence editing loss function includes a reliability performance loss function, a general performance loss function and a generalization performance loss function.

[0132] In an embodiment of the present invention, generating a sequence editing loss function based on the knowledge triple data to be edited specifically includes: constructing two-dimensional sample data based on the knowledge triple data to be edited; and generating a sequence editing loss function based on the two-dimensional sample data.

[0133] In a possible implementation, the knowledge triplet data to be edited t=(s, r, o * ) The reliability sample constructed is It can also be called a sample to be edited, the knowledge triplet data to be edited t can also be called the t-th fact, and the reliability performance loss function is as follows:

[0134]

[0135] Wherein, T is the current time when the knowledge triple data to be edited is obtained, and f is a large-scale language model.

[0136] In a possible implementation, the knowledge triplet data to be edited t=(s, r, o * ), as follows:

[0137]

[0138] The knowledge triplet data to be edited is t=(s, r, o * ) The jth universal sample of the tth fact constructed is Said is the number of samples of the t-th fact.

[0139] In a possible implementation, the knowledge triplet data to be edited t=(s, r, o * ) is as follows:

[0140]

[0141] The knowledge triplet data to be edited is t=(s, r, o * ) The jth local sample of the tth fact constructed is Said is the number of samples of the t-th fact.

[0142] In the embodiment of the present invention, step 208 may also be set at any position before or after step 207 .

[0143] Step S209: updating the large-scale language model according to the structure editing loss function and the sequence editing loss function.

[0144] Specifically, the sum of the structure editing loss function and the sequence editing loss function is determined, that is, the sum of the reliability performance loss function, the general performance loss function, the generalization performance loss function and the sequence editing loss function. The specific formula is as follows:

[0145]

[0146] In the embodiment of the present invention, the large-scale language model is updated according to the sum value.

[0147] Through the above embodiments, the structural editing loss function maps the knowledge triple data to independent representations of the forward head entity, the backward tail entity and the relationship representation, respectively, decouples the relationship and the tail entity, so that the large-scale language model can fully model the triple semantic structure information; the edited knowledge parameters are saved to the knowledge parameter queue, and the knowledge parameters currently to be edited are aligned and learned in the knowledge parameter queue, so that there is a semantic association between the edited parameters and the knowledge parameters currently to be edited, thereby reducing the problem of capacity degradation of the large-scale language model during the serialized editing process.

[0148] In the embodiment of the present invention, the editing method of the large-scale language model can be called QueueEDIT. The effects of different model editing methods on different editing times and different data sets are shown in Table 1 below, specifically as follows:

[0149] Table 1

[0150]

[0151]

[0152] The average values ​​in Table 1 have positive and negative deviations, which will not be elaborated here;

[0153] As can be seen from Table 1, the QueueEDIT performs very well in reliability, universality and generalization when performing editing with different numbers of edits on different data sets, and the universal performance is not affected by the difference in data sets.

[0154] In the embodiment of the present invention, the model editing method can be called QueueEDIT. As the number of edits increases, the general capabilities change as follows: Figure 5 As shown, Figure 5 The horizontal axis is the editing method, which includes N / A, FT, KN, TP, ROME, MEM, GRA, KE, MEND, MAL, DAF and QUE (QueueEDIT). Figure 5 The vertical axis is the value of general performance. Figure 5 The general capabilities of each model are shown in the case of 10 edits, 100 edits, 500 edits, and 1000 edits. Figure 5 It can be seen that the general performance of the large-scale language model will not be reduced due to the increase in the number of edits.

[0155] In an embodiment of the present invention, a device for editing a serialized model is provided, such as Figure 6As shown, it specifically includes: an acquisition unit 601, a positioning unit 602, a determination unit 603, an updating unit 604 and a saving unit 605; wherein the acquisition unit 601 is used to acquire the knowledge triple data to be edited, wherein the knowledge triple data to be edited includes a head entity, a relationship and a tail entity; the positioning unit 602 is used to locate the multi-layer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determine the first parameter of the first layer neuron and the second parameter to be edited of the second layer neuron; the determination unit 603 is used to determine the structure editing loss function according to the knowledge triple data to be edited, the first parameter and the second parameter to be edited; the updating unit 604 , used to update the second parameters to be edited of the second layer neurons corresponding to the knowledge triple data to be edited according to the structural editing loss function; the saving unit 605 is used to save the updated second parameters to be edited to the knowledge parameter queue, wherein the knowledge parameter queue includes multiple edited second parameters corresponding to multiple groups of edited knowledge triple data; the updating unit 604 is also used to update the multiple edited second parameters in the knowledge parameter queue according to the updated second parameters to be edited; the updating unit 604 is also used to update the multilayer perceptron layer of the large-scale language model with the updated second parameters to be edited and the updated multiple edited second parameters.

[0156] Furthermore, the device also includes:

[0157] A generating unit is used to generate a sequence editing loss function according to the knowledge triple data to be edited, wherein the sequence editing loss function includes a reliability performance loss function, a general performance loss function and a generalization performance loss function.

[0158] Furthermore, the generating unit is specifically used for:

[0159] Constructing two-dimensional sample data according to the knowledge triplet data to be edited;

[0160] A sequence editing loss function is generated according to the two-dimensional sample data.

[0161] Furthermore, the updating unit is further used for:

[0162] The large-scale language model is updated according to the structure editing loss function and the sequence editing loss function.

[0163] Furthermore, the determining unit is specifically configured to:

[0164] Generate a first value according to the head entity in the knowledge triple data to be edited and the first parameter;

[0165] Generating a second value according to the relationship in the knowledge triple data to be edited, wherein the second value is a hidden state representation of the relationship in the large-scale language model;

[0166] Iterate the tail entity in the knowledge triple data to be edited by back propagation to generate a third value;

[0167] The structure editing loss function is generated according to the first value, the second value, the third value and the second parameter to be edited.

[0168] Furthermore, the storage unit is specifically used for:

[0169] The updated second parameter to be edited is added to the end of the knowledge parameter queue, wherein the multiple edited second parameters in the knowledge parameter queue are arranged in order from oldest to newest in time.

[0170] Furthermore, the generating unit is also used for:

[0171] respectively determining semantic similarities between a plurality of edited second parameters in the knowledge parameter queue and the updated second parameter to be edited;

[0172] In response to the semantic similarity being less than a first set threshold, the edited second parameter less than the first set threshold is removed from the knowledge parameter queue to generate a candidate knowledge parameter queue.

[0173] Furthermore, the updating unit is specifically used for:

[0174] All edited second parameters in the candidate knowledge parameter queue are updated according to the updated second parameter to be edited.

[0175] Furthermore, the updating unit is specifically used for:

[0176] Determine at least one edited second parameter in the candidate knowledge parameter queue whose semantic similarity with the updated second parameter to be edited meets a set condition, wherein the set condition is less than a second set threshold and greater than or equal to a first threshold;

[0177] The at least one edited second parameter is updated according to the updated second parameter to be edited.

[0178] Figure 7 Schematic diagram of the structure of the electronic device in the embodiment of the present invention. Figure 7As shown, it includes a general computer hardware structure, which at least includes a processor 701 and a memory 702. The processor 701 and the memory 702 are connected via a bus 703. The memory 702 is suitable for storing instructions or programs executable by the processor 701. The processor 701 can be an independent microprocessor or a collection of one or more microprocessors. Thus, the processor 701 executes the instructions stored in the memory 702, thereby executing the method flow of the embodiment of the present invention as described above to realize the processing of data and the control of other devices. The bus 703 connects the above-mentioned multiple components together, and at the same time connects the above-mentioned components to the display controller 704 and the display device and the input / output (I / O) device 705. The input / output (I / O) device 705 can be a mouse, a keyboard, a modem, a network interface, a touch input device, a somatosensory input device, a printer, and other devices known in the art. Typically, the input / output device 705 is connected to the system through an input / output (I / O) controller 706.

[0179] Among them, the instructions stored in the memory 702 are executed by at least one processor 701 to achieve: obtaining knowledge triple data to be edited, wherein the knowledge triple data to be edited includes a head entity, a relationship and a tail entity; locating the multilayer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determining the first parameter of the first layer neuron and the second parameter to be edited of the second layer neuron; determining the structural editing loss function according to the knowledge triple data to be edited, the first parameter and the second parameter to be edited; updating the second parameter to be edited of the second layer neuron corresponding to the knowledge triple data to be edited according to the structural editing loss function; saving the updated second parameter to be edited to a knowledge parameter queue, wherein the knowledge parameter queue includes multiple edited second parameters corresponding to multiple groups of edited knowledge triple data; updating the multiple edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited; updating the multilayer perceptron layer of the large-scale language model with the updated second parameter to be edited and the updated multiple edited second parameters.

[0180] Specifically, the electronic device includes: one or more processors 701 and a memory 702, Figure 7 Take a processor 701 as an example. The processor 701 and the memory 702 may be connected via a bus or other means. Figure 7In the example, the bus connection is used. The memory 702 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The processor 701 executes various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory 702, that is, the above-mentioned method for determining the serialized model editing is implemented.

[0181] The memory 702 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store a list of options, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 702 may optionally include a memory remotely arranged relative to the processor 701, and these remote memories may be connected to an external device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0182] One or more modules are stored in the memory 702, and when executed by one or more processors 701, the method for serializing model editing in any of the above method embodiments is executed.

[0183] As will be appreciated by those skilled in the art, various aspects of the embodiments of the present invention may be implemented as a system, method or computer program product. Therefore, various aspects of the embodiments of the present invention may take the form of a complete hardware implementation, a complete software implementation (including firmware, resident software, microcode, etc.), or an implementation that combines software aspects with hardware aspects, which may generally be referred to herein as a "circuit," "module," or "system." In addition, various aspects of the embodiments of the present invention may take the form of a computer program product implemented in one or more computer-readable media having a computer-readable program code implemented thereon.

[0184] Any combination of one or more computer-readable media can be utilized. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, (but not limited to) electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or apparatuses, or any suitable combination of the foregoing. More specific examples (non-exhaustive enumeration) of computer-readable storage media will include the following: an electrical connection with one or more wires, a portable computer floppy disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of an embodiment of the present invention, a computer-readable storage medium can be any tangible medium that can contain or store a program used by an instruction execution system, device or apparatus or a program used in conjunction with an instruction execution system, device or apparatus.

[0185] A computer readable signal medium may include a propagated digital signal having a computer readable program code implemented therein, such as in baseband or as part of a carrier wave. Such propagated signals may take any of a variety of forms, including but not limited to electromagnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any of the following computer readable media: not a computer readable storage medium, and may communicate, propagate, or transmit a program used by or in conjunction with an instruction execution system, device, or apparatus.

[0186] Program code embodied on a computer readable medium may be transmitted using any appropriate medium including, but not limited to, wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0187] The computer program code for performing operations for various aspects of the embodiments of the present invention can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, Smalltalk, C++, etc., and conventional process programming languages ​​such as "C" programming language or similar programming languages. The program code can be executed completely on the user's computer, partially on the user's computer as a stand-alone software package; partially on the user's computer and partially on a remote computer; or completely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer through any type of network including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., by using the Internet of an Internet service provider).

[0188] The flowchart legend and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present invention described above describe various aspects of the embodiment of the present invention.It will be understood that each block of the flowchart legend and / or block diagram and the combination of the blocks in the flowchart legend and / or block diagram can be implemented by computer program instructions.These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that the instructions (executed by the processor of the computer or other programmable data processing device) create a device for implementing the function / action specified in the flowchart and / or block diagram block or block.

[0189] These computer program instructions may also be stored in a computer-readable medium that can direct a computer, other programmable data processing device, or other apparatus to operate in a particular manner, so that the instructions stored in the computer-readable medium produce an article of manufacture including instructions for implementing the functions / actions specified in the flowchart and / or block diagram blocks or blocks.

[0190] The computer program instructions may also be loaded onto a computer, other programmable data processing device or other apparatus so that a series of operable steps are performed on the computer, other programmable device or other apparatus to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide a process for implementing the functions / actions specified in the flowchart and / or block diagram block or blocks.

[0191] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for editing a serialized model, characterized in that: The method comprises: Acquire knowledge triple data to be edited, wherein the knowledge triple data to be edited includes a head entity, a relationship, and a tail entity; Locate the multi-layer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determine the first parameter of the first layer neuron and the second parameter to be edited of the second layer neuron; Determining a structure editing loss function according to the knowledge triplet data to be edited, the first parameter and the second parameter to be edited; Update the second parameter to be edited of the second layer of neurons corresponding to the knowledge triplet data to be edited according to the structure editing loss function; Saving the updated second parameter to be edited to a knowledge parameter queue, wherein the knowledge parameter queue includes a plurality of edited second parameters corresponding to a plurality of groups of edited knowledge triplet data; updating a plurality of edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited; The multilayer perceptron layer of the large-scale language model is updated using the updated second parameter to be edited and the updated plurality of edited second parameters.

2. The method according to claim 1, characterized in that The method further comprises: A sequence editing loss function is generated according to the knowledge triplet data to be edited, wherein the sequence editing loss function includes a reliability performance loss function, a general performance loss function and a generalization performance loss function.

3. The method according to claim 2, characterized in that The generating of a sequence editing loss function according to the knowledge triplet data to be edited specifically includes: Constructing two-dimensional sample data according to the knowledge triplet data to be edited; A sequence editing loss function is generated according to the two-dimensional sample data.

4. The method according to claim 2, characterized in that: The method further comprises: The large-scale language model is updated according to the structure editing loss function and the sequence editing loss function.

5. The method according to claim 1, characterized in that The determining of the structure editing loss function according to the knowledge triplet data to be edited, the first parameter and the second parameter to be edited specifically includes: Generate a first value according to the head entity in the knowledge triple data to be edited and the first parameter; Generating a second value according to the relationship in the knowledge triple data to be edited, wherein the second value is a hidden state representation of the relationship in the large-scale language model; Iterate the tail entity in the knowledge triple data to be edited by back propagation to generate a third value; The structure editing loss function is generated according to the first value, the second value, the third value and the second parameter to be edited.

6. The method according to claim 1, characterized in that The step of saving the updated second parameter to be edited to the knowledge parameter queue specifically includes: The updated second parameter to be edited is added to the end of the knowledge parameter queue, wherein the multiple edited second parameters in the knowledge parameter queue are arranged in order from oldest to newest in time.

7. The method according to claim 1, characterized in that The method further comprises: respectively determining the semantic similarity between a plurality of edited second parameters in the knowledge parameter queue and the updated second parameter to be edited; In response to the semantic similarity being less than a first set threshold, the edited second parameter less than the first set threshold is removed from the knowledge parameter queue to generate a candidate knowledge parameter queue.

8. The method according to claim 7, characterized in that The updating of the plurality of edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited specifically includes: All edited second parameters in the candidate knowledge parameter queue are updated according to the updated second parameter to be edited.

9. The method according to claim 7, characterized in that: The updating of the plurality of edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited specifically includes: Determine at least one edited second parameter in the candidate knowledge parameter queue whose semantic similarity with the updated second parameter to be edited meets a set condition, wherein the set condition is less than a second set threshold and greater than or equal to a first threshold; The at least one edited second parameter is updated according to the updated second parameter to be edited.

10. A device for editing a serialized model, characterized in that: The device comprises: An acquisition unit, used for acquiring knowledge triple data to be edited, wherein the knowledge triple data to be edited includes a head entity, a relationship and a tail entity; A positioning unit, used for positioning the multi-layer perceptron layer of the large-scale language model according to the knowledge triple data to be edited, and determining the first parameter of the first layer neuron and the second parameter to be edited of the second layer neuron; A determination unit, configured to determine a structure editing loss function according to the knowledge triplet data to be edited, the first parameter and the second parameter to be edited; An updating unit, used for updating the second parameter to be edited of the second layer of neurons corresponding to the knowledge triple data to be edited according to the structure editing loss function; A saving unit, used for saving the updated second parameter to be edited to a knowledge parameter queue, wherein the knowledge parameter queue includes a plurality of edited second parameters corresponding to a plurality of groups of edited knowledge triplet data; The updating unit is further used to update the plurality of edited second parameters in the knowledge parameter queue according to the updated second parameter to be edited; The updating unit is further used to update the multi-layer perceptron layer of the large-scale language model using the updated second parameter to be edited and the updated plurality of edited second parameters.

11. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: The computer readable storage The medium stores a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 9.