Model training method and device and computer readable storage medium

By extracting task-related non-entity words to generate representation matrices and main gradient space orthogonal basis, the model parameters are updated, which solves the problem of unavailable data in fine-tuning of pre-training models, achieves knowledge retention and enhancement of downstream task capabilities, and alleviates the problem of model Forgetting phenomenon.

CN118797335APending Publication Date: 2024-10-18CHINA MOBILE COMM LTD RES INST +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410106368.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-25
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

When fine-tuning pre-trained models (such as BERT/GPT, etc.), the original data is usually unavailable, causing the gradient projection memory method to be unable to construct the main gradient space and orthogonal basis, and cannot effectively alleviate the "catastrophic forgetting" phenomenon of the model.

Method used

By extracting task-related non-entity words, a representation matrix is ​​generated, and based on the matrix, a main gradient space orthogonal basis is generated, and the model parameters are updated to achieve the retention of model knowledge and the enhancement of downstream task capabilities.

Benefits of technology

It effectively solves the problem of unavailability of original data, achieves the retention of model knowledge and enhances downstream task capabilities, and avoids the phenomenon of model forgetting during multi-task training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118797335A_ABST
    Figure CN118797335A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a model training method, a model training device, electronic equipment, a chip, a computer readable storage medium and a computer program product, and the method comprises the steps: extracting a first non-entity word of training data of a first task, and obtaining a first representation matrix of the first non-entity word; generating a first main gradient space orthogonal basis of a basic model based on the first representation matrix; and updating parameters of the basic model based on the first gradient space orthogonal basis to obtain a first model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of large model technology, and specifically to a model training method, a model training device, an electronic device, a chip, a computer-readable storage medium, and a computer program product. Background Art

[0002] The gradient projection memory method needs to use the data X0 required for training the basic model during training. Only based on X0 can the main gradient space and basis related to the basic model be constructed, and the parameter update direction orthogonal to X0 can be obtained based on the main gradient space. In multi-task training scenarios, the original data X0 is available, but for the pre-training-fine-tuning paradigm, especially when using some classic pre-training models (such as BERT / GPT, etc.), the original data is usually not available, so only a subset of the original data can be obtained through some sampling methods, and the correct distribution of the original data cannot be guaranteed. Summary of the invention

[0003] Embodiments of the present application provide a model training method, a model training device, an electronic device, a chip, a computer-readable storage medium, and a computer program product.

[0004] The model training method provided in the embodiment of the present application includes:

[0005] Extracting a first non-entity word from training data of a first task to obtain a first representation matrix of the first non-entity word;

[0006] Based on the first characterization matrix, generating a first principal gradient space orthogonal basis of a basic model;

[0007] Based on the first gradient space orthogonal basis, the parameters of the basic model are updated to obtain a first model.

[0008] The model training device provided in the embodiment of the present application includes:

[0009] An extraction unit: used for extracting a first non-entity word from training data of a first task, and obtaining a first representation matrix of the first non-entity word;

[0010] A generating unit: used to generate a first principal gradient space orthogonal basis of a basic model based on the first characterization matrix; based on the first gradient space orthogonal basis, update the parameters of the basic model to obtain a first model.

[0011] The electronic device provided in an embodiment of the present application includes: a processor and a memory, the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute any model training method provided in the embodiment of the present application.

[0012] The chip provided in the embodiment of the present application includes: a processor, which is used to call and run a computer program from a memory, so that a device equipped with the chip executes any model training method provided in the embodiment of the present application.

[0013] The computer-readable storage medium provided in the embodiments of the present application is used to store a computer program, and the computer program enables a computer to execute any model training method provided in the embodiments of the present application.

[0014] The computer program product provided in the embodiments of the present application includes a computer program, which, when executed by a processor, implements any model training method provided in the embodiments of the present application.

[0015] Through the model training method provided in the embodiment of the present application, non-entity words related to the current task or field are obtained, and a representation matrix equivalent to the previous task is obtained, which can effectively solve the problem that the training data of the previous task cannot be obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0017] Figure 1 This is a schematic diagram of the implementation process of the model training method provided in the embodiment of the present application. Figure 1 ;

