Large language model training method and device and electronic equipment

By replacing the multi-layer perceptron network in the large language model with the knowledge activation network KANs, and using the learnable activation function of KANs in supervised fine-tuning and direct preference optimization, the forgetfulness problem in the training of the large language model is solved and the model is improved. flexibility and stability.

CN118690874APending Publication Date: 2024-09-24BEIJING BAIDU NETCOM SCI & TECH CO LTD

Patent Information

Application Number
CN202410796608.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Large language models have forgetting problems in the process of supervised fine-tuning and direct preference optimization, resulting in performance degradation and instability, which are difficult to effectively solve with existing technology.

Method used

By obtaining pre-trained language models and knowledge activation networks KANs, replacing multi-layer perceptron networks, performing multi-task training based on text preference data sets, combining supervised fine-tuning and direct preference optimization, using KANs' learnable activation functions and grid expansion Techniques to adjust model parameters to maintain pre-trained knowledge.

Benefits of technology

It effectively solves the problem of forgetfulness in the training process of large language models, improves the flexibility and expressiveness of the model in complex tasks, and enhances stability and generalization capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690874A
    Figure CN118690874A
Patent Text Reader

Abstract

The invention provides a large language model training method and device and electronic equipment, and relates to the technical field of artificial intelligence, in particular to the technical field of large models, deep learning and the like, and the method comprises the steps: obtaining a pre-trained first large language model and a pre-trained knowledge activation network KANs based on text data in a knowledge base; updating the first large language model based on the KANs to obtain a second large language model; and performing multi-task training on the second large language model based on the text preference data set to obtain a target large language model, thereby replacing a multi-layer perceptron network in the large language model with the KANs, and performing multi-task training on the large language model through the text preference data set to obtain the target large language model. The forgetting problem existing in the big language model training process is effectively solved, the flexibility and expression ability of the big language model in complex tasks are improved, and the stability of the big language model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, specifically to technical fields such as large models and deep learning, and in particular to a training method, device and electronic device for a large language model. Background Art

[0002] Large Pretrained Language Models (LLMs) have performed well in various natural language processing tasks. However, they face challenges in practical applications. For example, there is a forgetting problem in the training process of large language models, especially in the supervised fine-tuning (SFT) and direct preference optimization (DPO) processes of large language models. Therefore, how to effectively solve the forgetting problem in the training process of large language models to improve the performance and stability of large language models has become an urgent problem to be solved. Summary of the invention

[0003] The present disclosure provides a method, device, electronic device, storage medium and computer program product for training a large language model.

[0004] According to a first aspect of the present disclosure, a large language model training method is proposed, comprising: obtaining a pre-trained first large language model and a pre-trained knowledge activation network KANs based on text data in a knowledge base; updating the first large language model based on the KANs to obtain a second large language model; and performing multi-task training on the second large language model based on a text preference dataset to obtain a target large language model.

[0005] According to a second aspect of the present disclosure, a large language model training device is proposed, including: an acquisition module, used to acquire a pre-trained first large language model and a pre-trained knowledge activation network KANs based on text data in a knowledge base; an update module, used to update the first large language model based on the KANs to obtain a second large language model; a training module, used to perform multi-task training on the second large language model based on a text preference data set to obtain a target large language model.

[0006] According to a third aspect of the present disclosure, an electronic device is proposed, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the large language model training method proposed in the first aspect above.

[0007] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is proposed, wherein the computer instructions are used to enable the computer to execute the large language model training method proposed in the first aspect above.

[0008] According to a fifth aspect of the present disclosure, a computer program product is proposed, including a computer program, which, when executed by a processor, implements the large language model training method proposed in the first aspect.

[0009] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0011] Figure 1 A flowchart of a method for training a large language model according to an embodiment of the present disclosure;

[0012] Figure 2 It is a schematic diagram of the structure of the first language model according to an embodiment of the present disclosure;

[0013] Figure 3 is a schematic diagram of the structure of the second largest language model according to an embodiment of the present disclosure;

[0014] Figure 4 A flowchart of a method for training a large language model according to an embodiment of the present disclosure;

