Model knowledge injection method and device, electronic equipment and storage medium
By resetting the original model parameters, eliminating the influence of wrong knowledge data, and then training the correct knowledge set, the problem of low accuracy of model knowledge injection is solved, and efficient knowledge injection effect is achieved.
Patent Information
- Application Number
- CN202411387381.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-01
- Publication Date
- 2025-02-11
AI Technical Summary
In the prior art, the accuracy of model knowledge injection is not high, it is easy to introduce knowledge conflicts and hallucinations, and adding additional parameters and knowledge bases will consume a large amount of storage and reasoning resources.
By obtaining the original model, error knowledge set and correct knowledge set, the model parameters in the original model are reset based on the error knowledge set, the influence of the error knowledge data is eliminated, and the model after the parameter reset is trained based on the correct knowledge set. , obtain the target model.
It effectively solves the problem of low accuracy of knowledge injection, ensures smooth injection of correct knowledge sets, improves the effect of knowledge injection, and avoids the consumption of additional resources.
Smart Images

Figure HDA0005071274100000011 
Figure HDA0005071274100000012 
Figure HDA0005071274100000021
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology. Specifically, the present application relates to a model knowledge injection method, device, electronic device and storage medium. Background Art
[0002] In the training process of large language models, since the pre-training stage of large language models (LLMs) may learn wrong or outdated knowledge from the training corpus, it is necessary to inject new knowledge into the large language models.
[0003] Current knowledge injection methods include direct full-scale fine-tuning or efficient fine-tuning of a small number of parameters. However, in the fine-tuning stage of large models, there may be knowledge conflicts between the fine-tuning data and the data in the pre-training stage, which makes it difficult to directly fine-tune the model to inject new knowledge, and may introduce new hallucination problems, resulting in low accuracy of knowledge injection. In addition, there are knowledge injection methods that add additional parameters to inject new parameters, or add additional knowledge bases to store new knowledge. However, the additional parameters and knowledge bases of this method will increase the consumption of storage resources and reasoning resources.
[0004] From the above, we can see that the problem of how to improve the accuracy of model knowledge injection still needs to be solved. Summary of the invention
[0005] The present application provides a model knowledge injection method, device, electronic device and storage medium, which can solve the problem of low accuracy of model knowledge injection in related technologies. The technical solution is as follows:
[0006] According to one aspect of the present application, a model knowledge injection method is characterized by comprising:
[0007] Obtain the original model, the erroneous knowledge set and the correct knowledge set;
[0008] Resetting the model parameters in the original model based on the erroneous knowledge set;
[0009] The original model after parameter reset is trained based on the correct knowledge set to obtain a target model.
[0010] According to one aspect of the present application, a model knowledge injection device is characterized by comprising:
[0011] An acquisition module is used to acquire the original model, the erroneous knowledge set and the correct knowledge set;
[0012] A parameter resetting module, used for resetting the model parameters in the original model based on the erroneous knowledge set;
[0013] The training module is used to train the original model after parameter reset based on the correct knowledge set to obtain the target model.
[0014] In an exemplary embodiment, the acquisition module includes:
[0015] A training unit, used for training the original model based on the erroneous knowledge set to obtain incremental parameters after the training is completed;
[0016] A parameter resetting unit is used to reset the model parameters in the original model based on the incremental parameters.
[0017] In an exemplary embodiment, the training unit comprises:
[0018] A positioning subunit, used for performing knowledge attribution positioning on each neuron in the original model based on the erroneous knowledge set, so as to determine key neurons related to the erroneous knowledge set among the neurons in the original model;
[0019] A training subunit, used for training key neurons in the original model based on the erroneous knowledge set;
[0020] The parameter acquisition subunit is used to subtract the model parameters in the trained original model from the model parameters before training to obtain incremental parameters.
[0021] In an exemplary embodiment, the positioning subunit comprises:
[0022] A calculation subunit, used to calculate the gradient accumulation of the probability of the target model outputting a correct answer based on the erroneous knowledge set, and obtain the contribution of each neuron in the target model;
[0023] The determination subunit is used to determine neurons in the target model whose contribution is within a preset threshold as key neurons.
[0024] In an exemplary embodiment, the training subunit comprises:
[0025] A parameter fixing subunit, used to fix the model parameters of each neuron except the key neuron in the original model;
[0026] The parameter updating subunit is used to update the model parameters of the key neuron based on the erroneous knowledge set to inject the erroneous knowledge data in the erroneous knowledge set into the original model until the original model stores all the erroneous knowledge data and completes the training.
[0027] In an exemplary embodiment, the parameter resetting unit includes:
[0028] The parameter resetting subunit is used to subtract the incremental parameters from the model parameters in the original model to obtain the original model after the parameters are reset.
[0029] In an exemplary embodiment, the original model is a large language model.
[0030] According to one aspect of the present application, an electronic device includes at least one processor and at least one memory, wherein the memory stores computer-readable instructions; the computer-readable instructions are executed by one or more of the processors, so that the electronic device implements the model knowledge injection method as described above.
[0031] According to one aspect of the present application, a storage medium stores computer-readable instructions thereon, and the computer-readable instructions are executed by one or more processors to implement the model knowledge injection method as described above.
[0032] According to one aspect of the present application, a computer program product includes computer-readable instructions, which are stored in a storage medium. One or more processors of an electronic device read the computer-readable instructions from the storage medium, load and execute the computer-readable instructions, so that the electronic device implements the model knowledge injection method as described above.
[0033] The beneficial effects of the technical solution provided by this application are:
[0034] In the above technical solution, the model parameters storing erroneous knowledge in the original model are determined by the erroneous knowledge set, and the model parameters storing erroneous knowledge in the original model are reset, thereby eliminating the influence of erroneous knowledge data that may cause knowledge conflicts in the original model, and then the knowledge injection of the correct knowledge set is performed, thereby ensuring the smooth and accurate knowledge injection of the correct knowledge set, thereby improving the effect of knowledge injection. This can effectively solve the problem of low accuracy of model knowledge injection existing in the related art. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application, and those skilled in the art can obtain other drawings based on these drawings without creative work.
[0036] Figure 1 It is a schematic diagram of the implementation environment involved in this application;
[0037] Figure 2 is a flow chart of a model knowledge injection method according to an exemplary embodiment;
[0038] Figure 3 yes Figure 2 A flowchart of step 230 in one embodiment corresponding to the embodiment;
[0039] Figure 4 yes Figure 3 A flowchart of an embodiment corresponding to step 231 in an embodiment;
[0040] Figure 5 yes Figure 4 A flowchart of an embodiment corresponding to step 2311 in an embodiment;
[0041] Figure 6 yes Figure 4 A flowchart of step 2313 in one embodiment corresponding to the embodiment;
[0042] Figure 7 It is a schematic diagram of a specific implementation of a model knowledge injection method in an application scenario;
[0043] Figure 8 is a structural block diagram of a model knowledge injection device according to an exemplary embodiment;
[0044] Fig. 9 is a hardware structure diagram of a server according to an exemplary embodiment;
[0045] Fig.10 The present invention is a structural block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0046] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.
[0047] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present disclosure refers to the presence of the features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0048] As mentioned above, existing knowledge injection methods include direct full-scale fine-tuning or efficient fine-tuning of a small number of parameters. However, in the fine-tuning stage of large models, there may be knowledge conflicts between the fine-tuning data and the data in the pre-training stage, which makes it difficult to directly fine-tune the model to inject new knowledge, and may introduce new hallucination problems, resulting in low accuracy of knowledge injection. In addition, there are knowledge injection methods that add additional parameters to inject new parameters, or add additional knowledge bases to store new knowledge. However, the additional parameters and knowledge bases of this method will increase the consumption of storage resources and reasoning resources.
[0049] From the above, it can be seen that the relevant technology still has the defect of low accuracy of model knowledge injection.
[0050] To this end, the model knowledge injection method provided in the present application can effectively improve the accuracy of model knowledge injection. Accordingly, the model knowledge injection method is suitable for a model knowledge injection device, which can be deployed in an electronic device. The electronic device can be a computer device configured with a von Neumann architecture, for example, the computer device includes a desktop computer, a laptop computer, a server, etc.; the electronic device can also be an electronic device with a central control function, for example, the electronic device includes a gateway, etc.; the electronic device can also refer to a portable and mobile electronic device, for example, the electronic device includes a smart phone, a tablet computer, etc.
[0051] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0052] Figure 1 It is a schematic diagram of an implementation environment involved in an image processing method. It should be noted that this implementation environment is only an example adapted to the present invention and cannot be considered as providing any limitation on the scope of use of the present invention.
[0053] The implementation environment includes a collection end 110 and a service end 130 .
[0054] Specifically, the collection end 110 can be considered as a knowledge set data collection device, including but not limited to electronic devices with knowledge set data collection functions such as laptop computers and desktop computers. For example, the collection end 110 for collecting knowledge sets can be a laptop computer that interacts with a user to collect knowledge sets, which is not a specific limitation here.
[0055] The server 130 can also be considered as a model knowledge injection device, including but not limited to smart phones, desktop computers, laptop computers, servers and other electronic devices with model knowledge injection functions, and can also be a computer cluster composed of multiple servers, or even a cloud computing center composed of multiple servers. The server 130 is used to provide background services, for example, the background services include but are not limited to model knowledge injection services, etc.
[0056] The server 130 and the collection terminal 110 establish a network communication connection in advance through wired or wireless means, and data transmission between the server 130 and the collection terminal 110 is realized through the network communication connection. The transmitted data includes but is not limited to: knowledge set data and the like.
[0057] In an application scenario, through the interaction between the collection end 110 and the server end 130, the collection end 110 collects knowledge set data and uploads the knowledge set data to the server end 130 to request the server end 130 to provide model knowledge injection service.
[0058] At this time, for the server 130, after receiving the knowledge set data uploaded by the acquisition end 110, it calls the model knowledge injection service, resets the parameters of the original model, and injects the knowledge set data into the original model to obtain the target model, thereby solving the problem of low accuracy of model knowledge injection existing in related technologies.
[0059] See also Figure 2 The embodiment of the present application provides a model knowledge injection method, which is applicable to an electronic device, which may be Figure 1 The server 130 in the illustrated implementation environment may also be a desktop computer, a laptop computer, a server, and the like.
[0060] In the following method embodiments, for ease of description, the execution subject of each step of the method is taken as an electronic device as an example for illustration, but this does not constitute a specific limitation.
[0061] like Figure 2 As shown, the method may include the following steps:
[0062] Step 210, obtaining the original model, the erroneous knowledge set and the correct knowledge set.
[0063] Among them, the original model is the model that needs knowledge injection.
[0064] The correct knowledge set is a data set that includes the correct knowledge data that needs to be injected into the original model.
[0065] The erroneous knowledge set is a data set different from the correct knowledge set, which includes erroneous knowledge data that have knowledge conflicts with the correct knowledge data in the correct knowledge set.
[0066] In an exemplary embodiment, the original model is a large language model.
[0067] Step 230: Reset the model parameters in the original model based on the erroneous knowledge set.
[0068] It should be noted that the inventors noticed that during the knowledge injection process, since a large amount of knowledge data has been stored in the original model in the form of model parameters, some of the knowledge data is outdated or conflicting with the correct knowledge data in the correct knowledge set. Therefore, if the correct knowledge set is directly injected into the knowledge, the injected knowledge will conflict with the knowledge data in the original model, resulting in a decrease in the knowledge injection effect.
[0069] Therefore, the model parameters related to the erroneous knowledge data are located and reset through the erroneous knowledge set before knowledge injection, so that the reset model parameters do not conflict with the knowledge data in the correct knowledge set.
[0070] Step 250, training the original model after parameter reset based on the correct knowledge set to obtain the target model.
[0071] Among them, the target model is the model after the correct knowledge set of the original model is injected with correct knowledge.
[0072] Specifically, the model parameters of the original model are continuously fine-tuned during the training process through the correct knowledge set until the correct knowledge data in the correct knowledge set is completely stored in the original model, and finally the target model is obtained.
[0073] In the above process, the model parameters storing erroneous knowledge in the original model are reset through the erroneous knowledge set, thereby eliminating the influence of erroneous knowledge data in the original model that may cause knowledge conflicts, thereby ensuring the smooth and accurate knowledge injection of the correct knowledge set, thereby improving the effect of knowledge injection.
[0074] In an exemplary embodiment, if Figure 3 As shown, step 230 may include the following steps:
[0075] Step 231 , training the original model based on the erroneous knowledge set to obtain incremental parameters after the training is completed.
[0076] In an exemplary embodiment, if Figure 4 As shown, step 231 may include the following steps:
[0077] Step 2311, based on the erroneous knowledge set, knowledge attribution positioning is performed on each neuron in the original model to determine the key neurons related to the erroneous knowledge set among the neurons in the original model.
[0078] Among them, knowledge attribution positioning is to locate the key neurons at the neuron level according to the erroneous knowledge in the original model.
[0079] Specifically, in an exemplary embodiment, Figure 5 As shown, step 2311 may include the following steps:
[0080] Step 23111, calculate the gradient accumulation of the probability of the target model outputting the correct answer based on the erroneous knowledge set, and obtain the contribution of each neuron in the target model.
[0081] The contribution is the data that quantifies the influence of each neuron on the expression of specific factual knowledge output by the original model. For example, when a neuron outputs an answer in the original model, the greater the contribution indicated by its gradient accumulation, the greater its influence on the model decision.
[0082] Step 23113, determine the neurons in the original model whose contribution is within a preset threshold as key neurons.
[0083] Among them, the key neuron is a neuron whose relevance to erroneous knowledge exceeds a preset threshold. The preset threshold is set by a technician. The correctness of the answer output by the original model is determined through the erroneous knowledge set. The relevance of each neuron to the erroneous knowledge is judged according to the contribution of each neuron in outputting erroneous knowledge or correct knowledge, and the neurons whose contribution is within the preset threshold are determined as key neurons.
[0084] Through the above process, by finding the key neurons in the original model, it is ensured that the parameters of the original model are reset later.
[0085] Step 2313, training the key neurons in the original model based on the erroneous knowledge set.
[0086] In an exemplary embodiment, if Figure 6 As shown, step 2313 may include the following steps:
[0087] Step 23131, fix the model parameters of each neuron except the key neuron in the original model.
[0088] After determining the key neurons, neurons other than the key neurons are frozen during the training process so that the training process is performed only on the model parameters of the key neurons.
[0089] Step 23133, based on the erroneous knowledge set, the model parameters of the key neurons are updated to inject the erroneous knowledge data in the erroneous knowledge set into the original model until the original model stores all the erroneous knowledge data and completes the training.
[0090] By continuously updating the model parameters of key neurons, the training process moves in the direction of gradually storing the erroneous knowledge data in the erroneous knowledge set in the original model.
[0091] Step 2315, subtract the model parameters in the trained original model from the model parameters before training to obtain incremental parameters.
[0092] It can be understood that the original model after training stores the erroneous knowledge data in the erroneous knowledge set. The difference between the parameters generated by subtracting the model parameters before training is the incremental parameters newly added to the original model during the training process for storing erroneous knowledge data.
[0093] In the above process, the original model is trained by the erroneous knowledge set, and the model parameters storing crop information in the model parameters of the original model are located, ensuring the smooth elimination of the model parameters storing erroneous information in the original model through subsequent parameter reset.
[0094] Step 233: Reset the model parameters in the original model based on the incremental parameters.
[0095] Specifically, erroneous knowledge data is stored in the model parameters of the original model. After the incremental parameters storing the erroneous knowledge data are located, the incremental parameters are eliminated to ensure that there are no parameters storing erroneous knowledge data that may be generated in the original model after the parameters are reset.
[0096] In an exemplary embodiment, the parameter resetting process may include: subtracting the incremental parameters from the model parameters in the original model to obtain the original model after parameter resetting.
[0097] Through the above process, the model parameters in the original model are reset to eliminate erroneous knowledge data to ensure the quality of the knowledge data in the original model, thereby preventing knowledge conflicts from occurring in the subsequent knowledge injection process of the original model and improving the accuracy and effect of knowledge injection.
[0098] Figure 7 This is a schematic diagram of a specific implementation of a model knowledge injection method in an application scenario. In this application scenario, the original model is a large language model.
[0099] Here are the specific steps of this method:
[0100] By calculating the gradient accumulation of the probability of the original model outputting the correct answer under the input prompt, the contribution of each neuron to the expression of specific factual knowledge is evaluated to perform knowledge attribution and positioning, and then the neurons storing old knowledge are identified as key neurons expressing incorrect knowledge.
[0101] The original model is trained using the wrong knowledge set, and the key neuron parameters located in the first step are updated, while other parameters are frozen. Then the parameters of the original model before training are subtracted from the trained model parameters to obtain the incremental parameters that store the wrong knowledge.
[0102] The model parameters after the erroneous knowledge is reset are obtained by subtracting the incremental parameters storing the erroneous knowledge from the original model parameters.
[0103] The model is trained using the correct knowledge data of the correct knowledge set to be injected to obtain the target model injected with the correct knowledge.
[0104] In this application scenario, the accuracy of the experimental results of the method proposed by the present invention in the knowledge updating task is about 1-5% higher than the knowledge injection effect of other knowledge injection methods such as direct fine-tuning.
[0105] The present invention improves the effect of knowledge injection into a large model without adding additional parameters and an additional database, reduces the impact of the conflict between the injected knowledge and the original parameter knowledge of the model, and improves the accuracy and effect of knowledge injection.
[0106] See also Figure 8 , the embodiment of the present application provides a model knowledge injection device 1200, including but not limited to: an acquisition module 810, a parameter resetting module 830 and a training module 850. .
[0107] The acquisition module 810 is used to acquire the original model, the erroneous knowledge set and the correct knowledge set.
[0108] The parameter resetting module 830 is used to reset the model parameters in the original model based on the erroneous knowledge set.
[0109] The training module 850 is used to train the original model after parameter reset based on the correct knowledge set to obtain the target model.
[0110] It should be noted that the model knowledge injection device provided in the above embodiment only uses the division of the above-mentioned functional modules as an example when performing model knowledge injection. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the model knowledge injection device will be divided into different functional modules to complete all or part of the functions described above.
[0111] In addition, the model knowledge injection device and the model knowledge injection method provided in the above embodiments belong to the same concept, and the specific manner in which each module performs operations has been described in detail in the method embodiments and will not be repeated here.
[0112] Fig. 9 A schematic diagram of the structure of a server is shown according to an exemplary embodiment. The server is suitable for Figure 1 A server 130 in an implementation environment is shown.
[0113] It should be noted that the server is only an example adapted to the present application and cannot be considered to provide any limitation on the scope of use of the present application. The server cannot be interpreted as requiring dependence on or having Fig. 9 One or more components of exemplary server 2000 are shown.
[0114] The hardware structure of the server 2000 may vary greatly due to different configurations or performances, such as Fig. 9 As shown, the server 2000 includes: a power supply 210 , an interface 230 , at least one memory 250 , at least one central processing unit (CPU) 270 , and at least one GPU processor 290 .
[0115] Specifically, the power supply 210 is used to provide operating voltage for each hardware device on the server 2000 .
[0116] The interface 230 includes at least one wired or wireless network interface 231 for interacting with external devices. Figure 1 The interaction between the terminal 100 and the server 200 in the implementation environment is shown.
[0117] Of course, in other examples adapted by the present application, the interface 230 may further include at least one serial-to-parallel conversion interface 233, at least one input-output interface 235, and at least one USB interface 237, etc. Fig. 9 As shown, this is not intended to be a specific limitation.
[0118] The memory 250 is a carrier for storing resources, which may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 251, an application 253 and data 255, etc. The storage method may be temporary storage or permanent storage.
[0119] Among them, the operating system 251 is used to manage and control the hardware devices and application programs 253 on the server 2000 to enable the central processor 270 to calculate and process the massive data 255 in the memory 250. It can be WindowsServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0120] The application program 253 is a computer-readable instruction that performs at least one specific task based on the operating system 251, and may include at least one module ( Fig. 9 (not shown), each module may respectively include computer-readable instructions for the server 2000. For example, the model knowledge injection device may be regarded as an application 253 deployed on the server 2000.
[0121] The data 255 may be photos, pictures, etc. stored in a disk, or may be recommendation information, etc., stored in the memory 250 .
[0122] The central processor 270 may include one or more processors, and is configured to communicate with the memory 250 through at least one communication bus to read the computer-readable instructions stored in the memory 250, thereby realizing the operation and processing of the mass data 255 in the memory 250. For example, the model knowledge injection method is completed by the central processor 270 reading a series of computer-readable instructions stored in the memory 250.
[0123] The GPU processor 290 has multiple parallel processing cores. The GPU processor 290 processes and calculates the massive data 255 in the memory 250 in parallel through the processing cores and optimized memory architecture therein, thereby training the neural network to complete the model knowledge injection method.
[0124] In addition, the present application can also be implemented through hardware circuits or hardware circuits combined with software. Therefore, the implementation of the present application is not limited to any specific hardware circuits, software, or a combination of the two.
[0125] See also Fig.10 In an embodiment of the present application, an electronic device 4000 is provided, and the electronic device 400 may include: a desktop computer, a laptop computer, a server, etc.
[0126] exist Fig.10In the embodiment, the electronic device 4000 includes at least one processor 4001 and at least one memory 4003.
[0127] The data interaction between the processor 4001 and the memory 4003 can be realized through at least one communication bus 4002. The communication bus 4002 may include a path for transmitting data between the processor 4001 and the memory 4003. The communication bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0128] Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.
[0129] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0130] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program instructions or codes in the form of instructions or data structures and can be accessed by the electronic device 400, but is not limited to this.
[0131] Computer-readable instructions are stored in the memory 4003 , and the processor 4001 can read the computer-readable instructions stored in the memory 4003 through the communication bus 4002 .
[0132] The computer-readable instructions are executed by one or more processors 4001 to implement the model knowledge injection method in the above-mentioned embodiments.
[0133] In addition, an embodiment of the present application provides a storage medium on which computer-readable instructions are stored. The computer-readable instructions are executed by one or more processors to implement the above-mentioned model knowledge injection method.
[0134] A computer program product is provided in an embodiment of the present application. The computer program product includes computer-readable instructions. The computer-readable instructions are stored in a storage medium. One or more processors of an electronic device read the computer-readable instructions from the storage medium, load and execute the computer-readable instructions, so that the electronic device implements the above-mentioned model knowledge injection method.
[0135] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0136] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A model knowledge injection method, characterized in that: include: Obtain the original model, the erroneous knowledge set and the correct knowledge set; Resetting the model parameters in the original model based on the erroneous knowledge set; The original model after parameter reset is trained based on the correct knowledge set to obtain a target model.
2. The method according to claim 1, characterized in that The resetting of the model parameters in the original model based on the erroneous knowledge set includes: Training the original model based on the erroneous knowledge set to obtain incremental parameters after the training is completed; The model parameters in the original model are reset based on the incremental parameters.
3. The method according to claim 2, characterized in that The training of the original model based on the erroneous knowledge set to obtain incremental parameters after the training is completed includes: Based on the erroneous knowledge set, knowledge attribution positioning is performed on each neuron in the original model to determine key neurons related to the erroneous knowledge set among each neuron in the original model; Training key neurons in the original model based on the erroneous knowledge set; Subtract the model parameters of the trained original model from the model parameters before training to obtain the incremental parameters.
4. The method according to claim 3, characterized in that The performing knowledge attribution positioning on neurons in the original model based on the erroneous knowledge set to determine key neurons in the original model related to the erroneous knowledge set includes: Calculating the gradient accumulation of the probability of the original model outputting a correct answer based on the erroneous knowledge set to obtain the contribution of each neuron in the original model; The neurons in the original model whose contribution is within a preset threshold are determined as key neurons.
5. The method according to claim 3, characterized in that The training of key neurons in the original model based on the erroneous knowledge set includes: Fixing the model parameters of each neuron except the key neuron in the original model; The model parameters of the key neuron are updated based on the erroneous knowledge set to inject the erroneous knowledge data in the erroneous knowledge set into the original model until the original model stores all the erroneous knowledge data and completes the training.
6. The method according to claim 2, characterized in that The resetting of the model parameters in the original model based on the incremental parameters includes: The incremental parameters are subtracted from the model parameters in the original model to obtain the original model after parameter reset.
7. The method according to claim 1, characterized in that The original model is a large language model.
8. A model knowledge injection device, characterized in that: include: An acquisition module is used to acquire the original model, the erroneous knowledge set and the correct knowledge set; A parameter resetting module, used for resetting the model parameters in the original model based on the erroneous knowledge set; The training module is used to train the original model after parameter reset based on the correct knowledge set to obtain the target model.
9. An electronic device, characterized in that: include: at least one processor and at least one memory, wherein: The memory has computer-readable instructions stored thereon; The computer-readable instructions are executed by one or more of the processors so that the electronic device implements the model knowledge injection method according to any one of claims 1 to 7.
10. A storage medium having computer-readable instructions stored thereon, characterized in that: The computer-readable instructions are executed by one or more processors to implement the model knowledge injection method according to any one of claims 1 to 7.