[0018] Figure 2 Schematic diagram of the implementation process of the model training method provided in the embodiment of the present application Figure 2 ;

[0019] Figure 3 A schematic diagram of the structure of a model training device 300 provided in an embodiment of the present application;

[0020] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present application;

[0021] Figure 5 A schematic structural diagram of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0022] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0023] It should be noted that in the embodiments of the present application, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the embodiments of the present application, the character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0024] In the description of the embodiments of the present application, the term "corresponding" may indicate a direct or indirect correspondence between two items, or an association relationship between the two items, or a relationship between indication and being indicated, configuration and being configured, and the like.

[0025] To facilitate understanding of the technical solutions of the embodiments of the present application, the relevant technologies of the embodiments of the present application are described below. The following related technologies can be arbitrarily combined with the technical solutions of the embodiments of the present application as optional solutions, and they all belong to the protection scope of the embodiments of the present application.

[0026] In the related technologies, pre-trained language models (such as BERT / GPT) play an increasingly important role in the field of natural language processing and have excellent performance in natural language understanding and generation tasks. Through pre-training on a large amount of unsupervised corpus, the model can complete the learning of downstream tasks and achieve good results by fine-tuning with a small amount of labeled data. However, after the fine-tuned model, its original knowledge and task processing capabilities will be catastrophically "forgotten". For example, the original gpt model has the ability to continue writing customer service knowledge, but this ability has been weakened through training with multiple rounds of customer service conversation data; the original model has the ability to extract information from text, but through training with conversation data, it can no longer complete the information extraction task. In the research and development of key technologies for answering and managing harassing calls, there are two core tasks: based on the content of the call, the language model needs to determine whether there is harassment on the one hand, and give a reasonable response on the other hand. If the language model is directly trained on the downstream task on the phone content reply data set, it will lose some general capabilities and cannot determine whether there is harassment. In order to solve this problem, there are four types of algorithms in the related technologies:

[0027] Continuous learning method: This method usually adds a regularization term so that the model parameters θ during new data training are not much different from the basic model parameters θ0, weakening the model's update ability and thus slowing down the model's "catastrophic forgetting". For example, the loss function is modified and constrained by the L1 or L2 penalty factor |θ-θ0| or |θ-θ0|^2. Similarly, the knowledge distillation method can be used to penalize and constrain the output results of the model before and after continued training, so that the output of the trained model is as close as possible to the output of the basic model, specifically |fθ(x)-f(θ0)(x)|^2.

[0028] Out-of-distribution (OOD) generalization method: For example, the Wise-FT algorithm makes a linear interpolation between the parameters of the base model and the downstream training parameters, so as to maintain a balance between the basic capabilities and the new tasks, thereby slowing down the forgetting of the model. The original model parameters are θ0, and the downstream training model parameters are θ. Then the generalized model parameters can be expressed as θ = αθ0 + (1 - α)θ, where α is a hyperparameter used to balance the base model and the downstream training model. When α is close to 1, the model tends to retain the basic knowledge; on the contrary, when it is close to 0, the downstream task ability will be enhanced, while the basic knowledge and ability will be weakened. Therefore, choosing an appropriate α can weaken the forgetting of the model's generalization of basic capabilities while the model retains the downstream task ability. In general scenarios, this method performs better than the regularization term method.

[0029] Parameter-efficient fine-tuning method: The main purpose is to efficiently train and optimize the base model by fixing the base model parameters, adding additional network structures (the number of parameters in this part is much smaller than that of the base model), and only updating the parameters of the additional network during training. For example, the p-tuning algorithm adds a differentiable prompt encoder structure before the input embedding of the base model, so that the prompt part can be encoded and added to the original input. During model training, the base model structure is frozen, and only the parameters of the prompt encoder part are updated. Another example is the LoRA algorithm, which performs low-rank decomposition on the linear layers in the base model. For example, the Q / K / V matrices in the attention mechanism are decomposed into the form of AXB, where A = NXd, B = dXN, N is the input or output dimension of the Q / K / V matrix, and d is a number much smaller than N. During training, only the parameters of A / B are updated, and the original model parameters are frozen. Considering d << N, the overall number of updated parameters is much smaller than that of the base model.