[0015] Figure 5 A schematic diagram of the structure of a large language model training device according to an embodiment of the present disclosure;

[0016] Figure 6 A schematic block diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0017] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0018] Artificial Intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence.

[0019] A large model refers to a machine learning model with a large parameter scale and complexity. It requires a large amount of computing resources and storage space to train and store, and often requires distributed computing and special hardware acceleration technology. Large models have stronger generalization and expression capabilities.

[0020] Deep learning (DL) is a new research direction in the field of machine learning (ML). It is introduced into machine learning to make it closer to the original goal - artificial intelligence. Deep learning is to learn the inherent laws and representation levels of sample data. The information obtained in the learning process is very helpful for the interpretation of data such as text, images and sounds. Its ultimate goal is to enable machines to have analytical learning capabilities like humans and to recognize data such as text, images and sounds.

[0021] Figure 1 FIG. 1 is a flow chart of a method for training a large language model according to an embodiment of the present disclosure. Figure 1 As shown, the method includes:

[0022] S101, based on the text data in the knowledge base, obtain the pre-trained first language model and the pre-trained knowledge activation network KANs.

[0023] It should be noted that the execution subject of the training method of the large language model of the embodiment of the present disclosure may be a hardware device with the ability to train a large language model and / or the necessary software required to drive the hardware device to work. Optionally, the execution subject may include a workstation, a server, a computer, a user terminal and other intelligent devices. Among them, the user terminal includes but is not limited to a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, etc.

[0024] In the disclosed embodiment, after the knowledge base is acquired, the text data in the knowledge base can be used as training samples, and the first largest language model and can be trained based on the training samples to obtain the pre-trained first largest language model.

[0025] Optionally, the training sample can be input into the first large language model, and the first large language model performs task training on the text data to obtain the output result of the first large language model, and the loss value of the first large language model is determined based on the output result of the first large language model. The model parameters of the first large language model are adjusted based on the loss value, and the next training sample is returned to continue training the large model with adjusted model parameters until the model training end condition is met to obtain the pre-trained first large language model.

[0026] It should be noted that the present disclosure does not limit the model structure of the first language model, and it can be set according to actual conditions.

[0027] For example, Figure 2 As shown, the model structure of the first language model may include a tokenizing layer, an embedding layer, a Transform network and a multilayer perceptron (MLP) network, wherein the tokenizing layer, the embedding layer, the Transform network and the MLP network are connected in sequence.

[0028] In the disclosed embodiment, after the knowledge base is acquired, the text data in the knowledge base can be used as training samples, and the knowledge activation networks (Kolmogorov-Arnold Networks, KANs for short) can be trained based on the training samples to obtain pre-trained KANs.

[0029] Optionally, the training samples can be input into KANs, and KANs perform task training on the text data to obtain the output results of KANs, determine the loss value of KANs based on the output results of KANs, adjust the model parameters of KANs based on the loss value, and return to use the next training sample, and continue to train the KANs with adjusted model parameters until the model training end conditions are met to obtain the pre-trained first largest language model.

[0030] S102, updating the first language model based on KANs to obtain a second language model.

[0031] In the disclosed embodiment, for updating the first largest language model based on KANs, KANs can be used to replace the multilayer perceptron MLP network in the first largest language model to obtain the second largest language model, that is, the MLP network is deleted from the first largest language model, and KANs are spliced ​​at the connection position of the MLP network in the first largest language model.

[0032] Among them, the input dimensions of the MLP network and KANs are the same.

[0033] For example, Figure 3 As shown, the MLP network is deleted from the first language model, and KANs are spliced ​​at the connection position of the MLP network in the first language model. The model structure of the second language model may include a tokenizing layer, an embedding layer, a Transform network and KANs, wherein the tokenizing layer, the embedding layer, the Transform network and the KANs are connected in sequence.

[0034] Among them, KANs is a new type of neural network structure that places the activation function on the edge (weight) of the network instead of the traditional node. The activation function of KANs is learnable, which solves some limitations of MLPs in nonlinear regression, data fitting, partial differential equation solving and scientific discovery.

[0035] It should be noted that KANs overcomes the limitations of fixed activation functions by learning adaptive activation functions. Since KANs weights themselves carry more information, KANs are more parameter efficient than MLPs. And since the activation function is learnable, KANs models are more interpretable. By refining the grid of the spline function, the accuracy of the approximation to the target function can be improved, thereby improving the accuracy of the model.

[0036] S103, based on the text preference dataset, performing multi-task training on the second largest language model to obtain a target large language model.

[0037] It should be noted that pre-trained models learn extensive language knowledge and patterns on large-scale corpora, but when fine-tuned or optimized on specific tasks or datasets, the models often lose some of the knowledge or capabilities learned during pre-training, resulting in performance degradation or instability.

[0038] Among them, DPO adjusts the model parameters to make its output more in line with user preferences or specific standards, resulting in a substantial adjustment of the model parameters and covering the pre-training knowledge. The DPO stage focuses on the optimization goals of specific preferences, which reduces the performance of the model in other aspects. In addition, the preference of the training data set is single or limited, which easily leads to overfitting of the model to these data and reduced generalization ability. As the number of training epochs increases, parameter adjustments are continuously superimposed, causing the model to gradually deviate from the pre-training parameter configuration.

[0039] It should be noted that in the related art, a variety of technical solutions can be used to alleviate the forgetting problem in the training process of large language models:

[0040] For example: using periodic knowledge review technology, that is, regularly inserting pre-training tasks or data during the training process, so that the model can periodically review and strengthen the original knowledge to avoid long-term forgetting. However, although periodic knowledge review can help large language models maintain their memory of pre-training knowledge, it often increases training time and computing costs. Choosing the appropriate frequency and proportion of inserting pre-training tasks is more complicated and requires a lot of experiments and parameter adjustments. Moreover, if the difference between the pre-training task and the current task is large, noise may be introduced to interfere with the learning of the current task.

[0041] For example: parameter freezing technology, that is, in the SFT process or DPO process, only some model parameters are updated and other parameters are frozen to protect the important knowledge learned in the pre-training stage. However, while this technology protects the pre-training knowledge, it also limits the model's adaptability to new tasks. When the frozen parameters are related to the specific requirements of the new task, it may cause the model to perform poorly on the new task. In addition, how to choose frozen parameters often requires in-depth knowledge of the model structure and a large number of experiments to determine the optimal strategy.

[0042] For example: Gradual Unfreezing technology, which gradually unfreezes the model hierarchy, starting from the top layer and gradually unfreezing downwards, gradually adjusting more parameters during the training process to balance the learning of new knowledge and the retention of old knowledge. However, this technology requires a deep understanding of the model hierarchy, and the pace of unfreezing needs to be carefully designed. Unfreezing too fast may lead to a forgetting effect, while unfreezing too slowly may limit the learning of new knowledge. Determining the best unfreezing strategy requires a lot of experiments and parameter adjustments, which will increase development time and resource costs.

[0043] For example: Replay Techniques, which is to periodically replay pre-trained data or important old data during the training process, so that the model can keep the memory of old data while learning new data. However, when implemented on large-scale data sets, it will bring storage and computing challenges. Saving and managing a large amount of pre-training data or important old data requires additional storage resources. In addition, frequent replay of old data may interfere with the learning of new tasks, especially when the distribution difference between new and old data is large.

[0044] For example: regularization technology (L2 regularization or dropout) prevents the model from overfitting the fine-tuning data and helps large language models retain pre-training knowledge. However, this technology cannot completely solve the forgetting problem. It mainly prevents overfitting by increasing the difficulty of training, but cannot actively retain pre-training knowledge. In addition, excessive use of regularization may cause the model to perform poorly on new tasks, affecting its adaptability.

[0045] In the training method of the large language model in the embodiment of the present disclosure, KANs is used to replace the multi-layer perceptron MLP network in the first large language model to obtain a second large language model, and multi-task training is performed on the second large language model based on a text preference dataset to obtain a target large language model, which effectively solves the forgetting problem existing in the training process of the large language model and improves the flexibility and expressiveness of the large language model in complex tasks.