[0030] Gradient projection memory method: The base model parameters are W0, and the parameter change amount is ΔW0. When the direction of the parameter change amount is orthogonal to the original task data X0, the output of the new model on the original data can be expressed as WX0 = (W0 + ΔW0)X0 = W0X0. It can be seen that the output of the model updated by the downstream task remains unchanged on the original data, that is, the new model retains the original knowledge and ability.

[0031] Among the above four types of algorithms, the continued learning (including knowledge distillation) method, the distribution out-of-distribution generalization method, and the parameter efficiency fine-tuning method intuitively slow down the "catastrophic forgetting" phenomenon; the gradient projection memory method theoretically analyzes knowledge forgetting and draws a theoretically feasible conclusion. However, the above methods still have some shortcomings:

[0032] The gradient projection memory method needs to use the data X0 required for training the basic model during training. Only based on X0 can the main gradient space and basis related to the basic model be constructed, and the parameter update direction orthogonal to X0 can be obtained based on the main gradient space. In multi-task training scenarios, the original data X0 is available, but for the pre-training-fine-tuning paradigm, especially when using some classic pre-training models (such as BERT / GPT, etc.), the original data is usually not available, so only a subset of the original data can be obtained through some sampling methods, and the correct distribution of the original data cannot be guaranteed;

[0033] When the continuous learning method trains downstream tasks, it is necessary to balance the main loss function and the regularization term. If the regularization term weight is too large, the model will not be able to learn effectively in downstream tasks; if the regularization term is too small, it cannot ensure that the knowledge forgetting is alleviated. At the same time, the continuous learning method usually requires intermittent input of the original task data, otherwise, it cannot be clearly shown that the knowledge forgetting phenomenon will be alleviated;

[0034] The out-of-distribution generalization method also needs to balance the weights of the downstream task learning parameters and the basic model parameters. However, if the downstream task is very different from the basic model task, a simple linear weight relationship cannot ensure that a more reasonable weight value can be found, so that the model can perform well in the downstream task while retaining the knowledge of the basic model;

[0035] The parameter efficiency fine-tuning method builds a differentiable network structure outside the main model and only updates this part of the network during training to reduce the impact on the main model. However, this method cannot ensure that the output results of the randomly input original task data will not change significantly after passing through the updated network part.

[0036] Therefore, existing methods to alleviate the "catastrophic forgetting" phenomenon cannot effectively balance interpretability and dependence on original data.

[0037] Figure 1 Schematic diagram of the implementation process of the model training method provided in the embodiment of the present application Figure 1 ,like Figure 1 As shown, the embodiment of the present application provides a model training method, which includes the following steps:

[0038] Step 101: extract a first non-entity word from training data of a first task, and obtain a first representation matrix of the first non-entity word.

[0039] In an optional implementation of the present application, the number of the first non-entity words is one or more.

[0040] Exemplarily, in the generative model, in different natural language processing related tasks or professional fields, any non-entity word representations such as function words or verbs should be kept in a subspace that is independent of the task or field. The scheme uses non-entity words in the downstream task data to replace the non-entity words in the original model training data, and uses these non-entity words to obtain the orthogonal basis in the main gradient space. Specifically: for a piece of training data Ti = {wi0, wi1, ...wik}, where wik is the kth word in the text. Using the syntactic dependency analysis method, first extract the entity part of the text, such as the subject in the subject-predicate structure, the object in the verb-object structure, etc., which are all entity words related to the task or field. Taking the PKU Chinese tree library as an example, the entity words included in the dependency relationship are shown in Table 1:

[0041] TAG Description Dependencies ACT action object Action Object IOB indirect object Indirect Object POB Propositional object Preposition SBV subject subject TPC topic topic VOB direct object object

[0042] Table 1

[0043] Among them, the subject may exist in the subject-predicate relationship (SBV), attribute relationship (ATT), coordinate relationship (COO), left adjunct relationship (LAD) and right adjunct relationship (RAD); the object exists in the verb-object relationship (VOB), indirect-object relationship (IOB), fronting-object (FOB), etc.

[0044] After confirming the entity words, use the special symbol [mask] to mask these entity words, and the remaining part is non-entity words, that is, the words mentioned above that are not related to the task or field. Use the text representation of these entity words masks as an information representation equivalent to the original data, and further use these representations to solve the orthogonal basis of the main gradient space. For example, the baichuan13b-base model can be used as the base model to encode the text and implement the generative task.

[0045] In an optional implementation manner of the present application, the extracting the first non-entity word of the training data of the first task includes:

[0046] Through dependency syntactic analysis, a first entity word in the training data of the first task is obtained; the first entity word is an entity word related to the first task and / or field; a mask operation is performed on the first entity word in the training data of the first task to obtain the first non-entity word.

[0047] Step 102: Based on the first characterization matrix, generate a first principal gradient space orthogonal basis of the basic model.

[0048] For the LoRA structure, assuming that a linear layer W in the basic model L ∈R dxk dk, where W L is the linear layer in the base model, R dxk The input dimension of the linear layer is d, the output dimension is k, and the update parameters are decomposed into BA using low-rank decomposition, where B∈R dxr ,A∈R rxk , B and A both refer to linear layers, so W L The update can be expressed as W L +ΔW L =W L +BA, where ΔW represents the linear layer W L The update amount during training W L The parameters are frozen, and the low-rank decomposition matrices A and B will participate in the update. In the initial state, matrix A is initialized with a random Gaussian, and matrix B is initialized to 0. In this way, after the LoRA structure is added, before the downstream task (i.e., the first task) is trained, the output of the basic model training data will remain consistent with the previous one, and there is no "catastrophic forgetting" phenomenon in the model. Exemplarily, to adapt to the baichuan13b-base model, the LoRA structure is added to the "Wpack" linear module of the base model. "Wpack" is a linear unit in the attention structure of the baichuan model. Its purpose is to generate the state matrix (3d) of Q / K / V according to the input dimension (d).

[0049] After the basic model with LoRA structure is fine-tuned by downstream tasks, let the parameters of the lth LoRA layer be in, represents the lth LoRA layer, and ft means fine-tuning, which is the product of the lth linear layer B and the lth linear layer A. At this time, the gradient of this part of the parameters can be expressed as Refers to the gradient of the lth LoRA layer, that is, the derivative of the final loss function of the network to this LoRA layer, where L ft is the loss function of the downstream fine-tuning task. In the generative task, it can be expressed as -logp(x0,x1,...,x n) where p(x0,x1,...,x n ) refers to the probability value of generating text, x n Refers to the nth word of this text. According to the definition, the main gradient space is the vector space spanned by the basic model training data. In the scheme, the text representation of the entity mask layer is used instead of the basic model training data, so the representation matrix is ​​defined as Refers to the representation matrix of the bth batch of the lth LoRA layer, where It represents the input representation of the i-th text data in the mini-batch corresponding to the masked entity word in the l-th LoRA layer. In order to obtain the orthogonal basis of the main gradient space, the representation matrix is ​​first decomposed by SVD to obtain a set of orthogonal vectors: is the result of SVD decomposition, which is decomposed into and Transpose the form of multiplying three matrices, where Ul is selected b The first k vectors form the memory matrix Then the final main gradient space orthogonal basis can be expressed as: The left side of the equal sign represents the gradient representation required for updating the parameters of the l-th LoRA layer (it is perpendicular to the direction of the memory matrix), the first variable on the right represents the original gradient of the l-th LoRA layer, and the second variable on the right represents the projection of the original gradient on the memory matrix (the original gradient multiplied by the memory matrix and then multiplied by the transpose of the memory matrix), that is, the main gradient minus its projection on the representation matrix.

[0050] Based on this, in an optional implementation manner of the present application, generating a first principal gradient space orthogonal basis of the basic model based on the first representation matrix includes:

[0051] Performing singular value decomposition (SVD) processing on the first representation matrix to generate a first orthogonal vector group; the first orthogonal vector group includes at least one orthogonal vector;

[0052] The first K orthogonal vectors in the first orthogonal vector group are selected to form a first memory matrix; K is a positive integer;

[0053] Based on the main gradient of the basic model and the first memory matrix, the first main gradient space orthogonal basis is generated.

[0054] Step 103: Based on the first gradient space orthogonal basis, update the parameters of the basic model to obtain a first model.

[0055] In an optional implementation manner of the present application, the present invention further includes: extracting a second non-entity word from the training data of the second task to obtain a second representation matrix of the second non-entity word;

[0056] Generate a second principal gradient space orthogonal basis of the first model based on the second representation matrix and the first memory matrix;

[0057] Based on the second gradient space orthogonal basis, the parameters of the first model are updated to obtain a second model.

[0058] After the downstream task task0 (first task) is completed, if it is necessary to continue training a new downstream task (second task), such as task1, there are two options for the representation matrix: the first is to sample from the training data in task task0 and encode from the basic model to obtain the representation matrix; the second is to continue using the entity word masking strategy, continue to perform dependency syntactic analysis on the text of the new task task1, and extract entity words for masking operations to obtain the representation matrix. In order to maintain the consistency of the representation matrix, the entity word masking strategy is used in any round of downstream tasks taski to obtain the representation matrix of the current task. Considering that when training the taski task, the basic model task and the previous i-1 task representation matrices should be covered for orthogonal basis solution, the new memory matrix Mi should be based on the memory matrix of the previous task and updated into the current task representation matrix. That is: The left side of the equal sign represents the memory matrix of the lth LoRA layer of the i-th task, and the right side represents the memory matrix of the lth LoRA layer of the i-1th task. The memory matrix is ​​updated by adding the representation matrix of the lth LoRA layer of the i-th task. Since direct update will cause the new memory matrix to have redundant basis (that is, it is not the largest irrelevant group), it is necessary to deduplicate the representation matrix and memory matrix of the current task before updating. Suppose the representation matrix under the new task is Then the deduplication base operation can be expressed as: It is a specific representation of the update operation, which is obtained by subtracting the product of the following three matrices from the representation matrix of the lth LoRA layer under the i-th task. Then, as above, the final main gradient space orthogonal basis of the new task taski can be expressed as: in, It is a new task to re-represent the matrix Decompose and select the first k vectors to get it.

[0059] Based on this, in an optional implementation manner of the present application, generating a second principal gradient space orthogonal basis of the first model based on the first representation matrix and the first memory matrix includes:

[0060] Deduplication processing is performed on the second representation matrix and the first memory matrix to obtain a third representation matrix;

[0061] Performing SVD processing on the third characterization matrix to generate a second orthogonal vector group; the second orthogonal vector group includes at least one orthogonal vector;

[0062] Select the first N orthogonal vectors in the second orthogonal vector group to form a second memory matrix; N is a positive integer;

[0063] Based on the main gradient of the first model and the second memory matrix, the second main gradient space orthogonal basis is generated.

[0064] In an optional implementation manner of the present application, updating the parameters of the basic model based on the first gradient space orthogonal basis to obtain the first model includes:

[0065] Based on the first gradient space orthogonal basis, updating the parameters of the basic model by gradient projection to obtain a first model;

[0066] The updating of the parameters of the first model based on the second gradient space orthogonal basis to obtain the second model comprises:

[0067] Based on the second gradient space orthogonal basis, the parameters of the first model are updated by gradient projection to obtain a second model.

[0068] Exemplary, reference Figure 2 , Figure 2 Schematic diagram of the implementation process of the model training method provided in the embodiment of the present application Figure 2 .like Figure 2 As shown, the following steps are included:

[0069] Step 201: Entity word masking operation to obtain a representation matrix.

[0070] Extract the entity words in the training data of the current task, perform masking operation on the entity words to obtain the representation matrix of the non-entity words of the current task.

[0071] Step 202: Obtain a memory matrix.