[0046] Among them, multi-task training includes supervised fine-tuning (SFT) training tasks and direct preference optimization (DPO) training tasks.

[0047] In the disclosed embodiment, the training text in the text preference data set can be input into the second largest language model, and the second largest language model can perform SFT and DPO joint training on the training text to determine the target loss of the second largest language model, and some model parameters of the second largest language model can be adjusted based on the target loss. The adjusted second largest language model can continue to be trained based on the next training sample until the training is completed and the target large language model is obtained.

[0048] Among them, the model structure of the second largest language model and the target language model is the same, both of which include a marking layer, an embedding layer, a Transform network and KANs, among which the marking layer, the embedding layer, the Transform network and KANs are connected in sequence.

[0049] Furthermore, after multi-task training of the second largest language model based on the text preference data set, text preference data can be collected, and positive and negative samples of the text preference data can be distinguished to obtain the text preference data set based on the positive samples and the negative samples.

[0050] The training method of the large language model proposed in the present disclosure obtains a pre-trained first large language model and a pre-trained knowledge activation network KANs based on text data in a knowledge base, updates the first large language model based on KANs to obtain a second large language model, and performs multi-task training on the second large language model based on a text preference data set to obtain a target large language model. Therefore, the present disclosure replaces the multi-layer perceptron network in the large language model with KANs, and performs SFT tasks and DPO tasks on the large language model jointly through a text preference data set to obtain a target large language model, thereby effectively solving the forgetting problem existing in the training process of the large language model, improving the flexibility and expressiveness of the large language model in complex tasks, and improving the stability of the large language model.

[0051] Figure 4It is a flowchart of a method for training a large language model according to the second embodiment of the present disclosure.

[0052] like Figure 4 As shown, in Figure 4 Based on the illustrated embodiment, the training method of the large language model of the embodiment of the present disclosure may specifically include the following steps:

[0053] S401, based on the text data in the knowledge base, obtain the pre-trained first language model and the pre-trained knowledge activation network KANs.

[0054] For the relevant contents of step S401, please refer to the above embodiment, which will not be repeated here.

[0055] In the above embodiment, step S102 “updating the first largest language model based on KANs to obtain the second largest language model” may specifically include the following step S402 .

[0056] S402, using KANs to replace the multi-layer perceptron MLP network in the first language model to obtain a second language model.

[0057] In the disclosed embodiment, the MLP network may be deleted from the first large language model, and KANs may be spliced ​​at the connection position of the MLP network in the first large language model.

[0058] Among them, the input dimensions of the MLP network and KANs are the same.

[0059] It should be noted that by replacing the multi-layer perceptron MLP network in the first language model with KANs, the second language model can better retain previously learned knowledge and effectively apply it to new tasks, avoiding the forgetting problem that occurs during fine-tuning or optimization. Based on the model structure of the second language model, the generalization ability and learning efficiency of the second language model are improved, and it can better adapt to various tasks and have better performance.

[0060] In the disclosed embodiment, after obtaining the second largest language model, multi-task training can be performed on the second largest language model based on the text preference data set to obtain a target large language model, wherein the multi-task training includes: SFT training task and DPO training task.

[0061] In the above embodiment, step S103 “performing multi-task training on the second largest language model based on the text preference data set to obtain a target large language model” may specifically include the following steps S403 and S405 .

[0062] S403, input the training text in the text preference data set into the second largest language model, and the second largest language model performs SFT and DPO joint training on the training text to determine the target loss of the second largest language model.

[0063] It should be noted that in the multi-task training of the second largest language model based on the text preference dataset, multiple tasks, namely the SFT training task and the DPO training task, are trained simultaneously, which can share some parameters of the large language model, so that the second largest language model retains the knowledge of old tasks while learning new tasks, so as to solve the forgetting problem existing in the training process of the large language model.

[0064] In the disclosed embodiment, the first loss of the SFT training task and the second loss of the DPO training task may be obtained, and the target loss of the second largest language model may be determined based on the first loss and the second loss.

[0065] Among them, for the first loss of the SFT training task, the training text in the text preference data set can be input into the second largest language model, and the second largest language model is used to train the training text for the SFT training task to determine the first loss of the SFT training task.

[0066] Among them, for the second loss of the DPO training task, the training text in the text preference dataset can be input into the second largest language model, and the second largest language model can be used to train the DPO training task on the training text to determine the second loss of the DPO training task.

[0067] It should be noted that the training method of the large language model proposed in the embodiment of the present disclosure introduces the first loss of the SFT training task in the DPO training stage, and adds the loss of the SFT task as a regularization term to the second loss of the DPO training task. This can ensure that the second large language model retains the important knowledge learned in the pre-training stage while optimizing user preferences.

[0068] In the disclosed embodiment, after obtaining the second loss of the DPO training task, the reward loss, penalty loss and prediction loss in the second loss can be determined, and the prediction loss can be replaced based on the first loss, and based on the reward loss, penalty loss and the first loss, the target loss can be obtained, that is, the target loss is the sum of the reward loss, penalty loss and the first loss.

[0069] S404: Adjust some model parameters of the second largest language model based on the target loss.

[0070] In the disclosed embodiment, some model parameters that need to be adjusted in the second largest language model can be determined according to the SFT training task and the DPO training task, and some model parameters of the second largest language model can be adjusted based on the target loss.

[0071] It should be noted that after obtaining some model parameters that need to be adjusted in the second largest language model, the remaining model parameters in the second largest language model can be determined based on the partial model parameters, and during the training process of the second largest language model, the remaining model parameters are maintained in a frozen state, that is, the remaining model parameters are not adjusted.

[0072] S405, continue training the adjusted second largest language model based on the next training sample until the training is completed to obtain a target large language model.

[0073] It should be noted that the present disclosure does not limit the setting of the model training end condition, and the model training end condition can be set according to actual conditions.

[0074] Optionally, the model training termination condition may be set as a target loss value being less than a preset loss threshold; optionally, the model training termination condition may also be set as the number of adjustments to the model parameters of the second largest language model reaching a preset number threshold.

[0075] Among them, the model structure of the second largest language model and the target language model is the same, both of which include a marking layer, an embedding layer, a Transform network and KANs, among which the marking layer, the embedding layer, the Transform network and KANs are connected in sequence.

[0076] In summary, the training method of the large language model proposed in the present disclosure obtains a pre-trained first large language model and a pre-trained knowledge activation network KANs based on text data in a knowledge base, uses KANs to replace the multi-layer perceptron MLP network in the first large language model to obtain a second large language model, inputs the training text in the text preference data set into the second large language model, and uses the second large language model to perform SFT and DPO joint training on the training text, determines the target loss of the second large language model, adjusts some model parameters of the second large language model based on the target loss, and continues to train the adjusted second large language model based on the next training sample until the target large language model is obtained after the training. Thus, the training method of the large language model proposed in the present disclosure is The training method uses KANs to replace the multi-layer perceptron MLP network in the first language model to obtain the second language model. KANs improves the performance of the large language model in complex tasks through learnable activation functions and grid expansion technology, and enhances the flexibility and expressiveness of the target large language model. The second language model performs SFT and DPO joint training on the training text, and introduces SFT loss in the DPO stage, which is conducive to maintaining the model's memory of pre-training knowledge in the DPO stage, and effectively solves the forgetting problem in the training process of the large language model. Due to the high parameter efficiency and high interpretability of KANs, the target large language model can have stronger generalization ability, which improves the stability and performance of the large language model.

[0077] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0078] According to an embodiment of the present disclosure, the present disclosure also provides a large language model training device for implementing the above-mentioned large language model training method.

[0079] Figure 5 4 is a block diagram of a large language model training device according to an embodiment of the present disclosure.

[0080] like Figure 5 As shown, the large language model training device 500 includes: an acquisition module 501, an update module 502 and a training module 503.

[0081] An acquisition module 501 is used to acquire a pre-trained first language model and a pre-trained knowledge activation network KANs based on text data in a knowledge base;

[0082] An updating module 502, configured to update the first largest language model based on the KANs to obtain a second largest language model;