[0072] Here, for the first training task, singular value decomposition (SVD) processing is performed on the representation matrix of the current task to generate an orthogonal vector group; the first orthogonal vector group includes at least one orthogonal vector; the first K orthogonal vectors in the orthogonal vector group are selected to form a memory matrix; K is a positive integer;

[0073] For tasks that are not the first training task, the representation matrix of the current task and the memory matrix of the previous task are deduplicated to obtain a new representation matrix; the new representation matrix is ​​processed by SVD to generate an orthogonal vector group; the orthogonal vector group includes at least one orthogonal vector; the first N orthogonal vectors in the orthogonal vector group are selected to form a memory matrix.

[0074] Step 203: Obtain the main gradient space orthogonal basis.

[0075] The main gradient space orthogonal basis of the current model is obtained through the updated memory matrix and the main gradient of the current model.

[0076] Step 204: Gradient update to obtain the trained model.

[0077] The model gradient is updated through the main gradient space orthogonal basis to obtain the trained model.

[0078] It should be noted that for the first training task, the current model is the base model; for a non-first training task, the current model is the model trained in the previous training task.

[0079] In the technology of answering and managing harassing calls, there are two core tasks: judging whether the incoming call contains harassing information; and giving a reasonable reply to the incoming call. Both tasks can be achieved by training the language model on their respective relevant data sets. Using the traditional training method, if a single model is trained in series, the ability of the first task will be forgotten after training the second task; if multiple models are used in parallel, the video memory usage will be doubled. Therefore, according to the scheme proposed in this application, a single original language model is used to train the two tasks in sequence. Specifically, first, the task of judging whether the incoming call contains harassing information is trained, and the dependency syntactic analysis algorithm is used to mask the corresponding data and decompose it through SVD to obtain the memory matrix of task 1; then, when training the call reply task, the above method is also used to obtain the task-related memory matrix, and the representation matrix of task 2 and the memory matrix of task 1 are deduplicated to obtain the real memory matrix of task 2. Finally, the gradient projection method is used to complete the training.

[0080] The model training method provided in the embodiment of the present application performs dependency syntactic analysis on the text of the current task, obtains entity words related to the task or field, and performs masking operations on the entity words to obtain a representation matrix equivalent to the previous task. It can effectively solve the problem that the training data of the previous task cannot be obtained. In addition, based on the parameter efficiency training framework LoRA, the gradient projection memory algorithm is introduced to provide interpretability for fine-tuning of large language models, and gradient update correction is performed on the LoRA structure to save the parameters of the original model, making the interpretability of large language models to alleviate the CF phenomenon more efficient.

[0081] The present application embodiment also provides a model training device 300, referring to Figure 3 The model training device 300 in this embodiment includes:

[0082] Extraction unit 310: used to extract a first non-entity word of training data of a first task, and obtain a first representation matrix of the first non-entity word;

[0083] The generating unit 320 is used to generate a first principal gradient space orthogonal basis of a basic model based on the first characterization matrix; based on the first gradient space orthogonal basis, update the parameters of the basic model to obtain a first model.

[0084] In an embodiment of the present application, the extraction unit 310 is used to obtain the first entity word in the training data of the first task through dependency syntactic analysis; the first entity word is an entity word related to the first task and / or field; and a mask operation is performed on the first entity word in the training data of the first task to obtain the first non-entity word.

[0085] In an embodiment of the present application, the generation unit 320 is used to perform singular value decomposition (SVD) processing on the first characterization matrix to generate a first orthogonal vector group; the first orthogonal vector group includes at least one orthogonal vector; the first K orthogonal vectors in the first orthogonal vector group are selected to form a first memory matrix; K is a positive integer; based on the main gradient of the basic model and the first memory matrix, the first main gradient space orthogonal basis is generated.

[0086] In an embodiment of the present application, the extraction unit 310 is used to extract the second non-entity word of the training data of the second task to obtain a second representation matrix of the second non-entity word; the generation unit 320 is used to generate a second principal gradient space orthogonal basis of the first model based on the second representation matrix and the first memory matrix; based on the second gradient space orthogonal basis, the parameters of the first model are updated to obtain the second model.