[0083] The training module 503 is used to perform multi-task training on the second large language model based on the text preference data set to obtain a target large language model.

[0084] In one embodiment of the present disclosure, the updating module 502 is further used to: use the KANs to replace the multi-layer perceptron MLP network in the first large language model to obtain a second large language model.

[0085] In one embodiment of the present disclosure, the updating module 502 is further used to: delete the MLP network from the first large language model; and splice the KANs at the connection position of the MLP network in the first large language model.

[0086] In one embodiment of the present disclosure, the input dimensions of the MLP network and the KANs are the same.

[0087] In one embodiment of the present disclosure, the multi-task training includes: fine-tuning SFT training task and direct preference optimization DPO training task.

[0088] In one embodiment of the present disclosure, the training module 503 is further used to: input the training text in the text preference data set into the second largest language model, and use the second largest language model to jointly train the training text using SFT and DPO to determine the target loss of the second largest language model; adjust some model parameters of the second largest language model based on the target loss; and continue training the adjusted second largest language model based on the next training sample until the training is completed and the target large language model is obtained.

[0089] In one embodiment of the present disclosure, the device 500 is further used to: determine the part of model parameters that need to be adjusted in the second largest language model according to the SFT training task and the DPO training task.

[0090] In one embodiment of the present disclosure, the apparatus 500 is further configured to: determine the remaining model parameters in the second largest language model according to the partial model parameters, and maintain the remaining model parameters in a frozen state during the training of the second largest language model.

[0091] In one embodiment of the present disclosure, the device 500 is further used to: obtain a first loss of the SFT training task and a second loss of the DPO training task; and determine a target loss of the second largest language model based on the first loss and the second loss.

[0092] In one embodiment of the present disclosure, the device 500 is also used to: determine the reward loss, penalty loss and predicted loss in the second loss; replace the predicted loss based on the first loss, and obtain the target loss based on the reward loss, penalty loss and the first loss.

[0093] In one embodiment of the present disclosure, the device 500 is further used to: collect text preference data, and distinguish between positive and negative samples of the text preference data, and obtain the text preference data set based on the positive samples and the negative samples.

[0094] In one embodiment of the present disclosure, the second largest language model and the target language model have the same model structure, both of which include a marking layer, an embedding layer, a Transform network and the KANs, and the marking layer, the embedding layer, the Transform network and the KANs are connected in sequence.

[0095] The training device of the large language model proposed in the present disclosure obtains a pre-trained first large language model and a pre-trained knowledge activation network KANs based on text data in a knowledge base, updates the first large language model based on KANs to obtain a second large language model, and performs multi-task training on the second large language model based on a text preference data set to obtain a target large language model. Therefore, the present disclosure replaces the multi-layer perceptron network in the large language model with KANs, and performs SFT tasks and DPO tasks on the large language model jointly through a text preference data set to obtain a target large language model, thereby effectively solving the forgetting problem existing in the training process of the large language model, improving the flexibility and expressiveness of the large language model in complex tasks, and improving the stability of the large language model.

[0096] According to an embodiment of the present disclosure, the present disclosure also proposes an electronic device, a readable storage medium, and a computer program product.

[0097] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0098] like Figure 6As shown, the device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0099] A number of components in the device 600 are connected to the I / O interface 605, including: an input unit 606, such as a keyboard, a mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a disk, an optical disk, etc.; and a communication unit 609, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0100] The computing unit 601 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 601 performs the various methods and processes described above, such as the training method of a large language model. For example, in some embodiments, the training method of a large language model may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the training method of the large language model described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the training method of the large language model in any other appropriate manner (e.g., by means of firmware).

[0101] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0102] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be presented to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0103] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer 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.

[0104] To propose interactions with a user account, the systems and techniques described herein may be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user account; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user account can propose input to the computer. Other types of devices may also be used to propose interactions with the user account; for example, feedback proposed to the user account may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user account may be received in any form (including acoustic input, voice input, or tactile input).

[0105] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user account computer with a graphical user account interface or a web browser through which a user account can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0106] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0107] According to an embodiment of the present disclosure, the present disclosure further provides a computer program product, including a computer program, wherein when the computer program is executed by a processor, the steps of the large language model training method described in the above embodiment of the present disclosure are implemented.

[0108] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0109] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for training a large language model, wherein: The method comprises: Based on the text data in the knowledge base, obtain the pre-trained first language model and pre-trained knowledge activation network KANs; Updating the first language model based on the KANs to obtain a second language model; Based on the text preference dataset, multi-task training is performed on the second largest language model to obtain the target large language model.

2. The method according to claim 1, wherein: The updating of the first language model based on the KANs to obtain a second language model includes: The KANs are used to replace the multilayer perceptron MLP network in the first language model to obtain a second language model.

3. The method according to claim 2, wherein: The method of replacing the multilayer perceptron MLP network in the first language model with the KANs to obtain a second language model includes: Deleting the MLP network from the first large language model; The KANs are spliced ​​at the connection position of the MLP network in the first large language model.

4. The method according to claim 3, wherein: The input dimensions of the MLP network and the KANs are the same.

5. The method according to claim 1, wherein: The multi-task training includes: fine-tuning SFT training task and direct preference optimization DPO training task.

6. The method according to claim 2, wherein: The performing multi-task training on the second large language model based on the text preference dataset to obtain a target large language model includes: Inputting the training text in the text preference data set into the second largest language model, and having the second largest language model jointly train the training text with SFT and DPO to determine the target loss of the second largest language model; Adjusting some model parameters of the second largest language model based on the target loss; The adjusted second largest language model is continuously trained based on the next training sample until the training is completed to obtain the target large language model.

7. The method according to claim 6, wherein: Before adjusting some model parameters of the second largest language model based on the target loss, the method further includes: According to the SFT training task and the DPO training task, the part of model parameters that need to be adjusted in the second largest language model is determined.

8. The method according to claim 6, wherein: The method further comprises: The remaining model parameters in the second largest language model are determined according to the partial model parameters, and during the training process of the second largest language model, the remaining model parameters are maintained in a frozen state.

9. The method according to claim 6, wherein: The method further comprises: Obtaining a first loss for the SFT training task and a second loss for the DPO training task; A target loss of the second largest language model is determined according to the first loss and the second loss.

10. The method according to claim 9, wherein: The step of determining a target loss of the second largest language model according to the first loss and the second loss includes: Determine the reward loss, penalty loss and prediction loss in the second loss; The predicted loss is replaced based on the first loss, and the target loss is obtained based on the reward loss, the penalty loss and the first loss.

11. The method according to claim 1, wherein: After performing multi-task training on the second language model based on the text preference dataset, the method further includes: The text preference data is collected, and the text preference data is distinguished into positive and negative samples, and the text preference data set is obtained based on the positive samples and the negative samples.

12. The method according to claim 1, wherein: The second largest language model and the target language model have the same model structure, both of which include a marking layer, an embedding layer, a Transform network and the KANs, and the marking layer, the embedding layer, the Transform network and the KANs are connected in sequence.

13. A training device for a large language model, wherein: The device comprises: An acquisition module is used to acquire a pre-trained first language model and a pre-trained knowledge activation network KANs based on text data in the knowledge base; An updating module, configured to update the first largest language model based on the KANs to obtain a second largest language model; The training module is used to perform multi-task training on the second largest language model based on the text preference data set to obtain a target large language model.

14. An electronic device, characterized in that: including a processor and a memory; The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the method according to any one of claims 1 to 12.

15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 12 is implemented.

16. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Generative large language model training method and model-based man-machine voice interaction method

    CN116244416A

  • Financial intelligent analysis model training method and system oriented to multilevel tasks

    CN117892799A

  • Webpage navigation agent training method based on large language model

    CN118114742A

  • Knowledge question-answering method and system based on large language model

    CN118210890A

Cited By

  • Model training method, data processing method, electronic equipment and storage medium

    CN118886519A

  • Metalearning-based large language model training method, data classification method and device

    CN119378652A

  • Large language model training method and device, computer equipment and storage medium

    CN119397010A

  • Mathematical test question generation and solution collaborative enhancement method and system based on large model

    CN120822602A