[0087] In an embodiment of the present application, the generation unit 320 is used to deduplicate the second characterization matrix and the first memory matrix to obtain a third characterization matrix; perform SVD processing on the third characterization matrix to generate a second orthogonal vector group; the second orthogonal vector group includes at least one orthogonal vector; the first N orthogonal vectors in the second orthogonal vector group are selected to form a second memory matrix; N is a positive integer; based on the main gradient of the first model and the second memory matrix, the second main gradient space orthogonal basis is generated.

[0088] In an embodiment of the present application, the generation unit 320 is used to update the parameters of the basic model by gradient projection based on the first gradient space orthogonal basis to obtain a first model; and to update the parameters of the first model by gradient projection based on the second gradient space orthogonal basis to obtain a second model.

[0089] Those skilled in the art should understand that Figure 3 The implementation functions of each unit in the model training device 300 shown can be understood by referring to the relevant description of the aforementioned method. Figure 3The functions of each unit in the model training device 300 shown can be implemented by a program running on a processor, or by a specific logic circuit.

[0090] Figure 4 It is a schematic structural diagram of an electronic device 400 provided in an embodiment of the present application. Figure 4 The electronic device 400 shown includes a processor 410, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.

[0091] Alternatively, if Figure 4 As shown, the electronic device 400 may further include a memory 420. The processor 410 may call and run a computer program from the memory 420 to implement the method in the embodiment of the present application.

[0092] The memory 420 may be a separate device independent of the processor 410 , or may be integrated into the processor 410 .

[0093] Alternatively, if Figure 4 As shown, the electronic device 400 may further include a transceiver 430, and the processor 410 may control the transceiver 430 to communicate with other devices, specifically, may send information or data to other devices, or receive information or data sent by other devices.

[0094] The transceiver 430 may include a transmitter and a receiver. The transceiver 430 may further include an antenna, and the number of the antennas may be one or more.

[0095] The electronic device 400 may specifically be the model training device 300 of the embodiment of the present application, and the electronic device 400 may implement the corresponding processes implemented by the model training device 300 in each method of the embodiment of the present application, which will not be described in detail here for the sake of brevity.

[0096] Exemplarily, an embodiment of the present application further provides a computer program product, including a computer program, and the computer program can be executed by the processor 410 of the communication device 400 to complete the steps of any of the aforementioned methods.

[0097] Figure 5 It is a schematic structural diagram of the chip of an embodiment of the present application. Figure 5 The chip 500 shown includes a processor 510, which can call and run a computer program from a memory to implement the method in the embodiment of the present application.

[0098] Alternatively, if Figure 5As shown, the chip 500 may further include a memory 520. The processor 510 may call and run a computer program from the memory 520 to implement the method in the embodiment of the present application.

[0099] The memory 520 may be a separate device independent of the processor 510 , or may be integrated into the processor 510 .

[0100] Optionally, the chip 500 may further include an input interface 530. The processor 510 may control the input interface 530 to communicate with other devices or chips, and specifically, may obtain information or data sent by other devices or chips.

[0101] Optionally, the chip 500 may further include an output interface 540. The processor 510 may control the output interface 540 to communicate with other devices or chips, and specifically, may output information or data to other devices or chips.

[0102] The chip can be applied to the model training device 300 in the embodiment of the present application, and the chip can implement the corresponding processes implemented by the model training device 300 in each method of the embodiment of the present application. For the sake of brevity, it will not be repeated here.

[0103] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0104] It should be understood that the processor of the embodiment of the present application may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by the hardware integrated logic circuit or software instructions in the processor. The above processor can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or the hardware and software modules in the decoding processor are combined and performed. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, and other mature storage media in the art. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0105] It can be understood that the memory in the embodiments of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DR RAM). It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0106] It should be understood that the above-mentioned memory is exemplary but not restrictive. For example, the memory in the embodiments of the present application may also be static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous link dynamic random access memory (synch link DRAM, SLDRAM) and direct memory bus random access memory (Direct Rambus RAM, DR RAM), etc. That is to say, the memory in the embodiments of the present application is intended to include but not limited to these and any other suitable types of memory.

[0107] The embodiment of the present application also provides a computer-readable storage medium for storing a computer program. The computer-readable storage medium can be applied to the model training device 300 in the embodiment of the present application, and the computer program enables the computer to execute the corresponding processes implemented by the model training device 300 in each method of the embodiment of the present application, which will not be described here for the sake of brevity.

[0108] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0109] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0110] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0111] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0112] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0113] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a model training device 300, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory,) ROM, random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0114] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A model training method, characterized in that: include: Extracting a first non-entity word from training data of a first task, and obtaining a first representation matrix of the first non-entity word; Based on the first characterization matrix, generating a first principal gradient space orthogonal basis of a basic model; Based on the first gradient space orthogonal basis, the parameters of the basic model are updated to obtain a first model.

2. The method according to claim 1, characterized in that The extracting the first non-entity word of the training data of the first task includes: Obtaining a first entity word in the training data of the first task through dependency syntactic analysis; the first entity word is an entity word related to the first task and / or field; A masking operation is performed on the first entity word in the training data of the first task to obtain the first non-entity word.

3. The method according to claim 2, characterized in that The step of generating a first principal gradient space orthogonal basis of a basic model based on the first characterization matrix comprises: Performing singular value decomposition (SVD) processing on the first representation matrix to generate a first orthogonal vector group; the first orthogonal vector group includes at least one orthogonal vector; The first K orthogonal vectors in the first orthogonal vector group are selected to form a first memory matrix; K is a positive integer; Based on the main gradient of the basic model and the first memory matrix, the first main gradient space orthogonal basis is generated.

4. The method according to claim 3, characterized in that Also includes: Extracting a second non-entity word from the training data of the second task, and obtaining a second representation matrix of the second non-entity word; Generate a second principal gradient space orthogonal basis of the first model based on the second representation matrix and the first memory matrix; Based on the second gradient space orthogonal basis, the parameters of the first model are updated to obtain a second model.

5. The method according to claim 4, characterized in that The step of generating a second principal gradient space orthogonal basis of the first model based on the second representation matrix and the first memory matrix comprises: Deduplication processing is performed on the second representation matrix and the first memory matrix to obtain a third representation matrix; Performing SVD processing on the third characterization matrix to generate a second orthogonal vector group; the second orthogonal vector group includes at least one orthogonal vector; Select the first N orthogonal vectors in the second orthogonal vector group to form a second memory matrix; N is a positive integer; Based on the main gradient of the first model and the second memory matrix, the second main gradient space orthogonal basis is generated.

6. The method according to claim 4 or 5, characterized in that: The updating of the parameters of the basic model based on the first gradient space orthogonal basis to obtain the first model comprises: Based on the first gradient space orthogonal basis, updating the parameters of the basic model by gradient projection to obtain a first model; The updating of the parameters of the first model based on the second gradient space orthogonal basis to obtain the second model comprises: Based on the second gradient space orthogonal basis, the parameters of the first model are updated by gradient projection to obtain a second model.

7. A model training device, characterized in that: include: An extraction unit: used for extracting a first non-entity word from training data of a first task, and obtaining a first representation matrix of the first non-entity word; A generating unit: used for generating a first principal gradient space orthogonal basis of a basic model based on the first characterization matrix; Based on the first gradient space orthogonal basis, the parameters of the basic model are updated to obtain a first model.

8. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory to execute the model training method as described in any one of claims 1 to 6.

9. A chip, characterized in that: include: A processor, used to call and run a computer program from a memory so that a device equipped with the chip executes the model training method described in any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program enables a computer to execute the model training method as described in any one of claims 1 to 6.

11. A computer program product, comprising a computer program, characterized in that When executed by a processor, the computer program implements the model training method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Training method of property customer service question and answer model, question and answer method and device and medium

    CN116049374A

  • Construction method and system of pre-training model for patent document processing

    CN116187163A